fpm_compiler Module

Define compiler command options

This module defines compiler options to use for the debug and release builds.



Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: LANG_C = 2
integer, public, parameter :: LANG_CXX = 3
integer, public, parameter :: LANG_FORTRAN = 1

Source languages

integer, public, parameter :: compiler_enum = kind(id_unknown)
character(len=*), public, parameter :: flag_cray_fixed_form = " -ffixed"
character(len=*), public, parameter :: flag_cray_free_form = " -ffree"
character(len=*), public, parameter :: flag_cray_implicit_typing = " -el"
character(len=*), public, parameter :: flag_cray_no_implicit_typing = " -dl"
character(len=*), public, parameter :: flag_flang_debug = " -g"
character(len=*), public, parameter :: flag_flang_fixed_form = " -ffixed-form"
character(len=*), public, parameter :: flag_flang_free_form = " -ffree-form"
character(len=*), public, parameter :: flag_flang_no_implicit_typing = " -fimplicit-none"
character(len=*), public, parameter :: flag_flang_openmp = " -fopenmp"
character(len=*), public, parameter :: flag_flang_opt = " -O3"
character(len=*), public, parameter :: flag_flang_pic = " -fPIC"
character(len=*), public, parameter :: flag_gnu_backtrace = " -fbacktrace"
character(len=*), public, parameter :: flag_gnu_check = " -fcheck=bounds -fcheck=array-temps"
character(len=*), public, parameter :: flag_gnu_coarray = " -fcoarray=single"
character(len=*), public, parameter :: flag_gnu_debug = " -g"
character(len=*), public, parameter :: flag_gnu_external = " -Wimplicit-interface"
character(len=*), public, parameter :: flag_gnu_fixed_form = " -ffixed-form"
character(len=*), public, parameter :: flag_gnu_free_form = " -ffree-form"
character(len=*), public, parameter :: flag_gnu_limit = " -fmax-errors=1"
character(len=*), public, parameter :: flag_gnu_no_implicit_external = " -Werror=implicit-interface"
character(len=*), public, parameter :: flag_gnu_no_implicit_typing = " -fimplicit-none"
character(len=*), public, parameter :: flag_gnu_openmp = " -fopenmp"
character(len=*), public, parameter :: flag_gnu_opt = " -O3 -funroll-loops"
character(len=*), public, parameter :: flag_gnu_pic = " -fPIC"
character(len=*), public, parameter :: flag_gnu_warn = " -Wall -Wextra -Wno-external-argument-mismatch"
character(len=*), public, parameter :: flag_ibmxl_backslash = " -qnoescape"
character(len=*), public, parameter :: flag_intel_align = " -align all"
character(len=*), public, parameter :: flag_intel_align_win = " /align:all"
character(len=*), public, parameter :: flag_intel_backtrace = " -traceback"
character(len=*), public, parameter :: flag_intel_backtrace_win = " /traceback"
character(len=*), public, parameter :: flag_intel_byterecl = " -assume byterecl"
character(len=*), public, parameter :: flag_intel_byterecl_win = " /assume:byterecl"
character(len=*), public, parameter :: flag_intel_check = " -check all"
character(len=*), public, parameter :: flag_intel_check_win = " /check:all"
character(len=*), public, parameter :: flag_intel_debug = " -O0 -g"
character(len=*), public, parameter :: flag_intel_debug_win = " /Od /Z7"
character(len=*), public, parameter :: flag_intel_fixed_form = " -fixed"
character(len=*), public, parameter :: flag_intel_fixed_form_win = " /fixed"
character(len=*), public, parameter :: flag_intel_fp = " -fp-model precise -pc64"
character(len=*), public, parameter :: flag_intel_fp_win = " /fp:precise"
character(len=*), public, parameter :: flag_intel_free_form = " -free"
character(len=*), public, parameter :: flag_intel_free_form_win = " /free"
character(len=*), public, parameter :: flag_intel_limit = " -error-limit 1"
character(len=*), public, parameter :: flag_intel_limit_win = " /error-limit:1"
character(len=*), public, parameter :: flag_intel_llvm_check = " -check all,nouninit"
character(len=*), public, parameter :: flag_intel_nogen = " -nogen-interfaces"
character(len=*), public, parameter :: flag_intel_nogen_win = " /nogen-interfaces"
character(len=*), public, parameter :: flag_intel_openmp = " -qopenmp"
character(len=*), public, parameter :: flag_intel_openmp_win = " /Qopenmp"
character(len=*), public, parameter :: flag_intel_opt = " -O3"
character(len=*), public, parameter :: flag_intel_opt_win = " /O3"
character(len=*), public, parameter :: flag_intel_pthread = " -reentrancy threaded"
character(len=*), public, parameter :: flag_intel_pthread_win = " /reentrancy:threaded"
character(len=*), public, parameter :: flag_intel_standard_compliance = " -standard-semantics"
character(len=*), public, parameter :: flag_intel_standard_compliance_win = " /standard-semantics"
character(len=*), public, parameter :: flag_intel_unknown_cmd_err = " -diag-error 10006"
character(len=*), public, parameter :: flag_intel_unknown_cmd_err_win = " /Qdiag-error:10006"
character(len=*), public, parameter :: flag_intel_warn = " -warn all"
character(len=*), public, parameter :: flag_intel_warn_win = " /warn:all"
character(len=*), public, parameter :: flag_lfortran_fixed_form = " --fixed-form"
character(len=*), public, parameter :: flag_lfortran_implicit_external = " --implicit-interface"
character(len=*), public, parameter :: flag_lfortran_implicit_typing = " --implicit-typing"
character(len=*), public, parameter :: flag_lfortran_openmp = " --openmp"
character(len=*), public, parameter :: flag_lfortran_opt = " --fast"
character(len=*), public, parameter :: flag_nag_backtrace = " -gline"
character(len=*), public, parameter :: flag_nag_check = " -C"
character(len=*), public, parameter :: flag_nag_coarray = " -coarray=single"
character(len=*), public, parameter :: flag_nag_debug = " -g -O0"
character(len=*), public, parameter :: flag_nag_fixed_form = " -fixed"
character(len=*), public, parameter :: flag_nag_fpp = " -fpp"
character(len=*), public, parameter :: flag_nag_free_form = " -free"
character(len=*), public, parameter :: flag_nag_no_implicit_typing = " -u"
character(len=*), public, parameter :: flag_nag_openmp = " -openmp"
character(len=*), public, parameter :: flag_nag_opt = " -O4"
character(len=*), public, parameter :: flag_nag_pic = " -PIC"
character(len=*), public, parameter :: flag_pgi_backslash = " -Mbackslash"
character(len=*), public, parameter :: flag_pgi_check = " -Mbounds -Mchkptr -Mchkstk"
character(len=*), public, parameter :: flag_pgi_debug = " -g"
character(len=*), public, parameter :: flag_pgi_fixed_form = " -Mfixed"
character(len=*), public, parameter :: flag_pgi_free_form = " -Mfree"
character(len=*), public, parameter :: flag_pgi_openmp = " -mp"
character(len=*), public, parameter :: flag_pgi_traceback = " -traceback"
character(len=*), public, parameter :: flag_pgi_warn = " -Minform=inform"

