Hello list<div><br></div><div>I think I really finally found a way to crossbuild a binary for ARM using Clang/llvm.</div><div><br></div><div>This message would be a documentation for someone who may concern for the same issue with me.</div>
<div><br></div><div>- Target : TOSHIBA AC100 / Ubuntu 12.04 (<a href="https://wiki.ubuntu.com/ARM/TEGRA/AC100" target="_blank">https://wiki.ubuntu.com/ARM/<u></u>TEGRA/AC100</a>)</div><div>- Host : i386 Desktop PC / Ubuntu 12.04</div>
<div>- Toolchain on host : <span style="background-color:rgb(244,245,247);color:rgb(85,85,85);font-size:12px;line-height:17px">sudo apt-get install gcc-arm-linux-gnueabi</span></div><div>- Clang/llvm compile : <span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)"> </span><a href="http://clang.llvm.org/get_started.html" target="_blank" style="color:rgb(17,85,204);font-family:arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)">http://clang.llvm.org/get_started.html</a><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)"> </span></div>
<div>- Command string for crossbuild : ./clang -v --save-temps -ccc-host-triple arm-linux-gnueabi --sysroot=/usr/arm-linux-gnueabi -gcc-toolchain /usr/ -Wl,-dynamic-linker,/lib/ld-linux-armhf.so.3 hello.c -o hello</div><div>
<br></div><div>During this testing I found something like a bug in Clang or llvm.</div><div>Please note the Command string for crossbuild above.</div><div>Problem occurs if "-ccc-host-triple" gets "arm-linux-gnueabihf" instead of "arm-linux-gnueabi".</div>
<div>Problem is that ld is called with a incomplete or no path for libgcc, crtbegin.o and crtend.o "-gcc-toolchain" options doesn't seem to work.</div><div>Workaroud for this problem is using a command string like below.</div>
<div><br></div><div>./clang -v --save-temps -ccc-host-triple arm-linux-gnueabihf -mfloat-abi=hard -mfpu=vfpv3-d16 --sysroot=/usr/arm-linux-gnueabihf -gcc-toolchain /usr/ -Wl,-dynamic-linker,/lib/ld-linux-armhf.so.3 -L/usr/lib/gcc/arm-linux-gnueabihf/4.6 -L/usr/lib/gcc/arm-linux-gnueabihf/4.6/../../../../arm-linux-gnueabihf/lib/../lib -L/usr/lib/gcc/arm-linux-gnueabihf/4.6/../../../../arm-linux-gnueabihf/lib -L/lib/arm-linux-gnueabihf -L/usr/lib/arm-linux-gnueabihf -L/usr/lib -L/lib hello.c -o hello</div>
<div><br></div><div>Note all library path have to be specified. And more importantly crtend.o and crtbegin.o have to be symbolic-linked!!</div><div>I tested with a toolchain for arm-linux-gnueabihf for this test.(<span style="background-color:rgb(244,245,247);color:rgb(85,85,85);font-size:12px;line-height:17px">sudo apt-get install gcc-arm-linux-gnueabihf</span>)</div>
<div><br></div><div>Thank you everyone who answered for my questions.</div><div><br></div><div>Journeyer J. Joh</div><div><br></div><div>(ps. For Sid, The final binary "hello" prints "not a dynamic executable" when asked with "ldd". But it runs very well. ^^)</div>
<div><br></div><div><br><div class="gmail_quote">2012/6/27 Sid Manning <span dir="ltr"><<a href="mailto:sidneym@codeaurora.org" target="_blank">sidneym@codeaurora.org</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 06/27/12 07:24, Journeyer J. Joh wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,<br>
<br>
With your kind concern and help, I now can make a binary for ARM target.<br>
<br>
./clang -v --save-temps -ccc-host-triple arm-none-linux-gnueabi<br>
--sysroot=/home/hum/Documents/<u></u>Projects/arm_toolchain/arm-<u></u>2010.09/arm-none-linux-<u></u>gnueabi/libc<br>
-gcc-toolchain /home/hum/Documents/Projects/<u></u>arm_toolchain/arm-2010.09<br>
hello.c -o hello<br>
<br>
The build command is shown above.<br>
<br>
After that, I prepared an ARM laptop, AC100 - TOSHIBA.<br>
I installed Ubuntu 12.04 in the way guided from the link below.<br>
<br>
<a href="https://wiki.ubuntu.com/ARM/TEGRA/AC100" target="_blank">https://wiki.ubuntu.com/ARM/<u></u>TEGRA/AC100</a><br>
<br>
So I moved the final binary from host PC to AC100 and executed.<br>
But the binary DIDN'T RUN.<br>
<br>
$./hello<br>
<br>
returns an error message below.<br>
<br>
bash: ./hello: No such file hello<br>
<br>
</blockquote>
<br></div>
You could try readelf -l hello and check the INTERP header. When I've seen this message usually PT_INTERP points to something that the kernel can't find.<div class="im"><br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I need to understand why it doesn't run on ARM laptop.<br>
<br>
I compiled another sample program hi.c on the ARM laptop and compared<br>
both - the one cross compiled "hello" and the other self host compiled "hi".<br>
<br>
Output message of utility "file" is almost the same except Linux<br>
version, one is 2.6.16 and the other is 2.6.31. But the output of "ldd"<br>
shows something meaningful.<br>
</blockquote>
<br></div>
This is curious based on the output from ldd below, does file report each as, "dynamically linked".<div class="HOEnZb"><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
ldd hi<br>
libc.so.6 => /lib/arm-linux-gnueabihf/libc.<u></u>so.6 (0xb6ecf000)<br>
/lib/ld-linux-armhf.so.3 (0xb6fc3000)<br>
<br>
ldd hello<br>
not a dynamic executable<br>
<br>
<br>
</blockquote>
</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>
</div>