Respect $PATH ordering when registering compilers (#17967)
This commit is contained in:
parent
12aa6d221c
commit
edcc334631
2 changed files with 33 additions and 3 deletions
|
@ -576,9 +576,7 @@ def _default(search_paths):
|
||||||
)
|
)
|
||||||
command_arguments.append(detect_version_args)
|
command_arguments.append(detect_version_args)
|
||||||
|
|
||||||
# Reverse it here so that the dict creation (last insert wins)
|
return command_arguments
|
||||||
# does not spoil the intended precedence.
|
|
||||||
return reversed(command_arguments)
|
|
||||||
|
|
||||||
fn = getattr(
|
fn = getattr(
|
||||||
operating_system, 'arguments_to_detect_version_fn', _default
|
operating_system, 'arguments_to_detect_version_fn', _default
|
||||||
|
|
|
@ -250,3 +250,35 @@ def test_compiler_find_prefer_no_suffix(
|
||||||
|
|
||||||
assert clang['paths']['cc'] == str(clangdir.join('clang'))
|
assert clang['paths']['cc'] == str(clangdir.join('clang'))
|
||||||
assert clang['paths']['cxx'] == str(clangdir.join('clang++'))
|
assert clang['paths']['cxx'] == str(clangdir.join('clang++'))
|
||||||
|
|
||||||
|
|
||||||
|
def test_compiler_find_path_order(
|
||||||
|
no_compilers_yaml, working_env, clangdir):
|
||||||
|
"""Ensure that we find compilers that come first in the PATH first
|
||||||
|
"""
|
||||||
|
|
||||||
|
with clangdir.as_cwd():
|
||||||
|
os.mkdir('first_in_path')
|
||||||
|
shutil.copy('gcc-8', 'first_in_path/gcc-8')
|
||||||
|
shutil.copy('g++-8', 'first_in_path/g++-8')
|
||||||
|
shutil.copy('gfortran-8', 'first_in_path/gfortran-8')
|
||||||
|
|
||||||
|
# the first_in_path folder should be searched first
|
||||||
|
os.environ['PATH'] = '{0}:{1}'.format(
|
||||||
|
str(clangdir.join("first_in_path")),
|
||||||
|
str(clangdir),
|
||||||
|
)
|
||||||
|
|
||||||
|
compiler('find', '--scope=site')
|
||||||
|
|
||||||
|
config = spack.compilers.get_compiler_config('site', False)
|
||||||
|
|
||||||
|
gcc = next(c['compiler'] for c in config
|
||||||
|
if c['compiler']['spec'] == 'gcc@8.4.0')
|
||||||
|
|
||||||
|
assert gcc['paths'] == {
|
||||||
|
'cc': str(clangdir.join('first_in_path', 'gcc-8')),
|
||||||
|
'cxx': str(clangdir.join('first_in_path', 'g++-8')),
|
||||||
|
'f77': str(clangdir.join('first_in_path', 'gfortran-8')),
|
||||||
|
'fc': str(clangdir.join('first_in_path', 'gfortran-8')),
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue