@@ -5381,6 +5381,7 @@ with pkgs;
53815381 gambit = callPackage ../development/compilers/gambit { };
53825382 gerbil = callPackage ../development/compilers/gerbil { };
53835383
5384+ gccFun = callPackage ../development/compilers/gcc/6;
53845385 gcc = gcc6;
53855386 gcc-unwrapped = gcc.cc;
53865387
@@ -5429,6 +5430,8 @@ with pkgs;
54295430 cc = buildPackages.gccCrossStageStatic;
54305431 };
54315432
5433+ # The GCC used to build libc for the target platform. Normal gccs will be
5434+ # built with, and use, that cross-compiled libc.
54325435 gccCrossStageStatic = assert targetPlatform != buildPlatform; let
54335436 libcCross1 =
54345437 if targetPlatform.libc == "msvcrt" then __targetPackages.windows.mingw_w64_headers
@@ -5436,12 +5439,18 @@ with pkgs;
54365439 else null;
54375440 in wrapCCWith {
54385441 name = "gcc-cross-wrapper";
5439− cc = gcc.cc.override {
5442+ cc = gccFun {
5443+ # copy-pasted
5444+ inherit noSysDirs;
5445+ # PGO seems to speed up compilation by gcc by ~10%, see #445 discussion
5446+ profiledCompiler = with stdenv; (!isDarwin && (isi686 || isx86_64));
5447+ isl = if !stdenv.isDarwin then isl_0_14 else null;
5448+
5449+ # just for stage static
54405450 crossStageStatic = true;
54415451 langCC = false;
54425452 libcCross = libcCross1;
54435453 enableShared = false;
5444− # Why is this needed?
54455454 };
54465455 libc = libcCross1;
54475456 };
@@ -5453,14 +5462,6 @@ with pkgs;
54535462 libc = windows.mingw_headers2;
54545463 };
54555464
5456− gccCrossStageFinal = assert targetPlatform != buildPlatform; wrapCCWith {
5457− name = "gcc-cross-wrapper";
5458− cc = gcc.cc.override {
5459− crossStageStatic = false;
5460− };
5461− libc = libcCross;
5462− };
5463−
54645465 gcc45 = lowPrio (wrapCC (callPackage ../development/compilers/gcc/4.5 {
54655466 inherit noSysDirs;
54665467 texinfo = texinfo4;
@@ -6225,8 +6226,9 @@ with pkgs;
62256226 ccWrapperFun = callPackage ../build-support/cc-wrapper;
62266227
62276228 wrapCC = cc: wrapCCWith {
6229+ name = lib.optionalString (targetPlatform != hostPlatform) "gcc-cross-wrapper";
62286230 inherit cc;
6229− inherit (stdenv.cc) libc;
6231+ libc = if targetPlatform != hostPlatform then libcCross else stdenv.cc.libc;
62306232 };
62316233 # legacy version, used for gnat bootstrapping
62326234 wrapGCC-old = baseGCC: callPackage ../build-support/gcc-wrapper-old {