diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2020-04-16 10:45:01 -0700 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2020-04-16 17:23:33 -0700 |
commit | f6d26db93949503c5ade08705b015766dc4d9f75 (patch) | |
tree | e071033d02f542ee1e3b2d38a0e9d2732667fd47 /share | |
parent | 1f5ef5c8769bd257c73592744f0a305023f142e7 (diff) | |
download | spack-f6d26db93949503c5ade08705b015766dc4d9f75.tar.gz spack-f6d26db93949503c5ade08705b015766dc4d9f75.tar.bz2 spack-f6d26db93949503c5ade08705b015766dc4d9f75.tar.xz spack-f6d26db93949503c5ade08705b015766dc4d9f75.zip |
macos: use DYLD_FALLBACK_LIBRARY_PATH instead of DYLD_LIBRARY_PATH
`DYLD_LIBRARY_PATH` can frequently break builtin macOS software when
pointed at Spack libraries. This is because it takes *higher* precedence
than the default library search paths, which are used by system software.
`DYLD_FALLBACK_LIBRARY_PATH`, on the other hand, takes lower precedence.
At first glance, this might seem bad, because the software installed by
Spack in an environment needs to find *its* libraries, and it should not
use the defaults. However, Spack's isntallations are always `RPATH`'d,
so they do not have this problem.
`DYLD_FALLBACK_LIBRARY_PATH` is thus useful for things built in an
environment that need to use Spack's libraries, that don't set *their*
RPATHs correctly for whatever reason. We now prefer it to
`DYLD_LIBRARY_PATH` in modules and in environments because it helps a
little bit, and it is much less intrusive.
Diffstat (limited to 'share')
-rw-r--r-- | share/spack/csh/spack.csh | 5 | ||||
-rwxr-xr-x | share/spack/setup-env.sh | 11 |
2 files changed, 8 insertions, 8 deletions
diff --git a/share/spack/csh/spack.csh b/share/spack/csh/spack.csh index 7a51050281..0df547fab6 100644 --- a/share/spack/csh/spack.csh +++ b/share/spack/csh/spack.csh @@ -29,13 +29,16 @@ ######################################################################## # Store LD_LIBRARY_PATH variables from spack shell function # This is necessary because MacOS System Integrity Protection clears -# (DY?)LD_LIBRARY_PATH variables on process start. +# variables that affect dyld on process start. if ( ${?LD_LIBRARY_PATH} ) then setenv SPACK_LD_LIBRARY_PATH $LD_LIBRARY_PATH endif if ( ${?DYLD_LIBRARY_PATH} ) then setenv SPACK_DYLD_LIBRARY_PATH $DYLD_LIBRARY_PATH endif +if ( ${?DYLD_FALLBACK_LIBRARY_PATH} ) then + setenv SPACK_DYLD_FALLBACK_LIBRARY_PATH $DYLD_FALLBACK_LIBRARY_PATH +endif # accumulate initial flags for main spack command set _sp_flags = "" diff --git a/share/spack/setup-env.sh b/share/spack/setup-env.sh index 5968c4c016..d3aed61d1a 100755 --- a/share/spack/setup-env.sh +++ b/share/spack/setup-env.sh @@ -42,13 +42,10 @@ spack() { # Store LD_LIBRARY_PATH variables from spack shell function # This is necessary because MacOS System Integrity Protection clears - # (DY?)LD_LIBRARY_PATH variables on process start. - if [ -n "${LD_LIBRARY_PATH-}" ]; then - export SPACK_LD_LIBRARY_PATH=$LD_LIBRARY_PATH - fi - if [ -n "${DYLD_LIBRARY_PATH-}" ]; then - export SPACK_DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH - fi + # variables that affect dyld on process start. + for var in LD_LIBRARY_PATH DYLD_LIBRARY_PATH DYLD_FALLBACK_LIBRARY_PATH; do + eval "if [ -n \"\${${var}-}\" ]; then export SPACK_$var=\${${var}}; fi" + done # Zsh does not do word splitting by default, this enables it for this # function only |