ld64: search standard library locations

This is basically harmless for the same reason as it is for Clang, and
lets us avoid doing wrapper hacks to fix things like the .NET build.

This reverts commit 4340a5addb.
This commit is contained in:
Emily 2024-10-23 17:13:28 +01:00
parent 514b00cf08
commit b75c70282f
4 changed files with 12 additions and 38 deletions

View File

@ -85,13 +85,3 @@ mangleVarSingle DEVELOPER_DIR ${role_suffixes[@]+"${role_suffixes[@]}"}
# Allow wrapped bintools to do something useful when no `DEVELOPER_DIR` is set, which can happen when # Allow wrapped bintools to do something useful when no `DEVELOPER_DIR` is set, which can happen when
# the compiler is run outside of a stdenv or intentionally in an environment with no environment variables set. # the compiler is run outside of a stdenv or intentionally in an environment with no environment variables set.
DEVELOPER_DIR=${DEVELOPER_DIR_@suffixSalt@:-@fallback_sdk@} DEVELOPER_DIR=${DEVELOPER_DIR_@suffixSalt@:-@fallback_sdk@}
# Darwin looks for frameworks in the SDK located at `DEVELOPER_DIR`.
extraBefore+=("-F$DEVELOPER_DIR/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks")
extraBefore+=("-L$DEVELOPER_DIR/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib")
# While the Swift wrapper should take care of this, anything that needs to link Swift auto-linked frameworks
# also needs these paths. Note: Test and conditionally add it because the path may not exist in older SDKs.
if [ -d "$DEVELOPER_DIR/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/swift" ]; then
extraBefore+=("-L$DEVELOPER_DIR/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/swift")
fi

View File

@ -1,25 +0,0 @@
From 3e80d438e2a3ec50d666f2b6e32007c275d4a08a Mon Sep 17 00:00:00 2001
From: Randy Eckenrode <randy@largeandhighquality.com>
Date: Thu, 11 Apr 2024 23:13:29 -0400
Subject: [PATCH 8/8] Disable searching in standard library locations
---
src/ld/Options.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/ld/Options.cpp b/src/ld/Options.cpp
index 67a9f53..611b583 100644
--- a/src/ld/Options.cpp
+++ b/src/ld/Options.cpp
@@ -4320,7 +4320,7 @@ bool Options::shouldUseBuildVersion(ld::Platform plat, uint32_t minOSvers) const
void Options::buildSearchPaths(int argc, const char* argv[])
{
- bool addStandardLibraryDirectories = true;
+ bool addStandardLibraryDirectories = false;
ld::Platform platform = ld::Platform::unknown;
std::vector<const char*> libraryPaths;
std::vector<const char*> frameworkPaths;
--
2.45.1

View File

@ -128,8 +128,6 @@ stdenv.mkDerivation (finalAttrs: {
./0006-Add-libcd_is_blob_a_linker_signature-implementation.patch ./0006-Add-libcd_is_blob_a_linker_signature-implementation.patch
# Add OpenSSL implementation of CoreCrypto digest functions. Avoids use of private and non-free APIs. # Add OpenSSL implementation of CoreCrypto digest functions. Avoids use of private and non-free APIs.
./0007-Add-OpenSSL-based-CoreCrypto-digest-functions.patch ./0007-Add-OpenSSL-based-CoreCrypto-digest-functions.patch
# ld64 will search `/usr/lib`, `/Library/Frameworks`, etc by default. Disable that.
./0008-Disable-searching-in-standard-library-locations.patch
]; ];
postPatch = '' postPatch = ''

View File

@ -449,9 +449,15 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
bintools = selfDarwin.binutils-unwrapped; bintools = selfDarwin.binutils-unwrapped;
# Bootstrap tools cctools needs the hook and wrappers to make sure things are signed properly. # Bootstrap tools cctools needs the hook and wrappers to make sure things are signed properly,
# and additional linker flags to work around a sinceremoved patch.
# This can be dropped once the bootstrap tools cctools has been updated to 1010.6. # This can be dropped once the bootstrap tools cctools has been updated to 1010.6.
extraBuildCommands = '' extraBuildCommands = ''
printf %s ${lib.escapeShellArg ''
extraBefore+=("-F$DEVELOPER_DIR/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks")
extraBefore+=("-L$DEVELOPER_DIR/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib")
''} >> $out/nix-support/add-local-ldflags-before.sh
echo 'source ${selfDarwin.postLinkSignHook}' >> $out/nix-support/post-link-hook echo 'source ${selfDarwin.postLinkSignHook}' >> $out/nix-support/post-link-hook
export signingUtils=${selfDarwin.signingUtils} export signingUtils=${selfDarwin.signingUtils}
@ -694,6 +700,11 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
# Bootstrap tools cctools needs the hook and wrappers to make sure things are signed properly. # Bootstrap tools cctools needs the hook and wrappers to make sure things are signed properly.
# This can be dropped once the bootstrap tools cctools has been updated to 1010.6. # This can be dropped once the bootstrap tools cctools has been updated to 1010.6.
extraBuildCommands = '' extraBuildCommands = ''
printf %s ${lib.escapeShellArg ''
extraBefore+=("-F$DEVELOPER_DIR/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks")
extraBefore+=("-L$DEVELOPER_DIR/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib")
''} >> $out/nix-support/add-local-ldflags-before.sh
echo 'source ${selfDarwin.postLinkSignHook}' >> $out/nix-support/post-link-hook echo 'source ${selfDarwin.postLinkSignHook}' >> $out/nix-support/post-link-hook
export signingUtils=${selfDarwin.signingUtils} export signingUtils=${selfDarwin.signingUtils}