riscv64 linux kernel cross-compilation on M1 Mac

Viewed 94

I'm trying to compile linux kernel using this instruction: Running 64- and 32-bit RISC-V Linux on QEMU

My environment is macOS Monterey on M1, case sensitive APFS

riscv-gnu-toolchain building instructions:

arch -x86_64 zsh
./configure --prefix=/opt/riscv
make linux

After toolchain installation I've tried to build linux but got an error

make ARCH=riscv CROSS_COMPILE=riscv64-unknown-linux-gnu- -j 8
  HOSTCC  scripts/mod/file2alias.o
In file included from scripts/mod/file2alias.c:13:
scripts/mod/modpost.h:11:10: fatal error: 'elf.h' file not found
#include <elf.h>
         ^~~~~~~
1 error generated.
make[1]: *** [scripts/Makefile.host:112: scripts/mod/file2alias.o] Error 1
make: *** [Makefile:1193: prepare0] Error 2

Also I've tried to create symlink /usr/local/include -> /opt/riscv/sysroot/usr/include but got a new error:

make ARCH=riscv CROSS_COMPILE=riscv64-unknown-linux-gnu- -j 8
  HOSTCC  scripts/sorttable
In file included from scripts/sorttable.c:23:
In file included from /usr/local/include/sys/types.h:25:
In file included from /usr/local/include/features.h:473:
/usr/local/include/sys/cdefs.h:303:10: warning: '__nonnull' macro redefined [-Wmacro-redefined]
# define __nonnull(params) __attribute__ ((__nonnull__ params))
         ^
<built-in>:321:9: note: previous definition is here
#define __nonnull _Nonnull
        ^
In file included from scripts/sorttable.c:23:
In file included from /usr/local/include/sys/types.h:25:
In file included from /usr/local/include/features.h:473:
In file included from /usr/local/include/sys/cdefs.h:462:
/usr/local/include/bits/wordsize.h:22:3: error: unsupported ABI
# error unsupported ABI
  ^
In file included from scripts/sorttable.c:23:
In file included from /usr/local/include/sys/types.h:25:
In file included from /usr/local/include/features.h:497:
In file included from /usr/local/include/gnu/stubs.h:5:
/usr/local/include/bits/wordsize.h:22:3: error: unsupported ABI
# error unsupported ABI
...
0 Answers
Related