Enumerations

enum, bind(c)

Enumerators

enumerator:: id_all = -1
enumerator:: id_unknown = 0
enumerator:: id_gcc = 1
enumerator:: id_f95 = 2
enumerator:: id_caf = 3
enumerator:: id_intel_classic_nix = 4
enumerator:: id_intel_classic_mac = 5
enumerator:: id_intel_classic_windows = 6
enumerator:: id_intel_llvm_nix = 7
enumerator:: id_intel_llvm_windows = 8
enumerator:: id_intel_llvm_unknown = 9
enumerator:: id_pgi = 10
enumerator:: id_nvhpc = 11
enumerator:: id_nag = 12
enumerator:: id_flang_classic = 13
enumerator:: id_flang = 14
enumerator:: id_amdflang = 15
enumerator:: id_f18 = 16
enumerator:: id_ibmxl = 17
enumerator:: id_cray = 18
enumerator:: id_lahey = 19
enumerator:: id_lfortran = 20

Interfaces

public interface debug

Create debug printout

  • public pure function debug_compiler(self) result(repr)

    String representation of a compiler object

    Arguments

    Type IntentOptional Attributes Name
    type(compiler_t), intent(in) :: self

    Instance of the compiler object

    Return Value character(len=:), allocatable

    Representation as string

  • public pure function debug_archiver(self) result(repr)

    String representation of an archiver object

    Arguments

    Type IntentOptional Attributes Name
    type(archiver_t), intent(in) :: self

    Instance of the archiver object

    Return Value character(len=:), allocatable

    Representation as string


