Sysroot and build-sysroot when building cross-native compiler (linux/mingw32/mingw32).
Wed Apr 19 17:08:00 GMT 2006
First, I hope I've got the terminology right. I'm looking for the
"most correct" way to build a compiler with the following
In shorter words, (linux/mingw32/mingw32).
I've got a working cross-compiler on the build machine
(linux/linux/mingw32). It is installed in
/home/williamg/local/i586-pc-mingw32-gcc-4.1. MinGW runtime and w32api
are installed in the i586-pc-mingw32 subdirectory.
The question is, how to configure, build and install the native
mingw32 compiler. I'm a bit confused by the various sysroot, prefix,
DESTDIR options available. Let's suppose I want to build a toolchain
which will finally be installed in c:\tools\gcc41 on the target
My feeling is that the following should be right. First I unpack the
mingw-runtime and w32api in to /home/williamg/staging/i586-pc-mingw32,
then build binutils thus:
--with-build-sysroot=/home/williamg/staging --build=x86_64-pc-linux \
--host=i586-pc-mingw32 --target=i586-pc-mingw32 \
PATH=/home/williamg/local/i586-pc-mingw32-gcc-4.1/bin:$PATH make \
That all seems to work OK. Could I actually just use the path to my
already-built cross-toolchain as the sysroot, since this already
contains the system headers?
Then, I try to build gcc in a similar way (in a new build directory,
../gcc-4.1.0/configure --with-build-sysroot=/home/williamg/staging \
--build=x86_64-pc-linux --host=i586-pc-mingw32 \
--target=i586-pc-mingw32 --prefix=/tools/gcc41 \
However, this build fails. The first failure is in fixincludes,
because it can't find the appropriate directory containing system
headers, and then if I hack around that by hardcoding the correct
directory in gcc/config/i386/t-mingw32, libstdc++'s configure fails
testing for main in -lm, complaining that link tests aren't allowed
As for the fixincludes problem, it appears to hardcode /mingw/include,
which is never right for me, since I use i586-pc-mingw32. Should
t-mingw32 not use that version of the host description?
Anyway, that aside, is this a problem with the implementation of
--with-build-sysroot, or with my understanding of what it's for?
If I use --with-sysroot instead of --with-build-sysroot, the build
succeeds, and the resulting compiler appears to work OK on the target
system (It can compile and link a c++ hello world, from within Cygwin
environment at least). My impression was that it would be expecting
certain things on the _target_ machine to be located in that sysroot,
which doesn't exist there, only on my build machine.
So, have I misunderstood the meaning of with-build-sysroot? I took it
to mean "The location of system headers and libraries for the target
machine, on the build machine, when they _aren't_ in this location on
the target machine". Or, are there bugs in GCC's --with-build-sysroot
Pointers towards any enlightening documentation would be very welcome
More information about the Gcc-help