From 051793402076378f15ca4e3c2735d5b2bca95ffd Mon Sep 17 00:00:00 2001 From: Leona Maroni Date: Sun, 1 Jun 2025 18:31:52 +0200 Subject: [PATCH] gcc14: fix build on aarch64-darwin The previous patch didn't apply anymore for 14.3.0. Currently there is no branch for 14.3.0 in https://github.com/iains/gcc-14-branch nor in homebrew. This lead me to use the -pre branch with a custom target. --- .../fixup-gcc-14-darwin-aarch64-support.patch | 181 ------------------ .../compilers/gcc/patches/default.nix | 17 +- 2 files changed, 5 insertions(+), 193 deletions(-) delete mode 100644 pkgs/development/compilers/gcc/patches/14/fixup-gcc-14-darwin-aarch64-support.patch diff --git a/pkgs/development/compilers/gcc/patches/14/fixup-gcc-14-darwin-aarch64-support.patch b/pkgs/development/compilers/gcc/patches/14/fixup-gcc-14-darwin-aarch64-support.patch deleted file mode 100644 index 58bd60362650..000000000000 --- a/pkgs/development/compilers/gcc/patches/14/fixup-gcc-14-darwin-aarch64-support.patch +++ /dev/null @@ -1,181 +0,0 @@ -This patch was produced by manually merging: - -* -* - -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*:%&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*) diff --git a/pkgs/development/compilers/gcc/patches/default.nix b/pkgs/development/compilers/gcc/patches/default.nix index bb68f2cc4146..0d6a9c66808d 100644 --- a/pkgs/development/compilers/gcc/patches/default.nix +++ b/pkgs/development/compilers/gcc/patches/default.nix @@ -185,20 +185,13 @@ in ]; "14" = [ (fetchpatch { + # There are no upstream release tags nor a static branch for 14.3.0 in https://github.com/iains/gcc-14-branch. + # aa4cd614456de65ee3417acb83c6cff0640144e9 is the merge base of https://github.com/iains/gcc-14-branch/tree/gcc-14-3-darwin-pre-0 and https://github.com/gcc-mirror/gcc/releases/tag/releases%2Fgcc-14.3.0 + # 3e1d48d240f4aa5223c701b5c231c66f66ab1126 is the newest commit of https://github.com/iains/gcc-14-branch/tree/gcc-14-3-darwin-pre-0 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="; + url = "https://github.com/iains/gcc-14-branch/compare/aa4cd614456de65ee3417acb83c6cff0640144e9..3e1d48d240f4aa5223c701b5c231c66f66ab1126.diff"; + hash = "sha256-BSTSYnkBJBEm++mGerVVyaCUC4dUyXq0N1tqbk25bO4="; }) - ./14/fixup-gcc-14-darwin-aarch64-support.patch ]; "13" = [ (fetchpatch {