LINUX.ORG.RU

Clang - не линкует

 , ,


1

2

При попытке компиляции чего либо клангом 6.0.0 вылезает это

clang -v test.c      
clang version 6.0.0 (tags/RELEASE_600/final)
Target: x86_64-fantomos-linux-musl
Thread model: posix
InstalledDir: /bin
Found candidate GCC installation: /bin/../lib/gcc/x86_64-fantomos-linux-musl/7.3.0
Found candidate GCC installation: /bin/../lib64/gcc/x86_64-fantomos-linux-musl/7.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-fantomos-linux-musl/7.3.0
Found candidate GCC installation: /usr/lib64/gcc/x86_64-fantomos-linux-musl/7.3.0
 "/usr/bin/clang-6.0" -cc1 -triple x86_64-fantomos-linux-musl -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name test.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -v -resource-dir /usr/lib/clang/6.0.0 -internal-isystem /usr/local/include -internal-isystem /usr/lib/clang/6.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /tmp -ferror-limit 19 -fmessage-length 80 -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/test-0cf31c.o -x c test.c
clang -cc1 version 6.0.0 based upon LLVM 6.0.0 default target x86_64-fantomos-linux-musl
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/lib/clang/6.0.0/include
 /usr/include
End of search list.
 "/bin/ld" -pie --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib/ld-musl-x86_64.so.1 -o a.out /usr/bin/../lib64/Scrt1.o /usr/bin/../lib64/crti.o crtbeginS.o -L/usr/bin/../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/bin/../lib -L/lib -L/usr/lib /tmp/test-0cf31c.o /usr/lib/clang/6.0.0/lib/linux/libclang_rt.builtins-x86_64.a -lc /usr/lib/clang/6.0.0/lib/linux/libclang_rt.builtins-x86_64.a crtendS.o /usr/bin/../lib64/crtn.o
/bin/ld: error: cannot open crtbeginS.o: No such file or directory
/bin/ld: error: cannot open crtendS.o: No such file or directory
clang-6.0: error: linker command failed with exit code 1 (use -v to see invocation)

Работает, если положить crtbeginS.o и crtendS.o в текущую папку. Как это починить? Эти файлы лежат в /usr/lib/gcc/x86_64-fantomos-linux-musl/7.3.0, однако сам гцц там не стоит.

UPD. Решено. Надо было все файлы из папки /tools/lib/gcc/x86_64-fantomos-linux-musl/7.3.0 скинуть в /usr/lib/gcc/x86_64-fantomos-linux-musl/7.3.0