Journeyer J. Joh
2012-Jun-27 12:24 UTC
[LLVMdev] Is cross-compiling for ARM on x86 with llvm/Clang possible?
Hello, With your kind concern and help, I now can make a binary for ARM target. ./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 -gcc-toolchain /home/hum/Documents/Projects/arm_toolchain/arm-2010.09 hello.c -o hello The build command is shown above. After that, I prepared an ARM laptop, AC100 - TOSHIBA. I installed Ubuntu 12.04 in the way guided from the link below. https://wiki.ubuntu.com/ARM/TEGRA/AC100 So I moved the final binary from host PC to AC100 and executed. But the binary DIDN'T RUN. $./hello returns an error message below. bash: ./hello: No such file hello I need to understand why it doesn't run on ARM laptop. I compiled another sample program hi.c on the ARM laptop and compared both - the one cross compiled "hello" and the other self host compiled "hi". Output message of utility "file" is almost the same except Linux version, one is 2.6.16 and the other is 2.6.31. But the output of "ldd" shows something meaningful. ldd hi libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6ecf000) /lib/ld-linux-armhf.so.3 (0xb6fc3000) ldd hello not a dynamic executable I guess I have to use a cross toolchain for my ARM target - AC 100. It has been equipped with Ubuntu 12.04. Could you provide me any hint to analize this problem? Thank you in advance. Journeyer J. Joh 2012/6/21 Journeyer J. Joh <oosaprogrammer at gmail.com>> Hi Joerg, > > Thank you very much! > > I finally found a working command string to cross-compile for ARM on x86. > > ./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 > -gcc-toolchain /home/hum/Documents/Projects/arm_toolchain/arm-2010.09 > hello.c -o hello > > Above works fine! Important options are > > -ccc-host-triple arm-none-linux-gnueabi > > --sysroot=/home/hum/Documents/Projects/arm_toolchain/arm-2010.09/arm-none-linux-gnueabi/libc > -gcc-toolchain /home/hum/Documents/Projects/arm_toolchain/arm-2010.09 > > And the environment variable PATH doesn't need to be changed. > > Thank you everyone who answered for my questions. > > Regards > Journeyer J. Joh > > 2012/6/20 Joerg Sonnenberger <joerg at britannica.bec.de> > >> On Wed, Jun 20, 2012 at 05:59:07PM +0900, Journeyer J. Joh wrote: >> > >> /home/hum/Documents/Projects/arm_toolchain/arm-2010.09/bin/arm-none-linux-gnueabi-ld >> >> Make sure the directory is in PATH, it will pick up LD automatically >> then. >> >> Joerg >> > > > > -- > ---------------------------------------- > 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 > ---------------------------------------- > >-- ---------------------------------------- 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 ---------------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120627/2f144ec6/attachment.html>
Sid Manning
2012-Jun-27 13:45 UTC
[LLVMdev] Is cross-compiling for ARM on x86 with llvm/Clang possible?
On 06/27/12 07:24, Journeyer J. Joh wrote:> Hello, > > With your kind concern and help, I now can make a binary for ARM target. > > ./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 > -gcc-toolchain /home/hum/Documents/Projects/arm_toolchain/arm-2010.09 > hello.c -o hello > > The build command is shown above. > > After that, I prepared an ARM laptop, AC100 - TOSHIBA. > I installed Ubuntu 12.04 in the way guided from the link below. > > https://wiki.ubuntu.com/ARM/TEGRA/AC100 > > So I moved the final binary from host PC to AC100 and executed. > But the binary DIDN'T RUN. > > $./hello > > returns an error message below. > > bash: ./hello: No such file hello >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.> I need to understand why it doesn't run on ARM laptop. > > I compiled another sample program hi.c on the ARM laptop and compared > both - the one cross compiled "hello" and the other self host compiled "hi". > > Output message of utility "file" is almost the same except Linux > version, one is 2.6.16 and the other is 2.6.31. But the output of "ldd" > shows something meaningful.This is curious based on the output from ldd below, does file report each as, "dynamically linked".> > ldd hi > libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6ecf000) > /lib/ld-linux-armhf.so.3 (0xb6fc3000) > > ldd hello > not a dynamic executable > >
Journeyer J. Joh
2012-Jun-28 12:08 UTC
[LLVMdev] Is cross-compiling for ARM on x86 with llvm/Clang possible?
Hello list I think I really finally found a way to crossbuild a binary for ARM using Clang/llvm. This message would be a documentation for someone who may concern for the same issue with me. - Target : TOSHIBA AC100 / Ubuntu 12.04 (https://wiki.ubuntu.com/ARM/** TEGRA/AC100 <https://wiki.ubuntu.com/ARM/TEGRA/AC100>) - Host : i386 Desktop PC / Ubuntu 12.04 - Toolchain on host : sudo apt-get install gcc-arm-linux-gnueabi - Clang/llvm compile : http://clang.llvm.org/get_started.html - 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 During this testing I found something like a bug in Clang or llvm. Please note the Command string for crossbuild above. Problem occurs if "-ccc-host-triple" gets "arm-linux-gnueabihf" instead of "arm-linux-gnueabi". 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. Workaroud for this problem is using a command string like below. ./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 Note all library path have to be specified. And more importantly crtend.o and crtbegin.o have to be symbolic-linked!! I tested with a toolchain for arm-linux-gnueabihf for this test.(sudo apt-get install gcc-arm-linux-gnueabihf) Thank you everyone who answered for my questions. Journeyer J. Joh (ps. For Sid, The final binary "hello" prints "not a dynamic executable" when asked with "ldd". But it runs very well. ^^) 2012/6/27 Sid Manning <sidneym at codeaurora.org>> On 06/27/12 07:24, Journeyer J. Joh wrote: > >> Hello, >> >> With your kind concern and help, I now can make a binary for ARM target. >> >> ./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 >> -gcc-toolchain /home/hum/Documents/Projects/**arm_toolchain/arm-2010.09 >> hello.c -o hello >> >> The build command is shown above. >> >> After that, I prepared an ARM laptop, AC100 - TOSHIBA. >> I installed Ubuntu 12.04 in the way guided from the link below. >> >> https://wiki.ubuntu.com/ARM/**TEGRA/AC100<https://wiki.ubuntu.com/ARM/TEGRA/AC100> >> >> So I moved the final binary from host PC to AC100 and executed. >> But the binary DIDN'T RUN. >> >> $./hello >> >> returns an error message below. >> >> bash: ./hello: No such file hello >> >> > 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. > > > > I need to understand why it doesn't run on ARM laptop. >> >> I compiled another sample program hi.c on the ARM laptop and compared >> both - the one cross compiled "hello" and the other self host compiled >> "hi". >> >> Output message of utility "file" is almost the same except Linux >> version, one is 2.6.16 and the other is 2.6.31. But the output of "ldd" >> shows something meaningful. >> > > This is curious based on the output from ldd below, does file report each > as, "dynamically linked". > > > >> ldd hi >> libc.so.6 => /lib/arm-linux-gnueabihf/libc.**so.6 (0xb6ecf000) >> /lib/ld-linux-armhf.so.3 (0xb6fc3000) >> >> ldd hello >> not a dynamic executable >> >> >>-- ---------------------------------------- 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 ---------------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120628/d0862dc2/attachment.html>
Journeyer J. Joh
2012-Jun-29 01:02 UTC
[LLVMdev] Is cross-compiling for ARM on x86 with llvm/Clang possible?
Hello Sid I checked the binary with "readelf -l" and you are right. Originally, it pointed the one of the host system. It has to be the one of the target system. This is why the option Wl,-dynamic-linker,path_to_target_dynamic_loader is needed. I understood this issue now. Thank you very much! Regards Journeyer J. Joh 2012/6/27 Sid Manning <sidneym at codeaurora.org>> On 06/27/12 07:24, Journeyer J. Joh wrote: > >> Hello, >> >> With your kind concern and help, I now can make a binary for ARM target. >> >> ./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 >> -gcc-toolchain /home/hum/Documents/Projects/**arm_toolchain/arm-2010.09 >> hello.c -o hello >> >> The build command is shown above. >> >> After that, I prepared an ARM laptop, AC100 - TOSHIBA. >> I installed Ubuntu 12.04 in the way guided from the link below. >> >> https://wiki.ubuntu.com/ARM/**TEGRA/AC100<https://wiki.ubuntu.com/ARM/TEGRA/AC100> >> >> So I moved the final binary from host PC to AC100 and executed. >> But the binary DIDN'T RUN. >> >> $./hello >> >> returns an error message below. >> >> bash: ./hello: No such file hello >> >> > 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. > > > > I need to understand why it doesn't run on ARM laptop. >> >> I compiled another sample program hi.c on the ARM laptop and compared >> both - the one cross compiled "hello" and the other self host compiled >> "hi". >> >> Output message of utility "file" is almost the same except Linux >> version, one is 2.6.16 and the other is 2.6.31. But the output of "ldd" >> shows something meaningful. >> > > This is curious based on the output from ldd below, does file report each > as, "dynamically linked". > > > >> ldd hi >> libc.so.6 => /lib/arm-linux-gnueabihf/libc.**so.6 (0xb6ecf000) >> /lib/ld-linux-armhf.so.3 (0xb6fc3000) >> >> ldd hello >> not a dynamic executable >> >> >>-- ---------------------------------------- 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 ---------------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120629/c0701ba5/attachment.html>
Seemingly Similar Threads
- [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?
- [LLVMdev] Is cross-compiling for ARM on x86 with llvm/Clang possible?
- [LLVMdev] Is cross-compiling for ARM on x86 with llvm/Clang possible?