Derived Types

type, public, extends(serializable_t) ::  archiver_t

Definition of archiver object

Components

Type Visibility Attributes Name Initial
character(len=:), public, allocatable :: ar

Path to archiver

logical, public :: echo = .true.

Print all command

logical, public :: use_response_file = .false.

Use response files to pass arguments

logical, public :: verbose = .true.

Verbose output of command

Type-Bound Procedures

generic, public :: dump => dump_to_toml, dump_to_file, dump_to_unit
procedure, public :: dump_to_toml
generic, public :: load => load_from_toml, load_from_file, load_from_unit
procedure, public :: load_from_toml
procedure, public :: make_archive

Create static archive

generic, public :: operator(==) => serializable_is_same
procedure, public :: serializable_is_same => ar_is_same

Serialization interface

procedure, public, non_overridable :: test_serialization

Test load/write roundtrip

type, public, extends(serializable_t) ::  compiler_t

Definition of compiler object

Components

Type Visibility Attributes Name Initial
character(len=:), public, allocatable :: cc

Path to the C compiler

character(len=:), public, allocatable :: cxx

Path to the C++ compiler

logical, public :: echo = .true.

Print all commands

character(len=:), public, allocatable :: fc

Path to the Fortran compiler

integer(kind=compiler_enum), public :: id = id_unknown

Identifier of the compiler

logical, public :: verbose = .true.

Verbose output of command

Type-Bound Procedures

procedure, public :: check_c_flags_supported
procedure, public :: check_c_source_runs

C feature support

procedure, public :: check_cxx_flags_supported
procedure, public :: check_cxx_source_runs

C++ feature support

procedure, public :: check_flags_supported
procedure, public :: check_fortran_source_runs

Fortran feature support

procedure, public :: compile_c

Compile a C object

procedure, public :: compile_cpp

Compile a CPP object

procedure, public :: compile_fortran

Compile a Fortran object

generic, public :: dump => dump_to_toml, dump_to_file, dump_to_unit
procedure, public :: dump_to_toml => compiler_dump
procedure, public :: enumerate_libraries

Enumerate libraries, based on compiler and platform

procedure, public :: get_default_flags

Get default compiler flags

procedure, public :: get_export_flags

Get library export flags

procedure, public :: get_feature_flag

Get feature flag

procedure, public :: get_headerpad_flags

Generate header padding flags for macOS executables

procedure, public :: get_include_flag

Get flag for include directories

procedure, public :: get_install_name_flags

Get library install name flags

procedure, public :: get_main_flags

Get flags for the main linking command

procedure, public :: get_module_flag

Get flag for module output directories

procedure, public :: get_preprocess_flag

Get flag that preprocesses a source whose suffix asks for it

procedure, public :: is_gnu

Check whether this is a GNU compiler

procedure, public :: is_intel

Check whether this is an Intel compiler

procedure, public :: is_unknown

Check whether compiler is recognized

procedure, public :: link => link_executable

Link executable

procedure, public :: link_shared

Link a shared library

generic, public :: load => load_from_toml, load_from_file, load_from_unit
procedure, public :: load_from_toml => compiler_load
procedure, public :: name => compiler_name

Return compiler name

generic, public :: operator(==) => serializable_is_same
procedure, public :: serializable_is_same => compiler_is_same

Serialization interface

procedure, public, non_overridable :: test_serialization

Test load/write roundtrip

procedure, public :: with_qp
procedure, public :: with_xdp

Functions

public function ar_is_same(this, that)

Check that two archiver_t objects are equal All checks passed!

Arguments

Type IntentOptional Attributes Name
class(archiver_t), intent(in) :: this
class(serializable_t), intent(in) :: that

Return Value logical

public function check_c_flags_supported(self, compile_flags, link_flags)

Check if the given C compile and/or link flags are accepted by the C compiler

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(in) :: self
character(len=*), intent(in), optional :: compile_flags
character(len=*), intent(in), optional :: link_flags

Return Value logical

public function check_c_source_runs(self, input, compile_flags, link_flags) result(success)

Check if the given C source code compiles, links, and runs successfully Create temporary source file Write contents Get flags Compile Link using C compiler for pure C programs Run Delete temporary files

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(in) :: self

Instance of the compiler object

character(len=*), intent(in) :: input

C program source

character(len=*), intent(in), optional :: compile_flags

Optional build and link flags

