spack.compilers package

Submodules

spack.compilers.aocc module

class spack.compilers.aocc.Aocc(cspec, operating_system, target, paths, modules=None, alias=None, environment=None, extra_rpaths=None, enable_implicit_rpaths=None, **kwargs)

Bases: spack.compiler.Compiler

c11_flag
c99_flag
cc_names = ['clang']
cc_pic_flag

Returns the flag used by the C compiler to produce Position Independent Code (PIC).

cxx11_flag
cxx14_flag
cxx17_flag
cxx_names = ['clang++']
cxx_pic_flag

Returns the flag used by the C++ compiler to produce Position Independent Code (PIC).

debug_flags
classmethod extract_version_from_output(output)

Extracts the version from compiler’s output.

f77_names = ['flang']
f77_pic_flag

Returns the flag used by the F77 compiler to produce Position Independent Code (PIC).

classmethod f77_version(f77)
fc_names = ['flang']
fc_pic_flag

Returns the flag used by the FC compiler to produce Position Independent Code (PIC).

classmethod fc_version(fortran_compiler)
openmp_flag
opt_flags
required_libs = ['libclang']
verbose_flag

This property should be overridden in the compiler subclass if a verbose flag is available.

If it is not overridden, it is assumed to not be supported.

version_argument = '--version'

spack.compilers.apple_clang module

class spack.compilers.apple_clang.AppleClang(cspec, operating_system, target, paths, modules=None, alias=None, environment=None, extra_rpaths=None, enable_implicit_rpaths=None, **kwargs)

Bases: spack.compilers.clang.Clang

cxx11_flag
cxx14_flag
cxx17_flag
classmethod extract_version_from_output(output)

Extracts the version from compiler’s output.

openmp_flag = '-Xpreprocessor -fopenmp'
setup_custom_environment(pkg, env)

Set the DEVELOPER_DIR environment for the Xcode toolchain.

On macOS, not all buildsystems support querying CC and CXX for the compilers to use and instead query the Xcode toolchain for what compiler to run. This side-steps the spack wrappers. In order to inject spack into this setup, we need to copy (a subset of) Xcode.app and replace the compiler executables with symlinks to the spack wrapper. Currently, the stage is used to store the Xcode.app copies. We then set the ‘DEVELOPER_DIR’ environment variables to cause the xcrun and related tools to use this Xcode.app.

spack.compilers.arm module

class spack.compilers.arm.Arm(cspec, operating_system, target, paths, modules=None, alias=None, environment=None, extra_rpaths=None, enable_implicit_rpaths=None, **kwargs)

Bases: spack.compiler.Compiler

c11_flag
c99_flag
cc_names = ['armclang']
cc_pic_flag

Returns the flag used by the C compiler to produce Position Independent Code (PIC).

cxx11_flag
cxx14_flag
cxx17_flag
cxx_names = ['armclang++']
cxx_pic_flag

Returns the flag used by the C++ compiler to produce Position Independent Code (PIC).

classmethod extract_version_from_output(output)

Extracts the version from compiler’s output.

f77_names = ['armflang']
f77_pic_flag

Returns the flag used by the F77 compiler to produce Position Independent Code (PIC).

classmethod f77_version(f77)
fc_names = ['armflang']
fc_pic_flag

Returns the flag used by the FC compiler to produce Position Independent Code (PIC).

classmethod fc_version(fc)
openmp_flag
opt_flags
required_libs = ['libclang', 'libflang']
verbose_flag

This property should be overridden in the compiler subclass if a verbose flag is available.

If it is not overridden, it is assumed to not be supported.

version_argument = '--version'
version_regex = 'Arm C\\/C\\+\\+\\/Fortran Compiler version ([\\d\\.]+) \\(build number (\\d+)\\) '

spack.compilers.cce module

class spack.compilers.cce.Cce(cspec, operating_system, target, paths, modules=None, alias=None, environment=None, extra_rpaths=None, enable_implicit_rpaths=None, **kwargs)

Bases: spack.compiler.Compiler

Cray compiler environment compiler.

