This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
better default SYSTEM_HEADER_DIR when cross-compiling gcc
- From: Mike Frysinger <vapier at gentoo dot org>
- To: gcc-patches at gcc dot gnu dot org
- Cc: toolchain at gentoo dot org, kanaka at gentoo dot org
- Date: Sun, 30 Apr 2006 04:04:48 -0400
- Subject: better default SYSTEM_HEADER_DIR when cross-compiling gcc
- Geoman: IS A RETARD
when cross-compiling gcc (build != host && host == target), the default
SYSTEM_HEADER_DIR is set to NATIVE_SYSTEM_HEADER_DIR which
is /usr/include ... then when fixincludes runs, it pulls headers
from /usr/include for use in generation of the compiler
for example, using a configure such as:
../configure --build=x86_64-pc-linux-gnu --host=mips64el-unknown-linux-gnu --enable-languages=c
will run fixincludes like so:
(TARGET_MACHINE='mips64el-unknown-linux-gnu'; srcdir=`cd ../../gcc;
${PWDCMD-pwd}`; \
SHELL='/bin/sh'; MACRO_LIST=`${PWDCMD-pwd}`/macro_list ; \
export TARGET_MACHINE srcdir SHELL MACRO_LIST && \
cd ../build-x86_64-pc-linux-gnu/fixincludes && \
/bin/sh ./fixinc.sh ../../gcc/include \
/usr/include )
Fixing headers into /home/vapier/gcc-4.1.0/build/gcc/include for
mips64el-unknown-linux-gnu target
No forbidden identifiers defined by this target
Finding directories and links to directories
Searching /usr/include/.
depending on the headers in /usr/include, the issue may not even be noticed as
most things are "generic" ... but on a multilib Gentoo system,
the /usr/include headers from glibc are scrubbed such that any non-native
arch that includes them will not have things properly defined ... so the gcc
cross-compile ends in a failure such as:
mips64el-unknown-linux-gnu-gcc -O2 -O2 -g -O2 -DIN_GCC -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fPIC -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -I. -I. -I../../gcc -I../../gcc/. -I../../gcc/../include -I../../gcc/../libcpp/include -DL_eprintf -fvisibility=hidden -DHIDE_EXPORTS -c ../../gcc/libgcc2.c -o
libgcc/./_eprintf.o
../../gcc/libgcc2.c: In function '__eprintf':
../../gcc/libgcc2.c:1799: warning: implicit declaration of function 'fprintf'
../../gcc/libgcc2.c:1799: warning: incompatible implicit declaration of
built-in function 'fprintf'
../../gcc/libgcc2.c:1799: error: 'stderr' undeclared (first use in this
function)
../../gcc/libgcc2.c:1799: error: (Each undeclared identifier is reported only
once
../../gcc/libgcc2.c:1799: error: for each function it appears in.)
../../gcc/libgcc2.c:1800: warning: implicit declaration of function 'fflush'
make[3]: *** [libgcc/./_eprintf.o] Error 1
in this case, a vanilla stdio.h defines stderr properly without any
arch-specific cruft ... but not on Gentoo because we do enjoy being so
difficult ;). so one way to reproduce this issue for a mips target would be
to tweak the /usr/include/stdio.h with this:
#ifdef __mips__
# error oops
#endif
and watch it die
the attached patch changes the default SYSTEM_HEADER_DIR setting from
NATIVE_SYSTEM_HEADER_DIR to CROSS_SYSTEM_HEADER_DIR when host != build
-mike
2006-04-30 Mike Frysinger <vapier@gentoo.org>
* configure.ac: Set default SYSTEM_HEADER_DIR to
build_system_header_dir when build != host.
--- trunk/gcc/configure.ac
+++ trunk/gcc/configure.ac
@@ -1717,7 +1717,7 @@ then
| powerpc*-*-*,powerpc64*-*-*)
CROSS="$CROSS -DNATIVE_CROSS" ;;
esac
-elif test "x$TARGET_SYSTEM_ROOT" != x; then
+elif test "x$TARGET_SYSTEM_ROOT" != x -o $build != $host; then
SYSTEM_HEADER_DIR=$build_system_header_dir
fi