character(len=*), intent(in), optional :: link_flags

Optional build and link flags

Return Value logical

public function check_compiler(compiler, expected) result(match)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: compiler
character(len=*), intent(in) :: expected

Return Value logical

public function check_cxx_flags_supported(self, compile_flags, link_flags)

Check if the given C++ compile and/or link flags are accepted by the C++ compiler

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(in) :: self
character(len=*), intent(in), optional :: compile_flags
character(len=*), intent(in), optional :: link_flags

Return Value logical

public function check_cxx_source_runs(self, input, compile_flags, link_flags) result(success)

Check if the given C++ source code compiles, links, and runs successfully Create temporary source file Write contents Get flags Compile Link using C++ compiler for pure C++ programs Run Delete temporary files

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(in) :: self

Instance of the compiler object

character(len=*), intent(in) :: input

C++ program source

character(len=*), intent(in), optional :: compile_flags

Optional build and link flags

character(len=*), intent(in), optional :: link_flags

Optional build and link flags

Return Value logical

public function check_flags_supported(self, compile_flags, link_flags)

Check if the given compile and/or link flags are accepted by the compiler

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(in) :: self
character(len=*), intent(in), optional :: compile_flags
character(len=*), intent(in), optional :: link_flags

Return Value logical

public function check_fortran_source_runs(self, input, compile_flags, link_flags) result(success)

Run a single-source Fortran program using the current compiler Compile a Fortran object Create temporary source file Write contents Get flags Intel: Needs -warn last for error on unknown command line arguments to work Compile and link program Run and retrieve exit code

Read more…

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(in) :: self

Instance of the compiler object

character(len=*), intent(in) :: input

Program Source

character(len=*), intent(in), optional :: compile_flags

Optional build and link flags

character(len=*), intent(in), optional :: link_flags

Optional build and link flags

Return Value logical

public pure function compiler_id_name(id) result(name)

Convert compiler enum to name (reverse of match_compiler_type)

Arguments

Type IntentOptional Attributes Name
integer(kind=compiler_enum), intent(in) :: id

Return Value character(len=:), allocatable

public function compiler_is_same(this, that)

Check that two compiler_t objects are equal All checks passed!

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(in) :: this
class(serializable_t), intent(in) :: that

Return Value logical

public pure function compiler_name(self) result(name)

Return a compiler name string

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(in) :: self

Instance of the compiler object

Return Value character(len=:), allocatable

Representation as string

public pure function debug_archiver(self) result(repr)

String representation of an archiver object

Arguments

Type IntentOptional Attributes Name
type(archiver_t), intent(in) :: self

Instance of the archiver object

Return Value character(len=:), allocatable

Representation as string

public pure function debug_compiler(self) result(repr)

String representation of a compiler object

Arguments

Type IntentOptional Attributes Name
type(compiler_t), intent(in) :: self

Instance of the compiler object

Return Value character(len=:), allocatable

Representation as string

public function drop_compile_options(link_flags, compile_flags) result(flags)

Link flags without the options that the compile flags already pass: executables are linked with both, and a metapackage can set the same option in each (OpenMP), which a strict compiler rejects when repeated (NAG: -openmp). Only an option standing alone is dropped: paths, libraries, linker flags, repeats, and options that take an argument stay with that argument. The flags are split on blanks, not parsed, so Windows paths keep their backslashes.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: link_flags
character(len=*), intent(in) :: compile_flags

Return Value character(len=:), allocatable

public function ends_with_blank(str)

True when the string ends in a blank (space or tab), i.e. its last character separates it from anything concatenated after it.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: str

Return Value logical

public function enumerate_libraries(self, prefix, libs) result(r)

Enumerate libraries, based on compiler and platform

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(in) :: self
character(len=*), intent(in) :: prefix
type(string_t), intent(in) :: libs(:)

Return Value character(len=:), allocatable

public function get_compiler_id(compiler) result(id)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: compiler

Return Value integer(kind=compiler_enum)

public function get_default_flags(self, release) result(flags)

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(in) :: self
logical, intent(in) :: release

Return Value character(len=:), allocatable

public function get_export_flags(self, target_dir, target_name) result(export_flags)

Generate library export flags for a shared library build

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(in) :: self

Instance of the compiler

character(len=*), intent(in) :: target_dir

Path and package name

character(len=*), intent(in) :: target_name

Path and package name

Return Value character(len=:), allocatable

