From 826edbf7190c7249394f9180652bc8969aa8198a Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sun, 29 Sep 2024 13:54:47 -0400 Subject: [PATCH] {bintools,cc}-wrapper: fix static builds on Darwin Without this change, all Darwin platforms mangle to the same suffix salt. That is normally not an issue because build = host should mean a non-cross build, but it causes issues on Darwin with static builds because `DEVELOPER_DIR_FOR_BUILD` and `DEVELOPER_DIR` will refer to different SDKs but mangle to the same `DEVELOPER_DIR` with suffix salt. The fix is to mangle static builds differently from non-static ones on Darwin, which allows building for a static Darwin target on a same-architecture Darwin host. This fix is applied only to Dariwn because the issue does not appear to affect other platforms. --- pkgs/build-support/bintools-wrapper/default.nix | 3 ++- pkgs/build-support/cc-wrapper/default.nix | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/bintools-wrapper/default.nix b/pkgs/build-support/bintools-wrapper/default.nix index 4a6457350102..868bc8cdae1f 100644 --- a/pkgs/build-support/bintools-wrapper/default.nix +++ b/pkgs/build-support/bintools-wrapper/default.nix @@ -108,7 +108,8 @@ let coreutils_bin = optionalString (!nativeTools) (getBin coreutils); # See description in cc-wrapper. - suffixSalt = replaceStrings ["-" "."] ["_" "_"] targetPlatform.config; + suffixSalt = replaceStrings ["-" "."] ["_" "_"] targetPlatform.config + + lib.optionalString (targetPlatform.isDarwin && targetPlatform.isStatic) "_static"; # The dynamic linker has different names on different platforms. This is a # shell glob that ought to match it. diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index ed55e37cb76a..34b23acc80e3 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -115,7 +115,8 @@ let # without interfering. For the moment, it is defined as the target triple, # adjusted to be a valid bash identifier. This should be considered an # unstable implementation detail, however. - suffixSalt = replaceStrings ["-" "."] ["_" "_"] targetPlatform.config; + suffixSalt = replaceStrings ["-" "."] ["_" "_"] targetPlatform.config + + lib.optionalString (targetPlatform.isDarwin && targetPlatform.isStatic) "_static"; useGccForLibs = useCcForLibs && libcxx == null