Journeyer J. Joh
2012-Jun-16 11:20 UTC
[LLVMdev] Is cross-compiling for ARM on x86 with llvm/Clang possible?
Hello list, I wonder if llvm/Clang can compile C or C++ for ARM from on x86. http://comments.gmane.org/gmane.comp.compilers.clang.devel/8896 The talk above answered 'NO' to my question, which means Clang is not yet able to cross compile for ARM on X86. Is the answer still correct for my question? I saw somewhere that Clang supports ARM on Darwin only. Then is the cross compiling possible only on Darwin not on linux or FreeBSD? If the cross compiling is supported, is there any documentation on how to do it? Thank you very much in advance. Best regards Journeyer -- ---------------------------------------- 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/20120616/4a3017c1/attachment.html>
Gergö Barany
2012-Jun-18 10:36 UTC
[LLVMdev] Is cross-compiling for ARM on x86 with llvm/Clang possible?
On Sat, Jun 16, 2012 at 20:20:23 +0900, Journeyer J. Joh wrote:> I wonder if llvm/Clang can compile C or C++ for ARM from on x86.Yes. I use clang -emit-llvm -ccc-host-triple arm-unknown-linux-gnu -I /..arm../include/ to generate LLVM bitcode files for ARM. llc then automagically knows to generate ARM assembly, and ARM binutils take it from there.> If the cross compiling is supported, is there any documentation on how to > do it?Dunno. Last time I looked, the documentation of clang's command line flags disagreed with reality, and the -ccc-host-triple flag wasn't documented anywhere. This might have changed in the meantime. -- Gergö Barany, research assistant gergo at complang.tuwien.ac.at Institute of Computer Languages http://www.complang.tuwien.ac.at/gergo/ Vienna University of Technology Tel: +43-1-58801-58522 Argentinierstrasse 8/E185, 1040 Wien, Austria Fax: +43-1-58801-18598
Journeyer J. Joh
2012-Jun-18 11:40 UTC
[LLVMdev] Is cross-compiling for ARM on x86 with llvm/Clang possible?
Hi, Gergö Cross compiling with Clang/llvm is much easier than with llvm-gcc or gcc! Thank you very much!! Though I am so much new to llvm that I can't prove your answer right way, my friend verified your answer. Thank you very much. Sincerely Journeyer (PS. Sorry I am resending same email because I sent only to you. I want to say thank you on the mail list.) 2012/6/18 Gergö Barany <gergo at complang.tuwien.ac.at>> On Sat, Jun 16, 2012 at 20:20:23 +0900, Journeyer J. Joh wrote: > > I wonder if llvm/Clang can compile C or C++ for ARM from on x86. > > Yes. I use > clang -emit-llvm -ccc-host-triple arm-unknown-linux-gnu -I > /..arm../include/ > to generate LLVM bitcode files for ARM. llc then automagically knows to > generate ARM assembly, and ARM binutils take it from there. > > > If the cross compiling is supported, is there any documentation on how to > > do it? > > Dunno. Last time I looked, the documentation of clang's command line flags > disagreed with reality, and the -ccc-host-triple flag wasn't documented > anywhere. This might have changed in the meantime. > > -- > Gergö Barany, research assistant > gergo at complang.tuwien.ac.at > Institute of Computer Languages > http://www.complang.tuwien.ac.at/gergo/ > Vienna University of Technology Tel: > +43-1-58801-58522 > Argentinierstrasse 8/E185, 1040 Wien, Austria Fax: > +43-1-58801-18598 >-- ---------------------------------------- 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/20120618/12efcb9c/attachment.html>
Joerg Sonnenberger
2012-Jun-18 12:59 UTC
[LLVMdev] Is cross-compiling for ARM on x86 with llvm/Clang possible?
On Sat, Jun 16, 2012 at 08:20:23PM +0900, Journeyer J. Joh wrote:> If the cross compiling is supported, is there any documentation on how to > do it?The short version is: assuming you have a cross-binutils installation using e.g. x86_64--netbsd-as and x86_64--netbsd-ld, you add a symlink called x86_64--netbsd-clang to clang and just call that with an appropiate --sysroot to make it find your target include headers and libraries. Substitute x86_64--netbsd with the triple of your choice. Alternative, call clang -target x86_64--netbsd ... Joerg
Journeyer J. Joh
2012-Jun-19 07:47 UTC
[LLVMdev] Is cross-compiling for ARM on x86 with llvm/Clang possible?
Hello Gergö, Joerg and people on our list With your kind answer, I tried to build a hello world program for ARM(arm-none-linux-gnueabi) on my x86-64 PC. Thank you we verified the generated bitcode. The only thing remained is linking. Let me brief what I did so far. 1. Built Clang/llvm in a way explained in http://clang.llvm.org/get_started.html on Ubuntu 11.10 x86-64 PC 2. Downloaded gcc-4.0 toolchain binaries for x86-64 from http://www.gnuarm.com/ 3. Wrote a hello.c as shown below. #include <stdio.h> int main(void) { printf("\nHello World!\n\n"); return 0; } 4. Tested as shown below. ./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 5. Received an output and an error message shown below. clang version 3.2 (trunk 158657) Target: arm-none-linux-gnueabi Thread model: posix "/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 clang -cc1 version 3.2 based upon LLVM 3.2svn default target x86_64-unknown-linux-gnu ignoring nonexistent directory "/include" #include "..." search starts here: #include <...> search starts here: /home/hum/Documents/Projects/llvm_clang/gnuarm-4.0.2/arm-elf/include /usr/local/include /home/hum/Documents/Projects/llvm_clang/build/Debug+Asserts/bin/../lib/clang/3.2/include /usr/include End of search list. "/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 /usr/bin/ld: unrecognised emulation mode: armelf_linux_eabi Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 i386linux elf_l1om elf_k1om clang: error: linker command failed with exit code 1 (use -v to see invocation) 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. /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 7. And received an error message below. /home/hum/Documents/Projects/llvm_clang/gnuarm-4.0.2/arm-elf/bin/ld: unrecognised emulation mode: armelf_linux_eabi Supported emulations: armelf 8. I found a talk about this problem below. http://sourceware.org/bugzilla/show_bug.cgi?id=12643 9. But I don't know where ld/configure.tgt exists. Let me list up things I want to know. A. For the #6 above, how can I make clang use ld in the toolchain not int the system? B. For the #7 above, how can I trouble-shoot this, I couldn't find .tgt file introduced in the #9 above. C. For all the steps above, am I doing all right, I doubt if www.gnuarm.comis trustful. For Joerg, I tried using -isysroot as a clang option, but I couldn't find any difference it brings. Thank you very much. Sincerely Journeyer J. Joh 2012/6/18 Joerg Sonnenberger <joerg at britannica.bec.de>> On Sat, Jun 16, 2012 at 08:20:23PM +0900, Journeyer J. Joh wrote: > > If the cross compiling is supported, is there any documentation on how to > > do it? > > The short version is: assuming you have a cross-binutils installation > using e.g. x86_64--netbsd-as and x86_64--netbsd-ld, you add a symlink > called x86_64--netbsd-clang to clang and just call that with an > appropiate --sysroot to make it find your target include headers and > libraries. Substitute x86_64--netbsd with the triple of your choice. > Alternative, call clang -target x86_64--netbsd ... > > Joerg > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-- ---------------------------------------- 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/20120619/c663f4d0/attachment.html>
Apparently Analagous 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?