simple test case: $ >test.F90 $ armv7a-unknown-linux-gnueabi-gfortran -v -c test.F90 ... ignoring nonexistent directory "/usr/local/include" ... #include <...> search starts here: /usr/lib/gcc/armv7a-unknown-linux-gnueabi/4.6.3/finclude /usr/lib/gcc/armv7a-unknown-linux-gnueabi/4.6.3/include /usr/lib/gcc/armv7a-unknown-linux-gnueabi/4.6.3/include-fixed /usr/include End of search list. ... that doesn't seem right considering gcc/g++ don't do this: $ >test.c $ armv7a-unknown-linux-gnueabi-gcc -c test.c -v ... ignoring nonexistent directory "/usr/armv7a-unknown-linux-gnueabi/usr/local/include" ... #include <...> search starts here: /usr/lib/gcc/armv7a-unknown-linux-gnueabi/4.6.3/include /usr/lib/gcc/armv7a-unknown-linux-gnueabi/4.6.3/include-fixed /usr/armv7a-unknown-linux-gnueabi/usr/include End of search list. ...
You forgot to explain what you think is not quite right. gfortran searches only directories where it may have installed some modules and directories that you explicitly add via -I.
(In reply to comment #1) > You forgot to explain what you think is not quite right. > gfortran searches only directories where it may have > installed some modules and directories that you explicitly > add via -I. Because when you do cross compilation you don't want your compiler to pick up host modules. Apart from that ^^ shouldn't frontends behave in a consistent manner?
yeah, as Kacper said, cross compilers should not be searching native paths. the gcc and g++ frontends are working correctly (they use the sysrooted path) while the gfortran frontend is broken. -v output shows: Target: armv7a-unknown-linux-gnueabi Configured with: /var/tmp/portage/cross-armv7a-unknown-linux-gnueabi/gcc-4.6.3/work/gcc-4.6.3/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/armv7a-unknown-linux-gnueabi/gcc-bin/4.6.3 --includedir=/usr/lib/gcc/armv7a-unknown-linux-gnueabi/4.6.3/include --datadir=/usr/share/gcc-data/armv7a-unknown-linux-gnueabi/4.6.3 --mandir=/usr/share/gcc-data/armv7a-unknown-linux-gnueabi/4.6.3/man --infodir=/usr/share/gcc-data/armv7a-unknown-linux-gnueabi/4.6.3/info --with-gxx-include-dir=/usr/lib/gcc/armv7a-unknown-linux-gnueabi/4.6.3/include/g++-v4 --host=x86_64-pc-linux-gnu --target=armv7a-unknown-linux-gnueabi --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --without-ppl --without-cloog --enable-lto --enable-nls --without-included-gettext --with-system-zlib --enable-obsolete --disable-werror --enable-secureplt --disable-multilib --disable-libmudflap --disable-libssp --enable-libgomp --with-python-dir=/share/gcc-data/armv7a-unknown-linux-gnueabi/4.6.3/python --enable-poison-system-directories --enable-checking=release --disable-libgcj --with-arch=armv7-a --with-float=hard --with-fpu=vfpv3-d16 --enable-languages=c,c++,fortran --with-sysroot=/usr/armv7a-unknown-linux-gnueabi --disable-bootstrap --enable-__cxa_atexit --enable-clocale=gnu --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.6.3 p1.6, pie-0.5.2'
Untested draft patch. As I don't build cross compilers, I would be happy if someone could confirm that it works. --- a/gcc/fortran/cpp.c +++ b/gcc/fortran/cpp.c @@ -269,3 +269,3 @@ gfc_cpp_init_options (unsigned int decoded_options_count, gfc_cpp_option.prefix = NULL; - gfc_cpp_option.sysroot = NULL; + gfc_cpp_option.sysroot = TARGET_SYSTEM_ROOT;
I forgot half of the patch - the second half is needed when no system root exists. The patch is still untested. --- a/gcc/fortran/cpp.c +++ b/gcc/fortran/cpp.c @@ -40,2 +40,6 @@ along with GCC; see the file COPYING3. If not see +#ifndef TARGET_SYSTEM_ROOT +# define TARGET_SYSTEM_ROOT NULL +#endif + #ifndef TARGET_CPU_CPP_BUILTINS @@ -269,3 +273,3 @@ gfc_cpp_init_options (unsigned int decoded_options_count, gfc_cpp_option.prefix = NULL; - gfc_cpp_option.sysroot = NULL; + gfc_cpp_option.sysroot = TARGET_SYSTEM_ROOT;
(In reply to comment #5) that's half the equation. the other half is the build system support. in gcc/Makefile.in, they do: CFLAGS-c-family/c-opts.o += @TARGET_SYSTEM_ROOT_DEFINE@ but you can't do that in gcc/fortran/Make-lang.in. you can't use $(TARGET_SYSTEM_ROOT_DEFINE) either because the variable is only AC_SUBST(). so you could add this line to gcc/Makefile.in: CFLAGS-fortran/cpp.o += @TARGET_SYSTEM_ROOT_DEFINE@ and it'd work. this seems to be how they propagate the define into the CFLAGS-c-family/c-opts.o variable, so maybe this is OK. alternatively, gcc/Makefile.in does setup $(COMPILER_DEFINES), so adding this to gcc/fortran/Make-lang.in works: CFLAGS-fortran/cpp.o += $(DRIVER_DEFINES) but i'm sure that's the wrong answer. the other alternative is to declare a "static const char *sysroot" inside of gcc/fortran/gfortranspec.c and then initialize gfc_cpp_option.sysroot via that. this works because gfortranspec.c is compiled already with $(COMPILER_DEFINES). i'm wait out of my depth, so i don't know what the "right" answer is :).
Can you check whether the following patch works for you? http://gcc.gnu.org/ml/gcc-patches/2012-10/msg01780.html
(In reply to comment #7) that patch doesn't work as there is a typo in Make-lang.in. it needs to be: CFLAGS-fortran/cpp.o += $(TARGET_SYSTEM_ROOT_DEFINE) then it works OK
Author: burnus Date: Sun Oct 21 10:51:26 2012 New Revision: 192650 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=192650 Log: gcc/ 2012-10-21 Tobias Burnus <burnus@net-b.de> PR fortran/54725 * Makefile.in (TARGET_SYSTEM_ROOT_DEFINE): New. gcc/fortran 2012-10-21 Tobias Burnus <burnus@net-b.de> PR fortran/54725 * Make-lang.in (CFLAGS-cpp.o): Use TARGET_SYSTEM_ROOT_DEFINE. * cpp.o (gfc_cpp_init_options): Use it for setting gfc_cpp_option.sysroot. Modified: trunk/gcc/ChangeLog trunk/gcc/Makefile.in trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/Make-lang.in trunk/gcc/fortran/cpp.c
FIXED on the trunk (4.8). Thanks for the bug report, the debugging and for testing the patch!