OS can optionally provide search paths for compiler detection
This permits to deal more neatly with peculiarities of Cray systems when detecting compilers.
This commit is contained in:
parent
a75fc3c6dd
commit
f2824d64d9
@ -198,14 +198,15 @@ def find_compilers(*path_hints):
|
|||||||
"""
|
"""
|
||||||
# Turn the path hints into real paths that are to be searched
|
# Turn the path hints into real paths that are to be searched
|
||||||
path_hints = path_hints or get_path('PATH')
|
path_hints = path_hints or get_path('PATH')
|
||||||
paths = fs.search_paths_for_executables(*path_hints)
|
default_paths = fs.search_paths_for_executables(*path_hints)
|
||||||
|
|
||||||
# To detect the version of the compilers, we dispatch a certain number
|
# To detect the version of the compilers, we dispatch a certain number
|
||||||
# of function calls to different workers. Here we construct the list
|
# of function calls to different workers. Here we construct the list
|
||||||
# of arguments for each call.
|
# of arguments for each call.
|
||||||
arguments = []
|
arguments = []
|
||||||
for o in all_os_classes():
|
for o in all_os_classes():
|
||||||
arguments.extend(arguments_to_detect_version_fn(o, paths))
|
search_paths = getattr(o, 'compiler_search_paths', default_paths)
|
||||||
|
arguments.extend(arguments_to_detect_version_fn(o, search_paths))
|
||||||
|
|
||||||
# Here we map the function arguments to the corresponding calls
|
# Here we map the function arguments to the corresponding calls
|
||||||
tp = multiprocessing.pool.ThreadPool()
|
tp = multiprocessing.pool.ThreadPool()
|
||||||
@ -462,7 +463,7 @@ def all_compiler_types():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def arguments_to_detect_version_fn(operating_system, paths, override=True):
|
def arguments_to_detect_version_fn(operating_system, paths):
|
||||||
"""Returns a list of DetectVersionArgs tuples to be used in a
|
"""Returns a list of DetectVersionArgs tuples to be used in a
|
||||||
corresponding function to detect compiler versions.
|
corresponding function to detect compiler versions.
|
||||||
|
|
||||||
@ -473,8 +474,6 @@ def arguments_to_detect_version_fn(operating_system, paths, override=True):
|
|||||||
operating_system (OperatingSystem): the operating system on which
|
operating_system (OperatingSystem): the operating system on which
|
||||||
we are looking for compilers
|
we are looking for compilers
|
||||||
paths: paths to search for compilers
|
paths: paths to search for compilers
|
||||||
override (bool): whether we should search for an override to this
|
|
||||||
function in the operating system class
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
List of DetectVersionArgs tuples. Each item in the list will be later
|
List of DetectVersionArgs tuples. Each item in the list will be later
|
||||||
@ -511,11 +510,9 @@ def _default(search_paths):
|
|||||||
# does not spoil the intended precedence.
|
# does not spoil the intended precedence.
|
||||||
return reversed(command_arguments)
|
return reversed(command_arguments)
|
||||||
|
|
||||||
fn = _default
|
fn = getattr(
|
||||||
if override:
|
operating_system, 'arguments_to_detect_version_fn', _default
|
||||||
fn = getattr(
|
)
|
||||||
operating_system, 'arguments_to_detect_version_fn', _default
|
|
||||||
)
|
|
||||||
return fn(paths)
|
return fn(paths)
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,18 +52,14 @@ class CrayFrontend(LinuxDistro):
|
|||||||
It acts as a regular Linux without Cray-specific modules and compiler
|
It acts as a regular Linux without Cray-specific modules and compiler
|
||||||
wrappers."""
|
wrappers."""
|
||||||
|
|
||||||
def arguments_to_detect_version_fn(self, paths):
|
@property
|
||||||
"""Calls the default function but prevents it from detecting Cray
|
def compiler_search_paths(self):
|
||||||
compiler wrappers to avoid possible false detections.
|
"""Calls the default function but unloads Cray's programming
|
||||||
|
environments first.
|
||||||
|
|
||||||
The detected compilers come into play only if a user decides to
|
This prevents from detecting Cray compiler wrappers and avoids
|
||||||
work with the Cray's frontend OS as if it was a regular Linux
|
possible false detections.
|
||||||
environment.
|
|
||||||
"""
|
"""
|
||||||
import spack.compilers
|
|
||||||
with unload_programming_environment():
|
with unload_programming_environment():
|
||||||
search_paths = fs.search_paths_for_executables(*get_path('PATH'))
|
search_paths = fs.search_paths_for_executables(*get_path('PATH'))
|
||||||
args = spack.compilers.arguments_to_detect_version_fn(
|
return search_paths
|
||||||
self, search_paths, override=False
|
|
||||||
)
|
|
||||||
return args
|
|
||||||
|
Loading…
Reference in New Issue
Block a user