First, I hope I've got the terminology right. I'm looking for the "most correct" way to build a compiler with the following characteristics: build=x86_64-pc-linux host=i586-pc-mingw32 target=i586-pc-mingw32 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 Windows machine. 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: PATH=/home/williamg/local/i586-pc-mingw32-gcc-4.1/bin:$PATH \ ../binutils-2.16.91-20060119-1/configure \ --with-build-sysroot=/home/williamg/staging --build=x86_64-pc-linux \ --host=i586-pc-mingw32 --target=i586-pc-mingw32 \ --prefix=/tools/gcc41 PATH=/home/williamg/local/i586-pc-mingw32-gcc-4.1/bin:$PATH make PATH=/home/williamg/local/i586-pc-mingw32-gcc-4.1/bin:$PATH make \ install DESTDIR=/home/williamg/staging 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, of course): PATH=/home/williamg/local/i586-pc-mingw32-gcc-4.1/bin:$PATH \ ../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 \ --enable-languages=c,c++ PATH=/home/williamg/local/i586-pc-mingw32-gcc-4.1/bin:$PATH make PATH=/home/williamg/local/i586-pc-mingw32-gcc-4.1/bin:$PATH make install DESTDIR=/home/williamg/staging 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 after GCC_NO_EXECUTABLES. 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 handling? Pointers towards any enlightening documentation would be very welcome :)