Merge pull request #59969 from volth/gcc-arch-v4

fix bootstrap when platform.gcc.arch=="skylake"

authored by Matthew Bauer and committed by GitHub 0b1851d0 95373d63

+26 -3
+23 -2
pkgs/build-support/cc-wrapper/default.nix
··· 63 then import ../expand-response-params { inherit (buildPackages) stdenv; } 64 else ""; 65 66 in 67 68 # Ensure bintools matches ··· 287 # Always add -march based on cpu in triple. Sometimes there is a 288 # discrepency (x86_64 vs. x86-64), so we provide an "arch" arg in 289 # that case. 290 - + optionalString (targetPlatform ? platform.gcc.arch || targetPlatform.parsed.cpu ? arch) '' 291 echo "-march=${targetPlatform.platform.gcc.arch or targetPlatform.parsed.cpu.arch}" >> $out/nix-support/cc-cflags-before 292 '' 293 ··· 309 + optionalString (targetPlatform ? platform.gcc.mode) '' 310 echo "-mmode=${targetPlatform.platform.gcc.mode}" >> $out/nix-support/cc-cflags-before 311 '' 312 - + optionalString (targetPlatform ? platform.gcc.tune) '' 313 echo "-mtune=${targetPlatform.platform.gcc.tune}" >> $out/nix-support/cc-cflags-before 314 '' 315
··· 63 then import ../expand-response-params { inherit (buildPackages) stdenv; } 64 else ""; 65 66 + # older compilers (for example bootstrap's GCC 5) fail with -march=too-modern-cpu 67 + isGccArchSupported = arch: 68 + if cc.isGNU or false then 69 + { skylake = versionAtLeast ccVersion "6.0"; 70 + skylake-avx512 = versionAtLeast ccVersion "6.0"; 71 + cannonlake = versionAtLeast ccVersion "8.0"; 72 + icelake-client = versionAtLeast ccVersion "8.0"; 73 + icelake-server = versionAtLeast ccVersion "8.0"; 74 + knm = versionAtLeast ccVersion "8.0"; 75 + }.${arch} or true 76 + else if cc.isClang or false then 77 + { cannonlake = versionAtLeast ccVersion "5.0"; 78 + icelake-client = versionAtLeast ccVersion "7.0"; 79 + icelake-server = versionAtLeast ccVersion "7.0"; 80 + knm = versionAtLeast ccVersion "7.0"; 81 + }.${arch} or true 82 + else 83 + false; 84 + 85 in 86 87 # Ensure bintools matches ··· 306 # Always add -march based on cpu in triple. Sometimes there is a 307 # discrepency (x86_64 vs. x86-64), so we provide an "arch" arg in 308 # that case. 309 + + optionalString ((targetPlatform ? platform.gcc.arch || targetPlatform.parsed.cpu ? arch) && 310 + isGccArchSupported targetPlatform.platform.gcc.arch or targetPlatform.parsed.cpu.arch) '' 311 echo "-march=${targetPlatform.platform.gcc.arch or targetPlatform.parsed.cpu.arch}" >> $out/nix-support/cc-cflags-before 312 '' 313 ··· 329 + optionalString (targetPlatform ? platform.gcc.mode) '' 330 echo "-mmode=${targetPlatform.platform.gcc.mode}" >> $out/nix-support/cc-cflags-before 331 '' 332 + + optionalString (targetPlatform ? platform.gcc.tune && 333 + isGccArchSupported targetPlatform.platform.gcc.tune) '' 334 echo "-mtune=${targetPlatform.platform.gcc.tune}" >> $out/nix-support/cc-cflags-before 335 '' 336
+1 -1
pkgs/development/compilers/gcc/common/platform-flags.nix
··· 4 p = targetPlatform.platform.gcc or {} 5 // targetPlatform.parsed.abi; 6 in lib.concatLists [ 7 - (lib.optional (p ? arch) "--with-arch=${p.arch}") 8 (lib.optional (p ? cpu) "--with-cpu=${p.cpu}") 9 (lib.optional (p ? abi) "--with-abi=${p.abi}") 10 (lib.optional (p ? fpu) "--with-fpu=${p.fpu}")
··· 4 p = targetPlatform.platform.gcc or {} 5 // targetPlatform.parsed.abi; 6 in lib.concatLists [ 7 + (lib.optional (!targetPlatform.isx86_64 && p ? arch) "--with-arch=${p.arch}") # --with-arch= is unknown flag on x86_64 8 (lib.optional (p ? cpu) "--with-cpu=${p.cpu}") 9 (lib.optional (p ? abi) "--with-abi=${p.abi}") 10 (lib.optional (p ? fpu) "--with-fpu=${p.fpu}")
+2
pkgs/stdenv/generic/make-derivation.nix
··· 253 enableParallelChecking = attrs.enableParallelChecking or true; 254 } // lib.optionalAttrs (hardeningDisable != [] || hardeningEnable != []) { 255 NIX_HARDENING_ENABLE = enabledHardeningOptions; 256 } // lib.optionalAttrs (stdenv.buildPlatform.isDarwin) { 257 inherit __darwinAllowLocalNetworking; 258 # TODO: remove lib.unique once nix has a list canonicalization primitive
··· 253 enableParallelChecking = attrs.enableParallelChecking or true; 254 } // lib.optionalAttrs (hardeningDisable != [] || hardeningEnable != []) { 255 NIX_HARDENING_ENABLE = enabledHardeningOptions; 256 + } // lib.optionalAttrs (stdenv.hostPlatform.isx86_64 && stdenv.hostPlatform ? platform.gcc.arch) { 257 + requiredSystemFeatures = attrs.requiredSystemFeatures or [] ++ [ "gccarch-${stdenv.hostPlatform.platform.gcc.arch}" ]; 258 } // lib.optionalAttrs (stdenv.buildPlatform.isDarwin) { 259 inherit __darwinAllowLocalNetworking; 260 # TODO: remove lib.unique once nix has a list canonicalization primitive