<div>Hello,</div><div><br></div><div>Please ignore my previous email.</div><div>I received the final binary with command below.</div><div>I had to get rid of the option, -emit-llvm.</div><div><br></div><div><div>./clang -v --save-temps -ccc-host-triple arm-none-linux-gnueabi --sysroot=/home/hum/Documents/Projects/arm_toolchain/arm-2010.09/arm-none-linux-gnueabi/libc hello.c</div>
<div><br></div><div>file hello.i</div><div>hello.i: ASCII C program text</div><div><br></div><div>file hello.s</div><div>hello.s: ASCII assembler program text</div><div><br></div><div>/home/hum/Documents/Projects/arm_toolchain/arm-2010.09/bin/arm-none-linux-gnueabi-as -mfloat-abi=softfp -o hello.o hello.s</div>
<div><br></div><div>file hello.o</div><div>hello.o: ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), not stripped</div><div><br></div><div>/home/hum/Documents/Projects/arm_toolchain/arm-2010.09/bin/arm-none-linux-gnueabi-ld --sysroot=/home/hum/Documents/Projects/arm_toolchain/arm-2010.09/arm-none-linux-gnueabi/libc -z relro -X --hash-style=gnu --build-id --eh-frame-hdr -m armelf_linux_eabi -o a.out /home/hum/Documents/Projects/arm_toolchain/arm-2010.09/arm-none-linux-gnueabi/libc/usr/lib/crt1.o /home/hum/Documents/Projects/arm_toolchain/arm-2010.09/arm-none-linux-gnueabi/libc/usr/lib/crti.o /home/hum/Documents/Projects/arm_toolchain/arm-2010.09/lib/gcc/arm-none-linux-gnueabi/4.5.1/armv4t/crtbegin.o -L/home/hum/Documents/Projects/arm_toolchain/arm-2010.09/arm-none-linux-gnueabi/libc/lib -L/home/hum/Documents/Projects/arm_toolchain/arm-2010.09/arm-none-linux-gnueabi/libc/usr/lib -L/home/hum/Documents/Projects/arm_toolchain/arm-2010.09/lib/gcc/arm-none-linux-gnueabi/4.5.1/armv4t hello.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /home/hum/Documents/Projects/arm_toolchain/arm-2010.09/lib/gcc/arm-none-linux-gnueabi/4.5.1/armv4t/crtend.o /home/hum/Documents/Projects/arm_toolchain/arm-2010.09/arm-none-linux-gnueabi/libc/usr/lib/crtn.o</div>
<div><br></div><div>file a.out</div><div>a.out: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, BuildID[sha1]=0x7825ca07341b2f337c4f10b5711055c997820a9c, not stripped</div>
</div><div><br></div><div><br></div><div>The only thing remained is to specify the cross tool chain location to the clang so that clang uses cross-as and ld automatically.</div><div><br></div><div>If someone provide these information, it would be welcomed!</div>
<div><br></div><div>Thank you very much.</div><div><br></div><div>Journeyer J. Joh</div><div><br></div><br><br><div class="gmail_quote">2012/6/20 Journeyer J. Joh <span dir="ltr"><<a href="mailto:oosaprogrammer@gmail.com" target="_blank">oosaprogrammer@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>Hello,</div><div><br></div><div>Thank you for your kind attention to my issue and your help.</div><div><br></div><div>
I changed the tool chain and tried again. And there is a little progress but still have some problem.</div>
<div><br></div><div>Using --sysroot doesn't make clang use linker(ld) in the cross tool.</div><div>Most important question is how I can make clang use cross tool linker.</div><div><br></div><div><div>Let me show you my experiment and questions below.</div>
There are two questions.</div><div><br></div><div><div>[Run]</div><div>./clang -v --save-temps -emit-llvm -ccc-host-triple arm-none-linux-gnueabi --sysroot=/home/hum/Documents/Projects/arm_toolchain/arm-2010.09/arm-none-linux-gnueabi/libc hello.c</div>
<div><br></div><div>[Question]</div><div>1. How am I supposed to use --sysroot? Though I used "--sysroot" above, Clang uses native linker, "/usr/bin/ld" not the one in the tool chain, "/home/hum/Documents/Projects/arm_toolchain/arm-2010.09/bin/arm-none-linux-gnueabi-ld".</div>
<div><br></div><div>[Output]</div><div>clang version 3.2 (trunk 158784)</div><div class="im"><div>Target: arm-none-linux-gnueabi</div><div>Thread model: posix</div><div><br></div></div><div>"/home/hum/Documents/Projects/clang_llvm/build/Debug+Asserts/bin/clang"</div>
<div>-cc1 </div><div>-triple armv4t-none-linux-gnueabi </div><div>-E</div><div class="im"><div>-disable-free </div><div>-main-file-name hello.c </div><div>-mrelocation-model static </div><div>-mdisable-fp-elim </div><div>
-fmath-errno </div>
<div>-mconstructor-aliases </div><div>-target-abi aapcs-linux </div><div>-target-cpu arm7tdmi </div><div>-mfloat-abi soft </div><div>-target-feature +soft-float-abi </div></div><div>-target-linker-version 2.22 </div><div>
-momit-leaf-frame-pointer </div>
<div>-v </div><div>-resource-dir /home/hum/Documents/Projects/clang_llvm/build/Debug+Asserts/bin/../lib/clang/3.2 </div><div>-isysroot /home/hum/Documents/Projects/arm_toolchain/arm-2010.09/arm-none-linux-gnueabi/libc </div>
<div>-fmodule-cache-path /var/tmp/clang-module-cache </div><div>-internal-isystem /home/hum/Documents/Projects/arm_toolchain/arm-2010.09/arm-none-linux-gnueabi/libc/usr/local/include </div><div>-internal-isystem /home/hum/Documents/Projects/clang_llvm/build/Debug+Asserts/bin/../lib/clang/3.2/include </div>
<div>-internal-externc-isystem /home/hum/Documents/Projects/arm_toolchain/arm-2010.09/arm-none-linux-gnueabi/libc/include </div><div>-internal-externc-isystem /home/hum/Documents/Projects/arm_toolchain/arm-2010.09/arm-none-linux-gnueabi/libc/usr/include </div>
<div>-fno-dwarf-directory-asm </div><div>-fdebug-compilation-dir /home/hum/Documents/Projects/clang_llvm/build/Debug+Asserts/bin </div><div>-ferror-limit 19 </div><div>-fmessage-length 205 </div><div class="im"><div>-mstackrealign </div>
<div>-fno-signed-char </div><div>-fgnu-runtime </div><div>-fobjc-runtime-has-arc </div><div>-fobjc-runtime-has-weak </div><div>-fobjc-fragile-abi </div><div>-fdiagnostics-show-option </div><div>-fcolor-diagnostics </div>
</div><div>
-o hello.i</div><div>-x c </div><div>hello.c</div><div><br></div><div>clang -cc1 version 3.2 based upon LLVM 3.2svn default target i386-pc-linux-gnu</div><div>ignoring nonexistent directory "/home/hum/Documents/Projects/arm_toolchain/arm-2010.09/arm-none-linux-gnueabi/libc/usr/local/include"</div>
<div>ignoring nonexistent directory "/home/hum/Documents/Projects/arm_toolchain/arm-2010.09/arm-none-linux-gnueabi/libc/include"</div><div class="im"><div>#include "..." search starts here:</div><div>
#include <...> search starts here:</div>
</div><div> /home/hum/Documents/Projects/clang_llvm/build/Debug+Asserts/bin/../lib/clang/3.2/include</div><div> /home/hum/Documents/Projects/arm_toolchain/arm-2010.09/arm-none-linux-gnueabi/libc/usr/include</div><div>End of search list.</div>
<div><br></div><div><br></div><div>"/home/hum/Documents/Projects/clang_llvm/build/Debug+Asserts/bin/clang" </div><div class="im"><div>-cc1 </div><div>-triple armv4t-none-linux-gnueabi </div><div>-emit-llvm-bc </div>
<div>-disable-free </div>
<div>-main-file-name hello.c </div><div>-mrelocation-model static </div><div>-mdisable-fp-elim </div><div>-fmath-errno </div><div>-mconstructor-aliases </div><div>-target-abi aapcs-linux </div><div>-target-cpu arm7tdmi </div>
<div>-mfloat-abi soft </div><div>-target-feature +soft-float-abi </div></div><div>-target-linker-version 2.22 </div><div>-momit-leaf-frame-pointer </div><div>-v </div><div>-resource-dir /home/hum/Documents/Projects/clang_llvm/build/Debug+Asserts/bin/../lib/clang/3.2</div>
<div>-fno-dwarf-directory-asm </div><div>-fdebug-compilation</div><div>-dir /home/hum/Documents/Projects/clang_llvm/build/Debug+Asserts/bin </div><div>-ferror-limit 19 </div><div>-fmessage-length 205 </div><div class="im">
<div>-mstackrealign </div>
<div>-fno-signed-char </div><div>-fgnu-runtime </div><div>-fobjc-runtime-has-arc </div><div>-fobjc-runtime-has-weak </div><div>-fobjc-fragile-abi </div><div>-fdiagnostics-show-option </div><div>-fcolor-diagnostics </div>
</div><div>
-o hello.o</div><div>-x cpp-output </div><div>hello.i</div><div><br></div><div>clang -cc1 version 3.2 based upon LLVM 3.2svn default target i386-pc-linux-gnu</div><div class="im"><div>#include "..." search starts here:</div>
</div><div>
End of search list.</div><div><br></div><div><br></div><div>"/usr/bin/ld" <<<<<<<<<< Problem #1 : wrong linker! ld in cross toolchain is needed!</div><div>--sysroot=/home/hum/Documents/Projects/arm_toolchain/arm-2010.09/arm-none-linux-gnueabi/libc </div>
<div class="im">
<div>-z relro </div><div>-X </div><div>--hash-style=gnu </div><div>--build-id </div><div>--eh-frame-hdr </div><div>-m armelf_linux_eabi </div></div><div>-dynamic-linker /lib/ld-linux.so.3 <<<<<<<<<< Problem #2 : All libraries have to be of the cross toolchain!</div>
<div>-o a.out</div><div>/home/hum/Documents/Projects/arm_toolchain/arm-2010.09/arm-none-linux-gnueabi/libc/usr/lib/crt1.o </div><div>/home/hum/Documents/Projects/arm_toolchain/arm-2010.09/arm-none-linux-gnueabi/libc/usr/lib/crti.o </div>
<div>crtbegin.o <<<<<<<<<< Problem #3 : All libraries have to be of the cross toolchain! (/home/hum/Documents/Projects/arm_toolchain/arm-2010.09/lib/gcc/arm-none-linux-gnueabi/4.5.1/armv4t/crtbegin.o needs to be used!!!)</div>
<div>-L/home/hum/Documents/Projects/arm_toolchain/arm-2010.09/arm-none-linux-gnueabi/libc/lib </div><div>-L/home/hum/Documents/Projects/arm_toolchain/arm-2010.09/arm-none-linux-gnueabi/libc/usr/lib </div><div>-plugin /home/hum/Documents/Projects/clang_llvm/build/Debug+Asserts/bin/../lib/LLVMgold.so <<<<<<<<<< Problem #4 : There is no LLVMgold.so in llvm/clang bin/ </div>
<div>hello.o </div><div class="im"><div>-lgcc </div><div>--as-needed </div><div>-lgcc_s </div><div>--no-as-needed </div><div>-lc </div><div>-lgcc </div><div>--as-needed </div><div>-lgcc_s </div><div>--no-as-needed </div>
</div><div>crtend.o <<<<<<<<<< Problem #5 : All libraries have to be of the cross toolchain! (/home/hum/Documents/Projects/arm_toolchain/arm-2010.09/lib/gcc/arm-none-linux-gnueabi/4.5.1/armv4t/crtend.o needs to be used!!!)</div>
<div>/home/hum/Documents/Projects/arm_toolchain/arm-2010.09/arm-none-linux-gnueabi/libc/usr/lib/crtn.o</div><div><br></div><div>/usr/bin/ld: unrecognised emulation mode: armelf_linux_eabi</div><div>Supported emulations: elf_i386 i386linux elf32_x86_64 elf_x86_64 elf_l1om elf_k1om</div>
<div class="im">
<div>clang: error: linker command failed with exit code 1 (use -v to see invocation)</div><div><br></div><div><br></div></div><div>Problem #1 : wrong linker! ld in cross toolchain is needed!</div><div>Problem #2 : All libraries have to be of the cross toolchain!</div>
<div>Problem #3 : All libraries have to be of the cross toolchain! (/home/hum/Documents/Projects/arm_toolchain/arm-2010.09/lib/gcc/arm-none-linux-gnueabi/4.5.1/armv4t/crtbegin.o needs to be used!!!)</div><div>Problem #4 : There is no LLVMgold.so in llvm/clang bin/</div>
<div>Problem #5 : All libraries have to be of the cross toolchain! (/home/hum/Documents/Projects/arm_toolchain/arm-2010.09/lib/gcc/arm-none-linux-gnueabi/4.5.1/armv4t/crtend.o needs to be used!!!)</div><div><br></div><div>
<br></div><div>Workaround #1 : tried to run /home/hum/Documents/Projects/arm_toolchain/arm-2010.09/arm-none-linux-gnueabi/bin/ld manually.</div><div>Workaround #2 : Ignored this library in this manual run.</div><div>Workaround #3 : /home/hum/Documents/Projects/arm_toolchain/arm-2010.09/lib/gcc/arm-none-linux-gnueabi/4.5.1/armv4t/crtbegin.o used instead.</div>
<div>Workaround #4 : Ignored this library in this manual run.</div><div>Workaround #5 : /home/hum/Documents/Projects/arm_toolchain/arm-2010.09/lib/gcc/arm-none-linux-gnueabi/4.5.1/armv4t/crtend.o used instead.</div><div>
<br>
</div><div><br></div><div><br></div><div>[Workaround - Manual Run]</div><div>/home/hum/Documents/Projects/arm_toolchain/arm-2010.09/bin/arm-none-linux-gnueabi-ld --sysroot=/home/hum/Documents/Projects/arm_toolchain/arm-2010.09/arm-none-linux-gnueabi/libc -z relro -X --hash-style=gnu --build-id --eh-frame-hdr -m armelf_linux_eabi -o a.out /home/hum/Documents/Projects/arm_toolchain/arm-2010.09/arm-none-linux-gnueabi/libc/usr/lib/crt1.o /home/hum/Documents/Projects/arm_toolchain/arm-2010.09/arm-none-linux-gnueabi/libc/usr/lib/crti.o /home/hum/Documents/Projects/arm_toolchain/arm-2010.09/lib/gcc/arm-none-linux-gnueabi/4.5.1/armv4t/crtbegin.o -L/home/hum/Documents/Projects/arm_toolchain/arm-2010.09/arm-none-linux-gnueabi/libc/lib -L/home/hum/Documents/Projects/arm_toolchain/arm-2010.09/arm-none-linux-gnueabi/libc/usr/lib hello.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /home/hum/Documents/Projects/arm_toolchain/arm-2010.09/lib/gcc/arm-none-linux-gnueabi/4.5.1/armv4t/crtend.o /home/hum/Documents/Projects/arm_toolchain/arm-2010.09/arm-none-linux-gnueabi/libc/usr/lib/crtn.o</div>
<div><br></div><div>[Output]</div><div>hello.o: file not recognized: File format not recognized</div><div><br></div><div>[Test]</div><div>"file hello.o" prints out :</div><div>hello.o: LLVM bitcode</div><div><br>
</div><div>[Question]</div><div>2. Am I using a wrong cross toolchain? Doesn't feeding LLVM bitcode to the ARM cross linker make sense?</div><div><br></div></div><div class="im HOEnZb"><div><br></div><div><br></div><div>
<div>Thank you very much.</div>
<div><br></div><div>Sincerely</div><div>Journeyer J. Joh</div><br></div><div><br></div><br><br></div><div class="HOEnZb"><div class="h5"><div class="gmail_quote">2012/6/19 Anton Korobeynikov <span dir="ltr"><<a href="mailto:anton@korobeynikov.info" target="_blank">anton@korobeynikov.info</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello<br>
<div><br>
> ./clang -v -emit-llvm -ccc-host-triple arm-none-linux-gnueabi<br>
> -I/home/hum/Documents/Projects/llvm_clang/gnuarm-4.0.2/arm-elf/include<br>
> -L/home/hum/Documents/Projects/llvm_clang/gnuarm-4.0.2/arm-elf/bin hello.c<br>
</div>You forgot about sysroot here.<br>
<div><br>
> /home/hum/Documents/Projects/llvm_clang/gnuarm-4.0.2/arm-elf/bin/ld:<br>
> unrecognised emulation mode: armelf_linux_eabi<br>
> Supported emulations: armelf<br>
</div>1. Your ld is too old<br>
2. Your ld was built for arm-elf, not arm-linux-eabi<br>
<span><font color="#888888"><br>
--<br>
With best regards, Anton Korobeynikov<br>
Faculty of Mathematics and Mechanics, Saint Petersburg State University<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div></div></div><div class="HOEnZb"><div class="h5">-- <br><div>----------------------------------------</div><div>Journeyer J. Joh</div><div>o o s a p r o g r a m m e r</div>
<div>a t</div><div>g m a i l d o t c o m</div>
<div>----------------------------------------</div><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div>----------------------------------------</div><div>Journeyer J. Joh</div><div>o o s a p r o g r a m m e r</div><div>a t</div><div>g m a i l d o t c o m</div>
<div>----------------------------------------</div><br>