Negar Mir
2012-Nov-21 17:26 UTC
[LLVMdev] Is cross-compiling for ARM on x86 with llvm/Clang possible?
Hi Journeyer J. Joh, Thank you so much for the solution. It was very helpful. Now, I'm wondering if you have tested compiling a whole project (with several .c/.cpp files) and achieve one binary file. Previously (on X86), I built .bc files separately and then I used llvm-link to get one .bc file and produce one binary file for the whole project. But, this time I encountered some errors like the following, and it seems that it cannot link to the appropriate ARM libraries. In file included from ../../../../LLVM/project/file1.cpp:8: /usr/lib/gcc/arm-linux-gnueabi/4.6/../../../../include/c++/4.6/iostream:38:10: fatal error: 'bits/c++config.h' file not found #include <bits/c++config.h> ^ Thanks Negar -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121121/43e4f175/attachment.html>
Tim Northover
2012-Nov-21 18:13 UTC
[LLVMdev] Is cross-compiling for ARM on x86 with llvm/Clang possible?
Hi Negar,> In file included from ../../../../LLVM/project/file1.cpp:8: > /usr/lib/gcc/arm-linux-gnueabi/4.6/../../../../include/c++/4.6/iostream:38:10: > fatal error: > 'bits/c++config.h' file not found > #include <bits/c++config.h> > ^That's a compile-time error rather than link-time. Clang does its best to find all the bits of the cross-toolchain it needs, but it doesn't always succeed. The immediate error is it not knowing about the directory where c++config.h is stored, but in fact that path it's getting "iostream" from looks a little dodgy too. If I'm calculating my ..s correctly, it's "/usr/include/c++/4.6/iostream" which is probably the host's copy. It *may* be compatible, but then again it may not. Some combination of --sysroot, -gcc-toolchain and -target may be enough, but for more complex installations you may need to manually give it some -isystem options too. What clang command-line (and/or configure options) are you using to tell it where to find the arm-linux-gnueabi toolchain? Tim.
Tim Northover
2012-Nov-21 18:15 UTC
[LLVMdev] Is cross-compiling for ARM on x86 with llvm/Clang possible?
> What clang command-line (and/or configure options) are you using to > tell it where to find the arm-linux-gnueabi toolchain?Never mind, it looks like there's another thread with that information. Tim.
Journeyer J. Joh
2012-Nov-22 00:26 UTC
[LLVMdev] Is cross-compiling for ARM on x86 with llvm/Clang possible?
Hello Negar Mir, It's good that my experience help someone. For me, this kind of errors require to put '-v' option in the build command line so that the the exact build command can be exposed. I compiled with the options below. -ccc-host-triple $(CCC_HOST_TRIPLE_ARM) \ --sysroot=$(SYSROOT_ARM) \ -gcc-toolchain $(GCC_TOOLCHAIN) And this options below needed to run compiled binary on the target. -Wl,-dynamic-linker,/lib/ld-linux.so.3 (the version must be matched to the one in the target) But I haven't tried like you - mix .bc file with .c, .cpp to build a final output. I recommend you check with '-v' option. Good luck! Journeyer 2012/11/22 Negar Mir <nmiralaei at gmail.com>:> Hi Journeyer J. Joh, > > Thank you so much for the solution. It was very helpful. Now, I'm wondering > if you have tested compiling a whole project (with several .c/.cpp files) > and achieve one binary file. Previously (on X86), I built .bc files > separately and then I used llvm-link to get one .bc file and produce one > binary file for the whole project. But, this time I encountered some errors > like the following, and it seems that it cannot link to the appropriate ARM > libraries. > > In file included from ../../../../LLVM/project/file1.cpp:8: > /usr/lib/gcc/arm-linux-gnueabi/4.6/../../../../include/c++/4.6/iostream:38:10: > fatal error: > 'bits/c++config.h' file not found > #include <bits/c++config.h> > ^ > > Thanks > Negar > > > _______________________________________________ > 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 ----------------------------------------
David Tweed
2012-Nov-22 09:08 UTC
[LLVMdev] Is cross-compiling for ARM on x86 with llvm/Clang possible?
Sorry for the delay, only just saw this message. -----Original Message----- From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Tim Northover Sent: 21 November 2012 18:14 To: Negar Mir Cc: LLVM Developers Mailing List Subject: Re: [LLVMdev] Is cross-compiling for ARM on x86 with llvm/Clang possible? Hi Negar,> In file included from ../../../../LLVM/project/file1.cpp:8: >/usr/lib/gcc/arm-linux-gnueabi/4.6/../../../../include/c++/4.6/iostream:38:1 0:> fatal error: > 'bits/c++config.h' file not found > #include <bits/c++config.h> > ^| That's a compile-time error rather than link-time. Clang does its best | to find all the bits of the cross-toolchain it needs, but it doesn't | always succeed. The immediate error is it not knowing about the | directory where c++config.h is stored, but in fact that path it's | getting "iostream" from looks a little dodgy too. If I'm calculating | my ..s correctly, it's "/usr/include/c++/4.6/iostream" which is | probably the host's copy. It *may* be compatible, but then again it | may not.>From work on the pandaboard transition to hard float, I discovered the waythat this works is clang tries to find the gcc installation for the platform you're compiling for, then locates headers relative to that with ..'s . The idea is that natively it'll end up at "/usr/..." while you'd typically install cross-compilers in a different place and this will end up at the cross-compile targets. So the first thing to do is figure out which bits/c++config.h file corresponds to the ARM cross compile environment, and where it resides relative to the /usr/lib/gcc/arm-linux-gnueabi/4.6 directory. If it's not in the expected place then you may need, as Tim says, to specify some files manually or go for a different cross-compiler installation. (Note: I explicitly disavow understanding this stuff, it's purely at the level of "if you do this things work".)
Gordon Keiser
2012-Nov-23 05:03 UTC
[LLVMdev] Is cross-compiling for ARM on x86 with llvm/Clang possible?
If /usr/lib/gcc/arm-linux-gnueabi/4.6/../../../../include/c++/4.6/ is the proper c++ include directory for your toolchain, I'm guessing bits/c++config.h will be located at /usr/lib/gcc/arm-linux-gnueabi/4.6/../../../../include/c++/4.6/arm-linux-gnueabi/bits/c++config.h ... many of the arm cross toolchains (codesourcery for example) seem to be structured this way, although clang doesn't (or didn't as of 3.1) detect this layout. Adding an include for that /usr/lib/gcc/arm-linux-gnueabi/4.6/../../../../include/c++/4.6/arm-linux-gnueabi/bits should fix it. Cheers, Gordon Keiser Software Development Engineer Arxan Technologies From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Negar Mir Sent: Wednesday, November 21, 2012 12:27 PM To: llvmdev at cs.uiuc.edu Subject: [LLVMdev] Is cross-compiling for ARM on x86 with llvm/Clang possible? Hi Journeyer J. Joh, Thank you so much for the solution. It was very helpful. Now, I'm wondering if you have tested compiling a whole project (with several .c/.cpp files) and achieve one binary file. Previously (on X86), I built .bc files separately and then I used llvm-link to get one .bc file and produce one binary file for the whole project. But, this time I encountered some errors like the following, and it seems that it cannot link to the appropriate ARM libraries. In file included from ../../../../LLVM/project/file1.cpp:8: /usr/lib/gcc/arm-linux-gnueabi/4.6/../../../../include/c++/4.6/iostream:38:10: fatal error: 'bits/c++config.h' file not found #include <bits/c++config.h> ^ Thanks Negar -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121122/e6542f0d/attachment.html>
Possibly Parallel Threads
- [LLVMdev] Is cross-compiling for ARM on x86 with llvm/Clang possible?
- [LLVMdev] Question about compiling LLVM through cross-compiler for ARM
- [LLVMdev] Question about compiling LLVM through cross-compiler for ARM
- [LLVMdev] Question about compiling LLVM through cross-compiler for ARM
- [LLVMdev] About LLVM 3.1 ARM testing