PrgEnv = 'PrgEnv-cray'
PrgEnv_compiler = 'cce'
c11_flag
c99_flag
cc_names = ['cc']
cc_pic_flag

Returns the flag used by the C compiler to produce Position Independent Code (PIC).

cxx11_flag
cxx_names = ['CC']
cxx_pic_flag

Returns the flag used by the C++ compiler to produce Position Independent Code (PIC).

debug_flags
f77_names = ['ftn']
f77_pic_flag

Returns the flag used by the F77 compiler to produce Position Independent Code (PIC).

fc_names = ['ftn']
fc_pic_flag

Returns the flag used by the FC compiler to produce Position Independent Code (PIC).

is_clang_based
openmp_flag
suffixes = ['-mp-\\d\\.\\d']
verbose_flag

This property should be overridden in the compiler subclass if a verbose flag is available.

If it is not overridden, it is assumed to not be supported.

version_argument

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

version_regex = '[Vv]ersion.*?(\\d+(\\.\\d+)+)'

spack.compilers.clang module

class spack.compilers.clang.Clang(cspec, operating_system, target, paths, modules=None, alias=None, environment=None, extra_rpaths=None, enable_implicit_rpaths=None, **kwargs)

Bases: spack.compiler.Compiler

c11_flag
c99_flag
cc_names = ['clang']
cc_pic_flag

Returns the flag used by the C compiler to produce Position Independent Code (PIC).

cxx11_flag
cxx14_flag
cxx17_flag
cxx_names = ['clang++']
cxx_pic_flag

Returns the flag used by the C++ compiler to produce Position Independent Code (PIC).

debug_flags
classmethod extract_version_from_output(output)

Extracts the version from compiler’s output.

f77_names = ['flang', 'gfortran', 'xlf_r']
f77_pic_flag

Returns the flag used by the F77 compiler to produce Position Independent Code (PIC).

classmethod f77_version(f77)
fc_names = ['flang', 'gfortran', 'xlf90_r']
fc_pic_flag

Returns the flag used by the FC compiler to produce Position Independent Code (PIC).

classmethod fc_version(fc)
openmp_flag = '-fopenmp'
opt_flags
required_libs = ['libclang']
verbose_flag

This property should be overridden in the compiler subclass if a verbose flag is available.

If it is not overridden, it is assumed to not be supported.

version_argument = '--version'
spack.compilers.clang.f77_mapping = [('gfortran', 'clang/gfortran'), ('xlf_r', 'xl_r/xlf_r'), ('xlf', 'xl/xlf'), ('pgfortran', 'pgi/pgfortran'), ('ifort', 'intel/ifort')]

compiler symlink mappings for mixed f77 compilers

spack.compilers.clang.fc_mapping = [('gfortran', 'clang/gfortran'), ('xlf90_r', 'xl_r/xlf90_r'), ('xlf90', 'xl/xlf90'), ('pgfortran', 'pgi/pgfortran'), ('ifort', 'intel/ifort')]

compiler symlink mappings for mixed f90/fc compilers

spack.compilers.fj module

class spack.compilers.fj.Fj(cspec, operating_system, target, paths, modules=None, alias=None, environment=None, extra_rpaths=None, enable_implicit_rpaths=None, **kwargs)

Bases: spack.compiler.Compiler

c11_flag
c99_flag
cc_names = ['fcc']
cc_pic_flag

Returns the flag used by the C compiler to produce Position Independent Code (PIC).

cxx11_flag
cxx14_flag
cxx98_flag
cxx_names = ['FCC']
cxx_pic_flag

Returns the flag used by the C++ compiler to produce Position Independent Code (PIC).

f77_names = ['frt']
f77_pic_flag

Returns the flag used by the F77 compiler to produce Position Independent Code (PIC).

fc_names = ['frt']
fc_pic_flag

Returns the flag used by the FC compiler to produce Position Independent Code (PIC).

openmp_flag
opt_flags
required_libs = ['libfj90i', 'libfj90f', 'libfjsrcinfo']
verbose_flag

This property should be overridden in the compiler subclass if a verbose flag is available.

