summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorAdam Joseph <adam@westernsemico.com>2023-11-06 13:59:07 -0800
committerAdam Joseph <54836058+amjoseph-nixpkgs@users.noreply.github.com>2023-11-07 09:57:54 +0000
commitb9c6f5b754ebd1aa83457b616381a40c9570ec88 (patch)
tree4914f7a64b88e3b366ca07c6a96970598292ef5e /pkgs
parent78706a9184a7626e907fef3b97a916220efde67b (diff)
gcc: move version iteration out of all-packages.nix
This resolves a TODO previously in all-packages.nix.
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/development/compilers/gcc/all.nix53
-rw-r--r--pkgs/top-level/all-packages.nix36
2 files changed, 54 insertions, 35 deletions
diff --git a/pkgs/development/compilers/gcc/all.nix b/pkgs/development/compilers/gcc/all.nix
new file mode 100644
index 0000000000000..82a64f48c37e3
--- /dev/null
+++ b/pkgs/development/compilers/gcc/all.nix
@@ -0,0 +1,53 @@
+{ lib
+, stdenv
+, gccStdenv
+, gcc7Stdenv
+, callPackage
+, isl_0_11, isl_0_14, isl_0_17, isl_0_20
+, libcCross
+, threadsCrossFor
+, noSysDirs
+, texinfo5
+, cloog_0_18_0, cloog
+, lowPrio
+, wrapCC
+}@args:
+
+let
+  versions = import ./versions.nix;
+  gccForMajorMinorVersion = majorMinorVersion:
+    let
+      atLeast = lib.versionAtLeast majorMinorVersion;
+      attrName = "gcc${lib.replaceStrings ["."] [""] majorMinorVersion}";
+      pkg = lowPrio (wrapCC (callPackage ./default.nix ({
+        inherit noSysDirs;
+        inherit majorMinorVersion;
+        reproducibleBuild = true;
+        profiledCompiler = false;
+        libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then args.libcCross else null;
+        threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCrossFor majorMinorVersion else { };
+        isl = if       stdenv.isDarwin then null
+              else if    atLeast "9"   then isl_0_20
+              else if    atLeast "7"   then isl_0_17
+              else if    atLeast "6"   then (if stdenv.targetPlatform.isRedox then isl_0_17 else isl_0_14)
+              else if    atLeast "4.9" then isl_0_11
+              else            /* "4.8" */   isl_0_14;
+      } // lib.optionalAttrs (majorMinorVersion == "4.8") {
+        texinfo = texinfo5; # doesn't validate since 6.1 -> 6.3 bump
+      } // lib.optionalAttrs (majorMinorVersion == "4.9") {
+        # Build fails on Darwin with clang
+        stdenv = if stdenv.isDarwin then gccStdenv else stdenv;
+      } // lib.optionalAttrs (!(atLeast "6")) {
+        cloog = if stdenv.isDarwin
+                then null
+                else if atLeast "4.9" then cloog_0_18_0
+                else          /* 4.8 */    cloog;
+      } // lib.optionalAttrs (atLeast "6" && !(atLeast "9")) {
+        # gcc 10 is too strict to cross compile gcc <= 8
+        stdenv = if (stdenv.targetPlatform != stdenv.buildPlatform) && stdenv.cc.isGNU then gcc7Stdenv else stdenv;
+      })));
+    in
+      lib.nameValuePair attrName pkg;
+in
+lib.listToAttrs (map gccForMajorMinorVersion versions.allMajorVersions)
+
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 1b316c559463f..2f2a68a39a5a6 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -15979,41 +15979,7 @@ with pkgs;
       extraPackages = [];
   };
 
-  # This expression will be pushed into pkgs/development/compilers/gcc/common
-  # once the top-level gcc/${version}/default.nix files are deduplicated.
-  inherit
-    (lib.listToAttrs (map (majorMinorVersion:
-      let atLeast = lib.versionAtLeast majorMinorVersion;
-          attrName = "gcc${lib.replaceStrings ["."] [""] majorMinorVersion}";
-          pkg = lowPrio (wrapCC (callPackage ../development/compilers/gcc/default.nix ({
-            inherit noSysDirs;
-            inherit majorMinorVersion;
-            reproducibleBuild = true;
-            profiledCompiler = false;
-            libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null;
-            threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCrossFor majorMinorVersion else { };
-            isl = if       stdenv.isDarwin then null
-                  else if    atLeast "9"   then isl_0_20
-                  else if    atLeast "7"   then isl_0_17
-                  else if    atLeast "6"   then (if stdenv.targetPlatform.isRedox then isl_0_17 else isl_0_14)
-                  else if    atLeast "4.9" then isl_0_11
-                  else            /* "4.8" */   isl_0_14;
-          } // lib.optionalAttrs (majorMinorVersion == "4.8") {
-            texinfo = texinfo5; # doesn't validate since 6.1 -> 6.3 bump
-          } // lib.optionalAttrs (majorMinorVersion == "4.9") {
-            # Build fails on Darwin with clang
-            stdenv = if stdenv.isDarwin then gccStdenv else stdenv;
-          } // lib.optionalAttrs (!(atLeast "6")) {
-            cloog = if stdenv.isDarwin
-                    then null
-                    else if atLeast "4.9" then cloog_0_18_0
-                    else          /* 4.8 */    cloog;
-          } // lib.optionalAttrs (atLeast "6" && !(atLeast "9")) {
-            # gcc 10 is too strict to cross compile gcc <= 8
-            stdenv = if (stdenv.targetPlatform != stdenv.buildPlatform) && stdenv.cc.isGNU then gcc7Stdenv else stdenv;
-          })));
-      in lib.nameValuePair attrName pkg
-    ) [ "4.8" "4.9" "6" "7" "8" "9" "10" "11" "12" "13" ]))
+  inherit (callPackage ../development/compilers/gcc/all.nix { inherit noSysDirs; })
     gcc48 gcc49 gcc6 gcc7 gcc8 gcc9 gcc10 gcc11 gcc12 gcc13;
 
   gcc_latest = gcc13;