Skip to content

Commit

Permalink
ld64: search standard library locations
Browse files Browse the repository at this point in the history
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 4340a5a.
  • Loading branch information
emilazy committed Oct 24, 2024
1 parent bf7b0b5 commit 3f0333e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 38 deletions.
10 changes: 0 additions & 10 deletions pkgs/build-support/bintools-wrapper/add-darwin-ldflags-before.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
# 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@}

# 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

This file was deleted.

2 changes: 0 additions & 2 deletions pkgs/by-name/ld/ld64/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ stdenv.mkDerivation (finalAttrs: {
./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.
./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 = ''
Expand Down
8 changes: 7 additions & 1 deletion pkgs/stdenv/darwin/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,15 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check

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 since‐removed patch.
# This can be dropped once the bootstrap tools cctools has been updated to 1010.6.
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-darwin-ldflags-before.sh
echo 'source ${selfDarwin.postLinkSignHook}' >> $out/nix-support/post-link-hook
export signingUtils=${selfDarwin.signingUtils}
Expand Down

0 comments on commit 3f0333e

Please sign in to comment.