diff options
author | Kyle Gerheiser <3209794+kgerheiser@users.noreply.github.com> | 2022-06-17 16:01:49 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-17 14:01:49 -0600 |
commit | 043b2cbb7c99d69a373f3ecbf35bc3b4638bcf85 (patch) | |
tree | 7ef670ff1e87f01252fd59929bfa4f09c2111869 /var | |
parent | aedf215b9091eefdc27052ad48f03fbede25bfbb (diff) | |
download | spack-043b2cbb7c99d69a373f3ecbf35bc3b4638bcf85.tar.gz spack-043b2cbb7c99d69a373f3ecbf35bc3b4638bcf85.tar.bz2 spack-043b2cbb7c99d69a373f3ecbf35bc3b4638bcf85.tar.xz spack-043b2cbb7c99d69a373f3ecbf35bc3b4638bcf85.zip |
Fix external compiler detection for MPICH and OpenMPI (#30875)
os.path.dirname was being used to compare compilers. If two compilers
are in the same directory then it will pick up the first one it encounters.
Compare the full compiler path instead.
Diffstat (limited to 'var')
-rw-r--r-- | var/spack/repos/builtin/packages/mpich/package.py | 17 | ||||
-rw-r--r-- | var/spack/repos/builtin/packages/openmpi/package.py | 12 |
2 files changed, 15 insertions, 14 deletions
diff --git a/var/spack/repos/builtin/packages/mpich/package.py b/var/spack/repos/builtin/packages/mpich/package.py index 2b8f9a435d..a66023734a 100644 --- a/var/spack/repos/builtin/packages/mpich/package.py +++ b/var/spack/repos/builtin/packages/mpich/package.py @@ -239,13 +239,13 @@ with '-Wl,-commons,use_dylibs' and without @classmethod def determine_variants(cls, exes, version): - def get_spack_compiler_spec(path): - spack_compilers = spack.compilers.find_compilers([path]) + def get_spack_compiler_spec(compiler): + spack_compilers = spack.compilers.find_compilers( + [os.path.dirname(compiler)]) actual_compiler = None # check if the compiler actually matches the one we want for spack_compiler in spack_compilers: - if (spack_compiler.cc and - os.path.dirname(spack_compiler.cc) == path): + if (spack_compiler.cc and spack_compiler.cc == compiler): actual_compiler = spack_compiler break return actual_compiler.spec if actual_compiler else None @@ -328,10 +328,11 @@ with '-Wl,-commons,use_dylibs' and without variants += '+hcoll' match = re.search(r'MPICH CC:\s+(\S+)', output) - compiler_spec = get_spack_compiler_spec( - os.path.dirname(match.group(1))) - if compiler_spec: - variants.append('%' + str(compiler_spec)) + if match: + compiler = match.group(1) + compiler_spec = get_spack_compiler_spec(compiler) + if compiler_spec: + variants.append('%' + str(compiler_spec)) results.append(' '.join(variants)) return results diff --git a/var/spack/repos/builtin/packages/openmpi/package.py b/var/spack/repos/builtin/packages/openmpi/package.py index 9274c951b8..7072581201 100644 --- a/var/spack/repos/builtin/packages/openmpi/package.py +++ b/var/spack/repos/builtin/packages/openmpi/package.py @@ -520,8 +520,8 @@ class Openmpi(AutotoolsPackage, CudaPackage): # Get the appropriate compiler match = re.search(r'\bC compiler absolute: (\S+)', output) if match: - compiler_spec = get_spack_compiler_spec( - os.path.dirname(match.group(1))) + compiler = match.group(1) + compiler_spec = get_spack_compiler_spec(compiler) if compiler_spec: variants.append("%" + str(compiler_spec)) results.append(' '.join(variants)) @@ -1053,13 +1053,13 @@ class Openmpi(AutotoolsPackage, CudaPackage): self._test_examples() -def get_spack_compiler_spec(path): - spack_compilers = spack.compilers.find_compilers([path]) +def get_spack_compiler_spec(compiler): + spack_compilers = spack.compilers.find_compilers( + [os.path.dirname(compiler)]) actual_compiler = None # check if the compiler actually matches the one we want for spack_compiler in spack_compilers: - if (spack_compiler.cc and - os.path.dirname(spack_compiler.cc) == path): + if (spack_compiler.cc and spack_compiler.cc == compiler): actual_compiler = spack_compiler break return actual_compiler.spec if actual_compiler else None |