From 0569ae5f3c04ebba1eeb7910ef43e1b6e932753c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Sun, 27 Nov 2022 23:18:20 +0100 Subject: [PATCH 1/9] lib/systems/architectures: add microarchitecture levels --- lib/systems/architectures.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/systems/architectures.nix b/lib/systems/architectures.nix index ddc320d24e0a0..1103d32b3ea63 100644 --- a/lib/systems/architectures.nix +++ b/lib/systems/architectures.nix @@ -28,6 +28,12 @@ rec { znver1 = [ "sse3" "ssse3" "sse4_1" "sse4_2" "sse4a" "aes" "avx" "avx2" "fma" ]; znver2 = [ "sse3" "ssse3" "sse4_1" "sse4_2" "sse4a" "aes" "avx" "avx2" "fma" ]; znver3 = [ "sse3" "ssse3" "sse4_1" "sse4_2" "sse4a" "aes" "avx" "avx2" "fma" ]; + # Microarchitecture levels + # https://en.wikipedia.org/wiki/X86-64#Microarchitecture_levels + x86-64 = [ ]; + x86-64-v2 = [ "sse3" "ssse3" "sse4_1" "sse4_2" ]; + x86-64-v3 = [ "sse3" "ssse3" "sse4_1" "sse4_2" "avx" "avx2" "fma" ]; + x86-64-v4 = [ "sse3" "ssse3" "sse4_1" "sse4_2" "avx" "avx2" "avx512" "fma" ]; # other armv5te = [ ]; armv6 = [ ]; From b810ffcb8542f04ea371d2f2fa0d23fac9a9dbe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Wed, 23 Nov 2022 15:02:08 +0100 Subject: [PATCH 2/9] lib/systems/architecture: bump default architecture to x86-64-v2 Compile everything by default with SSE4.2 to gain free performance. This also removes support for any CPU older than westmere. --- lib/systems/architectures.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/systems/architectures.nix b/lib/systems/architectures.nix index 1103d32b3ea63..d1c510729620a 100644 --- a/lib/systems/architectures.nix +++ b/lib/systems/architectures.nix @@ -2,8 +2,8 @@ rec { # gcc.arch to its features (as in /proc/cpuinfo) - features = { - default = [ ]; + features = rec { + default = x86-64-v2; # x86_64 Intel westmere = [ "sse3" "ssse3" "sse4_1" "sse4_2" "aes" ]; sandybridge = [ "sse3" "ssse3" "sse4_1" "sse4_2" "aes" "avx" ]; From b47648471aea03af6cfa013051cb7be9c9da5947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Tue, 29 Nov 2022 19:40:42 +0100 Subject: [PATCH 3/9] lib/systems/architectures: add microarchitecture levels to inferiors --- lib/systems/architectures.nix | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/systems/architectures.nix b/lib/systems/architectures.nix index d1c510729620a..ba3a571ed442b 100644 --- a/lib/systems/architectures.nix +++ b/lib/systems/architectures.nix @@ -46,14 +46,18 @@ rec { # a superior CPU has all the features of an inferior and is able to build and test code for it inferiors = { # x86_64 Intel - default = [ ]; - westmere = [ ]; + default = [ "x86-64-v2" ]; + x86-64 = [ ]; + x86-64-v2 = [ "x86-64" ] ++ inferiors.x86-64; + westmere = [ "x86-64-v2" ] ++ inferiors.x86-64-v2; sandybridge = [ "westmere" ] ++ inferiors.westmere; ivybridge = [ "sandybridge" ] ++ inferiors.sandybridge; - haswell = [ "ivybridge" ] ++ inferiors.ivybridge; + x86-64-v3 = [ "ivybridge" ] ++ inferiors.ivybridge; + haswell = [ "x86-64-v3" ] ++ inferiors.x86-64-v3; broadwell = [ "haswell" ] ++ inferiors.haswell; skylake = [ "broadwell" ] ++ inferiors.broadwell; - skylake-avx512 = [ "skylake" ] ++ inferiors.skylake; + x86-64-v4 = [ "skylake" ] ++ inferiors.skylake; + skylake-avx512 = [ "x86-64-v4" ] ++ inferiors.x86-64-v4; # x86_64 AMD # TODO: fill this (need testing) From baeda76307c348d3a89992d144d287be8b722f81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Tue, 29 Nov 2022 19:36:07 +0100 Subject: [PATCH 4/9] lib/systems/platforms: set gcc.arch to x86-64-v2 equivalent on x86 platforms --- lib/systems/platforms.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/systems/platforms.nix b/lib/systems/platforms.nix index d574943e47df3..f762be869c890 100644 --- a/lib/systems/platforms.nix +++ b/lib/systems/platforms.nix @@ -16,6 +16,12 @@ rec { autoModules = true; target = "bzImage"; }; + gcc = { + # this should match the microarchitecture level of lib.systems.architectures.features.default + # but nehalem is used instead of x86-64-v2 because as of writting the bootstrapping gcc in stage 0 does not understand it + arch = "nehalem"; + tune = "generic"; + }; }; pc_simplekernel = lib.recursiveUpdate pc { From 68806b0034104b14a6aa7e50a6e794d1d987ba14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Tue, 29 Nov 2022 21:01:50 +0100 Subject: [PATCH 5/9] nixos/release-notes: mention default architecture bump --- .../manual/from_md/release-notes/rl-2305.section.xml | 11 ++++++++++- nixos/doc/manual/release-notes/rl-2305.section.md | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/nixos/doc/manual/from_md/release-notes/rl-2305.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2305.section.xml index c8bd237dbb003..4c835f46e43fc 100644 --- a/nixos/doc/manual/from_md/release-notes/rl-2305.section.xml +++ b/nixos/doc/manual/from_md/release-notes/rl-2305.section.xml @@ -10,7 +10,16 @@ In addition to numerous new and upgraded packages, this release has the following highlights: - + + + + On x86 platforms nixpkgs is now build by default with the + x86_64-v2 microarchitecture level. This + means any x86 processor that does not support SSE4.2 and AES + instructions is no longer supported by the precompiled binary + cache. + + Cinnamon has been updated to 5.6, see diff --git a/nixos/doc/manual/release-notes/rl-2305.section.md b/nixos/doc/manual/release-notes/rl-2305.section.md index c438fdc1aaafd..9109a8b364226 100644 --- a/nixos/doc/manual/release-notes/rl-2305.section.md +++ b/nixos/doc/manual/release-notes/rl-2305.section.md @@ -8,6 +8,9 @@ In addition to numerous new and upgraded packages, this release has the followin +- On x86 platforms nixpkgs is now build by default with the `x86_64-v2` microarchitecture level. + This means any x86 processor that does not support SSE4.2 and AES instructions is no longer supported by the precompiled binary cache. + - Cinnamon has been updated to 5.6, see [the pull request](https://github.com/NixOS/nixpkgs/pull/201328#issue-1449910204) for what is changed. ## New Services {#sec-release-23.05-new-services} From efdbf04d1080418fb3602960d712aefa1dc1f0bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Tue, 29 Nov 2022 21:13:31 +0100 Subject: [PATCH 6/9] stdenv/generic: do not require system features for x86-64-v1/2 and westmere to allow a smooth transition --- pkgs/stdenv/generic/make-derivation.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index 510537aac9f39..622b772a7c488 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -413,7 +413,10 @@ else let enableParallelChecking = attrs.enableParallelChecking or true; } // lib.optionalAttrs (hardeningDisable != [] || hardeningEnable != [] || stdenv.hostPlatform.isMusl) { NIX_HARDENING_ENABLE = enabledHardeningOptions; - } // lib.optionalAttrs (stdenv.hostPlatform.isx86_64 && stdenv.hostPlatform ? gcc.arch) { + } // lib.optionalAttrs (stdenv.hostPlatform.isx86_64 && stdenv.hostPlatform ? gcc.arch + # ignore x86-64-v1/2, nehalem and westmere to allow a smoother transition when bumping the default gcc.arch. + # This silently assumes that any x86 machines supports them at least! + && lib.all (x: stdenv.hostPlatform.gcc.arch != x) [ "x86-64" "x86-64-v2" "nehalem" "westmere" ]) { requiredSystemFeatures = attrs.requiredSystemFeatures or [] ++ [ "gccarch-${stdenv.hostPlatform.gcc.arch}" ]; } // lib.optionalAttrs (stdenv.buildPlatform.isDarwin) { inherit __darwinAllowLocalNetworking; From 8e137824d636380271a9bd2a278441aa116605fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Thu, 1 Dec 2022 13:13:34 +0100 Subject: [PATCH 7/9] lib/systems/architectures: add nehalem This is not strictly required but better to have complete data. --- lib/systems/architectures.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/systems/architectures.nix b/lib/systems/architectures.nix index ba3a571ed442b..7e6315f75320d 100644 --- a/lib/systems/architectures.nix +++ b/lib/systems/architectures.nix @@ -5,6 +5,7 @@ rec { features = rec { default = x86-64-v2; # x86_64 Intel + nehalem = [ "sse3" "ssse3" "sse4_1" "sse4_2" "aes" ]; westmere = [ "sse3" "ssse3" "sse4_1" "sse4_2" "aes" ]; sandybridge = [ "sse3" "ssse3" "sse4_1" "sse4_2" "aes" "avx" ]; ivybridge = [ "sse3" "ssse3" "sse4_1" "sse4_2" "aes" "avx" ]; @@ -49,7 +50,8 @@ rec { default = [ "x86-64-v2" ]; x86-64 = [ ]; x86-64-v2 = [ "x86-64" ] ++ inferiors.x86-64; - westmere = [ "x86-64-v2" ] ++ inferiors.x86-64-v2; + nehalem = [ "x86-64-v2" ] ++ inferiors.x86-64-v2; + westmere = [ "nehalem" ] ++ inferiors.nehalem; sandybridge = [ "westmere" ] ++ inferiors.westmere; ivybridge = [ "sandybridge" ] ++ inferiors.sandybridge; x86-64-v3 = [ "ivybridge" ] ++ inferiors.ivybridge; From c11ecb6a0fd30d89b8a2deda9462d72d48a9d83e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Fri, 2 Dec 2022 18:04:52 +0100 Subject: [PATCH 8/9] nixos/release-small: build unoptimized nixpkgs --- nixos/release-small.nix | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/nixos/release-small.nix b/nixos/release-small.nix index deb428d1bec05..bb5b623a792b7 100644 --- a/nixos/release-small.nix +++ b/nixos/release-small.nix @@ -25,6 +25,22 @@ let nixpkgs = nixpkgsSrc; }) [ "unstable" ]; + nixpkgs-unoptimised' = builtins.removeAttrs (import ../pkgs/top-level/release.nix { + inherit supportedSystems; + nixpkgs = nixpkgsSrc; + # default value plus empty gcc.arch/gcc.tune + nixpkgsArgs = { + config = { + allowUnfree = false; + gcc = { + arch = null; + tune = null; + }; + inHydra = true; + }; + }; + }) [ "unstable" ]; + in rec { nixos = { @@ -85,6 +101,31 @@ in rec { vim; }; + nixpkgs-unoptimised = { + inherit (nixpkgs-unoptimised') + apacheHttpd + cmake + cryptsetup + emacs + gettext + git + imagemagick + jdk + linux + mariadb + nginx + nodejs + openssh + php + postgresql + python + rsyslog + stdenv + subversion + tarball + vim; + }; + tested = let onSupported = x: map (system: "${x}.${system}") supportedSystems; onSystems = systems: x: map (system: "${x}.${system}") From c7ae9f8895025305a00434fa5b3d53842291d5a6 Mon Sep 17 00:00:00 2001 From: Sandro Date: Sat, 18 Feb 2023 17:46:05 +0100 Subject: [PATCH 9/9] fixup! nixos/release-notes: mention default architecture bump --- nixos/doc/manual/release-notes/rl-2305.section.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/doc/manual/release-notes/rl-2305.section.md b/nixos/doc/manual/release-notes/rl-2305.section.md index 9109a8b364226..6a29f2e5e520e 100644 --- a/nixos/doc/manual/release-notes/rl-2305.section.md +++ b/nixos/doc/manual/release-notes/rl-2305.section.md @@ -8,7 +8,7 @@ In addition to numerous new and upgraded packages, this release has the followin -- On x86 platforms nixpkgs is now build by default with the `x86_64-v2` microarchitecture level. +- On x86 platforms nixpkgs is now built by default with the `x86_64-v2` microarchitecture level. This means any x86 processor that does not support SSE4.2 and AES instructions is no longer supported by the precompiled binary cache. - Cinnamon has been updated to 5.6, see [the pull request](https://github.com/NixOS/nixpkgs/pull/201328#issue-1449910204) for what is changed.