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).
This commit is contained in:
parent
328a3f97fd
commit
9a85a7a5aa
2 changed files with 37 additions and 0 deletions
11
lib/spack/env/cc
vendored
11
lib/spack/env/cc
vendored
|
@ -382,6 +382,17 @@ case "$mode" in
|
||||||
flags=("${flags[@]}" "${SPACK_LDFLAGS[@]}") ;;
|
flags=("${flags[@]}" "${SPACK_LDFLAGS[@]}") ;;
|
||||||
esac
|
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
|
# Prepend include directories
|
||||||
IFS=':' read -ra include_dirs <<< "$SPACK_INCLUDE_DIRS"
|
IFS=':' read -ra include_dirs <<< "$SPACK_INCLUDE_DIRS"
|
||||||
if [[ $mode == cpp || $mode == cc || $mode == as || $mode == ccld ]]; then
|
if [[ $mode == cpp || $mode == cc || $mode == as || $mode == ccld ]]; then
|
||||||
|
|
|
@ -79,6 +79,9 @@
|
||||||
spack_ldflags = ['-L', 'foo']
|
spack_ldflags = ['-L', 'foo']
|
||||||
spack_ldlibs = ['-lfoo']
|
spack_ldlibs = ['-lfoo']
|
||||||
|
|
||||||
|
lheaderpad = ['-Wl,-headerpad_max_install_names']
|
||||||
|
headerpad = ['-headerpad_max_install_names']
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='session')
|
@pytest.fixture(scope='session')
|
||||||
def wrapper_environment():
|
def wrapper_environment():
|
||||||
|
@ -451,6 +454,7 @@ def test_ld_deps_partial():
|
||||||
check_args(
|
check_args(
|
||||||
ld, ['-r'] + test_args,
|
ld, ['-r'] + test_args,
|
||||||
['ld'] +
|
['ld'] +
|
||||||
|
headerpad +
|
||||||
test_include_paths +
|
test_include_paths +
|
||||||
test_library_paths +
|
test_library_paths +
|
||||||
['-Lxlib'] +
|
['-Lxlib'] +
|
||||||
|
@ -461,6 +465,7 @@ def test_ld_deps_partial():
|
||||||
|
|
||||||
def test_ccache_prepend_for_cc():
|
def test_ccache_prepend_for_cc():
|
||||||
with set_env(SPACK_CCACHE_BINARY='ccache'):
|
with set_env(SPACK_CCACHE_BINARY='ccache'):
|
||||||
|
os.environ['SPACK_SHORT_SPEC'] = "foo@1.2=linux-x86_64"
|
||||||
check_args(
|
check_args(
|
||||||
cc, test_args,
|
cc, test_args,
|
||||||
['ccache'] + # ccache prepended in cc mode
|
['ccache'] + # ccache prepended in cc mode
|
||||||
|
@ -469,9 +474,20 @@ def test_ccache_prepend_for_cc():
|
||||||
test_library_paths +
|
test_library_paths +
|
||||||
test_wl_rpaths +
|
test_wl_rpaths +
|
||||||
test_args_without_paths)
|
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():
|
def test_no_ccache_prepend_for_fc():
|
||||||
|
os.environ['SPACK_SHORT_SPEC'] = "foo@1.2=linux-x86_64"
|
||||||
check_args(
|
check_args(
|
||||||
fc, test_args,
|
fc, test_args,
|
||||||
# no ccache for Fortran
|
# no ccache for Fortran
|
||||||
|
@ -480,3 +496,13 @@ def test_no_ccache_prepend_for_fc():
|
||||||
test_library_paths +
|
test_library_paths +
|
||||||
test_wl_rpaths +
|
test_wl_rpaths +
|
||||||
test_args_without_paths)
|
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 +
|
||||||
|
test_args_without_paths)
|
||||||
|
|
Loading…
Reference in a new issue