ldflags=* are compiler flags, not linker flags (#43820)
We run `extend spack_flags_list SPACK_LDFLAGS` for `$mode in ld|ccld`. That's problematic, cause `ccld` needs `-Wl,--flag` whereas `ld` needs `--flag` directly. Only `-L` and `-l` are common to compiler & linker. In all build systems `LDFLAGS` is for the compiler not the linker, cause any linker flag `-x` can be passed as a compiler flag `-Wl,-x`, and there are many compiler flags that affect the linker invocation, like `-fopenmp`, `-fuse-ld=`, `-fsanitize=` etc. So don't pass `LDFLAGS` to the linker directly. This way users can set `ldflags: -Wl,--allow-shlib-undefined` in compilers.yaml to work around an issue where the linker tries to resolve the `libcuda.so.1` stub lib which cannot be located by design in `cuda`.
This commit is contained in:
parent
47a9f0bdf7
commit
d946c37cbb
2 changed files with 8 additions and 6 deletions
2
lib/spack/env/cc
vendored
2
lib/spack/env/cc
vendored
|
@ -755,7 +755,7 @@ esac
|
||||||
|
|
||||||
# Linker flags
|
# Linker flags
|
||||||
case "$mode" in
|
case "$mode" in
|
||||||
ld|ccld)
|
ccld)
|
||||||
extend spack_flags_list SPACK_LDFLAGS
|
extend spack_flags_list SPACK_LDFLAGS
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -127,7 +127,7 @@
|
||||||
spack_cflags = ["-Wall"]
|
spack_cflags = ["-Wall"]
|
||||||
spack_cxxflags = ["-Werror"]
|
spack_cxxflags = ["-Werror"]
|
||||||
spack_fflags = ["-w"]
|
spack_fflags = ["-w"]
|
||||||
spack_ldflags = ["-L", "foo"]
|
spack_ldflags = ["-Wl,--gc-sections", "-L", "foo"]
|
||||||
spack_ldlibs = ["-lfoo"]
|
spack_ldlibs = ["-lfoo"]
|
||||||
|
|
||||||
lheaderpad = ["-Wl,-headerpad_max_install_names"]
|
lheaderpad = ["-Wl,-headerpad_max_install_names"]
|
||||||
|
@ -279,7 +279,6 @@ def test_ld_flags(wrapper_environment, wrapper_flags):
|
||||||
test_args,
|
test_args,
|
||||||
["ld"]
|
["ld"]
|
||||||
+ test_include_paths
|
+ test_include_paths
|
||||||
+ [spack_ldflags[i] + spack_ldflags[i + 1] for i in range(0, len(spack_ldflags), 2)]
|
|
||||||
+ test_library_paths
|
+ test_library_paths
|
||||||
+ ["--disable-new-dtags"]
|
+ ["--disable-new-dtags"]
|
||||||
+ test_rpaths
|
+ test_rpaths
|
||||||
|
@ -307,13 +306,14 @@ def test_cc_flags(wrapper_environment, wrapper_flags):
|
||||||
[real_cc]
|
[real_cc]
|
||||||
+ target_args
|
+ target_args
|
||||||
+ test_include_paths
|
+ test_include_paths
|
||||||
+ [spack_ldflags[i] + spack_ldflags[i + 1] for i in range(0, len(spack_ldflags), 2)]
|
+ ["-Lfoo"]
|
||||||
+ test_library_paths
|
+ test_library_paths
|
||||||
+ ["-Wl,--disable-new-dtags"]
|
+ ["-Wl,--disable-new-dtags"]
|
||||||
+ test_wl_rpaths
|
+ test_wl_rpaths
|
||||||
+ test_args_without_paths
|
+ test_args_without_paths
|
||||||
+ spack_cppflags
|
+ spack_cppflags
|
||||||
+ spack_cflags
|
+ spack_cflags
|
||||||
|
+ ["-Wl,--gc-sections"]
|
||||||
+ spack_ldlibs,
|
+ spack_ldlibs,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -325,12 +325,13 @@ def test_cxx_flags(wrapper_environment, wrapper_flags):
|
||||||
[real_cc]
|
[real_cc]
|
||||||
+ target_args
|
+ target_args
|
||||||
+ test_include_paths
|
+ test_include_paths
|
||||||
+ [spack_ldflags[i] + spack_ldflags[i + 1] for i in range(0, len(spack_ldflags), 2)]
|
+ ["-Lfoo"]
|
||||||
+ test_library_paths
|
+ test_library_paths
|
||||||
+ ["-Wl,--disable-new-dtags"]
|
+ ["-Wl,--disable-new-dtags"]
|
||||||
+ test_wl_rpaths
|
+ test_wl_rpaths
|
||||||
+ test_args_without_paths
|
+ test_args_without_paths
|
||||||
+ spack_cppflags
|
+ spack_cppflags
|
||||||
|
+ ["-Wl,--gc-sections"]
|
||||||
+ spack_ldlibs,
|
+ spack_ldlibs,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -342,13 +343,14 @@ def test_fc_flags(wrapper_environment, wrapper_flags):
|
||||||
[real_cc]
|
[real_cc]
|
||||||
+ target_args
|
+ target_args
|
||||||
+ test_include_paths
|
+ test_include_paths
|
||||||
+ [spack_ldflags[i] + spack_ldflags[i + 1] for i in range(0, len(spack_ldflags), 2)]
|
+ ["-Lfoo"]
|
||||||
+ test_library_paths
|
+ test_library_paths
|
||||||
+ ["-Wl,--disable-new-dtags"]
|
+ ["-Wl,--disable-new-dtags"]
|
||||||
+ test_wl_rpaths
|
+ test_wl_rpaths
|
||||||
+ test_args_without_paths
|
+ test_args_without_paths
|
||||||
+ spack_fflags
|
+ spack_fflags
|
||||||
+ spack_cppflags
|
+ spack_cppflags
|
||||||
|
+ ["-Wl,--gc-sections"]
|
||||||
+ spack_ldlibs,
|
+ spack_ldlibs,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue