<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>Target: arm-none-linux-gnueabi</div><div>Thread model: posix</div><div><br></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>-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>-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>-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>
-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>#include "..." search starts here:</div><div>#include <...> search starts here:</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>-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>-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>-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>
-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>#include "..." search starts here:</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>-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>-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>-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>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>clang: error: linker command failed with exit code 1 (use -v to see invocation)</div><div><br></div><div><br></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><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 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>-- <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>