mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-07-21 16:11:22 +00:00
gcc: always apply Darwin patches for Darwin targets
The upstream issue was fixed, the branch has changes relevant to `x86_64-darwin` too, and you don’t really want to target Darwin without these patches. We reorder the deployment target patch after the patches, as they touch the same file, and apply it on AArch64 for all versions (but for Darwin targets rather than hosts, which should be the relevant case anyway). Co-Authored-By: sempiternal-aurora <78790545+sempiternal-aurora@users.noreply.github.com>
This commit is contained in:
committed by
sempiternal-aurora
parent
28aa84b964
commit
a6845cb0d6
@@ -1,11 +1,9 @@
|
||||
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"
|
||||
case ${host} in
|
||||
@@ -239,7 +239,7 @@ case ${host} in
|
||||
x86_64-*-darwin2[0-2]*)
|
||||
tmake_file="t-darwin-min-11 t-darwin-libgccs1 $tmake_file"
|
||||
;;
|
||||
- *-*-darwin2*)
|
||||
+ *-*-darwin2* | *-*-darwin)
|
||||
tmake_file="t-darwin-min-11 $tmake_file"
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
--- a/libgcc/config.host
|
||||
+++ b/libgcc/config.host
|
||||
@@ -239,8 +239,8 @@ 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"
|
||||
+ *-*-darwin2* | *-*-darwin)
|
||||
+ tmake_file="t-darwin-min-11 t-darwin-libgccs1 $tmake_file"
|
||||
;;
|
||||
*-*-darwin1[89]*)
|
||||
@@ -35,12 +35,6 @@ let
|
||||
is14 = majorVersion == "14";
|
||||
is13 = majorVersion == "13";
|
||||
|
||||
# We only apply these patches when building a native toolchain for
|
||||
# aarch64-darwin, as it breaks building a foreign one:
|
||||
# https://github.com/iains/gcc-12-branch/issues/18
|
||||
canApplyIainsDarwinPatches =
|
||||
stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64 && buildIsHost && hostIsTarget;
|
||||
|
||||
inherit (lib) optionals optional;
|
||||
in
|
||||
|
||||
@@ -108,7 +102,7 @@ optionals noSysDirs (
|
||||
# Needed to build llvm-18 and later
|
||||
# See https://github.com/NixOS/nixpkgs/pull/354107/commits/2de1b4b14e17f42ba8b4bf43a29347c91511e008
|
||||
++ optional (!atLeast14) ./cfi_startproc-reorder-label-09-1.diff
|
||||
++ optional (atLeast14 && !canApplyIainsDarwinPatches) ./cfi_startproc-reorder-label-14-1.diff
|
||||
++ optional (atLeast14 && !targetPlatform.isDarwin) ./cfi_startproc-reorder-label-14-1.diff
|
||||
# c++tools: Don't check --enable-default-pie.
|
||||
# --enable-default-pie breaks bootstrap gcc otherwise, because libiberty.a is not found
|
||||
++ optional (is14 || is15) ./c++tools-dont-check-enable-default-pie.patch
|
||||
@@ -120,30 +114,22 @@ optionals noSysDirs (
|
||||
|
||||
## Darwin
|
||||
|
||||
# Fixes detection of Darwin on x86_64-darwin and aarch64-darwin. Otherwise, GCC uses a deployment target of 10.5, which crashes ld64.
|
||||
++ optional (
|
||||
# this one would conflict with gcc-14-darwin-aarch64-support.patch
|
||||
is14 && stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64
|
||||
) ../patches/14/libgcc-darwin-detection.patch
|
||||
++ optional (atLeast15 && stdenv.hostPlatform.isDarwin) ../patches/15/libgcc-darwin-detection.patch
|
||||
|
||||
# Fix libgcc_s.1.dylib build on Darwin 11+ by not reexporting unwind symbols that don't exist
|
||||
++ optional (
|
||||
atLeast15 && stdenv.hostPlatform.isDarwin
|
||||
) ../patches/15/libgcc-darwin-fix-reexport.patch
|
||||
|
||||
# Here we apply patches by Iains (https://github.com/iains)
|
||||
# GitHub's "compare" API produces unstable diffs, so we resort to reusing
|
||||
# diffs from the Homebrew repo.
|
||||
++ optionals canApplyIainsDarwinPatches (
|
||||
++ optionals targetPlatform.isDarwin (
|
||||
{
|
||||
"15" = [
|
||||
# Fix libgcc_s.1.dylib build on Darwin 11+ by not reexporting unwind symbols that don't exist
|
||||
./15/libgcc-darwin-fix-reexport.patch
|
||||
# Patches from https://github.com/iains/gcc-15-branch/compare/releases/gcc-15..gcc-15.1-darwin-rc1
|
||||
(fetchpatch {
|
||||
name = "gcc-15-darwin-aarch64-support.patch";
|
||||
url = "https://raw.githubusercontent.com/Homebrew/formula-patches/a25079204c1cb3d78ba9dd7dd22b8aecce7ce264/gcc/gcc-15.1.0.diff";
|
||||
sha256 = "sha256-MJxSGv6LEP1sIM8cDqbmfUV7byV0bYgADeIBY/Teyu8=";
|
||||
})
|
||||
# Fixes detection of Darwin deployment target.
|
||||
./14/libgcc-darwin-detection.patch
|
||||
];
|
||||
"14" = [
|
||||
# Patches from https://github.com/iains/gcc-14-branch/compare/04696df09633baf97cdbbdd6e9929b9d472161d3..gcc-14.2-darwin-r2
|
||||
@@ -155,12 +141,13 @@ optionals noSysDirs (
|
||||
url = "https://github.com/iains/gcc-14-branch/compare/aa4cd614456de65ee3417acb83c6cff0640144e9..3e1d48d240f4aa5223c701b5c231c66f66ab1126.diff";
|
||||
hash = "sha256-BSTSYnkBJBEm++mGerVVyaCUC4dUyXq0N1tqbk25bO4=";
|
||||
})
|
||||
./14/libgcc-darwin-detection.patch
|
||||
];
|
||||
# Patches from https://github.com/iains/gcc-13-branch/compare/b71f1de6e9cf7181a288c0f39f9b1ef6580cf5c8..gcc-13-3-darwin
|
||||
"13" = [
|
||||
# Patches from https://github.com/iains/gcc-13-branch
|
||||
(fetchpatch {
|
||||
name = "gcc-13-darwin-aarch64-support.patch";
|
||||
url = "https://raw.githubusercontent.com/Homebrew/formula-patches/698885df7f624d0ce15bceb79a4d9760a473b502/gcc/gcc-13.4.0.diff";
|
||||
url = "https://raw.githubusercontent.com/Homebrew/homebrew-core/d23df58f83aeb2c3f43bdcc277a9fac0bbe3e896/Patches/gcc/gcc-13.4.0.diff";
|
||||
hash = "sha256-xqkBDFYZ6fdowtqR3kV7bR8a4Cu11RDokSzGn1k3a1w=";
|
||||
})
|
||||
];
|
||||
@@ -168,21 +155,6 @@ optionals noSysDirs (
|
||||
.${majorVersion} or [ ]
|
||||
)
|
||||
|
||||
# Use absolute path in GNAT dylib install names on Darwin
|
||||
++ optionals (stdenv.hostPlatform.isDarwin && langAda) (
|
||||
{
|
||||
"15" = [ ../patches/14/gnat-darwin-dylib-install-name-14.patch ];
|
||||
"14" = [ ../patches/14/gnat-darwin-dylib-install-name-14.patch ];
|
||||
# After the Iains patch, GCC 13 and 14 share the same patch.
|
||||
"13" = [ ../patches/14/gnat-darwin-dylib-install-name-14.patch ];
|
||||
}
|
||||
.${majorVersion} or [ ]
|
||||
)
|
||||
|
||||
++ optional (
|
||||
langAda && is13 && canApplyIainsDarwinPatches
|
||||
) ./13/gnat13-aarch64-darwin-trampoline.patch
|
||||
|
||||
++ optional (targetPlatform.isWindows || targetPlatform.isCygwin) (fetchpatch {
|
||||
name = "libstdc-fix-compilation-in-freestanding-win32.patch";
|
||||
url = "https://inbox.sourceware.org/gcc-patches/20250922182808.2599390-2-corngood@gmail.com/raw";
|
||||
|
||||
Reference in New Issue
Block a user