diff options
author | Sergey Kosukhin <sergey.kosukhin@mpimet.mpg.de> | 2022-05-04 19:13:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-04 10:13:12 -0700 |
commit | 8b0f6187e047532ed0c916b7493e3461032074e2 (patch) | |
tree | c5d267acdbfcdbbd86b7d3c3a1958d78544a31bc | |
parent | 8bf988abb9fc982875585277bb2336167a29e5b5 (diff) | |
download | spack-8b0f6187e047532ed0c916b7493e3461032074e2.tar.gz spack-8b0f6187e047532ed0c916b7493e3461032074e2.tar.bz2 spack-8b0f6187e047532ed0c916b7493e3461032074e2.tar.xz spack-8b0f6187e047532ed0c916b7493e3461032074e2.zip |
bugfix: fix filter_compiler_wrappers for Cray compiler (#29786)
-rw-r--r-- | lib/spack/spack/mixins.py | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/lib/spack/spack/mixins.py b/lib/spack/spack/mixins.py index ff99b181d6..b247c28d30 100644 --- a/lib/spack/spack/mixins.py +++ b/lib/spack/spack/mixins.py @@ -184,19 +184,38 @@ def filter_compiler_wrappers(*files, **kwargs): x = llnl.util.filesystem.FileFilter(*abs_files) - replacements = [ + compiler_vars = [ ('CC', self.compiler.cc), ('CXX', self.compiler.cxx), ('F77', self.compiler.f77), ('FC', self.compiler.fc) ] - for env_var, compiler_path in replacements: + + # Some paths to the compiler wrappers might be substrings of the others. + # For example: + # CC=/path/to/spack/lib/spack/env/cc (realpath to the wrapper) + # FC=/path/to/spack/lib/spack/env/cce/ftn + # Therefore, we perform the filtering in the reversed sorted order of + # the substituted strings. If, however, the strings are identical (e.g. + # both CC and FC are set using realpath), the filtering is done + # according to the order in compiler_vars. To achieve that, we populate + # the following array with tuples of three elements: path to the + # wrapper, negated index of the variable in compiler_vars, path to the + # real compiler. This way, the reversed sorted order of the resulting + # array is the order of replacements that we need. + replacements = [] + + for idx, (env_var, compiler_path) in enumerate(compiler_vars): if env_var in os.environ: # filter spack wrapper and links to spack wrapper in case # build system runs realpath wrapper = os.environ[env_var] for wrapper_path in (wrapper, os.path.realpath(wrapper)): - x.filter(wrapper_path, compiler_path, **filter_kwargs) + replacements.append((wrapper_path, -idx, compiler_path)) + + for wrapper_path, _, compiler_path in sorted(replacements, + reverse=True): + x.filter(wrapper_path, compiler_path, **filter_kwargs) # Remove this linking flag if present (it turns RPATH into RUNPATH) x.filter('{0}--enable-new-dtags'.format(self.compiler.linker_arg), '', |