Open dslm4515 opened 2 years ago
Per LLVM mailing lists,
The crt begin/end files are considered part of the standard library, not the compiler.
So ...
Adding -B/usr/lib/gcc/x86_64-linux-musl/11.2.0
to clang enabled LLVM to find crtbeginS.o
$ clang -B/usr/lib/gcc/x86_64-linux-musl/11.2.0 dummy.c -v -Wl,--verbose &> dummy.log
$ grep crtbeginS dummy.log | grep attempt
attempt to open /usr/lib/gcc/x86_64-linux-musl/11.2.0/crtbeginS.o
Then linking the static gcc library fixed the other errors:
$ sudo ln -sv ../../../usr/lib/gcc/x86_64-linux-musl/11.2.0/libgcc.a /opt/build/lib/libgcc.a
Configured clang:
$ sudo ln -s clang-14 /opt/build/bin/x86_64-linux-muls-clang
$ sudo ln -s clang-14 /opt/build/bin/x86_64-linux-musl-clang++
$ cat /opt/build/bin/x86_64-linux-musl.cfg
-B -B/usr/lib/gcc/x86_64-linux-musl/11.2.0
Linux kernel still wont compile with clang:
$ LLVM=1 LLVM_IAS=1 CC="x86_64-linux-musl-clang" make menuconfig
HOSTCC scripts/basic/fixdep
/usr/bin/ld: cannot find crtbeginS.o: No such file or directory
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [scripts/Makefile.host:95: scripts/basic/fixdep] Error 1
make: *** [Makefile:555: scripts_basic] Error 2
Kernel source now build after copying two static objects:
$ sudo cp /usr/lib/gcc/x86_64-linux-musl/11.2.0/crtbeginS.o /opt/build/lib/
$ sudo cp /usr/lib/gcc/x86_64-linux-musl/11.2.0/crtendS.o /opt/build/lib/
Installed LLVM-14.0.0 in
/opt/build
.LLVM compiles and installs, but cannot compile binaries/libraries:
If trying to compile the Linux kernel with LLVM: