diff options
author | Patrick Gartung <gartung@fnal.gov> | 2019-05-03 16:41:57 -0500 |
---|---|---|
committer | Peter Scheibel <scheibel1@llnl.gov> | 2019-05-04 06:41:57 +0900 |
commit | 9a85a7a5aa9ce28d744fc5718470bc4e17dc7216 (patch) | |
tree | aa70e497d030d0baf7abf5fbc0d160830c58e337 | |
parent | 328a3f97fd164ae4d33cc47d7f84a0b57e77d625 (diff) | |
download | spack-9a85a7a5aa9ce28d744fc5718470bc4e17dc7216.tar.gz spack-9a85a7a5aa9ce28d744fc5718470bc4e17dc7216.tar.bz2 spack-9a85a7a5aa9ce28d744fc5718470bc4e17dc7216.tar.xz spack-9a85a7a5aa9ce28d744fc5718470bc4e17dc7216.zip |
Binary caches on MacOS - allow expanded RPATHs (#11345)
Fixes #11335
Update the Spack compiler wrappers to add the headerpad_max_install_names
linker flag on MacOS. This allows the install_name_tool to rewrite
the RPATH entry of the binary to be longer if needed. This is
primarily useful for creating and distributing binary caches of
packages (i.e. using the "spack buildcache" command); binary caches
created on MacOS before this commit may not successfully relocate
(if the target root path is larger).
-rwxr-xr-x | lib/spack/env/cc | 11 | ||||
-rw-r--r-- | lib/spack/spack/test/cc.py | 26 |
2 files changed, 37 insertions, 0 deletions
diff --git a/lib/spack/env/cc b/lib/spack/env/cc index 199ce1d7e6..738a7e37af 100755 --- a/lib/spack/env/cc +++ b/lib/spack/env/cc @@ -382,6 +382,17 @@ case "$mode" in flags=("${flags[@]}" "${SPACK_LDFLAGS[@]}") ;; esac +# On macOS insert headerpad_max_install_names linker flag +if [[ ($mode == ld || $mode == ccld) && "$SPACK_SHORT_SPEC" =~ "darwin" ]]; +then + case "$mode" in + ld) + flags=("${flags[@]}" -headerpad_max_install_names) ;; + ccld) + flags=("${flags[@]}" -Wl,-headerpad_max_install_names) ;; + esac +fi + # Prepend include directories IFS=':' read -ra include_dirs <<< "$SPACK_INCLUDE_DIRS" if [[ $mode == cpp || $mode == cc || $mode == as || $mode == ccld ]]; then diff --git a/lib/spack/spack/test/cc.py b/lib/spack/spack/test/cc.py index 2a4d7ec3a8..3e8d5d8c70 100644 --- a/lib/spack/spack/test/cc.py +++ b/lib/spack/spack/test/cc.py @@ -79,6 +79,9 @@ spack_fflags = ['-w'] spack_ldflags = ['-L', 'foo'] spack_ldlibs = ['-lfoo'] +lheaderpad = ['-Wl,-headerpad_max_install_names'] +headerpad = ['-headerpad_max_install_names'] + @pytest.fixture(scope='session') def wrapper_environment(): @@ -451,6 +454,7 @@ def test_ld_deps_partial(): check_args( ld, ['-r'] + test_args, ['ld'] + + headerpad + test_include_paths + test_library_paths + ['-Lxlib'] + @@ -461,6 +465,7 @@ def test_ld_deps_partial(): def test_ccache_prepend_for_cc(): with set_env(SPACK_CCACHE_BINARY='ccache'): + os.environ['SPACK_SHORT_SPEC'] = "foo@1.2=linux-x86_64" check_args( cc, test_args, ['ccache'] + # ccache prepended in cc mode @@ -469,13 +474,34 @@ def test_ccache_prepend_for_cc(): test_library_paths + test_wl_rpaths + test_args_without_paths) + os.environ['SPACK_SHORT_SPEC'] = "foo@1.2=darwin-x86_64" + check_args( + cc, test_args, + ['ccache'] + # ccache prepended in cc mode + [real_cc] + + lheaderpad + + test_include_paths + + test_library_paths + + test_wl_rpaths + + test_args_without_paths) def test_no_ccache_prepend_for_fc(): + os.environ['SPACK_SHORT_SPEC'] = "foo@1.2=linux-x86_64" + check_args( + fc, test_args, + # no ccache for Fortran + [real_cc] + + test_include_paths + + test_library_paths + + test_wl_rpaths + + test_args_without_paths) + os.environ['SPACK_SHORT_SPEC'] = "foo@1.2=darwin-x86_64" check_args( fc, test_args, # no ccache for Fortran [real_cc] + + lheaderpad + test_include_paths + test_library_paths + test_wl_rpaths + |