If it is not overridden, it is assumed to not be supported.

version_argument = '--version'
version_regex = '\\((?:FCC|FRT)\\) ([a-z\\d.]+)'

spack.compilers.gcc module

class spack.compilers.gcc.Gcc(cspec, operating_system, target, paths, modules=None, alias=None, environment=None, extra_rpaths=None, enable_implicit_rpaths=None, **kwargs)

Bases: spack.compiler.Compiler

PrgEnv = 'PrgEnv-gnu'
PrgEnv_compiler = 'gcc'
c11_flag
c99_flag
cc_names = ['gcc']
cc_pic_flag

Returns the flag used by the C compiler to produce Position Independent Code (PIC).

cxx11_flag
cxx14_flag
cxx17_flag
cxx98_flag
cxx_names = ['g++']
cxx_pic_flag

Returns the flag used by the C++ compiler to produce Position Independent Code (PIC).

debug_flags
classmethod default_version(cc)

Older versions of gcc use the -dumpversion option. Output looks like this:

4.4.7

In GCC 7, this option was changed to only return the major version of the compiler:

7

A new -dumpfullversion option was added that gives us what we want:

7.2.0
f77_names = ['gfortran']
f77_pic_flag

Returns the flag used by the F77 compiler to produce Position Independent Code (PIC).

classmethod f77_version(f77)
fc_names = ['gfortran']
fc_pic_flag

Returns the flag used by the FC compiler to produce Position Independent Code (PIC).

classmethod fc_version(fc)

Older versions of gfortran use the -dumpversion option. Output looks like this:

GNU Fortran (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18)
Copyright (C) 2010 Free Software Foundation, Inc.

or:

4.8.5

In GCC 7, this option was changed to only return the major version of the compiler:

7

A new -dumpfullversion option was added that gives us what we want:

7.2.0
openmp_flag
opt_flags
required_libs = ['libgcc', 'libgfortran']
stdcxx_libs
suffixes = ['-mp-\\d+\\.\\d+', '-\\d+\\.\\d+', '-\\d+', '\\d\\d']
verbose_flag

This property should be overridden in the compiler subclass if a verbose flag is available.

If it is not overridden, it is assumed to not be supported.

spack.compilers.intel module

class spack.compilers.intel.Intel(cspec, operating_system, target, paths, modules=None, alias=None, environment=None, extra_rpaths=None, enable_implicit_rpaths=None, **kwargs)

Bases: spack.compiler.Compiler

PrgEnv = 'PrgEnv-intel'
PrgEnv_compiler = 'intel'
c11_flag
c99_flag
cc_names = ['icc']
cc_pic_flag

Returns the flag used by the C compiler to produce Position Independent Code (PIC).

cxx11_flag
cxx14_flag
cxx_names = ['icpc']
cxx_pic_flag

Returns the flag used by the C++ compiler to produce Position Independent Code (PIC).

debug_flags
f77_names = ['ifort']
f77_pic_flag

Returns the flag used by the F77 compiler to produce Position Independent Code (PIC).

fc_names = ['ifort']
fc_pic_flag

Returns the flag used by the FC compiler to produce Position Independent Code (PIC).

openmp_flag
opt_flags
required_libs = ['libirc', 'libifcore', 'libifcoremt', 'libirng']
stdcxx_libs
verbose_flag

This property should be overridden in the compiler subclass if a verbose flag is available.

If it is not overridden, it is assumed to not be supported.

version_argument = '--version'
version_regex = '\\((?:IFORT|ICC)\\) ([^ ]+)'

spack.compilers.nag module

class spack.compilers.nag.Nag(cspec, operating_system, target, paths, modules=None, alias=None, environment=None, extra_rpaths=None, enable_implicit_rpaths=None, **kwargs)

Bases: spack.compiler.Compiler

cc_names = []
cxx11_flag
cxx_names = []
debug_flags
f77_names = ['nagfor']
f77_pic_flag

Returns the flag used by the F77 compiler to produce Position Independent Code (PIC).

