Hello again!
Tried out the small Hello World Setup, worked as intended:
root@christian-forschung-virtual-machine:/home/progs# clang -v --target=arm-linux-gnueabihf hello.c -o hello -fuse-ld=lld
clang version 8.0.0 ( a152c7a4b7ba8f4cb9532ead9a38a7121db43d50) ( 1959ce6f3e01241919968ac1911fd45660239d23) Target: arm-unknown-linux-gnueabihf Thread model: posix InstalledDir: /usr/local/myclang/bin Found candidate GCC installation: /usr/lib/gcc-cross/arm-linux-gnueabihf/7 Found candidate GCC installation: /usr/lib/gcc-cross/arm-linux-gnueabihf/7.3.0 Selected GCC installation: /usr/lib/gcc-cross/arm-linux-gnueabihf/7.3.0 Candidate multilib: .;@m32 Selected multilib: .;@m32 “/usr/local/myclang/bin/clang-8” -cc1 -triple armv6kz-unknown-linux-gnueabihf -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name hello.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -fuse-init-array -target-cpu arm1176jzf-s -target-feature +strict-align -target-abi aapcs-linux -mfloat-abi hard -fallow-half-arguments-and-returns -dwarf-column-info -debugger-tuning=gdb -v -resource-dir /usr/local/myclang/lib/clang/8.0.0 -internal-isystem /usr/local/include -internal-isystem /usr/local/myclang/lib/clang/8.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /home/progs -ferror-limit 19 -fmessage-length 202 -fno-signed-char -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/hello-98a3a7.o -x c hello.c -faddrsig clang -cc1 version 8.0.0 based upon LLVM 8.0.0svn default target x86_64-unknown-linux-gnu ignoring nonexistent directory “/include” #include “…” search starts here: #include <…> search starts here: /usr/local/include /usr/local/myclang/lib/clang/8.0.0/include /usr/include End of search list. “/usr/local/myclang/bin/ld.lld” -EL -z relro -X --hash-style=gnu --eh-frame-hdr -m armelf_linux_eabi -dynamic-linker /lib/ld-linux-armhf.so.3 -o hello …/lib/crt1.o …/lib/crti.o /usr/lib/gcc-cross/arm-linux-gnueabihf/7.3.0/crtbegin.o -L/usr/lib/gcc-cross/arm-linux-gnueabihf/7.3.0 -L/usr/lib/gcc-cross/arm-linux-gnueabihf/7.3.0/…/…/…/…/lib -L/usr/lib/gcc-cross/arm-linux-gnueabihf/7.3.0/…/…/…/…/lib -L/usr/local/myclang/bin/…/lib -L/usr/lib/arm-linux-gnueabihf/…/…/lib -L/usr/lib/gcc-cross/arm-linux-gnueabihf/7.3.0/…/…/…/…/arm-linux-gnueabihf/lib -L/usr/lib/gcc-cross/arm-linux-gnueabihf/7.3.0/…/…/… -L/usr/local/myclang/bin/…/lib -L/lib -L/usr/lib /tmp/hello-98a3a7.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc-cross/arm-linux-gnueabihf/7.3.0/crtend.o …/lib/crtn.o
root@christian-forschung-virtual-machine:/home/progs# qemu-arm -L /usr/arm-linux-gnueabihf hello
Hello, World!
So far, so good. The Paths written more readable seem to be
/usr/local/myclang/lib, /lib, /usr/lib, /usr/arm-linux-gnueabihf/lib, so no surprised there.
Then I added the suggested -DCMAKE_ASM_FLAGS to the cmake for the standalone compiler-rt build while leaving out the --sysroot and --gcc-toolchain:
cmake -G “Ninja” … -DCOMPILER_RT_BUILD_BUILTINS=ON -DCOMPILER_RT_BUILD_SANITIZERS=OFF -DCOMPILER_RT_BUILD_XRAY=OFF -DCOMPILER_RT_BUILD_LIBFUZZER=OFF -DCOMPILER_RT_BUILD_PROFILE=OFF -DCMAKE_C_COMPILER=/usr/local/myclang/bin/clang -DCMAKE_AR=/usr/local/myclang/bin/llvm-ar -DCMAKE_NM=/usr/local/myclang/bin/llvm-nm -DCMAKE_RANLIB=/usr/local/myclang/bin/llvm-ranlib -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY -DCMAKE_C_COMPILER_TARGET=“arm-linux-gnueabihf” -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON -DLLVM_CONFIG_PATH=/usr/local/myclang/bin/llvm-config -DCMAKE_ASM_FLAGS=“–target=arm-linux-gnueabihf -march=armv7a” -DCMAKE_C_FLAGS=“–target=arm-linux-gnueabihf -march=armv7a”
now “ninja builtins” at least starts working, but fails after a while (see below). The error seems similar to to me, so it might still be some variant of the problem from before: Using a x86-header where an ARM one would be needed.
The ninja builtins output:
root@christian-forschung-virtual-machine:/home/llvm_all/buildrtonly# ninja builtins
[147/207] Building C object lib/builtins/CMakeFiles/clang_rt.builtins-armhf.dir/emutls.c.o
FAILED: lib/builtins/CMakeFiles/clang_rt.builtins-armhf.dir/emutls.c.o
/usr/local/myclang/bin/clang --target=arm-linux-gnueabihf -DVISIBILITY_HIDDEN --target=arm-linux-gnueabihf -march=armv7a -Wall -Wno-unused-parameter -fno-lto -std=c11 -fPIC -fno-builtin -fvisibility=hidden -fomit-frame-pointer -fomit-frame-pointer -DCOMPILER_RT_ARMHF_TARGET -MD -MT lib/builtins/CMakeFiles/clang_rt.builtins-armhf.dir/emutls.c.o -MF lib/builtins/CMakeFiles/clang_rt.builtins-armhf.dir/emutls.c.o.d -o lib/builtins/CMakeFiles/clang_rt.builtins-armhf.dir/emutls.c.o -c /home/llvm_all/llvm/projects/compiler-rt/lib/builtins/emutls.c
In file included from /home/llvm_all/llvm/projects/compiler-rt/lib/builtins/emutls.c:41:
/usr/include/pthread.h:682:6: error: ‘regparm’ is not valid on this platform
__cleanup_fct_attribute;
^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/bits/pthreadtypes-arch.h:103:50: note: expanded from macro ‘__cleanup_fct_attribute’
define __cleanup_fct_attribute attribute ((regparm (1)))
^ ~
In file included from /home/llvm_all/llvm/projects/compiler-rt/lib/builtins/emutls.c:41:
/usr/include/pthread.h:694:3: error: ‘regparm’ is not valid on this platform
__cleanup_fct_attribute;
^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/bits/pthreadtypes-arch.h:103:50: note: expanded from macro ‘__cleanup_fct_attribute’
define __cleanup_fct_attribute attribute ((regparm (1)))
^ ~
In file included from /home/llvm_all/llvm/projects/compiler-rt/lib/builtins/emutls.c:41:
/usr/include/pthread.h:735:6: error: ‘regparm’ is not valid on this platform
__cleanup_fct_attribute attribute ((noreturn))
^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/bits/pthreadtypes-arch.h:103:50: note: expanded from macro ‘__cleanup_fct_attribute’
define __cleanup_fct_attribute attribute ((regparm (1)))
^ ~
3 errors generated.
[148/207] Building C object lib/builtins/CMakeFiles/clang_rt.builtins-armhf.dir/gcc_personality_v0.c.o
/home/llvm_all/llvm/projects/compiler-rt/lib/builtins/gcc_personality_v0.c:148:47: warning: declaration of ‘struct _Unwind_Exception’ will not be visible outside of this function [-Wvisibility]
_Unwind_Reason_Code __gnu_unwind_frame(struct _Unwind_Exception *,
^
/home/llvm_all/llvm/projects/compiler-rt/lib/builtins/gcc_personality_v0.c:153:23: warning: declaration of ‘struct _Unwind_Exception’ will not be visible outside of this function [-Wvisibility]
continueUnwind(struct _Unwind_Exception *exceptionObject,
^
/home/llvm_all/llvm/projects/compiler-rt/lib/builtins/gcc_personality_v0.c:160:28: warning: incompatible pointer types passing ‘struct _Unwind_Exception *’ to parameter of type ‘struct _Unwind_Exception *’ [-Wincompatible-pointer-types]
if (__gnu_unwind_frame(exceptionObject, context) != _URC_OK)
^~~~~~~~~~~~~~~
/home/llvm_all/llvm/projects/compiler-rt/lib/builtins/gcc_personality_v0.c:148:66: note: passing argument to parameter here
_Unwind_Reason_Code __gnu_unwind_frame(struct _Unwind_Exception *,
^
/home/llvm_all/llvm/projects/compiler-rt/lib/builtins/gcc_personality_v0.c:184:38: warning: declaration of ‘struct _Unwind_Exception’ will not be visible outside of this function [-Wvisibility]
_Unwind_State state, struct _Unwind_Exception *exceptionObject,
^
/home/llvm_all/llvm/projects/compiler-rt/lib/builtins/gcc_personality_v0.c:202:31: warning: incompatible pointer types passing ‘struct _Unwind_Exception *’ to parameter of type ‘struct _Unwind_Exception *’ [-Wincompatible-pointer-types]
return continueUnwind(exceptionObject, context);
^~~~~~~~~~~~~~~
/home/llvm_all/llvm/projects/compiler-rt/lib/builtins/gcc_personality_v0.c:153:42: note: passing argument to parameter ‘exceptionObject’ here
continueUnwind(struct _Unwind_Exception *exceptionObject,
^
/home/llvm_all/llvm/projects/compiler-rt/lib/builtins/gcc_personality_v0.c:207:31: warning: incompatible pointer types passing ‘struct _Unwind_Exception *’ to parameter of type ‘struct _Unwind_Exception *’ [-Wincompatible-pointer-types]
return continueUnwind(exceptionObject, context);
^~~~~~~~~~~~~~~
/home/llvm_all/llvm/projects/compiler-rt/lib/builtins/gcc_personality_v0.c:153:42: note: passing argument to parameter ‘exceptionObject’ here
continueUnwind(struct _Unwind_Exception *exceptionObject,
^
/home/llvm_all/llvm/projects/compiler-rt/lib/builtins/gcc_personality_v0.c:250:27: warning: incompatible pointer types passing ‘struct _Unwind_Exception *’ to parameter of type ‘struct _Unwind_Exception *’ [-Wincompatible-pointer-types]
return continueUnwind(exceptionObject, context);
^~~~~~~~~~~~~~~
/home/llvm_all/llvm/projects/compiler-rt/lib/builtins/gcc_personality_v0.c:153:42: note: passing argument to parameter ‘exceptionObject’ here
continueUnwind(struct _Unwind_Exception *exceptionObject,
^
7 warnings generated.
[152/207] Building ASM object lib/builtins/CMakeFiles/clang_rt.builtins-armhf.dir/arm/aeabi_cdcmp.S.o
ninja: build stopped: subcommand failed.
Almost there! Thanks in advance!
Christian