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

fix bootstrap when platform.gcc.arch=="skylake"
This commit is contained in:
Matthew Bauer 2019-04-23 09:44:50 -04:00 committed by GitHub
commit 0b1851d084
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 3 deletions

View File

@ -63,6 +63,25 @@ let
then import ../expand-response-params { inherit (buildPackages) stdenv; }
else "";
# older compilers (for example bootstrap's GCC 5) fail with -march=too-modern-cpu
isGccArchSupported = arch:
if cc.isGNU or false then
{ skylake = versionAtLeast ccVersion "6.0";
skylake-avx512 = versionAtLeast ccVersion "6.0";
cannonlake = versionAtLeast ccVersion "8.0";
icelake-client = versionAtLeast ccVersion "8.0";
icelake-server = versionAtLeast ccVersion "8.0";
knm = versionAtLeast ccVersion "8.0";
}.${arch} or true
else if cc.isClang or false then
{ cannonlake = versionAtLeast ccVersion "5.0";
icelake-client = versionAtLeast ccVersion "7.0";
icelake-server = versionAtLeast ccVersion "7.0";
knm = versionAtLeast ccVersion "7.0";
}.${arch} or true
else
false;
in
# Ensure bintools matches
@ -287,7 +306,8 @@ stdenv.mkDerivation {
# Always add -march based on cpu in triple. Sometimes there is a
# discrepency (x86_64 vs. x86-64), so we provide an "arch" arg in
# that case.
+ optionalString (targetPlatform ? platform.gcc.arch || targetPlatform.parsed.cpu ? arch) ''
+ optionalString ((targetPlatform ? platform.gcc.arch || targetPlatform.parsed.cpu ? arch) &&
isGccArchSupported targetPlatform.platform.gcc.arch or targetPlatform.parsed.cpu.arch) ''
echo "-march=${targetPlatform.platform.gcc.arch or targetPlatform.parsed.cpu.arch}" >> $out/nix-support/cc-cflags-before
''
@ -309,7 +329,8 @@ stdenv.mkDerivation {
+ optionalString (targetPlatform ? platform.gcc.mode) ''
echo "-mmode=${targetPlatform.platform.gcc.mode}" >> $out/nix-support/cc-cflags-before
''
+ optionalString (targetPlatform ? platform.gcc.tune) ''
+ optionalString (targetPlatform ? platform.gcc.tune &&
isGccArchSupported targetPlatform.platform.gcc.tune) ''
echo "-mtune=${targetPlatform.platform.gcc.tune}" >> $out/nix-support/cc-cflags-before
''

View File

@ -4,7 +4,7 @@ let
p = targetPlatform.platform.gcc or {}
// targetPlatform.parsed.abi;
in lib.concatLists [
(lib.optional (p ? arch) "--with-arch=${p.arch}")
(lib.optional (!targetPlatform.isx86_64 && p ? arch) "--with-arch=${p.arch}") # --with-arch= is unknown flag on x86_64
(lib.optional (p ? cpu) "--with-cpu=${p.cpu}")
(lib.optional (p ? abi) "--with-abi=${p.abi}")
(lib.optional (p ? fpu) "--with-fpu=${p.fpu}")

View File

@ -253,6 +253,8 @@ in rec {
enableParallelChecking = attrs.enableParallelChecking or true;
} // lib.optionalAttrs (hardeningDisable != [] || hardeningEnable != []) {
NIX_HARDENING_ENABLE = enabledHardeningOptions;
} // lib.optionalAttrs (stdenv.hostPlatform.isx86_64 && stdenv.hostPlatform ? platform.gcc.arch) {
requiredSystemFeatures = attrs.requiredSystemFeatures or [] ++ [ "gccarch-${stdenv.hostPlatform.platform.gcc.arch}" ];
} // lib.optionalAttrs (stdenv.buildPlatform.isDarwin) {
inherit __darwinAllowLocalNetworking;
# TODO: remove lib.unique once nix has a list canonicalization primitive