f77_rpath_arg
fc_names = ['nagfor']
fc_pic_flag

Returns the flag used by the FC compiler to produce Position Independent Code (PIC).

fc_rpath_arg
linker_arg

Flag that need to be used to pass an argument to the linker.

openmp_flag
opt_flags
verbose_flag

This property should be overridden in the compiler subclass if a verbose flag is available.

If it is not overridden, it is assumed to not be supported.

version_argument = '-V'
version_regex = 'NAG Fortran Compiler Release ([0-9.]+)'

spack.compilers.nvhpc module

class spack.compilers.nvhpc.Nvhpc(cspec, operating_system, target, paths, modules=None, alias=None, environment=None, extra_rpaths=None, enable_implicit_rpaths=None, **kwargs)

Bases: spack.compiler.Compiler

PrgEnv = 'PrgEnv-nvhpc'
PrgEnv_compiler = 'nvhpc'
c11_flag
c99_flag
cc_names = ['nvc']
cc_pic_flag

Returns the flag used by the C compiler to produce Position Independent Code (PIC).

cxx11_flag
cxx14_flag
cxx17_flag
cxx_names = ['nvc++']
cxx_pic_flag

Returns the flag used by the C++ compiler to produce Position Independent Code (PIC).

debug_flags
f77_names = ['nvfortran']
f77_pic_flag

Returns the flag used by the F77 compiler to produce Position Independent Code (PIC).

fc_names = ['nvfortran']
fc_pic_flag

Returns the flag used by the FC compiler to produce Position Independent Code (PIC).

openmp_flag
opt_flags
required_libs = ['libnvc', 'libnvf']
stdcxx_libs
verbose_flag

This property should be overridden in the compiler subclass if a verbose flag is available.

If it is not overridden, it is assumed to not be supported.

version_argument = '--version'
version_regex = 'nv[^ ]* (?:[^ ]+ Dev-r)?([0-9.]+)(?:-[0-9]+)?'

spack.compilers.oneapi module

class spack.compilers.oneapi.Oneapi(cspec, operating_system, target, paths, modules=None, alias=None, environment=None, extra_rpaths=None, enable_implicit_rpaths=None, **kwargs)

Bases: spack.compiler.Compiler

PrgEnv = 'PrgEnv-oneapi'
PrgEnv_compiler = 'oneapi'
c11_flag
c99_flag
cc_names = ['icx']
cc_pic_flag

Returns the flag used by the C compiler to produce Position Independent Code (PIC).

cxx11_flag
cxx14_flag
cxx_names = ['icpx']
cxx_pic_flag

Returns the flag used by the C++ compiler to produce Position Independent Code (PIC).

debug_flags
f77_names = ['ifx']
f77_pic_flag

Returns the flag used by the F77 compiler to produce Position Independent Code (PIC).

fc_names = ['ifx']
fc_pic_flag

Returns the flag used by the FC compiler to produce Position Independent Code (PIC).

openmp_flag
opt_flags
required_libs = ['libirc', 'libifcore', 'libifcoremt', 'libirng']
stdcxx_libs
verbose_flag

This property should be overridden in the compiler subclass if a verbose flag is available.

If it is not overridden, it is assumed to not be supported.

version_argument = '--version'
version_regex = '\\((?:IFORT|ICC)\\)|DPC\\+\\+ [^ ]+ [^ ]+ [^ ]+ \\(([^ ]+)\\)'

spack.compilers.pgi module

class spack.compilers.pgi.Pgi(cspec, operating_system, target, paths, modules=None, alias=None, environment=None, extra_rpaths=None, enable_implicit_rpaths=None, **kwargs)

Bases: spack.compiler.Compiler

PrgEnv = 'PrgEnv-pgi'
PrgEnv_compiler = 'pgi'
c11_flag
c99_flag
cc_names = ['pgcc']
cc_pic_flag

Returns the flag used by the C compiler to produce Position Independent Code (PIC).

cxx11_flag
cxx_names = ['pgc++', 'pgCC']
cxx_pic_flag

Returns the flag used by the C++ compiler to produce Position Independent Code (PIC).

