Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions nixos/doc/manual/release-notes/rl-2505.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
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.
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.

- GCC has been updated from GCC 13 to GCC 14.
This introduces some backwards‐incompatible changes; see the [upstream porting guide](https://gcc.gnu.org/gcc-14/porting_to.html) for details.

<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->

## New Modules {#sec-release-25.05-new-modules}
Expand Down
31 changes: 30 additions & 1 deletion pkgs/development/compilers/gcc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,13 @@ pipe ((callFile ./common/builder.nix {}) ({
inherit version;

src = fetchurl {
url = "mirror://gcc/releases/gcc-${version}/gcc-${version}.tar.xz";
url = "mirror://gcc/${
# TODO: Remove this before 25.05.
if version == "14-20241116" then
"snapshots/"
else
"releases/gcc-"
}${version}/gcc-${version}.tar.xz";
${if is10 || is11 || is13 then "hash" else "sha256"} =
gccVersions.srcHashForVersion version;
};
Expand All @@ -206,6 +212,29 @@ pipe ((callFile ./common/builder.nix {}) ({
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 <<EOF
SHA256 (gcc/gengtype-lex.l) = 05acceeda02e673eaef47d187d3a68a1632508112fbe31b5dc2b0a898998d7ec
EOF

(XZ_OPT="--threads=$NIX_BUILD_CORES" xz -d < ${fetchurl {
url = "mirror://gcc/releases/gcc-14.2.0/gcc-14.2.0.tar.xz";
hash = "sha256-p7Obxpy/niWCbFpgqyZHcAH3wI2FzsBLwOKcq+1vPMk=";
}}; true) | tar xf - \
--mode=+w \
--warning=no-timestamp \
--strip-components=1 \
gcc-14.2.0/gcc/gengtype-lex.cc

# Make sure Make knows it’s up‐to‐date.
touch gcc/gengtype-lex.cc
''
# This should kill all the stdinc frameworks that gcc and friends like to
# insert into default search paths.
+ optionalString hostPlatform.isDarwin ''
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
This patch was produced by manually merging:

* <https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=74bfca7360910ae640c2c9c362fe9a4c0ebcc3ba>
* <https://github.com/iains/gcc-14-branch/tree/gcc-14.2-darwin-r2>

and then taking the diff between the result and the upstream GCC
commit, and excerpting only the files that have conflicts when
naively applying the branch’s diff to the snapshot. (This is
more files than the two that actually needed manual merge work –
`gcc/config/aarch64/aarch64-tune.md` and `libgcc/config.host` –
because `patch(1)` can’t do a three‐way merge using ancestor
information.)

diff --git a/gcc/config/aarch64/aarch64-tune.md b/gcc/config/aarch64/aarch64-tune.md
index 35b27ddb88..8ce2a93168 100644
--- a/gcc/config/aarch64/aarch64-tune.md
+++ b/gcc/config/aarch64/aarch64-tune.md
@@ -1,5 +1,5 @@
;; -*- buffer-read-only: t -*-
;; Generated automatically by gentune.sh from aarch64-cores.def
(define_attr "tune"
- "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"
+ "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"
(const (symbol_ref "((enum attr_tune) aarch64_tune)")))
diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index 0d8886c026..5370511bec 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -42,6 +42,7 @@

#define DARWIN_X86 0
#define DARWIN_PPC 0
+#define DARWIN_ARM64 0

#define OBJECT_FORMAT_MACHO 1

@@ -373,7 +374,8 @@
*/

#define DARWIN_NOCOMPACT_UNWIND \
-" %:version-compare(>= 10.6 mmacosx-version-min= -no_compact_unwind) "
+"%{!fuse-ld=lld: \
+ %:version-compare(>= 10.6 mmacosx-version-min= -no_compact_unwind)}"

/* In Darwin linker specs we can put -lcrt0.o and ld will search the library
path for crt0.o or -lcrtx.a and it will search for libcrtx.a. As for
@@ -397,7 +399,8 @@
LINK_PLUGIN_SPEC \
"%{flto*:%<fcompare-debug*} \
%{flto} %{fno-lto} %{flto=*} \
- %l " \
+ %l \
+ %{fuse-ld=*:-fuse-ld=%*} " \
DARWIN_PLATFORM_ID \
LINK_COMPRESS_DEBUG_SPEC \
"%X %{s} %{t} %{Z} %{u*} \
@@ -979,7 +982,12 @@
{ "apple_kext_compatibility", 0, 0, false, true, false, false, \
darwin_handle_kext_attribute, NULL }, \
{ "weak_import", 0, 0, true, false, false, false, \
- darwin_handle_weak_import_attribute, NULL }
+ darwin_handle_weak_import_attribute, NULL }, \
+ { "availability", 0, -1, true, false, false, false, \
+ darwin_handle_availability_attribute, NULL }
+
+#undef TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P
+#define TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P darwin_attribute_takes_identifier_p

/* Make local constant labels linker-visible, so that if one follows a
weak_global constant, ld64 will be able to separate the atoms. */
@@ -1227,6 +1235,10 @@
#define TARGET_N_FORMAT_TYPES 1
#define TARGET_FORMAT_TYPES darwin_additional_format_types

+/* We want __builtin_unreachable to be expanded as a trap instruction. */
+#undef TARGET_UNREACHABLE_SHOULD_TRAP
+#define TARGET_UNREACHABLE_SHOULD_TRAP darwin_unreachable_traps_p
+
#ifndef USED_FOR_TARGET
extern void darwin_driver_init (unsigned int *,struct cl_decoded_option **);
#define GCC_DRIVER_HOST_INITIALIZATION \
diff --git a/libgcc/config.host b/libgcc/config.host
index 7332903704..ae4c91dee3 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -82,7 +82,7 @@
cpu_type=m32c
tmake_file=t-fdpbit
;;
-aarch64*-*-*)
+aarch64*-*-* | arm64*-*-*)
cpu_type=aarch64
;;
alpha*-*-*)
@@ -236,22 +236,25 @@
esac
tmake_file="$tmake_file t-slibgcc-darwin"
case ${host} in
+ x86_64-*-darwin2[0-2]*)
+ tmake_file="t-darwin-min-11 t-darwin-libgccs1 $tmake_file"
+ ;;
*-*-darwin2*)
tmake_file="t-darwin-min-11 $tmake_file"
;;
*-*-darwin1[89]*)
- tmake_file="t-darwin-min-8 $tmake_file"
+ tmake_file="t-darwin-min-8 t-darwin-libgccs1 $tmake_file"
;;
*-*-darwin9* | *-*-darwin1[0-7]*)
- tmake_file="t-darwin-min-5 $tmake_file"
+ tmake_file="t-darwin-min-5 t-darwin-libgccs1 $tmake_file"
;;
*-*-darwin[4-8]*)
- tmake_file="t-darwin-min-1 $tmake_file"
+ tmake_file="t-darwin-min-1 t-darwin-libgccs1 $tmake_file"
;;
*)
# Fall back to configuring for the oldest system known to work with
# all archs and the current sources.
- tmake_file="t-darwin-min-5 $tmake_file"
+ tmake_file="t-darwin-min-5 t-darwin-libgccs1 $tmake_file"
echo "Warning: libgcc configured to support macOS 10.5" 1>&2
;;
esac
@@ -277,7 +280,7 @@
if test "x$enable_darwin_at_rpath" = "xyes"; then
tmake_file="$tmake_file t-darwin-rpath "
fi
- extra_parts="crt3.o libd10-uwfef.a crttms.o crttme.o libemutls_w.a"
+ extra_parts="crt3.o crttms.o crttme.o libemutls_w.a "
;;
*-*-dragonfly*)
tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-eh-dw2-dip"
@@ -421,6 +424,15 @@
tmake_file="${tmake_file} t-dfprules"
md_unwind_header=aarch64/aarch64-unwind.h
;;
+aarch64*-*-darwin*)
+ extra_parts="$extra_parts crtfastmath.o libheapt_w.a"
+ tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
+ tmake_file="${tmake_file} ${cpu_type}/t-lse"
+ tmake_file="${tmake_file} t-crtfm t-dfprules"
+ tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp"
+ tmake_file="${tmake_file} ${cpu_type}/t-heap-trampoline"
+ md_unwind_header=aarch64/aarch64-unwind.h
+ ;;
aarch64*-*-freebsd*)
extra_parts="$extra_parts crtfastmath.o"
tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
@@ -728,14 +740,14 @@
tmake_file="$tmake_file i386/t-crtpc t-crtfm i386/t-msabi"
tm_file="$tm_file i386/darwin-lib.h"
extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o"
- extra_parts="$extra_parts crtfastmath.o libheapt_w.a"
+ extra_parts="$extra_parts crtfastmath.o libd10-uwfef.a libheapt_w.a"
tmake_file="${tmake_file} i386/t-heap-trampoline"
;;
x86_64-*-darwin*)
tmake_file="$tmake_file i386/t-crtpc t-crtfm i386/t-msabi"
tm_file="$tm_file i386/darwin-lib.h"
extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o"
- extra_parts="$extra_parts crtfastmath.o libheapt_w.a"
+ extra_parts="$extra_parts crtfastmath.o libd10-uwfef.a libheapt_w.a"
tmake_file="${tmake_file} i386/t-heap-trampoline"
;;
i[34567]86-*-elfiamcu)
@@ -1218,12 +1230,14 @@
# We build the darwin10 EH shim for Rosetta (running on x86 machines).
tm_file="$tm_file i386/darwin-lib.h"
tmake_file="$tmake_file rs6000/t-ppc64-fp rs6000/t-ibm-ldouble"
+ extra_parts="$extra_parts libd10-uwfef.a "
extra_parts="$extra_parts crt2.o crt3_2.o libef_ppc.a dw_ppc.o"
;;
powerpc64-*-darwin*)
# We build the darwin10 EH shim for Rosetta (running on x86 machines).
tm_file="$tm_file i386/darwin-lib.h"
tmake_file="$tmake_file rs6000/t-darwin64 rs6000/t-ibm-ldouble"
+ extra_parts="$extra_parts libd10-uwfef.a "
extra_parts="$extra_parts crt2.o crt3_2.o libef_ppc.a dw_ppc.o"
;;
powerpc*-*-freebsd*)
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
diff -u a/libgcc/config.host b/libgcc/config.host
--- a/libgcc/config.host 2023-11-05 11:01:55.778638446 -0500
+++ b/libgcc/config.host 2023-11-05 11:07:29.405103979 -0500
@@ -227,7 +227,7 @@
diff --git a/libgcc/config.host b/libgcc/config.host
index 7332903704..27a8b5bedb 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -236,7 +236,7 @@
esac
tmake_file="$tmake_file t-slibgcc-darwin"
# newer toolsets produce warnings when building for unsupported versions.
case ${host} in
- *-*-darwin1[89]* | *-*-darwin2* )
+ *-*-darwin1[89]* | *-*-darwin2* | *-*-darwin)
tmake_file="t-darwin-min-8 $tmake_file"
- *-*-darwin2*)
+ *-*-darwin2* | *-*-darwin)
tmake_file="t-darwin-min-11 $tmake_file"
;;
*-*-darwin9* | *-*-darwin1[0-7]*)
*-*-darwin1[89]*)
24 changes: 17 additions & 7 deletions pkgs/development/compilers/gcc/patches/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,23 @@ in
# We only apply this patch when building a native toolchain for aarch64-darwin, as it breaks building
# a foreign one: https://github.com/iains/gcc-12-branch/issues/18
++ optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64 && buildPlatform == hostPlatform && hostPlatform == targetPlatform) ({
"14" = [ (fetchpatch {
# There are no upstream release tags in https://github.com/iains/gcc-14-branch.
# 04696df09633baf97cdbbdd6e9929b9d472161d3 is the commit from https://github.com/gcc-mirror/gcc/releases/tag/releases%2Fgcc-14.2.0
name = "gcc-14-darwin-aarch64-support.patch";
url = "https://github.com/iains/gcc-14-branch/compare/04696df09633baf97cdbbdd6e9929b9d472161d3..gcc-14.2-darwin-r0.diff";
hash = "sha256-GEUz7KdGzd2WJ0gjX3Uddq2y9bWKdZpT3E9uZ09qLs4=";
}) ];
"14" = [
(fetchpatch {
name = "gcc-14-darwin-aarch64-support.patch";
url = "https://raw.githubusercontent.com/Homebrew/formula-patches/41fdb9d5ec21fc8165cd4bee89bd23d0c90572ee/gcc/gcc-14.2.0-r2.diff";
# The patch is based on 14.2.0, but we use a GCC snapshot. We
# exclude the files with conflicts and apply our own merged patch
# to avoid vendoring the entire huge patch in‐tree.
excludes = [
"gcc/config/aarch64/aarch64-tune.md"
"gcc/config/darwin.h"
"libgcc/config.host"
"libgcc/config/t-darwin-min-11"
];
hash = "sha256-E4zEKm4tMhovOJKc1/FXZCLQvA+Jt5SC0O2C6SEvZjI=";
})
./14/fixup-gcc-14-darwin-aarch64-support.patch
];
"13" = [ (fetchpatch {
name = "gcc-13-darwin-aarch64-support.patch";
url = "https://raw.githubusercontent.com/Homebrew/formula-patches/bda0faddfbfb392e7b9c9101056b2c5ab2500508/gcc/gcc-13.3.0.diff";
Expand Down
4 changes: 2 additions & 2 deletions pkgs/development/compilers/gcc/versions.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
let
majorMinorToVersionMap = {
"14" = "14.2.0";
"14" = "14-20241116";
"13" = "13.3.0";
"12" = "12.4.0";
"11" = "11.5.0";
Expand All @@ -16,7 +16,7 @@ let

# TODO(amjoseph): convert older hashes to SRI form
srcHashForVersion = version: {
"14.2.0" = "sha256-p7Obxpy/niWCbFpgqyZHcAH3wI2FzsBLwOKcq+1vPMk=";
"14-20241116" = "sha256-aXSkle8Mzj/Q15cHOu0D9Os2PWQwMIboUZULhnsRSUo=";
"13.3.0" = "sha256-CEXpYhyVQ6E/SE6UWEpJ/8ASmXDpkUYkI1/B0GGgwIM=";
"12.4.0" = "sha256-cE9lJgTMvMsUvavzR4yVEciXiLEss7v/3tNzQZFqkXU=";
"11.5.0" = "sha256-puIYaOrVRc+H8MAfhCduS1KB1nIJhZHByJYkHwk2NHg=";
Expand Down
2 changes: 1 addition & 1 deletion pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6155,7 +6155,7 @@ with pkgs;
gerbilPackages-unstable = pkgs.gerbil-support.gerbilPackages-unstable; # NB: don't recurseIntoAttrs for (unstable!) libraries
glow-lang = pkgs.gerbilPackages-unstable.glow-lang;

default-gcc-version = 13;
default-gcc-version = 14;
gcc = pkgs.${"gcc${toString default-gcc-version}"};
gccFun = callPackage ../development/compilers/gcc;
gcc-unwrapped = gcc.cc;
Expand Down