Skip to content

Commit b09a788

Browse files
committed
Correct patch the rpath for GHC-built executables on Darwin
@peti This addresses #2488.
1 parent 458087d commit b09a788

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Diff for: pkgs/build-support/cabal/default.nix

+10
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ assert !enableStaticLibraries -> versionOlder "7.7" ghc.version;
197197
${optionalString (self.enableSharedExecutables && self.stdenv.isLinux) ''
198198
configureFlags+=" --ghc-option=-optl=-Wl,-rpath=$out/lib/${ghc.ghc.name}/${self.pname}-${self.version}";
199199
''}
200+
${optionalString (self.enableSharedExecutables && self.stdenv.isDarwin) ''
201+
configureFlags+=" --ghc-option=-optl=-Wl,-headerpad_max_install_names";
202+
''}
200203
201204
echo "configure flags: $extraConfigureFlags $configureFlags"
202205
./Setup configure --verbose --prefix="$out" --libdir='$prefix/lib/$compiler' \
@@ -256,6 +259,13 @@ assert !enableStaticLibraries -> versionOlder "7.7" ghc.version;
256259
ln -s $out/nix-support/propagated-native-build-inputs $out/nix-support/propagated-user-env-packages
257260
fi
258261
262+
${optionalString (self.enableSharedExecutables && self.isExecutable && self.stdenv.isDarwin) ''
263+
for exe in $out/bin/* ; do
264+
install_name_tool -add_rpath \
265+
$out/lib/${ghc.ghc.name}/${self.pname}-${self.version} $exe
266+
done
267+
''}
268+
259269
eval "$postInstall"
260270
'';
261271

0 commit comments

Comments
 (0)