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.

+5 -193
-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*)
+5 -12
pkgs/development/compilers/gcc/patches/default.nix
··· 185 185 ]; 186 186 "14" = [ 187 187 (fetchpatch { 188 + # There are no upstream release tags nor a static branch for 14.3.0 in https://github.com/iains/gcc-14-branch. 189 + # 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 190 + # 3e1d48d240f4aa5223c701b5c231c66f66ab1126 is the newest commit of https://github.com/iains/gcc-14-branch/tree/gcc-14-3-darwin-pre-0 188 191 name = "gcc-14-darwin-aarch64-support.patch"; 189 - url = "https://raw.githubusercontent.com/Homebrew/formula-patches/41fdb9d5ec21fc8165cd4bee89bd23d0c90572ee/gcc/gcc-14.2.0-r2.diff"; 190 - # The patch is based on 14.2.0, but we use a GCC snapshot. We 191 - # exclude the files with conflicts and apply our own merged patch 192 - # to avoid vendoring the entire huge patch in‐tree. 193 - excludes = [ 194 - "gcc/config/aarch64/aarch64-tune.md" 195 - "gcc/config/darwin.h" 196 - "libgcc/config.host" 197 - "libgcc/config/t-darwin-min-11" 198 - ]; 199 - hash = "sha256-E4zEKm4tMhovOJKc1/FXZCLQvA+Jt5SC0O2C6SEvZjI="; 192 + url = "https://github.com/iains/gcc-14-branch/compare/aa4cd614456de65ee3417acb83c6cff0640144e9..3e1d48d240f4aa5223c701b5c231c66f66ab1126.diff"; 193 + hash = "sha256-BSTSYnkBJBEm++mGerVVyaCUC4dUyXq0N1tqbk25bO4="; 200 194 }) 201 - ./14/fixup-gcc-14-darwin-aarch64-support.patch 202 195 ]; 203 196 "13" = [ 204 197 (fetchpatch {