16.10.2010 14:58, Uros Bizjak kirjoitti:
Trying to use --with-build-sysroot configure option, the build failed
with "error: no include path in which to search for ..." error.
This problem come down to the fact, that -isysroot is ignored when
crosscompiling:
Crosscompiler does not handle -isysroot correctly:
$ ~/gcc-build-alpha/gcc/xgcc -B ~/gcc-build-alpha/gcc -isysroot
/home/uros/sys-root -quiet -v in.c
Target: alphaev68-pc-linux-gnu
Configured with: ../gcc-svn/trunk/configure
--target=alphaev68-pc-linux-gnu --enable-languages=c
The '--with-sysroot=' option is missing. This makes a cross GCC
to behave like a native GCC...
The difference happens in gcc/cppdefault.c:
#if defined (CROSS_DIRECTORY_STRUCTURE)&& !defined (TARGET_SYSTEM_ROOT)
# undef LOCAL_INCLUDE_DIR
# undef SYSTEM_INCLUDE_DIR
# undef STANDARD_INCLUDE_DIR
#else
# undef CROSS_INCLUDE_DIR
#endif
Commenting out #undef STANDARD_INCLUDE_DIR fixes the problem.
The CROSS_INCLUDE_DIR, '$tooldir/sys-include', is not used in a
native GCC or in a cross GCC configured using '--with-sysroot=',
the '/usr/local/include', a possibly defined SYSTEM_INCLUDE_DIR,
the equivalent to the '$tooldir/sys-include' in a native GCC or
in a cross GCC configured using '--with-sysroot=', and the
'/usr/include' are not used in a traditional cross GCC at all...
A traditional cross GCC searches from the CROSS_INCLUDE_DIR,
'$tooldir/sys-include' and from TOOL_INCLUDE_DIR, '$tooldir/include',
in this order, so using 2 directories for headers when a native
GCC usually uses only one, '/usr/include' (if forgetting the
'/usr/local/include').
The real BUG with these is :
Generally people would expect some equivalency between a native
GCC and a traditional cross GCC (used with the embedded targets
which don't have a native GCC possibility), here :
/usr/include ---> $tooldir/include
/usr/lib ---> $tooldir/lib
But during the 15+ years I have built and used cross GCCs, this
very simple equivalency has never worked :( For some very odd
reason the GCC build has expected the target headers being in
the CROSS_INCLUDE_DIR, '$tooldir/sys-include', what comes to
fixinc and searching the existence of some headers in the
standard target headers. These of course being in the equivalent
to the always existing STANDARD_INCLUDE_DIR, '/usr/include'.
The SYSTEM_INCLUDE_DIR and its equivalent '$tooldir/sys-include'
are for some not specified "system specific headers", for instance
the Win32 API headers in a Windoze system could be these, they
aren't any "standard (posix) headers"...
Ok, my conclusion is that if you use the '--with-sysroot=' in
the cross GCC configure, then also '--with-build-sysroot='
(using something else instead of the defined $sysroot) should
work, otherwise it shouldn't have any influence at all, the
cross GCC is a traditional crosscompiler which uses the $tooldir
for the target headers and libraries! And with a traditional
cross GCC the 'include' and 'lib' in $tooldir should be searched,
the 'sys-include' there shouldn't be used at all!
should work