about summary refs log tree commit diff
path: root/pkgs/development/compilers/gcc
diff options
context:
space:
mode:
authorRandy Eckenrode <randy@largeandhighquality.com>2023-11-05 13:58:26 -0500
committerAdam Joseph <54836058+amjoseph-nixpkgs@users.noreply.github.com>2023-11-08 10:50:07 +0000
commite06f05d23c7dfa5d5cb73d416e612dd02b337f7d (patch)
treeebc09c36c2fa334dbe6f56bc38f35fc24e0b907d /pkgs/development/compilers/gcc
parente556bb0b675a849371645b6b79eccd4130744967 (diff)
downloadnixlib-e06f05d23c7dfa5d5cb73d416e612dd02b337f7d.tar
nixlib-e06f05d23c7dfa5d5cb73d416e612dd02b337f7d.tar.gz
nixlib-e06f05d23c7dfa5d5cb73d416e612dd02b337f7d.tar.bz2
nixlib-e06f05d23c7dfa5d5cb73d416e612dd02b337f7d.tar.lz
nixlib-e06f05d23c7dfa5d5cb73d416e612dd02b337f7d.tar.xz
nixlib-e06f05d23c7dfa5d5cb73d416e612dd02b337f7d.tar.zst
nixlib-e06f05d23c7dfa5d5cb73d416e612dd02b337f7d.zip
gcc11: fix build on aarch64-darwin
The libgcc configure script was middetecting aarch64-darwin and trying
to use a deployment target of 10.5, which is not valid for that
platform. The build was failing because the linker was looking for stubs
that don’t exist (neither as part of the source releases nor as part of
the official SDK from Apple).

Backporting the `config.host` check and `t-darwin-rpath` from GCC 12
allows GCC 11 to build again on aarch64-darwin.
Diffstat (limited to 'pkgs/development/compilers/gcc')
-rw-r--r--pkgs/development/compilers/gcc/patches/11/libgcc-aarch64-darwin-detection.patch21
-rw-r--r--pkgs/development/compilers/gcc/patches/default.nix3
2 files changed, 24 insertions, 0 deletions
diff --git a/pkgs/development/compilers/gcc/patches/11/libgcc-aarch64-darwin-detection.patch b/pkgs/development/compilers/gcc/patches/11/libgcc-aarch64-darwin-detection.patch
new file mode 100644
index 000000000000..08dbfec6b249
--- /dev/null
+++ b/pkgs/development/compilers/gcc/patches/11/libgcc-aarch64-darwin-detection.patch
@@ -0,0 +1,21 @@
+diff -u a/libgcc/config.host b/libgcc/config.host
+--- a/libgcc/config.host	2023-11-05 11:01:55.778638446 -0500
++++ b/libgcc/config.host	2023-11-05 11:07:29.405103979 -0500
+@@ -227,7 +227,7 @@
+   tmake_file="$tmake_file t-slibgcc-darwin"
+   # newer toolsets produce warnings when building for unsupported versions.
+   case ${host} in
+-    *-*-darwin1[89]* | *-*-darwin2* )
++    *-*-darwin1[89]* | *-*-darwin2* | aarch64*-*-darwin*)
+       tmake_file="t-darwin-min-8 $tmake_file"
+       ;;
+     *-*-darwin9* | *-*-darwin1[0-7]*)
+diff -ur a/libgcc/config/t-darwin-rpath b/libgcc/config/t-darwin-rpath
+--- a/libgcc/config/t-darwin-rpath	2023-11-05 11:34:18.691150009 -0500
++++ b/libgcc/config/t-darwin-rpath	2023-11-05 11:50:36.968920904 -0500
+@@ -2,4 +2,4 @@
+ SHLIB_RPATH = @rpath
+
+ # Which does not work for Darwin < 9
+-HOST_LIBGCC2_CFLAGS += -mmacosx-version-min=10.5
++SHLIB_LOADER_PATH = -Wl,-rpath,@loader_path
diff --git a/pkgs/development/compilers/gcc/patches/default.nix b/pkgs/development/compilers/gcc/patches/default.nix
index 0afc6586511a..2052d0f674f2 100644
--- a/pkgs/development/compilers/gcc/patches/default.nix
+++ b/pkgs/development/compilers/gcc/patches/default.nix
@@ -178,6 +178,9 @@ in
 # https://github.com/osx-cross/homebrew-avr/issues/280#issuecomment-1272381808
 ++ optional (is11 && stdenv.isDarwin && targetPlatform.isAvr) ./avr-gcc-11.3-darwin.patch
 
+# libgcc’s `configure` script misdetects aarch64-darwin, resulting in an invalid deployment target.
+++ optional (is11 && stdenv.isDarwin && stdenv.isAarch64) ./11/libgcc-aarch64-darwin-detection.patch
+
 # openjdk build fails without this on -march=opteron; is upstream in gcc12
 ++ optionals (is11) [ ./11/gcc-issue-103910.patch ]