Journeyer J. Joh
2012-Sep-20 13:01 UTC
[LLVMdev] How can I make clang/llvm use specific toolchain?
Hello list. I wonder how I can make clang use specific linker. I am now trying to compile a hello world c code on an Ubuntu box for ARM and X86. And I have successfully built for ARM but NOT ABLE TO build one for X86. I am using a cross toolchain in the scratchbox environment of Tizen SDK. You can refer to the url below for my testing environment. http://blog.mikeasoft.com/2012/06/23/writing-native-tizen-applications-using-the-1-0-larkspur-sdk-scratchbox-and-efl/ ===========================================================================CC = /home/hum/Projects/clang_llvm/build/Debug+Asserts/bin/clang GCC_TOOLCHAIN /home/hum/tizen_sdk/SDK/build-system/toolchains/gcc-4.5.3.sb2/usr SYSROOT = /home/hum/tizen_sdk/SDK/build-system/rootstraps/tizen-emulator-1.0.sb2 #export LD_LIBRARY_PATH = $(GCC_TOOLCHAIN)/lib CFLAGS = -v \ --sysroot=$(SYSROOT) \ -gcc-toolchain $(GCC_TOOLCHAIN) # -ccc-host-triple i386-pc-linux-gnu \ LDFLAGS = -Wl,-dynamic-linker,/lib/ld-linux.so hello: $(CC) $(CFLAGS) $(LDFLAGS) -o hello hello.c clean: rm -f hello =========================================================================== This is the Makefile I am trying to make for X86 compile. And the result is shown below. ===========================================================================hum at hum-PEGATRON:~/src/tizen/hello$ make /home/hum/Projects/clang_llvm/build/Debug+Asserts/bin/clang -v --sysroot=/home/hum/tizen_sdk/SDK/build-system/rootstraps/tizen-emulator-1.0.sb2 -gcc-toolchain /home/hum/tizen_sdk/SDK/build-system/toolchains/gcc-4.5.3.sb2/usr -Wl,-dynamic-linker,/lib/ld-linux.so -o hello hello.c clang version 3.2 (trunk 163501) Target: i386-pc-linux-gnu Thread model: posix "/home/hum/Projects/clang_llvm/build/Debug+Asserts/bin/clang" -cc1 -triple i386-pc-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name hello.c -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -target-cpu pentium4 -target-linker-version 2.21.53.20110810 -momit-leaf-frame-pointer -v -resource-dir /home/hum/Projects/clang_llvm/build/Debug+Asserts/bin/../lib/clang/3.2 -isysroot /home/hum/tizen_sdk/SDK/build-system/rootstraps/tizen-emulator-1.0.sb2 -fmodule-cache-path /var/tmp/clang-module-cache -internal-isystem /home/hum/tizen_sdk/SDK/build-system/rootstraps/tizen-emulator-1.0.sb2/usr/local/include -internal-isystem /home/hum/Projects/clang_llvm/build/Debug+Asserts/bin/../lib/clang/3.2/include -internal-externc-isystem /home/hum/tizen_sdk/SDK/build-system/rootstraps/tizen-emulator-1.0.sb2/include -internal-externc-isystem /home/hum/tizen_sdk/SDK/build-system/rootstraps/tizen-emulator-1.0.sb2/usr/include -fdebug-compilation-dir /home/hum/src/tizen/hello -ferror-limit 19 -fmessage-length 212 -mstackrealign -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/hello-GdLQ8Z.o -x c hello.c clang -cc1 version 3.2 based upon LLVM 3.2svn default target i386-pc-linux-gnu ignoring nonexistent directory "/home/hum/tizen_sdk/SDK/build-system/rootstraps/tizen-emulator-1.0.sb2/include" #include "..." search starts here: #include <...> search starts here: /home/hum/tizen_sdk/SDK/build-system/rootstraps/tizen-emulator-1.0.sb2/usr/local/include /home/hum/Projects/clang_llvm/build/Debug+Asserts/bin/../lib/clang/3.2/include /home/hum/tizen_sdk/SDK/build-system/rootstraps/tizen-emulator-1.0.sb2/usr/include End of search list. "ld" --sysroot=/home/hum/tizen_sdk/SDK/build-system/rootstraps/tizen-emulator-1.0.sb2 -z relro --hash-style=gnu --build-id --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o hello /home/hum/tizen_sdk/SDK/build-system/rootstraps/tizen-emulator-1.0.sb2/usr/lib/crt1.o /home/hum/tizen_sdk/SDK/build-system/rootstraps/tizen-emulator-1.0.sb2/usr/lib/crti.o /home/hum/tizen_sdk/SDK/build-system/toolchains/gcc-4.5.3.sb2/usr/lib/gcc/i486-linux-gnu/4.5/crtbegin.o -L/home/hum/tizen_sdk/SDK/build-system/toolchains/gcc-4.5.3.sb2/usr/lib/gcc/i486-linux-gnu/4.5 -L/home/hum/tizen_sdk/SDK/build-system/rootstraps/tizen-emulator-1.0.sb2/lib -L/home/hum/tizen_sdk/SDK/build-system/rootstraps/tizen-emulator-1.0.sb2/usr/lib -dynamic-linker /lib/ld-linux.so /tmp/hello-GdLQ8Z.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /home/hum/tizen_sdk/SDK/build-system/toolchains/gcc-4.5.3.sb2/usr/lib/gcc/i486-linux-gnu/4.5/crtend.o /home/hum/tizen_sdk/SDK/build-system/rootstraps/tizen-emulator-1.0.sb2/usr/lib/crtn.o clang: error: unable to execute command: No such file or directory clang: error: linker command failed due to signal (use -v to see invocation) =========================================================================== The problem above is that clang tries to call "ld" but there is not a effective path to it. I now need to make clang use a specific "ld" in the cross toolchain of the scratchbox. For your information, with gcc in the scratchbox the hello world compiles with no problem. gcc uses collect2 in the toolchain of the scratchbox. and the collect2 uses ld in the same toolchain. So I am trying to make clang use the same ld. But I DON'T KNOW how I can make this. I learned that the clang option "-gcc-toolchain" is for this purpose. But I doubt if it works ONLY FOR ARM or different architecture. For your information, I am trying to compile on X86 host for another X86 target but with a special toolchain for the target X86. Thank you in advance. Best regards Journeyer J. Joh -- ---------------------------------------- Journeyer J. Joh o o s a p r o g r a m m e r a t g m a i l d o t c o m ----------------------------------------
Seemingly Similar Threads
- [LLVMdev] Recompiling llvm+clang how-to?
- [LLVMdev] Is cross-compiling for ARM on x86 with llvm/Clang possible?
- [LLVMdev] Is cross-compiling for ARM on x86 with llvm/Clang possible?
- [LLVMdev] Is cross-compiling for ARM on x86 with llvm/Clang possible?
- updating arguments of formulae