haskell: workaround for bug with dynamic libraries on darwin
This commit is contained in:
parent
b87a59bc69
commit
19e2e7290a
@ -245,9 +245,41 @@ stdenv.mkDerivation ({
|
|||||||
runHook postConfigure
|
runHook postConfigure
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
# The darwin pre/post build sections are a workaround https://github.com/haskell/cabal/issues/4183
|
||||||
|
# It seems like --extra-lib-dirs from the previous steps is not detected properly,
|
||||||
|
# to work around this we build using a DYLD_LIBRARY_PATH and fixup the build afterwards.
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
runHook preBuild
|
runHook preBuild
|
||||||
|
${optionalString stdenv.isDarwin ''
|
||||||
|
local inputClosure=""
|
||||||
|
for i in $propagatedNativeBuildInputs $nativeBuildInputs; do
|
||||||
|
findInputs $i inputClosure propagated-native-build-inputs
|
||||||
|
done
|
||||||
|
local -a inputLibs=()
|
||||||
|
for p in $inputClosure; do
|
||||||
|
if [ -d "$p/lib/${ghc.name}/package.conf.d" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if [ -d "$p/lib" ]; then
|
||||||
|
inputLibs+="$p/lib"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
for lib in $inputLibs; do
|
||||||
|
export DYLD_LIBRARY_PATH="$lib:''${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}"
|
||||||
|
done
|
||||||
|
''}
|
||||||
${setupCommand} build ${buildTarget}${crossCabalFlagsString}
|
${setupCommand} build ${buildTarget}${crossCabalFlagsString}
|
||||||
|
${optionalString stdenv.isDarwin ''
|
||||||
|
unset DYLD_LIBRARY_PATH
|
||||||
|
|
||||||
|
local outputLib=dist/build/*-ghc${ghc.version}.dylib
|
||||||
|
for lib in $inputLib/*.dylib; do
|
||||||
|
for name in $(otool -L $outputLib | awk '$1 ~ /^'$(basename lib)'/ {print $1}' | cat); do
|
||||||
|
install_name_tool -change $name $lib $outputLib
|
||||||
|
done
|
||||||
|
done
|
||||||
|
''}
|
||||||
runHook postBuild
|
runHook postBuild
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user