Skip to content

Commit 40a267e

Browse files
markmentovaicjones051073
authored andcommitted
gcc14: Fix macOS 15 x86_64 build
This also fixes the macOS 14 x86_64 build when using Xcode 16. Closes: https://trac.macports.org/ticket/70866
1 parent d0dbbcb commit 40a267e

5 files changed

+191
-21
lines changed

lang/gcc14/Portfile

+15-8
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ long_description {*}${description}, including front ends for \
2525
# Remember to reset all revision increments below to 0 on new versions
2626
version ${gcc_major_v}.2.0
2727
revision 1
28+
# Remove OS dependent revision bump on next version update
29+
if { ${os.platform} eq "darwin" && ${os.major} >= 23 } {
30+
revision [ expr ${revision} + 1 ]
31+
}
2832

2933
set libgccname lib${name}
3034
subport ${libgccname} { revision [ expr ${revision} + 0 ] }
@@ -177,14 +181,17 @@ if { ${os.platform} eq "darwin" } {
177181
if { ${os.major} == 18 } {
178182
patchfiles-append patch-OSX10.14-ucred-atomic-define.diff
179183
}
180-
# TEMPORARY workaround for macOS15+. See
181-
# https://trac.macports.org/ticket/70641
182-
# and upstream discussion at
183-
# https://github.com/iains/gcc-darwin-arm64/issues/136
184-
# An upstream fix is likely not too far off, but in the meantime use
185-
# this workaround to provide users with a working build
186-
if { ${os.major} >= 24 } {
187-
patchfiles-append patch-as_needs_dash_for_piped_input.diff
184+
185+
# Additional macOS 15 (and macOS 14 with Xcode 16) compatibility patches
186+
# from https://github.com/iains/gcc-14-branch, after tag gcc-14.2-darwin-r1.
187+
# See https://trac.macports.org/ticket/70641,
188+
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116794,
189+
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116809, and
190+
# https://github.com/iains/gcc-darwin-arm64/issues/136.
191+
if { ${os.major} >= 23 } {
192+
patchfiles-append 0001-Darwin-Allow-for-as-versions-that-need-for-std-in.patch \
193+
0002-libgcc-Darwin-Drop-the-legacy-library-build-for-macO.patch \
194+
0003-libgcc-Darwin-Don-t-build-legacy-libgcc_s.1-on-macOS.patch
188195
}
189196
}
190197

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
From ea41179dab5df144d2ec137c94dcbe171e427728 Mon Sep 17 00:00:00 2001
2+
From: Iain Sandoe <iain@sandoe.co.uk>
3+
Date: Wed, 18 Sep 2024 17:46:32 +0100
4+
Subject: [PATCH 1/3] Darwin: Allow for as versions that need '-' for std in.
5+
6+
Recent versions of Xcode as require a dash to read from standard
7+
input. We can use this on all supported OS versions so make it
8+
unconditional. Patch from Mark Mentovai.
9+
10+
gcc/ChangeLog:
11+
12+
* config/darwin.h (AS_NEEDS_DASH_FOR_PIPED_INPUT): New.
13+
14+
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
15+
---
16+
gcc/config/darwin.h | 2 ++
17+
1 file changed, 2 insertions(+)
18+
19+
diff --git gcc/config/darwin.h gcc/config/darwin.h
20+
index 7a53a1688a7d..5370511bec21 100644
21+
--- gcc/config/darwin.h
22+
+++ gcc/config/darwin.h
23+
@@ -651,6 +651,8 @@ extern GTY(()) int darwin_ms_struct;
24+
#define ASM_OPTIONS "%{v} %{w:-W} %{I*}"
25+
#endif
26+
27+
+#define AS_NEEDS_DASH_FOR_PIPED_INPUT
28+
+
29+
/* Default Darwin ASM_SPEC, very simple. */
30+
#define ASM_SPEC \
31+
"%{static} -arch %(darwin_arch) " \
32+
--
33+
2.46.2
34+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
From df72eb16a5bda90be31681a8d494a4053f891986 Mon Sep 17 00:00:00 2001
2+
From: Iain Sandoe <iain@sandoe.co.uk>
3+
Date: Sun, 22 Sep 2024 11:43:32 +0100
4+
Subject: [PATCH 2/3] libgcc, Darwin: Drop the legacy library build for macOS
5+
>= 15 [PR116809].
6+
7+
We have been building a legacy libgcc_s.1 DSO to support code that
8+
was built with older compilers.
9+
10+
From macOS 15, the unwinder no longer exports some of the symbols used
11+
in that library which (a) cuases bootstrap fail and (b) means that the
12+
legacy library is no longer useful.
13+
14+
No open branch of GCC emits references to this library - and any already
15+
-built code that depends on the symbols would need rework anyway.
16+
17+
PR target/116809
18+
19+
libgcc/ChangeLog:
20+
21+
* config.host: Build legacy libgcc_s.1 on hosts before macOS 15.
22+
* config/i386/t-darwin: Remove reference to legacy libgcc_s.1
23+
* config/rs6000/t-darwin: Likewise.
24+
* config/t-darwin-libgccs1: New file.
25+
26+
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
27+
(cherry picked from commit d9cafa0c4f0a81304d9b95a78ccc8e9003c6d7a3)
28+
---
29+
libgcc/config.host | 11 +++++++----
30+
libgcc/config/i386/t-darwin | 3 ---
31+
libgcc/config/rs6000/t-darwin | 3 ---
32+
libgcc/config/t-darwin-libgccs1 | 3 +++
33+
4 files changed, 10 insertions(+), 10 deletions(-)
34+
create mode 100644 libgcc/config/t-darwin-libgccs1
35+
36+
diff --git libgcc/config.host libgcc/config.host
37+
index d27204f3fb47..08be426f3fe4 100644
38+
--- libgcc/config.host
39+
+++ libgcc/config.host
40+
@@ -236,22 +236,25 @@ case ${host} in
41+
esac
42+
tmake_file="$tmake_file t-slibgcc-darwin"
43+
case ${host} in
44+
+ x86_64-*-darwin2[0-3]*)
45+
+ tmake_file="t-darwin-min-11 t-darwin-libgccs1 $tmake_file"
46+
+ ;;
47+
*-*-darwin2*)
48+
tmake_file="t-darwin-min-11 $tmake_file"
49+
;;
50+
*-*-darwin1[89]*)
51+
- tmake_file="t-darwin-min-8 $tmake_file"
52+
+ tmake_file="t-darwin-min-8 t-darwin-libgccs1 $tmake_file"
53+
;;
54+
*-*-darwin9* | *-*-darwin1[0-7]*)
55+
- tmake_file="t-darwin-min-5 $tmake_file"
56+
+ tmake_file="t-darwin-min-5 t-darwin-libgccs1 $tmake_file"
57+
;;
58+
*-*-darwin[4-8]*)
59+
- tmake_file="t-darwin-min-1 $tmake_file"
60+
+ tmake_file="t-darwin-min-1 t-darwin-libgccs1 $tmake_file"
61+
;;
62+
*)
63+
# Fall back to configuring for the oldest system known to work with
64+
# all archs and the current sources.
65+
- tmake_file="t-darwin-min-5 $tmake_file"
66+
+ tmake_file="t-darwin-min-5 t-darwin-libgccs1 $tmake_file"
67+
echo "Warning: libgcc configured to support macOS 10.5" 1>&2
68+
;;
69+
esac
70+
diff --git libgcc/config/i386/t-darwin libgcc/config/i386/t-darwin
71+
index 4c18da1efbfd..c6b3acaaca28 100644
72+
--- libgcc/config/i386/t-darwin
73+
+++ libgcc/config/i386/t-darwin
74+
@@ -4,6 +4,3 @@ LIB2FUNCS_EXCLUDE = _fixtfdi _fixunstfdi _floatditf _floatunditf
75+
76+
# Extra symbols for this port.
77+
SHLIB_MAPFILES += $(srcdir)/config/i386/libgcc-darwin.ver
78+
-
79+
-# Build a legacy libgcc_s.1
80+
-BUILD_LIBGCCS1 = YES
81+
diff --git libgcc/config/rs6000/t-darwin libgcc/config/rs6000/t-darwin
82+
index 183d0df92ce9..8b513bdb1d78 100644
83+
--- libgcc/config/rs6000/t-darwin
84+
+++ libgcc/config/rs6000/t-darwin
85+
@@ -56,6 +56,3 @@ unwind-dw2_s.o: HOST_LIBGCC2_CFLAGS += -maltivec
86+
unwind-dw2.o: HOST_LIBGCC2_CFLAGS += -maltivec
87+
88+
LIB2ADDEH += $(srcdir)/config/rs6000/darwin-fallback.c
89+
-
90+
-# Build a legacy libgcc_s.1
91+
-BUILD_LIBGCCS1 = YES
92+
diff --git libgcc/config/t-darwin-libgccs1 libgcc/config/t-darwin-libgccs1
93+
new file mode 100644
94+
index 000000000000..b88b1a5bba8a
95+
--- /dev/null
96+
+++ libgcc/config/t-darwin-libgccs1
97+
@@ -0,0 +1,3 @@
98+
+
99+
+# Build a legacy libgcc_s.1
100+
+BUILD_LIBGCCS1 = YES
101+
--
102+
2.46.2
103+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
From df3861926d0604145810f38a8719984447f33a3c Mon Sep 17 00:00:00 2001
2+
From: Mark Mentovai <mark@mentovai.com>
3+
Date: Tue, 24 Sep 2024 16:11:14 -0400
4+
Subject: [PATCH 3/3] libgcc, Darwin: Don't build legacy libgcc_s.1 on macOS 14
5+
[PR116809]
6+
7+
d9cafa0c4f0a stopped building libgcc_s.1 on macOS >= 15, in part because
8+
that is required to bootstrap the compiler using the macOS 15 SDK. The
9+
macOS 15 SDK ships in Xcode 16, which also runs on macOS 14. libgcc_s.1
10+
can no longer be built on macOS 14 using Xcode 16 by the same logic that
11+
the previous change disabled it for macOS 15.
12+
13+
PR target/116809
14+
15+
libgcc/ChangeLog:
16+
17+
* config.host: Don't build legacy libgcc_s.1 on macOS 14.
18+
19+
Signed-off-by: Mark Mentovai <mark@mentovai.com>
20+
---
21+
libgcc/config.host | 2 +-
22+
1 file changed, 1 insertion(+), 1 deletion(-)
23+
24+
diff --git libgcc/config.host libgcc/config.host
25+
index 08be426f3fe4..ae4c91dee351 100644
26+
--- libgcc/config.host
27+
+++ libgcc/config.host
28+
@@ -236,7 +236,7 @@ case ${host} in
29+
esac
30+
tmake_file="$tmake_file t-slibgcc-darwin"
31+
case ${host} in
32+
- x86_64-*-darwin2[0-3]*)
33+
+ x86_64-*-darwin2[0-2]*)
34+
tmake_file="t-darwin-min-11 t-darwin-libgccs1 $tmake_file"
35+
;;
36+
*-*-darwin2*)
37+
--
38+
2.46.2
39+

lang/gcc14/files/patch-as_needs_dash_for_piped_input.diff

-13
This file was deleted.

0 commit comments

Comments
 (0)