public function get_feature_flag(self, feature) result(flags)

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(in) :: self
character(len=*), intent(in) :: feature

Return Value character(len=:), allocatable

public function get_headerpad_flags(self) result(flags)

Generate header padding flags for install_name_tool compatibility on macOS

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(in) :: self

Return Value character(len=:), allocatable

public function get_include_flag(self, path) result(flags)

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(in) :: self
character(len=*), intent(in) :: path

Return Value character(len=:), allocatable

public function get_install_name_flags(self, target_dir, target_name) result(flags)

Generate install_name flag for a shared library build on macOS

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(in) :: self
character(len=*), intent(in) :: target_dir
character(len=*), intent(in) :: target_name

Return Value character(len=:), allocatable

public function get_macros(id, macros_list, version) result(macros)

This function will parse and read the macros list and return them as defined flags. Set macro defintion symbol on the basis of compiler used Check if macros are not allocated. Split the macro name and value.

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=compiler_enum), intent(in) :: id
type(string_t), intent(in), allocatable :: macros_list(:)
type(version_t), intent(in), optional :: version

Return Value character(len=:), allocatable

public function get_module_flag(self, path) result(flags)

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(in) :: self
character(len=*), intent(in) :: path

Return Value character(len=:), allocatable

public function get_preprocess_flag(self, source_file) result(flag)

Get the flag that preprocesses a Fortran source with an upper-case .F90 or .F suffix, for compilers that do not do so on their own: NAG runs fpp by suffix only on .ff90, .ff95 and .ff sources

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(in) :: self
character(len=*), intent(in) :: source_file

Return Value character(len=:), allocatable

public function get_shared_flag(self) result(shared_flag)

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(in) :: self

Return Value character(len=:), allocatable

public function identify_compiler(compiler) result(id)

Identify a compiler from its name, and for a compiler named like LLVM flang, from its installation: AOCC, like other classic flang installs, also calls its compiler flang

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: compiler

Return Value integer(kind=compiler_enum)

public function is_classic_flang(compiler) result(classic)

Whether a compiler named flang is classic flang: its driver runs the flang1 program installed next to it, which LLVM flang does not have

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: compiler

Return Value logical

public function is_cxx_gnu_based(self) result(is_gnu)

Check if C++ compiler is GNU-based by checking its version output

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(in) :: self

Return Value logical

public pure function is_gnu(self)

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(in) :: self

Return Value logical

public pure function is_intel(self)

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(in) :: self

Return Value logical

public pure function is_unknown(self)

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(in) :: self

Return Value logical

public function match_compiler_type(compiler) result(id)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: compiler

Return Value integer(kind=compiler_enum)

public function with_qp(self)

Check if the current compiler supports 128-bit real precision

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(in) :: self

Instance of the compiler object

Return Value logical

public function with_xdp(self)

Check if the current compiler supports 80-bit “extended” real precision

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(in) :: self

Instance of the compiler object

Return Value logical


Subroutines

public subroutine append_clean_flags(flags, new_flags)

Append new flags to existing flags, removing duplicates and empty flags (string version)

Arguments

Type IntentOptional Attributes Name
character(len=:), intent(inout), allocatable :: flags
character(len=*), intent(in) :: new_flags

public subroutine append_clean_flags_array(flags_array, new_flags_array)

Append new flags to existing flags, removing duplicates and empty flags (array version)

Arguments

Type IntentOptional Attributes Name
type(string_t), intent(inout), allocatable :: flags_array(:)
type(string_t), intent(in) :: new_flags_array(:)

public subroutine compile_c(self, input, output, args, log_file, stat, table, dry_run)

Compile a C object

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(in) :: self

Instance of the compiler object

character(len=*), intent(in) :: input

Source file input

character(len=*), intent(in) :: output

Output file of object

character(len=*), intent(in) :: args

Arguments for compiler

character(len=*), intent(in) :: log_file

Compiler output log file

integer, intent(out) :: stat

Status flag

type(compile_command_table_t), intent(inout), optional :: table

Optional compile_commands table

logical, intent(in), optional :: dry_run

Optional mocking

public subroutine compile_cpp(self, input, output, args, log_file, stat, table, dry_run)

Compile a CPP object

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(in) :: self

Instance of the compiler object

character(len=*), intent(in) :: input

Source file input

character(len=*), intent(in) :: output

Output file of object

character(len=*), intent(in) :: args

Arguments for compiler

character(len=*), intent(in) :: log_file

