summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <gamblin2@llnl.gov>2021-03-31 14:47:38 -0700
committerGitHub <noreply@github.com>2021-03-31 21:47:38 +0000
commitcf9adfd748b2171a10e2dea5ff87cab2dcd6b28a (patch)
tree16e00cc4becf6fe15170c05d12bd1cf20437d779 /lib
parenta1d9a56a43fa59d5e3609047bf2037a92006dc4f (diff)
downloadspack-cf9adfd748b2171a10e2dea5ff87cab2dcd6b28a.tar.gz
spack-cf9adfd748b2171a10e2dea5ff87cab2dcd6b28a.tar.bz2
spack-cf9adfd748b2171a10e2dea5ff87cab2dcd6b28a.tar.xz
spack-cf9adfd748b2171a10e2dea5ff87cab2dcd6b28a.zip
hotfix: make ifx work with autoconf <= 2.69 in Spack (#22683)
Autoconf before 2.70 will erroneously pass ifx's -loopopt argument to the linker, requiring all packages to use autoconf 2.70 or newer to use ifx. This is a hotfix enabling ifx to be used in Spack. Instead of bothering to upgrade autoconf for every package, we'll just strip out the problematic flag if we're in `ld` mode. - [x] Add a conditional to the `cc` wrapper to skip `-loopopt` in `ld` mode. This can probably be generalized in the future to strip more things (e.g., via an environment variable we can constrol from Spack) but it's good enough for now. - [x] Add a test ensuring that `-loopopt` arguments are stripped in link mode, but not in compile mode.
Diffstat (limited to 'lib')
-rwxr-xr-xlib/spack/env/cc8
-rw-r--r--lib/spack/spack/test/cc.py14
2 files changed, 22 insertions, 0 deletions
diff --git a/lib/spack/env/cc b/lib/spack/env/cc
index 5dd315c225..752bcde54a 100755
--- a/lib/spack/env/cc
+++ b/lib/spack/env/cc
@@ -311,6 +311,14 @@ while [ -n "$1" ]; do
fi
;;
-l*)
+ # -loopopt=0 is passed to the linker erroneously in
+ # autoconf <= 2.69. Filter it out.
+ # TODO: generalize filtering of args with an env var, so that
+ # TODO: we do not have to special case this here.
+ if [ "$mode" = "ld" ] && [ "$1" != "${1#-loopopt}" ]; then
+ shift
+ continue
+ fi
arg="${1#-l}"
if [ -z "$arg" ]; then shift; arg="$1"; fi
other_args+=("-l$arg")
diff --git a/lib/spack/spack/test/cc.py b/lib/spack/spack/test/cc.py
index 59b2f8e4cb..fa61a5e9e6 100644
--- a/lib/spack/spack/test/cc.py
+++ b/lib/spack/spack/test/cc.py
@@ -622,3 +622,17 @@ def test_filter_enable_new_dtags(wrapper_flags):
result = cc(*(test_args + ['-Wl,--enable-new-dtags']), output=str)
result = result.strip().split('\n')
assert '-Wl,--enable-new-dtags' not in result
+
+
+@pytest.mark.regression('22643')
+def test_linker_strips_loopopt(wrapper_flags):
+ with set_env(SPACK_TEST_COMMAND='dump-args'):
+ # ensure that -loopopt=0 is not present in ld mode
+ result = ld(*(test_args + ["-loopopt=0"]), output=str)
+ result = result.strip().split('\n')
+ assert '-loopopt=0' not in result
+
+ # ensure that -loopopt=0 is present in compile mode
+ result = cc(*(test_args + ["-loopopt=0"]), output=str)
+ result = result.strip().split('\n')
+ assert '-loopopt=0' in result