gcc: gcc13 -> gcc14 (again) (#356812)

authored by

Emily and committed by
GitHub
abae8042 160537bb

+244 -20
+3
nixos/doc/manual/release-notes/rl-2505.section.md
··· 10 10 Users on old macOS versions should consider upgrading to a supported version (potentially using [OpenCore Legacy Patcher](https://dortania.github.io/OpenCore-Legacy-Patcher/) for old hardware) or installing NixOS. 11 11 If neither of those options are viable and you require new versions of software, [MacPorts](https://www.macports.org/) supports versions back to Mac OS X Snow Leopard 10.6. 12 12 13 + - GCC has been updated from GCC 13 to GCC 14. 14 + This introduces some backwards‐incompatible changes; see the [upstream porting guide](https://gcc.gnu.org/gcc-14/porting_to.html) for details. 15 + 13 16 <!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. --> 14 17 15 18 ## New Modules {#sec-release-25.05-new-modules}
+30 -1
pkgs/development/compilers/gcc/default.nix
··· 184 184 inherit version; 185 185 186 186 src = fetchurl { 187 - url = "mirror://gcc/releases/gcc-${version}/gcc-${version}.tar.xz"; 187 + url = "mirror://gcc/${ 188 + # TODO: Remove this before 25.05. 189 + if version == "14-20241116" then 190 + "snapshots/" 191 + else 192 + "releases/gcc-" 193 + }${version}/gcc-${version}.tar.xz"; 188 194 ${if is10 || is11 || is13 then "hash" else "sha256"} = 189 195 gccVersions.srcHashForVersion version; 190 196 }; ··· 205 211 for configureScript in $configureScripts; do 206 212 patchShebangs $configureScript 207 213 done 214 + '' 215 + # Copy the precompiled `gcc/gengtype-lex.cc` from the 14.2.0 tarball. 216 + # Since the `gcc/gengtype-lex.l` file didn’t change between 14.2.0 217 + # and 14-2024116, this is safe. If it changes and we update the 218 + # snapshot, we might need to vendor the compiled output in Nixpkgs. 219 + # 220 + # TODO: Remove this before 25.05. 221 + + optionalString (version == "14-20241116") '' 222 + cksum -c <<EOF 223 + SHA256 (gcc/gengtype-lex.l) = 05acceeda02e673eaef47d187d3a68a1632508112fbe31b5dc2b0a898998d7ec 224 + EOF 225 + 226 + (XZ_OPT="--threads=$NIX_BUILD_CORES" xz -d < ${fetchurl { 227 + url = "mirror://gcc/releases/gcc-14.2.0/gcc-14.2.0.tar.xz"; 228 + hash = "sha256-p7Obxpy/niWCbFpgqyZHcAH3wI2FzsBLwOKcq+1vPMk="; 229 + }}; true) | tar xf - \ 230 + --mode=+w \ 231 + --warning=no-timestamp \ 232 + --strip-components=1 \ 233 + gcc-14.2.0/gcc/gengtype-lex.cc 234 + 235 + # Make sure Make knows it’s up‐to‐date. 236 + touch gcc/gengtype-lex.cc 208 237 '' 209 238 # This should kill all the stdinc frameworks that gcc and friends like to 210 239 # insert into default search paths.
+181
pkgs/development/compilers/gcc/patches/14/fixup-gcc-14-darwin-aarch64-support.patch
··· 1 + This patch was produced by manually merging: 2 + 3 + * <https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=74bfca7360910ae640c2c9c362fe9a4c0ebcc3ba> 4 + * <https://github.com/iains/gcc-14-branch/tree/gcc-14.2-darwin-r2> 5 + 6 + and then taking the diff between the result and the upstream GCC 7 + commit, and excerpting only the files that have conflicts when 8 + naively applying the branch’s diff to the snapshot. (This is 9 + more files than the two that actually needed manual merge work – 10 + `gcc/config/aarch64/aarch64-tune.md` and `libgcc/config.host` – 11 + because `patch(1)` can’t do a three‐way merge using ancestor 12 + information.) 13 + 14 + diff --git a/gcc/config/aarch64/aarch64-tune.md b/gcc/config/aarch64/aarch64-tune.md 15 + index 35b27ddb88..8ce2a93168 100644 16 + --- a/gcc/config/aarch64/aarch64-tune.md 17 + +++ b/gcc/config/aarch64/aarch64-tune.md 18 + @@ -1,5 +1,5 @@ 19 + ;; -*- buffer-read-only: t -*- 20 + ;; Generated automatically by gentune.sh from aarch64-cores.def 21 + (define_attr "tune" 22 + - "cortexa34,cortexa35,cortexa53,cortexa57,cortexa72,cortexa73,thunderx,thunderxt88p1,thunderxt88,octeontx,octeontxt81,octeontxt83,thunderxt81,thunderxt83,ampere1,ampere1a,ampere1b,emag,xgene1,falkor,qdf24xx,exynosm1,phecda,thunderx2t99p1,vulcan,thunderx2t99,cortexa55,cortexa75,cortexa76,cortexa76ae,cortexa77,cortexa78,cortexa78ae,cortexa78c,cortexa65,cortexa65ae,cortexx1,cortexx1c,neoversen1,ares,neoversee1,octeontx2,octeontx2t98,octeontx2t96,octeontx2t93,octeontx2f95,octeontx2f95n,octeontx2f95mm,a64fx,fujitsu_monaka,tsv110,thunderx3t110,neoversev1,zeus,neoverse512tvb,saphira,cortexa57cortexa53,cortexa72cortexa53,cortexa73cortexa35,cortexa73cortexa53,cortexa75cortexa55,cortexa76cortexa55,cortexr82,cortexa510,cortexa520,cortexa710,cortexa715,cortexa720,cortexa725,cortexx2,cortexx3,cortexx4,cortexx925,neoversen2,cobalt100,neoversen3,neoversev2,grace,neoversev3,neoversev3ae,demeter,generic,generic_armv8_a,generic_armv9_a" 23 + + "cortexa34,cortexa35,cortexa53,cortexa57,cortexa72,cortexa73,thunderx,thunderxt88p1,thunderxt88,octeontx,octeontxt81,octeontxt83,thunderxt81,thunderxt83,ampere1,ampere1a,ampere1b,emag,xgene1,falkor,qdf24xx,exynosm1,phecda,thunderx2t99p1,vulcan,thunderx2t99,cortexa55,cortexa75,cortexa76,cortexa76ae,cortexa77,cortexa78,cortexa78ae,cortexa78c,cortexa65,cortexa65ae,cortexx1,cortexx1c,neoversen1,ares,neoversee1,octeontx2,octeontx2t98,octeontx2t96,octeontx2t93,octeontx2f95,octeontx2f95n,octeontx2f95mm,a64fx,fujitsu_monaka,tsv110,thunderx3t110,neoversev1,zeus,neoverse512tvb,saphira,cortexa57cortexa53,cortexa72cortexa53,cortexa73cortexa35,cortexa73cortexa53,cortexa75cortexa55,cortexa76cortexa55,cortexr82,applea12,applem1,applem2,applem3,cortexa510,cortexa520,cortexa710,cortexa715,cortexa720,cortexa725,cortexx2,cortexx3,cortexx4,cortexx925,neoversen2,cobalt100,neoversen3,neoversev2,grace,neoversev3,neoversev3ae,demeter,generic,generic_armv8_a,generic_armv9_a" 24 + (const (symbol_ref "((enum attr_tune) aarch64_tune)"))) 25 + diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h 26 + index 0d8886c026..5370511bec 100644 27 + --- a/gcc/config/darwin.h 28 + +++ b/gcc/config/darwin.h 29 + @@ -42,6 +42,7 @@ 30 + 31 + #define DARWIN_X86 0 32 + #define DARWIN_PPC 0 33 + +#define DARWIN_ARM64 0 34 + 35 + #define OBJECT_FORMAT_MACHO 1 36 + 37 + @@ -373,7 +374,8 @@ 38 + */ 39 + 40 + #define DARWIN_NOCOMPACT_UNWIND \ 41 + -" %:version-compare(>= 10.6 mmacosx-version-min= -no_compact_unwind) " 42 + +"%{!fuse-ld=lld: \ 43 + + %:version-compare(>= 10.6 mmacosx-version-min= -no_compact_unwind)}" 44 + 45 + /* In Darwin linker specs we can put -lcrt0.o and ld will search the library 46 + path for crt0.o or -lcrtx.a and it will search for libcrtx.a. As for 47 + @@ -397,7 +399,8 @@ 48 + LINK_PLUGIN_SPEC \ 49 + "%{flto*:%<fcompare-debug*} \ 50 + %{flto} %{fno-lto} %{flto=*} \ 51 + - %l " \ 52 + + %l \ 53 + + %{fuse-ld=*:-fuse-ld=%*} " \ 54 + DARWIN_PLATFORM_ID \ 55 + LINK_COMPRESS_DEBUG_SPEC \ 56 + "%X %{s} %{t} %{Z} %{u*} \ 57 + @@ -979,7 +982,12 @@ 58 + { "apple_kext_compatibility", 0, 0, false, true, false, false, \ 59 + darwin_handle_kext_attribute, NULL }, \ 60 + { "weak_import", 0, 0, true, false, false, false, \ 61 + - darwin_handle_weak_import_attribute, NULL } 62 + + darwin_handle_weak_import_attribute, NULL }, \ 63 + + { "availability", 0, -1, true, false, false, false, \ 64 + + darwin_handle_availability_attribute, NULL } 65 + + 66 + +#undef TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P 67 + +#define TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P darwin_attribute_takes_identifier_p 68 + 69 + /* Make local constant labels linker-visible, so that if one follows a 70 + weak_global constant, ld64 will be able to separate the atoms. */ 71 + @@ -1227,6 +1235,10 @@ 72 + #define TARGET_N_FORMAT_TYPES 1 73 + #define TARGET_FORMAT_TYPES darwin_additional_format_types 74 + 75 + +/* We want __builtin_unreachable to be expanded as a trap instruction. */ 76 + +#undef TARGET_UNREACHABLE_SHOULD_TRAP 77 + +#define TARGET_UNREACHABLE_SHOULD_TRAP darwin_unreachable_traps_p 78 + + 79 + #ifndef USED_FOR_TARGET 80 + extern void darwin_driver_init (unsigned int *,struct cl_decoded_option **); 81 + #define GCC_DRIVER_HOST_INITIALIZATION \ 82 + diff --git a/libgcc/config.host b/libgcc/config.host 83 + index 7332903704..ae4c91dee3 100644 84 + --- a/libgcc/config.host 85 + +++ b/libgcc/config.host 86 + @@ -82,7 +82,7 @@ 87 + cpu_type=m32c 88 + tmake_file=t-fdpbit 89 + ;; 90 + -aarch64*-*-*) 91 + +aarch64*-*-* | arm64*-*-*) 92 + cpu_type=aarch64 93 + ;; 94 + alpha*-*-*) 95 + @@ -236,22 +236,25 @@ 96 + esac 97 + tmake_file="$tmake_file t-slibgcc-darwin" 98 + case ${host} in 99 + + x86_64-*-darwin2[0-2]*) 100 + + tmake_file="t-darwin-min-11 t-darwin-libgccs1 $tmake_file" 101 + + ;; 102 + *-*-darwin2*) 103 + tmake_file="t-darwin-min-11 $tmake_file" 104 + ;; 105 + *-*-darwin1[89]*) 106 + - tmake_file="t-darwin-min-8 $tmake_file" 107 + + tmake_file="t-darwin-min-8 t-darwin-libgccs1 $tmake_file" 108 + ;; 109 + *-*-darwin9* | *-*-darwin1[0-7]*) 110 + - tmake_file="t-darwin-min-5 $tmake_file" 111 + + tmake_file="t-darwin-min-5 t-darwin-libgccs1 $tmake_file" 112 + ;; 113 + *-*-darwin[4-8]*) 114 + - tmake_file="t-darwin-min-1 $tmake_file" 115 + + tmake_file="t-darwin-min-1 t-darwin-libgccs1 $tmake_file" 116 + ;; 117 + *) 118 + # Fall back to configuring for the oldest system known to work with 119 + # all archs and the current sources. 120 + - tmake_file="t-darwin-min-5 $tmake_file" 121 + + tmake_file="t-darwin-min-5 t-darwin-libgccs1 $tmake_file" 122 + echo "Warning: libgcc configured to support macOS 10.5" 1>&2 123 + ;; 124 + esac 125 + @@ -277,7 +280,7 @@ 126 + if test "x$enable_darwin_at_rpath" = "xyes"; then 127 + tmake_file="$tmake_file t-darwin-rpath " 128 + fi 129 + - extra_parts="crt3.o libd10-uwfef.a crttms.o crttme.o libemutls_w.a" 130 + + extra_parts="crt3.o crttms.o crttme.o libemutls_w.a " 131 + ;; 132 + *-*-dragonfly*) 133 + tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-eh-dw2-dip" 134 + @@ -421,6 +424,15 @@ 135 + tmake_file="${tmake_file} t-dfprules" 136 + md_unwind_header=aarch64/aarch64-unwind.h 137 + ;; 138 + +aarch64*-*-darwin*) 139 + + extra_parts="$extra_parts crtfastmath.o libheapt_w.a" 140 + + tmake_file="${tmake_file} ${cpu_type}/t-aarch64" 141 + + tmake_file="${tmake_file} ${cpu_type}/t-lse" 142 + + tmake_file="${tmake_file} t-crtfm t-dfprules" 143 + + tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp" 144 + + tmake_file="${tmake_file} ${cpu_type}/t-heap-trampoline" 145 + + md_unwind_header=aarch64/aarch64-unwind.h 146 + + ;; 147 + aarch64*-*-freebsd*) 148 + extra_parts="$extra_parts crtfastmath.o" 149 + tmake_file="${tmake_file} ${cpu_type}/t-aarch64" 150 + @@ -728,14 +740,14 @@ 151 + tmake_file="$tmake_file i386/t-crtpc t-crtfm i386/t-msabi" 152 + tm_file="$tm_file i386/darwin-lib.h" 153 + extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o" 154 + - extra_parts="$extra_parts crtfastmath.o libheapt_w.a" 155 + + extra_parts="$extra_parts crtfastmath.o libd10-uwfef.a libheapt_w.a" 156 + tmake_file="${tmake_file} i386/t-heap-trampoline" 157 + ;; 158 + x86_64-*-darwin*) 159 + tmake_file="$tmake_file i386/t-crtpc t-crtfm i386/t-msabi" 160 + tm_file="$tm_file i386/darwin-lib.h" 161 + extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o" 162 + - extra_parts="$extra_parts crtfastmath.o libheapt_w.a" 163 + + extra_parts="$extra_parts crtfastmath.o libd10-uwfef.a libheapt_w.a" 164 + tmake_file="${tmake_file} i386/t-heap-trampoline" 165 + ;; 166 + i[34567]86-*-elfiamcu) 167 + @@ -1218,12 +1230,14 @@ 168 + # We build the darwin10 EH shim for Rosetta (running on x86 machines). 169 + tm_file="$tm_file i386/darwin-lib.h" 170 + tmake_file="$tmake_file rs6000/t-ppc64-fp rs6000/t-ibm-ldouble" 171 + + extra_parts="$extra_parts libd10-uwfef.a " 172 + extra_parts="$extra_parts crt2.o crt3_2.o libef_ppc.a dw_ppc.o" 173 + ;; 174 + powerpc64-*-darwin*) 175 + # We build the darwin10 EH shim for Rosetta (running on x86 machines). 176 + tm_file="$tm_file i386/darwin-lib.h" 177 + tmake_file="$tmake_file rs6000/t-darwin64 rs6000/t-ibm-ldouble" 178 + + extra_parts="$extra_parts libd10-uwfef.a " 179 + extra_parts="$extra_parts crt2.o crt3_2.o libef_ppc.a dw_ppc.o" 180 + ;; 181 + powerpc*-*-freebsd*)
+10 -9
pkgs/development/compilers/gcc/patches/14/libgcc-darwin-detection.patch
··· 1 - diff -u a/libgcc/config.host b/libgcc/config.host 2 - --- a/libgcc/config.host 2023-11-05 11:01:55.778638446 -0500 3 - +++ b/libgcc/config.host 2023-11-05 11:07:29.405103979 -0500 4 - @@ -227,7 +227,7 @@ 1 + diff --git a/libgcc/config.host b/libgcc/config.host 2 + index 7332903704..27a8b5bedb 100644 3 + --- a/libgcc/config.host 4 + +++ b/libgcc/config.host 5 + @@ -236,7 +236,7 @@ 6 + esac 5 7 tmake_file="$tmake_file t-slibgcc-darwin" 6 - # newer toolsets produce warnings when building for unsupported versions. 7 8 case ${host} in 8 - - *-*-darwin1[89]* | *-*-darwin2* ) 9 - + *-*-darwin1[89]* | *-*-darwin2* | *-*-darwin) 10 - tmake_file="t-darwin-min-8 $tmake_file" 9 + - *-*-darwin2*) 10 + + *-*-darwin2* | *-*-darwin) 11 + tmake_file="t-darwin-min-11 $tmake_file" 11 12 ;; 12 - *-*-darwin9* | *-*-darwin1[0-7]*) 13 + *-*-darwin1[89]*)
+17 -7
pkgs/development/compilers/gcc/patches/default.nix
··· 138 138 # We only apply this patch when building a native toolchain for aarch64-darwin, as it breaks building 139 139 # a foreign one: https://github.com/iains/gcc-12-branch/issues/18 140 140 ++ optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64 && buildPlatform == hostPlatform && hostPlatform == targetPlatform) ({ 141 - "14" = [ (fetchpatch { 142 - # There are no upstream release tags in https://github.com/iains/gcc-14-branch. 143 - # 04696df09633baf97cdbbdd6e9929b9d472161d3 is the commit from https://github.com/gcc-mirror/gcc/releases/tag/releases%2Fgcc-14.2.0 144 - name = "gcc-14-darwin-aarch64-support.patch"; 145 - url = "https://github.com/iains/gcc-14-branch/compare/04696df09633baf97cdbbdd6e9929b9d472161d3..gcc-14.2-darwin-r0.diff"; 146 - hash = "sha256-GEUz7KdGzd2WJ0gjX3Uddq2y9bWKdZpT3E9uZ09qLs4="; 147 - }) ]; 141 + "14" = [ 142 + (fetchpatch { 143 + name = "gcc-14-darwin-aarch64-support.patch"; 144 + url = "https://raw.githubusercontent.com/Homebrew/formula-patches/41fdb9d5ec21fc8165cd4bee89bd23d0c90572ee/gcc/gcc-14.2.0-r2.diff"; 145 + # The patch is based on 14.2.0, but we use a GCC snapshot. We 146 + # exclude the files with conflicts and apply our own merged patch 147 + # to avoid vendoring the entire huge patch in‐tree. 148 + excludes = [ 149 + "gcc/config/aarch64/aarch64-tune.md" 150 + "gcc/config/darwin.h" 151 + "libgcc/config.host" 152 + "libgcc/config/t-darwin-min-11" 153 + ]; 154 + hash = "sha256-E4zEKm4tMhovOJKc1/FXZCLQvA+Jt5SC0O2C6SEvZjI="; 155 + }) 156 + ./14/fixup-gcc-14-darwin-aarch64-support.patch 157 + ]; 148 158 "13" = [ (fetchpatch { 149 159 name = "gcc-13-darwin-aarch64-support.patch"; 150 160 url = "https://raw.githubusercontent.com/Homebrew/formula-patches/bda0faddfbfb392e7b9c9101056b2c5ab2500508/gcc/gcc-13.3.0.diff";
+2 -2
pkgs/development/compilers/gcc/versions.nix
··· 1 1 let 2 2 majorMinorToVersionMap = { 3 - "14" = "14.2.0"; 3 + "14" = "14-20241116"; 4 4 "13" = "13.3.0"; 5 5 "12" = "12.4.0"; 6 6 "11" = "11.5.0"; ··· 16 16 17 17 # TODO(amjoseph): convert older hashes to SRI form 18 18 srcHashForVersion = version: { 19 - "14.2.0" = "sha256-p7Obxpy/niWCbFpgqyZHcAH3wI2FzsBLwOKcq+1vPMk="; 19 + "14-20241116" = "sha256-aXSkle8Mzj/Q15cHOu0D9Os2PWQwMIboUZULhnsRSUo="; 20 20 "13.3.0" = "sha256-CEXpYhyVQ6E/SE6UWEpJ/8ASmXDpkUYkI1/B0GGgwIM="; 21 21 "12.4.0" = "sha256-cE9lJgTMvMsUvavzR4yVEciXiLEss7v/3tNzQZFqkXU="; 22 22 "11.5.0" = "sha256-puIYaOrVRc+H8MAfhCduS1KB1nIJhZHByJYkHwk2NHg=";
+1 -1
pkgs/top-level/all-packages.nix
··· 6149 6149 gerbilPackages-unstable = pkgs.gerbil-support.gerbilPackages-unstable; # NB: don't recurseIntoAttrs for (unstable!) libraries 6150 6150 glow-lang = pkgs.gerbilPackages-unstable.glow-lang; 6151 6151 6152 - default-gcc-version = 13; 6152 + default-gcc-version = 14; 6153 6153 gcc = pkgs.${"gcc${toString default-gcc-version}"}; 6154 6154 gccFun = callPackage ../development/compilers/gcc; 6155 6155 gcc-unwrapped = gcc.cc;