Compiler output log file

integer, intent(out) :: stat

Status flag

type(compile_command_table_t), intent(inout), optional :: table

Optional compile_commands table

logical, intent(in), optional :: dry_run

Optional mocking

public subroutine compile_fortran(self, input, output, args, log_file, stat, table, dry_run)

Compile a Fortran object

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(in) :: self

Instance of the compiler object

character(len=*), intent(in) :: input

Source file input

character(len=*), intent(in) :: output

Output file of object

character(len=*), intent(in) :: args

Arguments for compiler

character(len=*), intent(in) :: log_file

Compiler output log file

integer, intent(out) :: stat

Status flag

type(compile_command_table_t), intent(inout), optional :: table

Optional compile_commands table

logical, intent(in), optional :: dry_run

Optional mocking

public subroutine compile_object(self, lang, input, output, args, log_file, stat, table, dry_run)

Compile an object with the compiler for its language

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(in) :: self

Instance of the compiler object

integer, intent(in) :: lang

Source language: LANG_FORTRAN, LANG_C or LANG_CXX

character(len=*), intent(in) :: input

Source file input

character(len=*), intent(in) :: output

Output file of object

character(len=*), intent(in) :: args

Arguments for compiler

character(len=*), intent(in) :: log_file

Compiler output log file

integer, intent(out) :: stat

Status flag

type(compile_command_table_t), intent(inout), optional :: table

Optional compile_commands table

logical, intent(in), optional :: dry_run

Optional mocking

public subroutine compiler_dump(self, table, error)

Dump dependency to toml table

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(inout) :: self

Instance of the serializable object

type(toml_table), intent(inout) :: table

Data structure

type(error_t), intent(out), allocatable :: error

Error handling

public subroutine compiler_load(self, table, error)

Read dependency from toml table (no checks made at this stage)

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(inout) :: self

Instance of the serializable object

type(toml_table), intent(inout) :: table

Data structure

type(error_t), intent(out), allocatable :: error

Error handling

public subroutine dump_to_toml(self, table, error)

Dump dependency to toml table

Read more…

Arguments

Type IntentOptional Attributes Name
class(archiver_t), intent(inout) :: self

Instance of the serializable object

type(toml_table), intent(inout) :: table

Data structure

type(error_t), intent(out), allocatable :: error

Error handling

public subroutine get_debug_compile_flags(id, flags)

Arguments

Type IntentOptional Attributes Name
integer(kind=compiler_enum), intent(in) :: id
character(len=:), intent(out), allocatable :: flags

public subroutine get_default_c_compiler(f_compiler, c_compiler)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: f_compiler
character(len=:), intent(out), allocatable :: c_compiler

public subroutine get_default_cxx_compiler(f_compiler, cxx_compiler)

Get C++ Compiler.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: f_compiler
character(len=:), intent(out), allocatable :: cxx_compiler

public subroutine get_main_flags(self, language, flags)

Get special flags for the main linker

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(in) :: self
character(len=*), intent(in) :: language
character(len=:), intent(out), allocatable :: flags

public subroutine get_release_compile_flags(id, flags)

Arguments

Type IntentOptional Attributes Name
integer(kind=compiler_enum), intent(in) :: id
character(len=:), intent(out), allocatable :: flags

public subroutine link_executable(self, output, args, log_file, stat, dry_run)

Link an executable

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(in) :: self

Instance of the compiler object

character(len=*), intent(in) :: output

Output file of object

character(len=*), intent(in) :: args

Arguments for compiler

character(len=*), intent(in) :: log_file

Compiler output log file

integer, intent(out) :: stat

Status flag

logical, intent(in), optional :: dry_run

Optional mocking

public subroutine link_shared(self, output, args, log_file, stat, dry_run)

Link a shared library

Arguments

Type IntentOptional Attributes Name
class(compiler_t), intent(in) :: self

Instance of the compiler object

character(len=*), intent(in) :: output

Output file of shared library object

character(len=*), intent(in) :: args

Arguments for the compiler

character(len=*), intent(in) :: log_file

Compiler output log file

integer, intent(out) :: stat

Status flag

logical, intent(in), optional :: dry_run

Optional mocking

public subroutine load_from_toml(self, table, error)

Read dependency from toml table (no checks made at this stage)

Arguments

Type IntentOptional Attributes Name
class(archiver_t), intent(inout) :: self

Instance of the serializable object

