fab.tools.linker#
This file contains the base class for any Linker.
Classes
|
This is the base class for any Linker. |
- class fab.tools.linker.Linker(compiler, linker=None, name=None)#
This is the base class for any Linker. It takes an existing compiler instance as parameter, and optional another linker. The latter is used to get linker settings - for example, linker-mpif90-gfortran will use mpif90-gfortran as compiler (i.e. to test if it is available and get compilation flags), and linker-gfortran as linker. This way a user only has to specify linker flags in the most basic class (gfortran), all other linker wrapper will inherit the settings.
- Parameters:
- Raises:
RuntimeError – if both compiler and linker are specified.
RuntimeError – if neither compiler nor linker is specified.
- check_available()#
- Return type:
- Returns:
whether this linker is available by asking the wrapped linker or compiler.
- property suite: str#
- Returns:
the suite this linker belongs to by getting it from the wrapped compiler.
- property mpi: bool#
- Returns:
whether this linker supports MPI or not by checking with the wrapped compiler.
- property openmp: bool#
- Returns:
whether this linker supports OpenMP or not by checking with the wrapped compiler.
- define_profile(name, inherit_from=None)#
Defines a new profile name, and allows to specify if this new profile inherit settings from an existing profile.
- get_profile_flags(profile)#
- get_lib_flags(lib)#
Gets the standard flags for a standard library
- Parameters:
lib (
str
) – the library name- Return type:
- Returns:
a list of flags
- Raises:
RuntimeError – if lib is not recognised
- add_lib_flags(lib, flags, silent_replace=False)#
Add a set of flags for a standard library
- add_pre_lib_flags(flags, profile=None)#
Add a set of flags to use before any library-specific flags
- add_post_lib_flags(flags, profile=None)#
Add a set of flags to use after any library-specific flags
- get_pre_link_flags(config)#
Returns the list of pre-link flags. It will concatenate the flags for this instance with all potentially wrapped linkers. This wrapper’s flag will come first - the assumption is that the pre-link flags are likely paths, so we need a wrapper to be able to put a search path before the paths from a wrapped linker.
- get_post_link_flags(config)#
Returns the list of post-link flags. It will concatenate the flags for this instance with all potentially wrapped linkers. This wrapper’s flag will be added to the end.
- link(input_files, output_file, config, libs=None, add_flags=None)#
Executes the linker with the specified input files, creating output_file.
- Parameters:
- Return type:
- Returns:
the stdout of the link command