[cfe-dev] Cross compiling with clang (and sysroot support)

Stephen Kelly steveire at gmail.com
Fri May 17 05:05:31 PDT 2013


Stephen Kelly wrote:

> Stephen Kelly wrote:
> 
>> Stephen Kelly <steveire at ...> writes:
>> 
>>> I find it odd that it considers
>>> 
>>>  /home/stephen/rpi/gcc-4.7-linaro-rpi-gnueabihf//usr/include/x86_64-
> linux-
>>> gnu
>>> 
>>> before finding it is non-existant. It's mixing triples.
>> 
>> Ping? Any further help on this issue?
>> 
>>  
> http://thread.gmane.org/gmane.comp.compilers.clang.devel/28960/focus=29153
>> 
> 
> I've seen commits relating to cross compiling, so I'm sure others are
> somehow able to cross compile using clang.
> 
> Can anyone else help here to get a trivial program cross compiled?
> 

I found that if I specify paths with -B I can make it find the crti.o etc 
files. I didn't find documentation for -B, so I don't really know what it 
does. I just found it here:

 http://blog.boceto.fr/2012/05/03/the-universal-compiler-used-with-cmake/

I have to specify it several times. I think I'm just missing the right 
option to clang to tell it where to look for stuff. After specifying all 
those paths, I also have to specify some -L paths for gcc, and then I get a 
fresh error (which might be only a result of hacking around with these 
paths):

stephen at hal:/tmp$ clang -v -target arm-linux-gnueabi -
B/home/stephen/rpi/gcc-4.7-linaro-rpi-gnueabihf/lib/gcc/arm-linux-
gnueabihf/4.7.2/ -B/home/stephen/rpi/gcc-4.7-linaro-rpi-gnueabihf/arm-linux-
gnueabihf/libc/usr/lib/arm-linux-gnueabihf/ -L/home/stephen/rpi/gcc-4.7-
linaro-rpi-gnueabihf/arm-linux-gnueabihf/lib -L /home/stephen/rpi/gcc-4.7-
linaro-rpi-gnueabihf/lib/gcc/arm-linux-gnueabihf/4.7.2/ main.c 
Ubuntu clang version 3.2-1~exp9ubuntu1 (tags/RELEASE_32/final) (based on 
LLVM 3.2)
Target: arm--linux-gnueabi
Thread model: posix
 "/usr/bin/clang" -cc1 -triple armv4t--linux-gnueabi -S -disable-free -
disable-llvm-verifier -main-file-name main.c -mrelocation-model static -
mdisable-fp-elim -fmath-errno -mconstructor-aliases -target-abi aapcs-linux 
-target-cpu arm7tdmi -mfloat-abi soft -target-feature +soft-float-abi -
target-linker-version 2.23.2 -momit-leaf-frame-pointer -v -resource-dir 
/usr/bin/../lib/clang/3.2 -fmodule-cache-path /var/tmp/clang-module-cache -
internal-isystem /usr/local/include -internal-isystem 
/usr/bin/../lib/clang/3.2/include -internal-isystem 
/usr/include/clang/3.2/include/ -internal-externc-isystem 
/usr/include/x86_64-linux-gnu -internal-externc-isystem /usr/include/x86_64-
linux-gnu -internal-externc-isystem /usr/include -fno-dwarf-directory-asm -
fdebug-compilation-dir /tmp -ferror-limit 19 -fmessage-length 211 -
mstackrealign -fno-signed-char -fobjc-runtime=gcc -fdiagnostics-show-option 
-fcolor-diagnostics -o /tmp/main-87BC7C.s -x c main.c
clang -cc1 version 3.2 based upon LLVM 3.2svn default target x86_64-pc-
linux-gnu
ignoring nonexistent directory "/usr/bin/../lib/clang/3.2/include"
ignoring duplicate directory "/usr/include/x86_64-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/include/clang/3.2/include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
 "/usr/bin/arm-linux-gnueabi-as" -mfloat-abi=softfp -o /tmp/main-1pJbtV.o 
/tmp/main-87BC7C.s
 "/usr/bin/arm-linux-gnueabi-ld" -z relro -X --hash-style=gnu --build-id --
eh-frame-hdr -m armelf_linux_eabi -dynamic-linker /lib/ld-linux.so.3 -o 
a.out /home/stephen/rpi/gcc-4.7-linaro-rpi-gnueabihf/arm-linux-
gnueabihf/libc/usr/lib/arm-linux-gnueabihf/crt1.o /home/stephen/rpi/gcc-4.7-
linaro-rpi-gnueabihf/arm-linux-gnueabihf/libc/usr/lib/arm-linux-
gnueabihf/crti.o /home/stephen/rpi/gcc-4.7-linaro-rpi-gnueabihf/lib/gcc/arm-
linux-gnueabihf/4.7.2/crtbegin.o -L/home/stephen/rpi/gcc-4.7-linaro-rpi-
gnueabihf/arm-linux-gnueabihf/lib -L/home/stephen/rpi/gcc-4.7-linaro-rpi-
gnueabihf/lib/gcc/arm-linux-gnueabihf/4.7.2/ -L/usr/lib/../lib32 -L/lib -
L/usr/lib /tmp/main-1pJbtV.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -
lgcc --as-needed -lgcc_s --no-as-needed /home/stephen/rpi/gcc-4.7-linaro-
rpi-gnueabihf/lib/gcc/arm-linux-gnueabihf/4.7.2/crtend.o 
/home/stephen/rpi/gcc-4.7-linaro-rpi-gnueabihf/arm-linux-
gnueabihf/libc/usr/lib/arm-linux-gnueabihf/crtn.o
/usr/bin/arm-linux-gnueabi-ld: error: a.out uses VFP register arguments, 
/tmp/main-1pJbtV.o does not
/usr/bin/arm-linux-gnueabi-ld: failed to merge target specific data of file 
/tmp/main-1pJbtV.o
/usr/bin/arm-linux-gnueabi-ld: error: a.out uses VFP register arguments, 
/usr/arm-linux-gnueabi/lib/libc_nonshared.a(elf-init.oS) does not
/usr/bin/arm-linux-gnueabi-ld: failed to merge target specific data of file 
/usr/arm-linux-gnueabi/lib/libc_nonshared.a(elf-init.oS)
clang: error: linker command failed with exit code 1 (use -v to see 
invocation)


Thanks,

Steve.






More information about the cfe-dev mailing list