From 33c0dd692b0cbc47e6edb4e5c158378fe4962769 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Thu, 4 Jul 2024 12:27:50 -0400 Subject: [PATCH] binutils: fix build on Darwin - Update Darwin version check patch; and - Use CoreServices when building on Darwin. --- ...update-macos-version-detection-block.patch | 51 +++++-------------- .../tools/misc/binutils/default.nix | 7 ++- pkgs/top-level/all-packages.nix | 2 + 3 files changed, 22 insertions(+), 38 deletions(-) diff --git a/pkgs/development/tools/misc/binutils/0001-libtool.m4-update-macos-version-detection-block.patch b/pkgs/development/tools/misc/binutils/0001-libtool.m4-update-macos-version-detection-block.patch index e601be3a3308..f487ed708333 100644 --- a/pkgs/development/tools/misc/binutils/0001-libtool.m4-update-macos-version-detection-block.patch +++ b/pkgs/development/tools/misc/binutils/0001-libtool.m4-update-macos-version-detection-block.patch @@ -1,47 +1,24 @@ -From 33a8dc728eb5da3e1d3439c96810d1f6b2660b89 Mon Sep 17 00:00:00 2001 -From: Andrew Childs -Date: Tue, 22 Feb 2022 12:24:46 +0900 +From 368f26bfece3899a8c992cfec66427266918ab80 Mon Sep 17 00:00:00 2001 +From: Randy Eckenrode +Date: Thu, 4 Jul 2024 12:20:34 -0400 Subject: [PATCH] libtool.m4: update macos version detection block -Includes upstream change -9e8c882517082fe5755f2524d23efb02f1522490 --- - libtool.m4 | 21 ++++++++------------- - 1 file changed, 8 insertions(+), 13 deletions(-) + libtool.m4 | 1 + + 1 file changed, 1 insertion(+) diff --git a/libtool.m4 b/libtool.m4 -index 7a711249304..f452efb4300 100644 +index e36fdd3c0e2..dd4725f8cd1 100644 --- a/libtool.m4 +++ b/libtool.m4 -@@ -996,20 +996,15 @@ _LT_EOF - ]) - case $host_os in - rhapsody* | darwin1.[[012]]) -- _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; -+ _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;; - darwin1.*) -- _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; -- darwin*) # darwin 5.x on -- # if running on 10.5 or later, the deployment target defaults -- # to the OS version, if on x86, and 10.4, the deployment -- # target defaults to 10.4. Don't you love it? -- case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in -- 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) -- _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; -- 10.[[012]][[,.]]*) -- _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; -- 10.*) -- _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; -+ _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; -+ darwin*) -+ case $MACOSX_DEPLOYMENT_TARGET,$host in -+ 10.[[012]],*|,*powerpc*-darwin[[5-8]]*) -+ _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; -+ *) -+ _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; - esac +@@ -1011,6 +1011,7 @@ _LT_EOF + _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + ;; + *) ++ _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}dynamic_lookup' + ;; + esac ;; - esac -- -2.34.1 +2.45.1 diff --git a/pkgs/development/tools/misc/binutils/default.nix b/pkgs/development/tools/misc/binutils/default.nix index afee755e43f4..63b3f70e3970 100644 --- a/pkgs/development/tools/misc/binutils/default.nix +++ b/pkgs/development/tools/misc/binutils/default.nix @@ -16,6 +16,7 @@ in , perl , substitute , zlib +, CoreServices , enableGold ? withGold stdenv.targetPlatform , enableGoldDefault ? false @@ -87,6 +88,10 @@ stdenv.mkDerivation (finalAttrs: { # not need to know binutils' BINDIR at all. It's an absolute path # where libraries are stored. ./plugins-no-BINDIR.patch + + # ld64 needs `-undefined dynamic_lookup` to link `libctf-nobfd.dylib`, but the Darwin + # version detection in `libtool.m4` fails to detect the Darwin version correctly. + ./0001-libtool.m4-update-macos-version-detection-block.patch ] ++ lib.optional targetPlatform.isiOS ./support-ios.patch # Adds AVR-specific options to "size" for compatibility with Atmel's downstream distribution @@ -120,7 +125,7 @@ stdenv.mkDerivation (finalAttrs: { ++ lib.optionals targetPlatform.isVc4 [ flex ] ; - buildInputs = [ zlib gettext ]; + buildInputs = [ zlib gettext ] ++ lib.optionals buildPlatform.isDarwin [ CoreServices ]; inherit noSysDirs; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 69de54109269..bef7528f0b40 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -17968,11 +17968,13 @@ with pkgs; binutils-unwrapped = callPackage ../development/tools/misc/binutils { autoreconfHook = autoreconfHook269; + inherit (darwin.apple_sdk.frameworks) CoreServices; # FHS sys dirs presumably only have stuff for the build platform noSysDirs = (stdenv.targetPlatform != stdenv.hostPlatform) || noSysDirs; }; binutils-unwrapped-all-targets = callPackage ../development/tools/misc/binutils { autoreconfHook = if targetPlatform.isiOS then autoreconfHook269 else autoreconfHook; + inherit (darwin.apple_sdk.frameworks) CoreServices; # FHS sys dirs presumably only have stuff for the build platform noSysDirs = (stdenv.targetPlatform != stdenv.hostPlatform) || noSysDirs; withAllTargets = true;