debug_flags
f77_names = ['pgfortran', 'pgf77']
f77_pic_flag

Returns the flag used by the F77 compiler to produce Position Independent Code (PIC).

fc_names = ['pgfortran', 'pgf95', 'pgf90']
fc_pic_flag

Returns the flag used by the FC compiler to produce Position Independent Code (PIC).

ignore_version_errors = [2]
openmp_flag
opt_flags
required_libs = ['libpgc', 'libpgf90']
verbose_flag

This property should be overridden in the compiler subclass if a verbose flag is available.

If it is not overridden, it is assumed to not be supported.

version_argument = '-V'
version_regex = 'pg[^ ]* ([0-9.]+)-[0-9]+ (LLVM )?[^ ]+ target on '

spack.compilers.xl module

class spack.compilers.xl.Xl(cspec, operating_system, target, paths, modules=None, alias=None, environment=None, extra_rpaths=None, enable_implicit_rpaths=None, **kwargs)

Bases: spack.compiler.Compiler

c11_flag
c99_flag
cc_names = ['xlc']
cc_pic_flag

Returns the flag used by the C compiler to produce Position Independent Code (PIC).

cxx11_flag
cxx_names = ['xlC', 'xlc++']
cxx_pic_flag

Returns the flag used by the C++ compiler to produce Position Independent Code (PIC).

debug_flags
f77_names = ['xlf']
f77_pic_flag

Returns the flag used by the F77 compiler to produce Position Independent Code (PIC).

classmethod f77_version(f77)
fc_names = ['xlf90', 'xlf95', 'xlf2003', 'xlf2008']
fc_pic_flag

Returns the flag used by the FC compiler to produce Position Independent Code (PIC).

classmethod fc_version(fc)
fflags
openmp_flag
opt_flags
verbose_flag

This property should be overridden in the compiler subclass if a verbose flag is available.

If it is not overridden, it is assumed to not be supported.

version_argument = '-qversion'
version_regex = '([0-9]?[0-9]\\.[0-9])'

spack.compilers.xl_r module

class spack.compilers.xl_r.XlR(cspec, operating_system, target, paths, modules=None, alias=None, environment=None, extra_rpaths=None, enable_implicit_rpaths=None, **kwargs)

Bases: spack.compilers.xl.Xl

cc_names = ['xlc_r']
cxx_names = ['xlC_r', 'xlc++_r']
f77_names = ['xlf_r']
fc_names = ['xlf90_r', 'xlf95_r', 'xlf2003_r', 'xlf2008_r']

Module contents

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

class spack.compilers.CacheReference(val)

Bases: object

This acts as a hashable reference to any object (regardless of whether the object itself is hashable) and also prevents the object from being garbage-collected (so if two CacheReference objects are equal, they will refer to the same object, since it will not have been gc’ed since the creation of the first CacheReference).

exception spack.compilers.CompilerDuplicateError(compiler_spec, arch_spec)

Bases: spack.error.SpackError

class spack.compilers.CompilerID(os, compiler_name, version)

Bases: tuple

Gathers the attribute values by which a detected compiler is considered unique in Spack.

  • os: the operating system
  • compiler_name: the name of the compiler (e.g. ‘gcc’, ‘clang’, etc.)
  • version: the version of the compiler
compiler_name

Alias for field number 1

os

Alias for field number 0

version

Alias for field number 2

exception spack.compilers.CompilerSpecInsufficientlySpecificError(compiler_spec)

Bases: spack.error.SpackError

class spack.compilers.DetectVersionArgs(id, variation, language, path)

Bases: tuple

Groups together the arguments needed by detect_version. The four entries in the tuple are:

  • id: An instance of the CompilerID named tuple (version can be set to None
    as it will be detected later)
  • variation: a NameVariation for file being tested
  • language: compiler language being tested (one of ‘cc’, ‘cxx’, ‘fc’, ‘f77’)
  • path: full path to the executable being tested
id

Alias for field number 0

language

Alias for field number 2

path

Alias for field number 3

variation

Alias for field number 1