type(toml_table), intent(inout) :: table

Data structure

type(error_t), intent(out), allocatable :: error

Error handling

public subroutine make_archive(self, output, args, log_file, stat, dry_run)

Create an archive

Read more…

Arguments

Type IntentOptional Attributes Name
class(archiver_t), intent(in) :: self

Instance of the archiver object

character(len=*), intent(in) :: output

Name of the archive to generate

type(string_t), intent(in) :: args(:)

Object files to include into the archive

character(len=*), intent(in) :: log_file

Compiler output log file

integer, intent(out) :: stat

Status flag

logical, intent(in), optional :: dry_run

Optional mocking

public subroutine new_archiver(self, ar, echo, verbose)

Create new archiver instance

Arguments

Type IntentOptional Attributes Name
type(archiver_t), intent(out) :: self

New instance of the archiver

character(len=*), intent(in) :: ar

User provided archiver command

logical, intent(in) :: echo

Echo compiler command

logical, intent(in) :: verbose

Verbose mode: dump compiler output

public subroutine new_compiler(self, fc, cc, cxx, echo, verbose)

Create new compiler instance

Arguments

Type IntentOptional Attributes Name
type(compiler_t), intent(out) :: self

New instance of the compiler

character(len=*), intent(in) :: fc

Fortran compiler name or path

character(len=*), intent(in) :: cc

C compiler name or path

character(len=*), intent(in) :: cxx

C++ Compiler name or path

logical, intent(in) :: echo

Echo compiler command

logical, intent(in) :: verbose

Verbose mode: dump compiler output

public subroutine run_tool(command, argv, tokenized, echo, verbose, log_file, stat)

Run a tool by argv spawn, which is safe from several OpenMP threads. When its arguments could not be split, run the shell command instead, one at a time.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: command

Shell command

type(string_t), intent(in), allocatable :: argv(:)

Arguments for run_argv

logical, intent(in) :: tokenized

Whether argv is complete

logical, intent(in) :: echo

Echo and verbosity settings of the tool

logical, intent(in) :: verbose

Echo and verbosity settings of the tool

character(len=*), intent(in) :: log_file

Tool output log file

integer, intent(out) :: stat

Status flag

public pure subroutine set_cpp_preprocessor_flags(id, flags)

Modify the flag_cpp_preprocessor on the basis of the compiler.

Arguments

Type IntentOptional Attributes Name
integer(kind=compiler_enum), intent(in) :: id
character(len=:), intent(inout), allocatable :: flags

public subroutine split_append(argv, str, join_spaced, ok)

Split a command fragment into argv tokens with the OS-native lexer and append them to argv. fortran-shlex is not reentrant, so the split runs in a critical region. Both lexers remove the quoting as a shell does, so -DMSG=‘“hi”’ gives -DMSG=”hi”. join_spaced applies to the POSIX lexer.

Arguments

Type IntentOptional Attributes Name
type(string_t), intent(inout), allocatable :: argv(:)
character(len=*), intent(in) :: str
logical, intent(in) :: join_spaced
logical, intent(inout) :: ok

public subroutine tokenize_flags(flags, flags_array)

Tokenize a string into an array of compiler flags

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: flags
type(string_t), intent(out), allocatable :: flags_array(:)

public subroutine tool_command(prog, args, output, command, argv, tokenized, input)

Build prog [-c input] args -o output both as a shell command and as an argv list, splitting prog and args with the OS-native lexer. tokenized is .false. when a part cannot be split: only the shell command can run then.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: prog

Program, possibly followed by its own flags

character(len=*), intent(in) :: args

Arguments for the program

character(len=*), intent(in) :: output

Output file, passed with -o

character(len=:), intent(out), allocatable :: command

Shell command

type(string_t), intent(out), allocatable :: argv(:)

Arguments for run_argv

logical, intent(out) :: tokenized

Whether every part could be split

character(len=*), intent(in), optional :: input

Optional source file, passed with -c

public pure elemental subroutine validate_compiler_name(compiler_name, is_valid)

Check if compiler name is a valid compiler name

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: compiler_name

Name of a compiler

logical, intent(out) :: is_valid

Boolean value of whether compiler_name is valid or not

public subroutine write_response_file(name, argv)

Response files allow to read command line options from files. Whitespace is used to separate the arguments, we will use newlines as separator to create readable response files which can be inspected in case of errors.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: name
type(string_t), intent(in) :: argv(:)