about summary refs log tree commit diff
diff options
context:
space:
mode:
authorWeijia Wang <9713184+wegank@users.noreply.github.com>2024-04-06 01:48:48 +0200
committerGitHub <noreply@github.com>2024-04-06 01:48:48 +0200
commitd7d443c4ce766510ab94ba4f3e114ffa53075f03 (patch)
treee19749e38345d95b005b51e61b483a8c5e6b2189
parenta3402282c5d499c39ebc3be51bdd04494f57eebd (diff)
parent0e00487628f8fd59987659db671ffb7445eeb50d (diff)
Merge pull request #300894 from wegank/gnat13-fix
gnat13: fix build on x86_64-darwin
-rw-r--r--pkgs/development/ada-modules/gprbuild/default.nix4
-rw-r--r--pkgs/development/compilers/gcc/patches/default.nix5
-rw-r--r--pkgs/development/compilers/gcc/patches/gnat-darwin-dylib-install-name-13.patch18
3 files changed, 26 insertions, 1 deletions
diff --git a/pkgs/development/ada-modules/gprbuild/default.nix b/pkgs/development/ada-modules/gprbuild/default.nix
index fcb358d5fb5fd..4e25bc313a63d 100644
--- a/pkgs/development/ada-modules/gprbuild/default.nix
+++ b/pkgs/development/ada-modules/gprbuild/default.nix
@@ -41,6 +41,10 @@ stdenv.mkDerivation {
     "LIBRARY_TYPE=relocatable"
   ];
 
+  env = lib.optionalAttrs stdenv.isDarwin {
+    NIX_LDFLAGS = "-headerpad_max_install_names";
+  };
+
   # Fixes gprbuild being linked statically always. Based on the AUR's patch:
   # https://aur.archlinux.org/cgit/aur.git/plain/0001-Makefile-build-relocatable-instead-of-static-binary.patch?h=gprbuild&id=bac524c76cd59c68fb91ef4dfcbe427357b9f850
   patches = lib.optionals (!stdenv.hostPlatform.isStatic) [
diff --git a/pkgs/development/compilers/gcc/patches/default.nix b/pkgs/development/compilers/gcc/patches/default.nix
index 9cb2f701df577..8f0c8f6d288c8 100644
--- a/pkgs/development/compilers/gcc/patches/default.nix
+++ b/pkgs/development/compilers/gcc/patches/default.nix
@@ -128,7 +128,10 @@ in
 ++ optional (atLeast12 && stdenv.isDarwin && langAda) ./ada-cctools-as-detection-configure.patch
 
 # Use absolute path in GNAT dylib install names on Darwin
-++ optional (atLeast12 && stdenv.isDarwin && langAda) ./gnat-darwin-dylib-install-name.patch
+++ optionals (stdenv.isDarwin && langAda) ({
+  "13" = [ ./gnat-darwin-dylib-install-name-13.patch ];
+  "12" = [ ./gnat-darwin-dylib-install-name.patch ];
+}.${majorVersion} or [])
 
 # We only apply this patch when building a native toolchain for aarch64-darwin, as it breaks building
 # a foreign one: https://github.com/iains/gcc-12-branch/issues/18
diff --git a/pkgs/development/compilers/gcc/patches/gnat-darwin-dylib-install-name-13.patch b/pkgs/development/compilers/gcc/patches/gnat-darwin-dylib-install-name-13.patch
new file mode 100644
index 0000000000000..19c405d1226dc
--- /dev/null
+++ b/pkgs/development/compilers/gcc/patches/gnat-darwin-dylib-install-name-13.patch
@@ -0,0 +1,18 @@
+--- a/gcc/ada/gcc-interface/Makefile.in
++++ b/gcc/ada/gcc-interface/Makefile.in
+@@ -788,13 +788,13 @@ gnatlib-shared-darwin:
+ 		-o libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
+ 		$(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) \
+ 		$(SO_OPTS) \
+-		-Wl,-install_name,@rpath/libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
++		-Wl,-install_name,$(ADA_RTL_DSO_DIR)/libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
+ 		$(MISCLIB)
+ 	cd $(RTSDIR); $(GCC_FOR_ADA_RTS) -dynamiclib $(PICFLAG_FOR_TARGET) \
+ 		-o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
+ 		$(GNATRTL_TASKING_OBJS) \
+ 		$(SO_OPTS) \
+-		-Wl,-install_name,@rpath/libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
++		-Wl,-install_name,$(ADA_RTL_DSO_DIR)/libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
+ 		$(THREADSLIB) -Wl,libgnat$(hyphen)$(LIBRARY_VERSION)$(soext)
+ 	cd $(RTSDIR); $(LN_S) libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
+ 		libgnat$(soext)