From 385a5e291736a41841967bd3b0662e8c2c997794 Mon Sep 17 00:00:00 2001 From: Ben Siraphob Date: Thu, 13 Nov 2025 23:59:30 -0800 Subject: [PATCH] gcc15: fix build on aarch64-darwin This fixes the GCC 15.2.0 build on aarch64-darwin by addressing two issues in the libgcc build process: 1. Update libgcc-darwin-detection.patch: - Catch arm64-apple-darwin (which lacks a version number) - Add t-darwin-libgccs1 to enable libgcc_s.1.dylib compatibility build 2. Added libgcc-darwin-fix-reexport.patch: - Remove reexport of darwin-unwind.ver symbols in libgcc_s.1.dylib - These symbols (___register_frame_info, etc.) don't exist in libgcc on modern macOS as they come from libSystem The original build failed with: Undefined symbols for architecture arm64: "___deregister_frame_info", referenced from: -reexported_symbols_list command line option ... This occurred because darwin-unwind.ver lists unwinder symbols that are excluded from libgcc (via libgcc-libsystem.ver) on macOS 11+ where they are provided by the system's libSystem. --- .../gcc/patches/15/libgcc-darwin-detection.patch | 5 +++-- .../gcc/patches/15/libgcc-darwin-fix-reexport.patch | 11 +++++++++++ pkgs/development/compilers/gcc/patches/default.nix | 13 +++++++------ 3 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 pkgs/development/compilers/gcc/patches/15/libgcc-darwin-fix-reexport.patch diff --git a/pkgs/development/compilers/gcc/patches/15/libgcc-darwin-detection.patch b/pkgs/development/compilers/gcc/patches/15/libgcc-darwin-detection.patch index 810d8e6f69a1..41e1c4c89869 100644 --- a/pkgs/development/compilers/gcc/patches/15/libgcc-darwin-detection.patch +++ b/pkgs/development/compilers/gcc/patches/15/libgcc-darwin-detection.patch @@ -1,11 +1,12 @@ --- a/libgcc/config.host +++ b/libgcc/config.host -@@ -239,7 +239,7 @@ case ${host} in +@@ -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 $tmake_file" ++ tmake_file="t-darwin-min-11 t-darwin-libgccs1 $tmake_file" ;; *-*-darwin1[89]*) diff --git a/pkgs/development/compilers/gcc/patches/15/libgcc-darwin-fix-reexport.patch b/pkgs/development/compilers/gcc/patches/15/libgcc-darwin-fix-reexport.patch new file mode 100644 index 000000000000..dbb790e1eec3 --- /dev/null +++ b/pkgs/development/compilers/gcc/patches/15/libgcc-darwin-fix-reexport.patch @@ -0,0 +1,11 @@ +--- a/libgcc/config/t-slibgcc-darwin ++++ b/libgcc/config/t-slibgcc-darwin +@@ -139,8 +139,7 @@ libgcc_s.1.dylib: all-multi libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT) + $(CC) -arch $${arch} -nodefaultlibs -dynamiclib -nodefaultrpaths \ + -o libgcc_s.1$(SHLIB_EXT)_T_$${mlib} \ + -Wl,-reexport_library,libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} \ + -lSystem \ +- -Wl,-reexported_symbols_list,$(srcdir)/config/darwin-unwind.ver \ + -install_name $(SHLIB_RPATH)/libgcc_s.1.dylib \ + -compatibility_version 1 -current_version 1.1 ; \ + done diff --git a/pkgs/development/compilers/gcc/patches/default.nix b/pkgs/development/compilers/gcc/patches/default.nix index 93a1d4eb5cf3..0f7db57689e1 100644 --- a/pkgs/development/compilers/gcc/patches/default.nix +++ b/pkgs/development/compilers/gcc/patches/default.nix @@ -160,13 +160,14 @@ optionals noSysDirs ( ## Darwin -# Fixes detection of Darwin on x86_64-darwin. Otherwise, GCC uses a deployment target of 10.5, which crashes ld64. +# Fixes detection of Darwin on x86_64-darwin and aarch64-darwin. Otherwise, GCC uses a deployment target of 10.5, which crashes ld64. +++ optional (is14 && stdenv.hostPlatform.isDarwin) ../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 ( - is14 && stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64 -) ../patches/14/libgcc-darwin-detection.patch -++ optional ( - atLeast15 && stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64 -) ../patches/15/libgcc-darwin-detection.patch + atLeast15 && stdenv.hostPlatform.isDarwin +) ../patches/15/libgcc-darwin-fix-reexport.patch # Fix detection of bootstrap compiler Ada support (cctools as) on Nix Darwin ++ optional (stdenv.hostPlatform.isDarwin && langAda) ./ada-cctools-as-detection-configure.patch