summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHarmen Stoppels <harmenstoppels@gmail.com>2023-05-05 12:16:31 +0200
committerGitHub <noreply@github.com>2023-05-05 12:16:31 +0200
commitbbc779f3f0d8b4462b3dd3d205dca809ecdf4441 (patch)
treeb9e5cb7ecbfaeab85963a61520652aed4300e429 /lib
parent3ecb84d398611749ded7376e9e9e2a786d528bad (diff)
downloadspack-bbc779f3f0d8b4462b3dd3d205dca809ecdf4441.tar.gz
spack-bbc779f3f0d8b4462b3dd3d205dca809ecdf4441.tar.bz2
spack-bbc779f3f0d8b4462b3dd3d205dca809ecdf4441.tar.xz
spack-bbc779f3f0d8b4462b3dd3d205dca809ecdf4441.zip
cc: deal with -Wl,-rpath= without value, deal with NAG (#37215)
Spack never parsed `nagfor` linker arguments put on the compiler line: ``` nagfor -Wl,-Wl,,-rpath,,/path ```` so, let's continue not attempting to parse that.
Diffstat (limited to 'lib')
-rwxr-xr-xlib/spack/env/cc19
-rw-r--r--lib/spack/spack/test/cc.py18
2 files changed, 32 insertions, 5 deletions
diff --git a/lib/spack/env/cc b/lib/spack/env/cc
index eee39e7f35..a647602cad 100755
--- a/lib/spack/env/cc
+++ b/lib/spack/env/cc
@@ -434,8 +434,6 @@ wl_expect_rpath=no
xlinker_expect_rpath=no
parse_Wl() {
- # drop -Wl
- shift
while [ $# -ne 0 ]; do
if [ "$wl_expect_rpath" = yes ]; then
if system_dir "$1"; then
@@ -448,7 +446,9 @@ parse_Wl() {
case "$1" in
-rpath=*)
arg="${1#-rpath=}"
- if system_dir "$arg"; then
+ if [ -z "$arg" ]; then
+ shift; continue
+ elif system_dir "$arg"; then
append system_rpath_dirs_list "$arg"
else
append rpath_dirs_list "$arg"
@@ -456,7 +456,9 @@ parse_Wl() {
;;
--rpath=*)
arg="${1#--rpath=}"
- if system_dir "$arg"; then
+ if [ -z "$arg" ]; then
+ shift; continue
+ elif system_dir "$arg"; then
append system_rpath_dirs_list "$arg"
else
append rpath_dirs_list "$arg"
@@ -467,6 +469,11 @@ parse_Wl() {
;;
"$dtags_to_strip")
;;
+ -Wl)
+ # Nested -Wl,-Wl means we're in NAG compiler territory, we don't support
+ # it.
+ return 1
+ ;;
*)
append other_args_list "-Wl,$1"
;;
@@ -576,7 +583,9 @@ while [ $# -ne 0 ]; do
;;
-Wl,*)
IFS=,
- parse_Wl $1
+ if ! parse_Wl ${1#-Wl,}; then
+ append other_args_list "$1"
+ fi
unset IFS
;;
-Xlinker)
diff --git a/lib/spack/spack/test/cc.py b/lib/spack/spack/test/cc.py
index 0df374866f..7dc02d01f9 100644
--- a/lib/spack/spack/test/cc.py
+++ b/lib/spack/spack/test/cc.py
@@ -352,6 +352,24 @@ def test_Wl_parsing(wrapper_environment):
)
+@pytest.mark.regression("37179")
+def test_Wl_parsing_with_missing_value(wrapper_environment):
+ check_args(
+ cc,
+ ["-Wl,-rpath=/a,-rpath=", "-Wl,--rpath="],
+ [real_cc] + target_args + ["-Wl,--disable-new-dtags", "-Wl,-rpath,/a"],
+ )
+
+
+@pytest.mark.regression("37179")
+def test_Wl_parsing_NAG_is_ignored(wrapper_environment):
+ check_args(
+ fc,
+ ["-Wl,-Wl,,x,,y,,z"],
+ [real_cc] + target_args + ["-Wl,--disable-new-dtags", "-Wl,-Wl,,x,,y,,z"],
+ )
+
+
def test_Xlinker_parsing(wrapper_environment):
# -Xlinker <x> ... -Xlinker <y> may have compiler flags inbetween, like -O3 in this
# example. Also check that a trailing -Xlinker (which is a compiler error) is not