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.
This commit is contained in:
parent
aedf215b90
commit
043b2cbb7c
@ -239,13 +239,13 @@ def determine_version(cls, exe):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def determine_variants(cls, exes, version):
|
def determine_variants(cls, exes, version):
|
||||||
def get_spack_compiler_spec(path):
|
def get_spack_compiler_spec(compiler):
|
||||||
spack_compilers = spack.compilers.find_compilers([path])
|
spack_compilers = spack.compilers.find_compilers(
|
||||||
|
[os.path.dirname(compiler)])
|
||||||
actual_compiler = None
|
actual_compiler = None
|
||||||
# check if the compiler actually matches the one we want
|
# check if the compiler actually matches the one we want
|
||||||
for spack_compiler in spack_compilers:
|
for spack_compiler in spack_compilers:
|
||||||
if (spack_compiler.cc and
|
if (spack_compiler.cc and spack_compiler.cc == compiler):
|
||||||
os.path.dirname(spack_compiler.cc) == path):
|
|
||||||
actual_compiler = spack_compiler
|
actual_compiler = spack_compiler
|
||||||
break
|
break
|
||||||
return actual_compiler.spec if actual_compiler else None
|
return actual_compiler.spec if actual_compiler else None
|
||||||
@ -328,10 +328,11 @@ def is_disabled(text):
|
|||||||
variants += '+hcoll'
|
variants += '+hcoll'
|
||||||
|
|
||||||
match = re.search(r'MPICH CC:\s+(\S+)', output)
|
match = re.search(r'MPICH CC:\s+(\S+)', output)
|
||||||
compiler_spec = get_spack_compiler_spec(
|
if match:
|
||||||
os.path.dirname(match.group(1)))
|
compiler = match.group(1)
|
||||||
if compiler_spec:
|
compiler_spec = get_spack_compiler_spec(compiler)
|
||||||
variants.append('%' + str(compiler_spec))
|
if compiler_spec:
|
||||||
|
variants.append('%' + str(compiler_spec))
|
||||||
results.append(' '.join(variants))
|
results.append(' '.join(variants))
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
@ -520,8 +520,8 @@ def determine_variants(cls, exes, version):
|
|||||||
# Get the appropriate compiler
|
# Get the appropriate compiler
|
||||||
match = re.search(r'\bC compiler absolute: (\S+)', output)
|
match = re.search(r'\bC compiler absolute: (\S+)', output)
|
||||||
if match:
|
if match:
|
||||||
compiler_spec = get_spack_compiler_spec(
|
compiler = match.group(1)
|
||||||
os.path.dirname(match.group(1)))
|
compiler_spec = get_spack_compiler_spec(compiler)
|
||||||
if compiler_spec:
|
if compiler_spec:
|
||||||
variants.append("%" + str(compiler_spec))
|
variants.append("%" + str(compiler_spec))
|
||||||
results.append(' '.join(variants))
|
results.append(' '.join(variants))
|
||||||
@ -1053,13 +1053,13 @@ def test(self):
|
|||||||
self._test_examples()
|
self._test_examples()
|
||||||
|
|
||||||
|
|
||||||
def get_spack_compiler_spec(path):
|
def get_spack_compiler_spec(compiler):
|
||||||
spack_compilers = spack.compilers.find_compilers([path])
|
spack_compilers = spack.compilers.find_compilers(
|
||||||
|
[os.path.dirname(compiler)])
|
||||||
actual_compiler = None
|
actual_compiler = None
|
||||||
# check if the compiler actually matches the one we want
|
# check if the compiler actually matches the one we want
|
||||||
for spack_compiler in spack_compilers:
|
for spack_compiler in spack_compilers:
|
||||||
if (spack_compiler.cc and
|
if (spack_compiler.cc and spack_compiler.cc == compiler):
|
||||||
os.path.dirname(spack_compiler.cc) == path):
|
|
||||||
actual_compiler = spack_compiler
|
actual_compiler = spack_compiler
|
||||||
break
|
break
|
||||||
return actual_compiler.spec if actual_compiler else None
|
return actual_compiler.spec if actual_compiler else None
|
||||||
|
Loading…
Reference in New Issue
Block a user