[cfe-users] C/C++ system include dirs when cross-compiling
Hi list, I'm using clang to cross-compile for a sparc-target. Except for the compiler I (seem to) rely entirely on gcc-tools (ld, asm). I doing this by passing the -B - flag to clang. I'm now facing an issue where I would like to have clang use the c++-system-includes of my gcc-installation. When I dump the considered include-dirs with echo | sparc-elf-gcc -nostdlib -xc++ -E -Wp,-v - -fsyntax-only I'm getting a list of all the paths I'm looking for. Doing the same with clang (even with the -B-flag) having the -target-flag set, the list is empty. What is the proper way to let clang now where to find the system-includes in cross-compilation scenarios? I'm now using a script which generates -isystem-arguments which based on a list generated with a call as shown above. Should the list be derived from the -B-argument? best regards, -- Patrick. ___ cfe-users mailing list cfe-users@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
Re: [cfe-users] C/C++ system include dirs when cross-compiling
Hi Patrick, This is a common case when cross compiling, so clang knows how to use a gcc-toolchain installation: you just have to pass it the "--sysroot=..." and "--toolchain=..." arguments, and it will get the header files and linker / assembler for your target --- assuming your gcc-toolchain has a standard layout. Kind regards, Arnaud On Thu, Mar 24, 2016 at 4:22 PM, Patrick Boettcher via cfe-users < cfe-users@lists.llvm.org> wrote: > Hi list, > > I'm using clang to cross-compile for a sparc-target. > > Except for the compiler I (seem to) rely entirely on gcc-tools (ld, > asm). I doing this by passing the -B > - flag to clang. > > I'm now facing an issue where I would like to have clang use the > c++-system-includes of my gcc-installation. > > When I dump the considered include-dirs with > > echo | sparc-elf-gcc -nostdlib -xc++ -E -Wp,-v - -fsyntax-only > > I'm getting a list of all the paths I'm looking for. Doing the same > with clang (even with the -B-flag) having the -target-flag set, the > list is empty. > > What is the proper way to let clang now where to find the > system-includes in cross-compilation scenarios? > > I'm now using a script which generates -isystem-arguments which based > on a list generated with a call as shown above. > > Should the list be derived from the -B-argument? > > best regards, > -- > Patrick. > ___ > cfe-users mailing list > cfe-users@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users > ___ cfe-users mailing list cfe-users@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
Re: [cfe-users] C/C++ system include dirs when cross-compiling
On Thu, Mar 24, 2016 at 11:48 AM, Arnaud Allard de Grandmaison via cfe-users wrote: > Hi Patrick, > > This is a common case when cross compiling, so clang knows how to use a > gcc-toolchain installation: you just have to pass it the "--sysroot=..." and > "--toolchain=..." arguments, and it will get the header files and linker / > assembler for your target --- assuming your gcc-toolchain has a standard > layout. That last caveat is the one that gives me the most trouble on Ubuntu. They seem to have an odd layout for their ARM-HF toolchain, and using --sysroot fails to compile/link. Also see "g++-arm-linux-gnueabi cannot compile a C++ program with --sysroot", http://bugs.launchpad.net/ubuntu/+source/gcc-defaults-armel-cross/+bug/1375071. Jeff ___ cfe-users mailing list cfe-users@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
Re: [cfe-users] C/C++ system include dirs when cross-compiling
There must be some misunderstanding there. The goal is to write: > clang++ -target sparc--netbsd -mcpu=... compile_flags --sysroot=... --toolchain=.. -o program.exe program.cpp And clang will cross-compile program.cpp for this specific sparc cpu using the includes from the sysroot, and link using the linker and libraries from sysroot+toolchain. I do no think there is any reason to try to use "g++-arm-linux-gnueabi" with sysroot, and the fact that the g++ you refer to does not work with --sysroot is something not relevant to this clang user mailing list --- but I may be missing something. For your specific problem, you may want to give a try to the gcc packaged by linaro (http://www.linaro.org/downloads/) which works pretty well in my experience. Kind regards, Arnaud On Thu, Mar 24, 2016 at 8:29 PM, Jeffrey Walton wrote: > On Thu, Mar 24, 2016 at 11:48 AM, Arnaud Allard de Grandmaison via > cfe-users wrote: > > Hi Patrick, > > > > This is a common case when cross compiling, so clang knows how to use a > > gcc-toolchain installation: you just have to pass it the "--sysroot=..." > and > > "--toolchain=..." arguments, and it will get the header files and linker > / > > assembler for your target --- assuming your gcc-toolchain has a standard > > layout. > > That last caveat is the one that gives me the most trouble on Ubuntu. > They seem to have an odd layout for their ARM-HF toolchain, and using > --sysroot fails to compile/link. Also see "g++-arm-linux-gnueabi > cannot compile a C++ program with --sysroot", > > http://bugs.launchpad.net/ubuntu/+source/gcc-defaults-armel-cross/+bug/1375071 > . > > Jeff > ___ cfe-users mailing list cfe-users@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
Re: [cfe-users] C/C++ system include dirs when cross-compiling
Hi Arnaud, On Thu, 24 Mar 2016 16:48:30 +0100 Arnaud Allard de Grandmaison wrote: > Hi Patrick, > > This is a common case when cross compiling, so clang knows how to use > a gcc-toolchain installation: you just have to pass it the > "--sysroot=..." and "--toolchain=..." arguments, and it will get the > header files and linker / assembler for your target --- assuming your > gcc-toolchain has a standard layout. It wasn't that straight-forward for me to find information about this "common case" as you call it ;-) . I initially had problems finding the -B option of clang (it is not listed in --help nor in --help-hidden). The --gcc-toolchain-argument does not work with the clang I built: ../../upstream/build/bin/clang++ --gcc-toolchain clang-3.8: error: unsupported option '--gcc-toolchain' clang-3.8: error: no input files But it is listed in --help. Is this a bug or is my build faulty? I tried --sysroot and it made the path appear in the clang-system-include-paths. But my gcc-toolchain does not have the c++-headers in there just the C ones. C++ header files were installed to path/to/toolchain//include/c++/ I generated my gcc-toolchain with crosstool-ng. I haven't found yet the option (if any) to tell ct-ng to install c++-headers in sysroot as well. Thank you for your input. regards, -- Patrick. ___ cfe-users mailing list cfe-users@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users