From 7ee958a27041539b0740bb37ac2c3b64e1cea9c7 Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Thu, 27 Mar 2025 23:00:22 +0000 Subject: [PATCH] gcc14: 14-20241116 -> 14.2.1.20250322 `gcc-14.3.0` will likely release around the end of April (https://gcc.gnu.org/develop.html) which is a bit late for nixos-25.05 release. We can update to `gcc-14.3.0` after a branch-off, but let's make the delca smaller by picking the current snapshot. While at it: - fix `flex` dependency propagation and use it for snapshots - fix `version` to always contain the base version as cc-wrapper constructs paths to libraries based in `version` attribute Co-authored-by: Pavol Rusnak --- .../compilers/gcc/common/dependencies.nix | 3 +- pkgs/development/compilers/gcc/default.nix | 63 ++++++++++--------- pkgs/development/compilers/gcc/versions.nix | 6 +- 3 files changed, 40 insertions(+), 32 deletions(-) diff --git a/pkgs/development/compilers/gcc/common/dependencies.nix b/pkgs/development/compilers/gcc/common/dependencies.nix index 1f4393ce753f..5356ac149022 100644 --- a/pkgs/development/compilers/gcc/common/dependencies.nix +++ b/pkgs/development/compilers/gcc/common/dependencies.nix @@ -15,6 +15,7 @@ libucontext ? null, libxcrypt ? null, darwin ? null, + isSnapshot ? false, isl ? null, zlib ? null, gnat-bootstrap ? null, @@ -44,7 +45,7 @@ in gettext ] ++ optionals (perl != null) [ perl ] - ++ optionals (with stdenv.targetPlatform; isVc4 || isRedox && flex != null) [ flex ] + ++ optionals (with stdenv.targetPlatform; isVc4 || isRedox || isSnapshot && flex != null) [ flex ] ++ optionals langAda [ gnat-bootstrap ] ++ optionals langRust [ cargo ] # The builder relies on GNU sed (for instance, Darwin's `sed' fails with diff --git a/pkgs/development/compilers/gcc/default.nix b/pkgs/development/compilers/gcc/default.nix index e89030321d62..9aaf11c12887 100644 --- a/pkgs/development/compilers/gcc/default.nix +++ b/pkgs/development/compilers/gcc/default.nix @@ -40,6 +40,7 @@ libcCross ? null, threadsCross ? null, # for MinGW withoutTargetLibc ? false, + flex, gnused ? null, buildPackages, pkgsBuildTarget, @@ -90,6 +91,18 @@ let is10 = majorVersion == "10"; is9 = majorVersion == "9"; + # releases have a form: MAJOR.MINOR.MICRO, like 14.2.1 + # snapshots have a form like MAJOR.MINOR.MICRO.DATE, like 14.2.1.20250322 + isSnapshot = lib.length (lib.splitVersion version) == 4; + # return snapshot date of gcc's given version: + # "14.2.1.20250322" -> "20250322" + # "14.2.0" -> "" + snapDate = lib.concatStrings (lib.drop 3 (lib.splitVersion version)); + # return base version without a snapshot: + # "14.2.1.20250322" -> "14.2.1" + # "14.2.0" -> "14.2.0" + baseVersion = lib.concatStringsSep "." (lib.take 3 (lib.splitVersion version)); + disableBootstrap = atLeast11 && !stdenv.hostPlatform.isDarwin && (atLeast12 -> !profiledCompiler); inherit (stdenv) buildPlatform hostPlatform targetPlatform; @@ -109,6 +122,7 @@ let # lets inherit majorVersion + isSnapshot version buildPlatform hostPlatform @@ -135,6 +149,7 @@ let enableShared fetchpatch fetchurl + flex gettext gmp gnat-bootstrap @@ -198,13 +213,18 @@ pipe ((callFile ./common/builder.nix { }) ( { pname = "${crossNameAddon}${name}"; - inherit version; + # retain snapshot date in package version, but not in final version + # as the version is frequently used to construct pathnames (at least + # in cc-wrapper). + name = "${crossNameAddon}${name}-${version}"; + version = baseVersion; src = fetchurl { - url = "mirror://gcc/${ - # TODO: Remove this before 25.05. - if version == "14-20241116" then "snapshots/" else "releases/gcc-" - }${version}/gcc-${version}.tar.xz"; + url = + if isSnapshot then + "mirror://gcc/snapshots/${majorVersion}-${snapDate}/gcc-${majorVersion}-${snapDate}.tar.xz" + else + "mirror://gcc/releases/gcc-${version}/gcc-${version}.tar.xz"; ${if is10 || is11 || is13 then "hash" else "sha256"} = gccVersions.srcHashForVersion version; }; @@ -232,31 +252,16 @@ pipe for configureScript in $configureScripts; do patchShebangs $configureScript done - '' - # Copy the precompiled `gcc/gengtype-lex.cc` from the 14.2.0 tarball. - # Since the `gcc/gengtype-lex.l` file didn’t change between 14.2.0 - # and 14-2024116, this is safe. If it changes and we update the - # snapshot, we might need to vendor the compiled output in Nixpkgs. - # - # TODO: Remove this before 25.05. - + optionalString (version == "14-20241116") '' - cksum -c <