https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91879
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Stas Sergeev from comment #4) > (In reply to Harald van Dijk from comment #1) > > The ways to handle libc being installed in non-standard locations depend on > > your specific use case. GCC provides the --with-sysroot and > > --with-native-system-header-dir configure options, > > These ones specify the locations permanently. > My problem is that I need a different sysroot/system-header-dir > only for the time of building the gcc libs. Have you looked into --with-build-sysroot ? --with-build-sysroot --with-build-sysroot=dir Tells GCC to consider dir as the system root (see --with-sysroot) while building target libraries, instead of the directory specified with --with-sysroot. This option is only useful when you are already using --with-sysroot. You can use --with-build-sysroot when you are configuring with --prefix set to a directory that is different from the one in which you are installing GCC and your target libraries. This option affects the system root for the compiler used to build target libraries (which runs on the build system); it does not affect the compiler which is used to build GCC itself. If you specify the --with-native-system-header-dir=dirname option then the compiler will search that directory within dirname for native system headers rather than the default /usr/include.