Any cross-gcc has $prefix/include before
$prefix/<target>/include and $prefix/lib/gcc-lib/<target>/<version>/include in its include-path.
This is not correct, because $prefix/include for cross-gccs contains host-headers, not target-headers, like it does for native gccs and therefore bogusly pulls-in host headers.
gcc-3.2.x, gcc-3.3, gcc-3.4
Build a cross-gcc and examine the include-path
i386-rtems-gcc -v -o tmp.o -c tmp.c
gcc version 3.2.2 (OAR Corporation gcc-3.2.2-20030425/newlib-1.11.0-20030416a-0_rc_10)
/opt/rtems/lib/gcc-lib/i386-rtems/3.2.2/cc1 -lang-c -v -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=2 -D__GXX_ABI_VERSION=102
-D__rtems__ -D__ELF__ -D__i386__ -D__USE_INIT_FINI__ -D__rtems__ -D__ELF__ -D__i386__ -D__USE_INIT_FINI__ -Asystem=rtems -D__NO_INLINE__ -D__STDC_HOSTED__=1 -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i386__ tmp.c -quiet -dumpbase tmp.c -version -o /tmp/cc66lQPD.s
GNU CPP version 3.2.2 (OAR Corporation gcc-3.2.2-20030425/newlib-1.11.0-20030416a-0_rc_10) (cpplib) (i386 bare ELF target)
GNU C version 3.2.2 (OAR Corporation gcc-3.2.2-20030425/newlib-1.11.0-20030416a-0_rc_10) (i386-rtems)
compiled by GNU C version 3.2.2 20030313 (Red Hat Linux 3.2.2-10).
ignoring nonexistent directory "/opt/rtems/i386-rtems/sys-include"
#include "..." search starts here:
#include <...> search starts here:
End of search list.
The cause of this seems to be PREFIX_INCLUDE_DIR in gcc/configure.in.
The patch in the attachment works around this issue by #undef'ing PREFIX_INCLUDE_DIR in cppdefaults.h for cross-compilation.
I can confirm that this problem still occurs on gcc 3.3 branch. On mainline, the code in question
seems to have changed quite a bit. Could you send your patch to gcc-patches, with a note that it
fixes this PR? Thanks,
P.S. The category of this report should be changed to preprocessor IMHO.
See Dara's comment 2.
Ralf wrote on gcc-patches:
> Well, all I can say is:
> * I had been able to reproduce my problem with gcc-trunk as of last
> week. (The date 2003-02-13 makes me wonder.)
This doesn't make sense. No cross compiler on the trunk should be
including $prefix/include, and shouldn't have since I checked in that
patch, in February 2003. Please investigate why that happened.
No feedback in 3 months (T-3 days).