<div>Hello <span style>Gergö, Joerg and people on our list</span></div><div><br></div><div>With your kind answer, I tried to build a hello world program for ARM(arm-none-linux-gnueabi) on my x86-64 PC.</div><div><br></div>
<div>Thank you we verified the generated bitcode. The only thing remained is linking.</div><div><br></div><div>Let me brief what I did so far.</div><div><br></div><div>1. Built Clang/llvm in a way explained in <a href="http://clang.llvm.org/get_started.html">http://clang.llvm.org/get_started.html</a> on Ubuntu 11.10 x86-64 PC</div>
<div>2. Downloaded gcc-4.0 toolchain binaries for x86-64 from <a href="http://www.gnuarm.com/">http://www.gnuarm.com/</a></div><div>3. Wrote a hello.c as shown below.</div><div><div><br></div><div>#include <stdio.h></div>
<div><br></div><div>int main(void)</div><div>{</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>printf("\nHello World!\n\n");</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">     </span>return 0;</div>
<div>}</div></div><div><br></div><div>4. Tested as shown below.</div><div><br></div><div>./clang -v -emit-llvm -ccc-host-triple arm-none-linux-gnueabi -I/home/hum/Documents/Projects/llvm_clang/gnuarm-4.0.2/arm-elf/include -L/home/hum/Documents/Projects/llvm_clang/gnuarm-4.0.2/arm-elf/bin hello.c</div>
<div><br></div><div>5. Received an output and an error message shown below.</div><div><br></div><div><div>clang version 3.2 (trunk 158657)</div><div>Target: arm-none-linux-gnueabi</div><div>Thread model: posix</div><div> "/home/hum/Documents/Projects/llvm_clang/build/Debug+Asserts/bin/clang" -cc1 -triple armv4t-none-linux-gnueabi -emit-llvm-bc -disable-free -main-file-name hello.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.21.53.20110810 -momit-leaf-frame-pointer -v -resource-dir /home/hum/Documents/Projects/llvm_clang/build/Debug+Asserts/bin/../lib/clang/3.2 -I /home/hum/Documents/Projects/llvm_clang/gnuarm-4.0.2/arm-elf/include -fmodule-cache-path /var/tmp/clang-module-cache -internal-isystem /usr/local/include -internal-isystem /home/hum/Documents/Projects/llvm_clang/build/Debug+Asserts/bin/../lib/clang/3.2/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fno-dwarf-directory-asm -fdebug-compilation-dir /home/hum/Documents/Projects/llvm_clang/build/Debug+Asserts/bin -ferror-limit 19 -fmessage-length 212 -mstackrealign -fno-signed-char -fgnu-runtime -fobjc-runtime-has-arc -fobjc-runtime-has-weak -fobjc-fragile-abi -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/hello-T8xLAt.o -x c hello.c</div>
<div>clang -cc1 version 3.2 based upon LLVM 3.2svn default target x86_64-unknown-linux-gnu</div><div>ignoring nonexistent directory "/include"</div><div>#include "..." search starts here:</div><div>#include <...> search starts here:</div>
<div> /home/hum/Documents/Projects/llvm_clang/gnuarm-4.0.2/arm-elf/include</div><div> /usr/local/include</div><div> /home/hum/Documents/Projects/llvm_clang/build/Debug+Asserts/bin/../lib/clang/3.2/include</div><div> /usr/include</div>
<div>End of search list.</div><div> "/usr/bin/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 crt1.o crti.o crtbegin.o -L/home/hum/Documents/Projects/llvm_clang/gnuarm-4.0.2/arm-elf/bin -L/usr/lib/../lib32 -L/lib -L/usr/lib -plugin /home/hum/Documents/Projects/llvm_clang/build/Debug+Asserts/bin/../lib/LLVMgold.so /tmp/hello-T8xLAt.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed crtend.o crtn.o</div>
<div>/usr/bin/ld: unrecognised emulation mode: armelf_linux_eabi</div><div>Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 i386linux elf_l1om elf_k1om</div><div>clang: error: linker command failed with exit code 1 (use -v to see invocation)</div>
</div><div><br></div><div>6. The problem occurred when clang starts to link with ld. Clang tried to use the ld in a wrong place - "/usr/bin/ld". So I tried it  myself like below.</div><div><br></div>/home/hum/Documents/Projects/llvm_clang/gnuarm-4.0.2/arm-elf/bin/ld -z relro -X --hash-style=gnu --build-id --eh-frame-hdr -m armelf_linux_eabi -o a.out crt1.o crti.o crtbegin.o -L/home/hum/Documents/Projects/llvm_clang/gnuarm-4.0.2/arm-elf/bin -plugin /home/hum/Documents/Projects/llvm_clang/build/Debug+Asserts/bin/../lib/LLVMgold.so /tmp/hello-Fe7D3Y.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed crtend.o crtn.o<div>
<br></div><div>7. And received an error message below.</div><div><br></div><div><div>/home/hum/Documents/Projects/llvm_clang/gnuarm-4.0.2/arm-elf/bin/ld: unrecognised emulation mode: armelf_linux_eabi</div><div>Supported emulations: armelf</div>
</div><div><br></div><div>8. I found a talk about this problem below.</div><div><br></div><div><a href="http://sourceware.org/bugzilla/show_bug.cgi?id=12643">http://sourceware.org/bugzilla/show_bug.cgi?id=12643</a>
</div><div><br></div><div>9. But I don't know where <span style="font-size:medium;white-space:pre-wrap">ld/configure.tgt </span>exists.</div><div><br></div><div><br></div><div>Let me list up things I want to know.</div>
<div><br></div><div>A. For the #6 above, how can I make clang use ld in the toolchain not int the system?</div><div>B. For the #7 above, how can I trouble-shoot this, I couldn't find .tgt file introduced in the #9 above.</div>
<div>C. For all the steps above, am I doing all right, I doubt if <a href="http://www.gnuarm.com">www.gnuarm.com</a> is trustful.</div><div><br></div><div>For Joerg, I tried using -isysroot as a clang option, but I couldn't find any difference it brings.</div>
<div><br></div><div>Thank you very much.</div><div><br></div><div>Sincerely</div><div><br></div><div>Journeyer J. Joh</div><div><br></div><div><br><div class="gmail_quote">2012/6/18 Joerg Sonnenberger <span dir="ltr"><<a href="mailto:joerg@britannica.bec.de" target="_blank">joerg@britannica.bec.de</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Sat, Jun 16, 2012 at 08:20:23PM +0900, Journeyer J. Joh wrote:<br>
> If the cross compiling is supported, is there any documentation on how to<br>
> do it?<br>
<br>
</div>The short version is: assuming you have a cross-binutils installation<br>
using e.g. x86_64--netbsd-as and x86_64--netbsd-ld, you add a symlink<br>
called x86_64--netbsd-clang to clang and just call that with an<br>
appropiate --sysroot to make it find your target include headers and<br>
libraries. Substitute x86_64--netbsd with the triple of your choice.<br>
Alternative, call clang -target x86_64--netbsd ...<br>
<br>
Joerg<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</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>
</div>