spack.compilers package

Submodules

spack.compilers.adaptor module

class spack.compilers.adaptor.CompilerAdaptor(compiled_spec: Spec, compilers: Dict[Languages, Spec])[source]

Bases: object

Provides access to compiler attributes via Package.compiler. Useful for packages which do not yet access compiler properties via self.spec[language].

property c11_flag: str
property c17_flag: str
property c23_flag: str
property c99_flag: str
property cc
property cc_pic_flag: str
property cc_rpath_arg: str
property cxx
property cxx11_flag: str
property cxx14_flag: str
property cxx17_flag: str
property cxx20_flag: str
property cxx23_flag: str
property cxx98_flag: str
property cxx_pic_flag: str
property cxx_rpath_arg: str
property debug_flags: List[str]
property extra_rpaths: List[str]
property f77
property f77_pic_flag: str
property f77_rpath_arg: str
property fc
property fc_pic_flag: str
property fc_rpath_arg: str
implicit_rpaths() List[str][source]
property linker_arg: str
property name
property openmp_flag: str
property opt_flags: List[str]
property prefix: str
property stdcxx_libs
property version
class spack.compilers.adaptor.DeprecatedCompiler[source]

Bases: DeprecatedProperty

factory(instance, owner) CompilerAdaptor[source]
name
class spack.compilers.adaptor.Languages(*values)[source]

Bases: Enum

C
CXX
FORTRAN

spack.compilers.config module

This module contains functions related to finding compilers on the system, and configuring Spack to use multiple compilers.

spack.compilers.config.COMPILER_TAG

Tag used to identify packages providing a compiler

class spack.compilers.config.CompilerFactory[source]

Bases: object

Class aggregating all ways of constructing a list of compiler specs from config entries.

static from_compilers_yaml(configuration: Configuration, *, scope: str | None = None) List[Spec][source]

Returns the compiler specs defined in the “compilers” section of the configuration

static from_legacy_yaml(compiler_dict: Dict[str, Any]) List[Spec][source]

Returns a list of external specs, corresponding to a compiler entry from compilers.yaml.

static from_packages_yaml(configuration: Configuration, *, scope: str | None = None) List[Spec][source]

Returns the compiler specs defined in the “packages” section of the configuration

class spack.compilers.config.CompilerRemover(configuration: Configuration)[source]

Bases: object

Removes compiler from configuration.

flush()[source]

Removes from configuration the specs that have been marked by the previous call of remove_compilers.

mark_compilers(*, match: str, scope: str | None = None) List[Spec][source]

Marks compilers to be removed in configuration, and returns a corresponding list of specs.

Parameters:
  • match – constraint that the compiler must match to be removed.

  • scope – scope where to remove the compiler. If None, all writeable scopes are checked.

marked_packages_yaml: List[Tuple[str, Any]]
exception spack.compilers.config.NoAvailableCompilerError(message: str, long_message: str | None = None)[source]

Bases: SpackError

exception spack.compilers.config.UnknownCompilerError(compiler_name)[source]

Bases: SpackError

spack.compilers.config.add_compiler_to_config(new_compilers, *, scope=None) None[source]

Add a Compiler object to the configuration, at the required scope.

spack.compilers.config.all_compilers(scope: str | None = None, init_config: bool = True) List[Spec][source]

Returns all the compilers from the current global configuration.

Parameters:
  • scope – configuration scope from which to extract the compilers. If None, the merged configuration is used.

  • init_config – if True, search for compilers if none is found in configuration.

spack.compilers.config.all_compilers_from(configuration: Configuration, scope: str | None = None) List[Spec][source]

Returns all the compilers from the current global configuration.

Parameters:
  • configuration – configuration to be queried

  • scope – configuration scope from which to extract the compilers. If None, the merged configuration is used.

spack.compilers.config.compiler_config_files()[source]
spack.compilers.config.compilers_for_arch(arch_spec: ArchSpec, *, scope: str | None = None) List[Spec][source]

Returns the compilers that can be used on the input architecture

spack.compilers.config.find_compilers(path_hints: List[str] | None = None, *, scope: str | None = None, max_workers: int | None = None) List[Spec][source]

