Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cross-compiler 8.2.0 doesn't have {sysroot}/usr/include in its header search path #3

Closed
avilleret opened this issue Jan 10, 2019 · 5 comments
Labels
Bug 🐛 Error, flaw or fault Solved 🎏 Goal Achieved!

Comments

@avilleret
Copy link

with your 8.2.0 compiler I got :

$ echo | LANG=en_US.UTF-8 arm-linux-gnueabihf-gcc --sysroot=/home/antoine/dev/ofnode/sysroot -E -Wp,-v -
ignoring nonexistent directory "/opt/cross-pi-gcc-8.2.0/bin/../lib/gcc/arm-linux-gnueabihf/8.2.0/../../../../arm-linux-gnueabihf/sys-include"
ignoring duplicate directory "/opt/cross-pi-gcc-8.2.0/bin/../lib/gcc/../../lib/gcc/arm-linux-gnueabihf/8.2.0/include"
ignoring duplicate directory "/opt/cross-pi-gcc-8.2.0/bin/../lib/gcc/../../lib/gcc/arm-linux-gnueabihf/8.2.0/include-fixed"
ignoring nonexistent directory "/opt/cross-pi-gcc-8.2.0/bin/../lib/gcc/../../lib/gcc/arm-linux-gnueabihf/8.2.0/../../../../arm-linux-gnueabihf/sys-include"
ignoring duplicate directory "/opt/cross-pi-gcc-8.2.0/bin/../lib/gcc/../../lib/gcc/arm-linux-gnueabihf/8.2.0/../../../../arm-linux-gnueabihf/include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/cross-pi-gcc-8.2.0/bin/../lib/gcc/arm-linux-gnueabihf/8.2.0/include
 /opt/cross-pi-gcc-8.2.0/bin/../lib/gcc/arm-linux-gnueabihf/8.2.0/include-fixed
 /opt/cross-pi-gcc-8.2.0/bin/../lib/gcc/arm-linux-gnueabihf/8.2.0/../../../../arm-linux-gnueabihf/include
End of search list.
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 31 "<command-line>"
# 1 "/opt/cross-pi-gcc-8.2.0/arm-linux-gnueabihf/include/stdc-predef.h" 1 3
# 32 "<command-line>" 2
# 1 "<stdin>"

while with the 8.1.0 I installed from archlinux repo I have :

$  echo | arm-linux-gnueabihf-gcc --sysroot=~/dev/ofnode/sysroot -E -Wp,-v -
ignoring nonexistent directory "~/dev/ofnode/sysroot/usr/arm-linux-gnueabihf/include"
ignoring nonexistent directory "~/dev/ofnode/sysroot/usr/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/arm-linux-gnueabihf/8.1.0/include
 /usr/lib/gcc/arm-linux-gnueabihf/8.1.0/include-fixed
 /usr/lib/gcc/arm-linux-gnueabihf/8.1.0/../../../../arm-linux-gnueabihf/include
End of search list.
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 31 "<command-line>"
# 1 "/usr/arm-linux-gnueabihf/include/stdc-predef.h" 1 3
# 32 "<command-line>" 2
# 1 "<stdin>"
[antoine@antoine-pc ~]$  echo | arm-linux-gnueabihf-gcc --sysroot=/home/antoine/dev/ofnode/sysroot -E -Wp,-v -
ignoring nonexistent directory "/home/antoine/dev/ofnode/sysroot/usr/arm-linux-gnueabihf/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/arm-linux-gnueabihf/8.1.0/include
 /usr/lib/gcc/arm-linux-gnueabihf/8.1.0/include-fixed
 /usr/lib/gcc/arm-linux-gnueabihf/8.1.0/../../../../arm-linux-gnueabihf/include
 /home/antoine/dev/ofnode/sysroot/usr/include
End of search list.
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 31 "<command-line>"
# 1 "/usr/arm-linux-gnueabihf/include/stdc-predef.h" 1 3
# 32 "<command-line>" 2
# 1 "<stdin>"

Please note that in the second case, #include <...> search starts here: lists /home/antoine/dev/ofnode/sysroot/usr/include while the first (8.2.0) doesn't.

While I can manually add the include path with a -I flag, it makes this compiler hard to use with CMake which strips off "${CMAKE_SYSROOT}/usr/include".
see related issue here : https://gitlab.kitware.com/cmake/cmake/issues/17966

@abhiTronix abhiTronix added Bug 🐛 Error, flaw or fault mid labels Jan 10, 2019
@abhiTronix
Copy link
Owner

@avilleret Can share the GCC 8.1.0 link that you tried from archlinux repo?

@avilleret
Copy link
Author

@abhiTronix
Copy link
Owner

abhiTronix commented Jan 10, 2019

@avilleret I thought you're using custom Cross-Compiler similar this repo. ,

The main reason behind this bug/error is that the Official Cross Compiler install files directly to the default system root directory, i.e /usr/ or /usr/local/ and Cmake is made explicitly to work with these paths/configurations only and not with custom paths/configurations, to prevent any broken binding. Therefore any custom Cross-Compiler(like provided here) fails to work in this scenario as its default installation path is /opt/ normally, not the root directory.

So, unfortunately, if you want to use GCC 8.2.0 Cross-Compiler with Cmake on your system, you yourself have compiled & installed it from source to the root directory of your machine.

@abhiTronix abhiTronix added Invalid 🙅‍♂️ This doesn't seem right and removed mid labels Jan 10, 2019
@abhiTronix
Copy link
Owner

@avilleret They're working on a fix here(in progress): https://gitlab.kitware.com/cmake/cmake/merge_requests/2716

@avilleret
Copy link
Author

it is indeed possible to use your Crosscompiler build with CMake (and I thanks you a lot for sharing)
I have to disable the CMake's implicit directory feature by injecting the following lines into my toolchain file

unset(CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES)
unset(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES)

I was unsure if its a bug (or a feature) of CMake or if it's a lake of configuration on your side.
Now I'm fixed :-)
Thanks for the quick reply, thanks for the explanation, and thanks again for all this wonderful work.

@abhiTronix abhiTronix added Solved 🎏 Goal Achieved! and removed Invalid 🙅‍♂️ This doesn't seem right labels Jan 10, 2019
avilleret added a commit to ossia/libossia that referenced this issue Feb 10, 2019
when crosscompiling, this happen when `avahi-client/avahi.h` is the `${CMAKE_SYSROOT]/usr/include/` folder.
And that default folder is not added automatically to headers search path.
This might be related to abhiTronix/raspberry-pi-cross-compilers#3 (comment).
Btw I have to install avahi libs in /opt/avahi and add this folder to `CMAKE_PREFIX_PATH`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🐛 Error, flaw or fault Solved 🎏 Goal Achieved!
Projects
None yet
Development

No branches or pull requests

2 participants