diff options
-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 + |