We have been using clang-7 for a few years for address sanitizer and it has been working well, but I want to see if there is anything new so I built clang-12, but when I try to build cmake fails fast because the compiler doesn’t work, cannot find -lgcc
I build all tools from scratch because that is required to import them into our custom build system. With clang-7 I built with gcc and used that, but now I’ve switched to a stage-2 build using the example files in clang/cmake/cache
when I first tried this I was also getting errors about unable to find crtbegin, but a -B to the proper directory killed that error (secondary question - why is the -B needed, shouldn’t clang be able to figure this out itself). Even though there is a libgcc.a in the same directory as crtbegin.o, it isn’t found. (is the .o/.a extension a factor?)
I have tried clang 9.01, 12.0.1, and 13-rc2 and get the same error.
Full output below: One thing I find weird is -fgnuc-version=4.2.1 - but my gcc version is 5.2.0
Run Build Command(s):/usr/bin/ninja cmTC_5a104
[1/2] Building C object CMakeFiles/cmTC_5a104.dir/testCCompiler.c.o
LLVM.org clang version 12.0.1 (https://github.deere.com/Platform-health/clang.git 8d75984a760e897bf86a45ae924e7edac8d76990)
Target: x86_64-wrs-linux
Thread model: posix
InstalledDir: /opt/jdx/tools/usr/clang12/bin
Found candidate GCC installation: /home/hm68841/workspace/gsx/jdx/wr8-baytrail_64-clang/buildbox/usr/lib64/gcc/x86_64-wrs-linux/5.2.0
(in-process)
"/opt/jdx/tools/usr/clang12/bin/clang-12" -cc1 -triple x86_64-wrs-linux -emit-obj -mrelax-all --mrelax-relocations -disable-free -disable-llvm-verifier -discard-value-names -main-file-name testCCompiler.c -mrelocation-model static -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -fno-split-dwarf-inlining -debugger-tuning=gdb -v -resource-dir /opt/jdx/tools/usr/clang12/lib/clang/12.0.1 -isysroot /home/hm68841/workspace/gsx/jdx/wr8-baytrail_64-clang/buildbox -internal-isystem /home/hm68841/workspace/gsx/jdx/wr8-baytrail_64-clang/buildbox/usr/local/include -internal-isystem /opt/jdx/tools/usr/clang12/lib/clang/12.0.1/include -internal-externc-isystem /home/hm68841/workspace/gsx/jdx/wr8-baytrail_64-clang/buildbox/include -internal-externc-isystem /home/hm68841/workspace/gsx/jdx/wr8-baytrail_64-clang/buildbox/usr/include -fdebug-compilation-dir /home/hm68841/workspace/gsx/jdx/wr8-baytrail_64-clang/build/CMakeFiles/CMakeTmp -ferror-limit 19 -fgnuc-version=4.2.1 -faddrsig -o CMakeFiles/cmTC_5a104.dir/testCCompiler.c.o -x c testCCompiler.c
clang -cc1 version 12.0.1 based upon LLVM 12.0.1 default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/home/hm68841/workspace/gsx/jdx/wr8-baytrail_64-clang/buildbox/include"
#include "..." search starts here:
#include <...> search starts here:
/home/hm68841/workspace/gsx/jdx/wr8-baytrail_64-clang/buildbox/usr/local/include
/opt/jdx/tools/usr/clang12/lib/clang/12.0.1/include
/home/hm68841/workspace/gsx/jdx/wr8-baytrail_64-clang/buildbox/usr/include
End of search list.
[2/2] Linking C executable cmTC_5a104
FAILED: cmTC_5a104
: && /opt/jdx/tools/usr/clang12/bin//clang-12 --sysroot=/home/hm68841/workspace/gsx/jdx/wr8-baytrail_64-clang/buildbox -fno-omit-frame-pointer -B /home/hm68841/workspace/gsx/jdx/wr8-baytrail_64-clang/buildbox/usr/lib64/x86_64-wrs-linux/5.2.0 -v --target=x86_64-wrs-linux --target=x86_64-wrs-linux --sysroot=/home/hm68841/workspace/gsx/jdx/wr8-baytrail_64-clang/buildbox -rdynamic CMakeFiles/cmTC_5a104.dir/testCCompiler.c.o -o cmTC_5a104 && :
LLVM.org clang version 12.0.1 (https://github.deere.com/Platform-health/clang.git 8d75984a760e897bf86a45ae924e7edac8d76990)
Target: x86_64-wrs-linux
Thread model: posix
InstalledDir: /opt/jdx/tools/usr/clang12/bin
Found candidate GCC installation: /home/hm68841/workspace/gsx/jdx/wr8-baytrail_64-clang/buildbox/usr/lib64/gcc/x86_64-wrs-linux/5.2.0
"/opt/jdx/tools/sysroots/x86_64-wrlinuxsdk-linux/usr/bin/x86_64-wrs-linux/x86_64-wrs-linux-ld" --sysroot=/home/hm68841/workspace/gsx/jdx/wr8-baytrail_64-clang/buildbox -export-dynamic -z relro --hash-style=gnu --eh-frame-hdr -m elf_x86_64 -export-dynamic -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o cmTC_5a104 /home/hm68841/workspace/gsx/jdx/wr8-baytrail_64-clang/buildbox/usr/lib/../lib64/crt1.o /home/hm68841/workspace/gsx/jdx/wr8-baytrail_64-clang/buildbox/usr/lib/../lib64/crti.o /home/hm68841/workspace/gsx/jdx/wr8-baytrail_64-clang/buildbox/usr/lib64/x86_64-wrs-linux/5.2.0/crtbegin.o -L/home/hm68841/workspace/gsx/jdx/wr8-baytrail_64-clang/buildbox/lib/../lib64 -L/home/hm68841/workspace/gsx/jdx/wr8-baytrail_64-clang/buildbox/usr/lib/../lib64 -L/home/hm68841/workspace/gsx/jdx/wr8-baytrail_64-clang/buildbox/lib -L/home/hm68841/workspace/gsx/jdx/wr8-baytrail_64-clang/buildbox/usr/lib CMakeFiles/cmTC_5a104.dir/testCCompiler.c.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /home/hm68841/workspace/gsx/jdx/wr8-baytrail_64-clang/buildbox/usr/lib64/x86_64-wrs-linux/5.2.0/crtend.o /home/hm68841/workspace/gsx/jdx/wr8-baytrail_64-clang/buildbox/usr/lib/../lib64/crtn.o
/opt/jdx/tools/sysroots/x86_64-wrlinuxsdk-linux/usr/bin/x86_64-wrs-linux/x86_64-wrs-linux-ld: cannot find -lgcc
clang-12: error: linker command failed with exit code 1 (use -v to see invocation)