Skip to content

Commit

Permalink
gcc14: Fix macOS 15 x86_64 build
Browse files Browse the repository at this point in the history
This also fixes the macOS 14 x86_64 build when using Xcode 16.

Closes: https://trac.macports.org/ticket/70866
  • Loading branch information
markmentovai authored and cjones051073 committed Sep 26, 2024
1 parent d0dbbcb commit 40a267e
Show file tree
Hide file tree
Showing 5 changed files with 191 additions and 21 deletions.
23 changes: 15 additions & 8 deletions lang/gcc14/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ long_description {*}${description}, including front ends for \
# Remember to reset all revision increments below to 0 on new versions
version ${gcc_major_v}.2.0
revision 1
# Remove OS dependent revision bump on next version update
if { ${os.platform} eq "darwin" && ${os.major} >= 23 } {
revision [ expr ${revision} + 1 ]
}

set libgccname lib${name}
subport ${libgccname} { revision [ expr ${revision} + 0 ] }
Expand Down Expand Up @@ -177,14 +181,17 @@ if { ${os.platform} eq "darwin" } {
if { ${os.major} == 18 } {
patchfiles-append patch-OSX10.14-ucred-atomic-define.diff
}
# TEMPORARY workaround for macOS15+. See
# https://trac.macports.org/ticket/70641
# and upstream discussion at
# https://github.com/iains/gcc-darwin-arm64/issues/136
# An upstream fix is likely not too far off, but in the meantime use
# this workaround to provide users with a working build
if { ${os.major} >= 24 } {
patchfiles-append patch-as_needs_dash_for_piped_input.diff

# Additional macOS 15 (and macOS 14 with Xcode 16) compatibility patches
# from https://github.com/iains/gcc-14-branch, after tag gcc-14.2-darwin-r1.
# See https://trac.macports.org/ticket/70641,
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116794,
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116809, and
# https://github.com/iains/gcc-darwin-arm64/issues/136.
if { ${os.major} >= 23 } {
patchfiles-append 0001-Darwin-Allow-for-as-versions-that-need-for-std-in.patch \
0002-libgcc-Darwin-Drop-the-legacy-library-build-for-macO.patch \
0003-libgcc-Darwin-Don-t-build-legacy-libgcc_s.1-on-macOS.patch
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
From ea41179dab5df144d2ec137c94dcbe171e427728 Mon Sep 17 00:00:00 2001
From: Iain Sandoe <[email protected]>
Date: Wed, 18 Sep 2024 17:46:32 +0100
Subject: [PATCH 1/3] Darwin: Allow for as versions that need '-' for std in.

Recent versions of Xcode as require a dash to read from standard
input. We can use this on all supported OS versions so make it
unconditional. Patch from Mark Mentovai.

gcc/ChangeLog:

* config/darwin.h (AS_NEEDS_DASH_FOR_PIPED_INPUT): New.

Signed-off-by: Iain Sandoe <[email protected]>
---
gcc/config/darwin.h | 2 ++
1 file changed, 2 insertions(+)

diff --git gcc/config/darwin.h gcc/config/darwin.h
index 7a53a1688a7d..5370511bec21 100644
--- gcc/config/darwin.h
+++ gcc/config/darwin.h
@@ -651,6 +651,8 @@ extern GTY(()) int darwin_ms_struct;
#define ASM_OPTIONS "%{v} %{w:-W} %{I*}"
#endif

+#define AS_NEEDS_DASH_FOR_PIPED_INPUT
+
/* Default Darwin ASM_SPEC, very simple. */
#define ASM_SPEC \
"%{static} -arch %(darwin_arch) " \
--
2.46.2

Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
From df72eb16a5bda90be31681a8d494a4053f891986 Mon Sep 17 00:00:00 2001
From: Iain Sandoe <[email protected]>
Date: Sun, 22 Sep 2024 11:43:32 +0100
Subject: [PATCH 2/3] libgcc, Darwin: Drop the legacy library build for macOS
>= 15 [PR116809].

We have been building a legacy libgcc_s.1 DSO to support code that
was built with older compilers.

From macOS 15, the unwinder no longer exports some of the symbols used
in that library which (a) cuases bootstrap fail and (b) means that the
legacy library is no longer useful.

No open branch of GCC emits references to this library - and any already
-built code that depends on the symbols would need rework anyway.

PR target/116809

libgcc/ChangeLog:

* config.host: Build legacy libgcc_s.1 on hosts before macOS 15.
* config/i386/t-darwin: Remove reference to legacy libgcc_s.1
* config/rs6000/t-darwin: Likewise.
* config/t-darwin-libgccs1: New file.

Signed-off-by: Iain Sandoe <[email protected]>
(cherry picked from commit d9cafa0c4f0a81304d9b95a78ccc8e9003c6d7a3)
---
libgcc/config.host | 11 +++++++----
libgcc/config/i386/t-darwin | 3 ---
libgcc/config/rs6000/t-darwin | 3 ---
libgcc/config/t-darwin-libgccs1 | 3 +++
4 files changed, 10 insertions(+), 10 deletions(-)
create mode 100644 libgcc/config/t-darwin-libgccs1

diff --git libgcc/config.host libgcc/config.host
index d27204f3fb47..08be426f3fe4 100644
--- libgcc/config.host
+++ libgcc/config.host
@@ -236,22 +236,25 @@ case ${host} in
esac
tmake_file="$tmake_file t-slibgcc-darwin"
case ${host} in
+ x86_64-*-darwin2[0-3]*)
+ 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
diff --git libgcc/config/i386/t-darwin libgcc/config/i386/t-darwin
index 4c18da1efbfd..c6b3acaaca28 100644
--- libgcc/config/i386/t-darwin
+++ libgcc/config/i386/t-darwin
@@ -4,6 +4,3 @@ LIB2FUNCS_EXCLUDE = _fixtfdi _fixunstfdi _floatditf _floatunditf

# Extra symbols for this port.
SHLIB_MAPFILES += $(srcdir)/config/i386/libgcc-darwin.ver
-
-# Build a legacy libgcc_s.1
-BUILD_LIBGCCS1 = YES
diff --git libgcc/config/rs6000/t-darwin libgcc/config/rs6000/t-darwin
index 183d0df92ce9..8b513bdb1d78 100644
--- libgcc/config/rs6000/t-darwin
+++ libgcc/config/rs6000/t-darwin
@@ -56,6 +56,3 @@ unwind-dw2_s.o: HOST_LIBGCC2_CFLAGS += -maltivec
unwind-dw2.o: HOST_LIBGCC2_CFLAGS += -maltivec

LIB2ADDEH += $(srcdir)/config/rs6000/darwin-fallback.c
-
-# Build a legacy libgcc_s.1
-BUILD_LIBGCCS1 = YES
diff --git libgcc/config/t-darwin-libgccs1 libgcc/config/t-darwin-libgccs1
new file mode 100644
index 000000000000..b88b1a5bba8a
--- /dev/null
+++ libgcc/config/t-darwin-libgccs1
@@ -0,0 +1,3 @@
+
+# Build a legacy libgcc_s.1
+BUILD_LIBGCCS1 = YES
--
2.46.2

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
From df3861926d0604145810f38a8719984447f33a3c Mon Sep 17 00:00:00 2001
From: Mark Mentovai <[email protected]>
Date: Tue, 24 Sep 2024 16:11:14 -0400
Subject: [PATCH 3/3] libgcc, Darwin: Don't build legacy libgcc_s.1 on macOS 14
[PR116809]

d9cafa0c4f0a stopped building libgcc_s.1 on macOS >= 15, in part because
that is required to bootstrap the compiler using the macOS 15 SDK. The
macOS 15 SDK ships in Xcode 16, which also runs on macOS 14. libgcc_s.1
can no longer be built on macOS 14 using Xcode 16 by the same logic that
the previous change disabled it for macOS 15.

PR target/116809

libgcc/ChangeLog:

* config.host: Don't build legacy libgcc_s.1 on macOS 14.

Signed-off-by: Mark Mentovai <[email protected]>
---
libgcc/config.host | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git libgcc/config.host libgcc/config.host
index 08be426f3fe4..ae4c91dee351 100644
--- libgcc/config.host
+++ libgcc/config.host
@@ -236,7 +236,7 @@ case ${host} in
esac
tmake_file="$tmake_file t-slibgcc-darwin"
case ${host} in
- x86_64-*-darwin2[0-3]*)
+ x86_64-*-darwin2[0-2]*)
tmake_file="t-darwin-min-11 t-darwin-libgccs1 $tmake_file"
;;
*-*-darwin2*)
--
2.46.2

13 changes: 0 additions & 13 deletions lang/gcc14/files/patch-as_needs_dash_for_piped_input.diff

This file was deleted.

0 comments on commit 40a267e

Please sign in to comment.