exception spack.compilers.InvalidCompilerConfigurationError(compiler_spec)

Bases: spack.error.SpackError

class spack.compilers.NameVariation(prefix, suffix)

Bases: tuple

Variations on a matched compiler name

prefix

Alias for field number 0

suffix

Alias for field number 1

exception spack.compilers.NoCompilerForSpecError(compiler_spec, target)

Bases: spack.error.SpackError

exception spack.compilers.NoCompilersError

Bases: spack.error.SpackError

spack.compilers.add_compilers_to_config(compilers, scope=None, init_config=True)

Add compilers to the config for the specified architecture.

Parameters:
  • compilers (-) – a list of Compiler objects.
  • scope (-) – configuration scope to modify.
spack.compilers.all_compiler_specs(scope=None, init_config=True)
spack.compilers.all_compiler_types()
spack.compilers.all_compilers(scope=None)
spack.compilers.all_compilers_config(scope=None, init_config=True)

Return a set of specs for all the compiler versions currently available to build with. These are instances of CompilerSpec.

spack.compilers.all_os_classes()

Return the list of classes for all operating systems available on this platform

spack.compilers.arguments_to_detect_version_fn(operating_system, paths)

Returns a list of DetectVersionArgs tuples to be used in a corresponding function to detect compiler versions.

The operating_system instance can customize the behavior of this function by providing a method called with the same name.

Parameters:
  • operating_system (OperatingSystem) – the operating system on which we are looking for compilers
  • paths – paths to search for compilers
Returns:

List of DetectVersionArgs tuples. Each item in the list will be later mapped to the corresponding function call to detect the version of the compilers in this OS.

spack.compilers.class_for_compiler_name(compiler_name)

Given a compiler module name, get the corresponding Compiler class.

spack.compilers.compiler_config_files()
spack.compilers.compiler_for_spec(cspec_like, *args, **kwargs)
spack.compilers.compiler_from_dict(items)
spack.compilers.compilers_for_arch(arch_spec, scope=None)
spack.compilers.compilers_for_spec(cspec_like, *args, **kwargs)
spack.compilers.detect_version(detect_version_args)

Computes the version of a compiler and adds it to the information passed as input.

As this function is meant to be executed by worker processes it won’t raise any exception but instead will return a (value, error) tuple that needs to be checked by the code dispatching the calls.

Parameters:detect_version_args (DetectVersionArgs) – information on the compiler for which we should detect the version.
Returns:A (DetectVersionArgs, error) tuple. If error is None the version of the compiler was computed correctly and the first argument of the tuple will contain it. Otherwise error is a string containing an explanation on why the version couldn’t be computed.
spack.compilers.find(cspec_like, *args, **kwargs)
spack.compilers.find_compilers(path_hints=None)

Returns the list of compilers found in the paths given as arguments.

Parameters:path_hints (list or None) – 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
Returns:List of compilers found
spack.compilers.find_specs_by_arch(cspec_like, *args, **kwargs)
spack.compilers.get_compiler_config(scope=None, init_config=True)

Return the compiler configuration for the specified architecture.

spack.compilers.get_compiler_duplicates(cspec_like, *args, **kwargs)
spack.compilers.get_compilers(config, cspec=None, arch_spec=None)
spack.compilers.is_mixed_toolchain(compiler)

Returns True if the current compiler is a mixed toolchain, False otherwise.

Parameters:compiler (Compiler) – a valid compiler object
spack.compilers.make_compiler_list(detected_versions)

Process a list of detected versions and turn them into a list of compiler specs.

Parameters:detected_versions (list) – list of DetectVersionArgs containing a valid version
Returns:list of Compiler objects
spack.compilers.pkg_spec_for_compiler(cspec)

Return the spec of the package that provides the compiler.

spack.compilers.remove_compiler_from_config(cspec_like, *args, **kwargs)
spack.compilers.supported(cspec_like, *args, **kwargs)
spack.compilers.supported_compilers()

Return a set of names of compilers supported by Spack.

See available_compilers() to get a list of all the available versions of supported compilers.