https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71001
Bug ID: 71001
Summary: cross build native: fixincludes searches host path on
build system
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: other
Assignee: unassigned at gcc dot gnu.org
Reporter: daniel.c.klauer at web dot de
Target Milestone: ---
Created attachment 38437
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38437&action=edit
example to reproduce the problem
Hello,
I have encountered an issue when cross-compiling a native gcc for
i686-w64-mingw32 on a GNU/Linux system. The build tries to access a host path
on the build system, which makes no sense when cross-compiling.
In this case it is "/mingw/include", which is supposed to exist on
i686-w64-mingw32 but of course not on the GNU/Linux that's used as build
system,
thus the build fails (perhaps luckily even -- if it was a more common path like
/usr/include, I imagine the problem would go unnoticed).
$ uname -m -o
x86_64 GNU/Linux
$ ../gcc-6.1.0/configure \
--build=x86_64-pc-linux-gnu \
--host=i686-w64-mingw32 \
--target=i686-w64-mingw32 \
--prefix=/usr \
--enable-languages=c \
--with-gmp="$sysroot"/usr \
--with-mpfr="$sysroot"/usr \
--with-mpc="$sysroot"/usr
...
$ make
...
The directory that should contain system headers does not exist:
/mingw/include
Makefile:2907: recipe for target 'stmp-fixinc' failed
...
It appears that using --with-sysroot to specify a i686-w64-mingw32 sysroot
fixes it, but it also encodes the sysroot path into the newly built compiler
for use at runtime, which I don't want since it is a build-system-specific
path. And this isn't building a cross-compiler anyways (which is where
--with-sysroot makes sense).
So I looked at --with-build-sysroot instead. If I understood correctly,
--with-build-sysroot is meant for specifying the target sysroot for use during
the gcc build process only, and not later at runtime. But the fixincludes step
does not respect --with-build-sysroot.
Maybe fixincludes should use --with-build-sysroot if that's set, and be
disabled
otherwise (when cross-compiling and no sysroot is given).
I found an old posting about this issue here, though it wasn't answered:
https://gcc.gnu.org/ml/gcc-help/2006-04/msg00191.html