Searches for compiler in the paths given as argument. If any new compiler is found, the configuration is updated, and the list of new compiler objects is returned.

Parameters:
  • path_hints – list of path hints where to look for. A sensible default based on the PATH environment variable will be used if the value is None

  • scope – configuration scope to modify

  • max_workers – number of processes used to search for compilers

spack.compilers.config.name_os_target(spec: Spec) Tuple[str, str, str][source]
spack.compilers.config.select_new_compilers(candidates: List[Spec], *, scope: str | None = None) List[Spec][source]

Given a list of compilers, remove those that are already defined in the configuration.

spack.compilers.config.supported_compilers() List[str][source]

Returns all the currently supported compiler packages

spack.compilers.error module

exception spack.compilers.error.CompilerAccessError(compiler, paths)[source]

Bases: SpackError

exception spack.compilers.error.UnsupportedCompilerFlag(message, long_message=None)[source]

Bases: SpackError

Raised when a compiler does not support a flag type (e.g. a flag to enforce a language standard).

spack.compilers.flags module

spack.compilers.flags.tokenize_flags(flags_values: str, propagate: bool = False) List[Tuple[str, bool]][source]

Given a compiler flag specification as a string, this returns a list where the entries are the flags. For compiler options which set values using the syntax -flag value, this function groups flags and their values together. Any token not preceded by a - is considered the value of a prior flag.

spack.compilers.libraries module

class spack.compilers.libraries.CompilerCache[source]

Bases: object

Base class for compiler output cache. Default implementation does not cache anything.

get(compiler: Spec) CompilerCacheEntry[source]
value(compiler: Spec) Dict[str, str | None][source]
class spack.compilers.libraries.CompilerCacheEntry(c_compiler_output: str | None)[source]

Bases: object

Deserialized cache entry for a compiler

c_compiler_output
property empty: bool

Sometimes the compiler is temporarily broken, preventing us from getting output. The call site determines if that is a problem.

classmethod from_dict(data: Dict[str, str | None])[source]
class spack.compilers.libraries.CompilerPropertyDetector(compiler_spec: Spec)[source]

Bases: object

Detects compiler properties of a given compiler spec. Useful for compiler wrappers.

compiler_environment()[source]

Sets the environment to run this compiler

compiler_verbose_output() str | None[source]

Get the compiler verbose output from the cache or by compiling a dummy C source.

default_dynamic_linker() str | None[source]

Determine the default dynamic linker path from the compiler verbose output.

default_libc() Spec | None[source]

Determine libc targeted by the compiler from link line

implicit_rpaths() List[str][source]

Obtain the implicit rpaths to be added from the default -L link directories, excluding system directories.

class spack.compilers.libraries.DefaultDynamicLinkerFilter(dynamic_linker: str | None)[source]

Bases: object

Remove rpaths to directories that are default search paths of the dynamic linker.

is_dynamic_loader_default_path(p: str) bool[source]
class spack.compilers.libraries.FileCompilerCache(cache: FileCache)[source]

Bases: CompilerCache

Cache for compiler output, which is used to determine implicit link paths, the default libc version, and the compiler version.

get(compiler: Spec) CompilerCacheEntry[source]
name
spack.compilers.libraries.compiler_spec(node: Spec) Spec | None[source]

Returns a compiler Spec associated with the node passed as argument.

The function looks for a c, cxx, and fortran compiler in that order, and returns the first found. If the node does not depend on any of these languages, it returns None.

Use of this function is discouraged, because a single spec can have multiple compilers associated with it, and this function only returns one of them. It can be better to refer to compilers on a per-language basis, through the language virtuals: spec["c"], spec["cxx"], and spec["fortran"].

spack.compilers.libraries.dynamic_linker_filter_for(node: Spec) DefaultDynamicLinkerFilter | None[source]
spack.compilers.libraries.filter_non_existing_dirs(dirs)[source]
spack.compilers.libraries.in_system_subdirectory(path)[source]

Parses link paths out of compiler debug output.

Parameters:

compiler_debug_output – compiler debug output as a string

Returns:

Implicit link paths parsed from the compiler output