target_compile source destfile type options
sourceSource file or other arguments if type is none.
destfileDestination file or empty string to request output as return value.
typeType of output that should be produced.
none | Special applications where no source is actually given. |
preprocess | Run the source files through the C preprocessor. |
assembly | Produce assembler source from the compiler. |
object | Produce binary object files. |
executable | Produce an executable program. |
optionsList of additional options:
Language-selection options:
adaUse an Ada compiler.
c++Use a C++ compiler.
dUse a compiler for the D language.
f77Use a compiler for Fortran 77.
f90Use a compiler for Fortran 90.
goUse a compiler for Go.
rustUse a compiler for Rust.
If none of these options are given, the C compiler is used by default. Giving multiple language-selection options is an error.
The f77 option generally selects the g77 compiler,
while the f90 option selects the newer gfortran
frontend. Both of these can compile Fortran 77, but only
gfortran supports Fortran 90.
Search path options:
incdir=dirAdditional directory to search for preprocessor include files. Multiple uses of this option add multiple directories to the search path.
libdir=dirAdditional directory to search for libraries. Multiple uses of this option add multiple directories to the search path.
Target options:
debugCompile with debugging information. Multiple uses of this option are treated as a single use.
dest=targetOverride the current target and compile for target instead. If this option is given multiple times, only the last use is significant.
compiler=commandOverride the defaults and use command as the compiler. If this option is given multiple times, only the last use is significant.
linker=commandOverride the defaults and use command to build executables. If this option is given multiple times, only the last use is significant.
early_flags=flagsPrepend flags to the set of arguments to be passed to the compiler. Multiple uses of this option specify additional arguments.
additional_flags=flagsAdd flags to the set of arguments to be passed to the compiler. Multiple uses of this option specify additional arguments.
optimize=flagsSpecify optimization flags to be passed to the compiler. Nothing enforces that the flags given with option must actually be related to optimization, however. If this option is given multiple times, only the last use is significant.
ldflags=flagsAdd flags to the set of arguments to be passed to the linker. Note that these are passed literally to the compiler driver, without adding a special prefix to each option. If a ‘-Wl,’ prefix is needed with GCC, it must be included in the given flags. As a group, the linker flags are only used if an executable is requested and are given special treatment with some languages. Multiple uses of this option specify additional arguments.
ldscript=scriptSpecify a linker script, or more precisely, the argument to pass to the linker via the compiler driver to select a linker script. The script value is passed literally to the compiler driver. If this option is given multiple times, only the last use is significant.
libs=libsSpecify additional libraries to be included in the link. The
libs value is a space-separated list of libraries to include.
Each element is checked, and if a file exists with that exact name, it
is added to the list of sources to be given to the compiler.
Otherwise, the element is passed literally to the compiler driver
after any linker flags specified with the ldflags option.
Multiple uses of this option specify additional lists, which are
concatenated in the order they are given.
Execution options:
timeout=timeoutAbort the compile job if it is still running after timeout seconds. This is intended for compiler tests that are known to cause infinite loops upon failure.
redirect=fileInstead of returning output emitted on stdout, place it into
file.
The target_compile procedure also uses several global Tcl variables as overrides:
CFLAGS_FOR_TARGETIf CFLAGS_FOR_TARGET is set, its value is prepended to the
flags otherwise prepared for the compiler, even ahead of any
board-specific flags inserted as a result of a language-selection
option.
LDFLAGS_FOR_TARGETIf LDFLAGS_FOR_TARGET is set, the set of arguments to be passed
to linker is initialized to its value instead of an empty list. The
ldflags option appends to this list.
CC_FOR_TARGETOverride default compiler. If no other compiler is given and this
variable is set, its value will be used instead of searching for a
compiler or using the default from the target board configuration.
The compiler option overrides this variable.
CXX_FOR_TARGETOverride C++ compiler. If the c++ option is given, this
compiler will be used and the compiler option ignored.
D_FOR_TARGETOverride D language compiler. If the d option is given, this
compiler will be used and the compiler option ignored.
F77_FOR_TARGETOverride Fortran 77 compiler. If the f77 option is given, this
compiler will be used and the compiler option ignored.
F90_FOR_TARGETOverride Fortran 90 compiler. If the f90 option is given, this
compiler will be used and the compiler option ignored.
GO_FOR_TARGETOverride Go compiler. If the go option is given, this
compiler will be used and the compiler option ignored.
GO_LD_FOR_TARGETOverride Go linker. If the go option is given, this
linker will be used.
RUSTC_FOR_TARGETOverride Rust compiler. If the rust option is given, this
compiler will be used and the compiler option ignored.
GNATMAKE_FOR_TARGETOverride Ada compiler. If the ada option is given, this
compiler will be used and the compiler option ignored.
The target_compile procedure obtains most defaults from the
target board configuration, but additionally inserts any flags
specified as cflags_for_target on the host board
configuration. If no host is set, the unix board configuration
is checked for a cflags_for_target key. If the
cflags_for_target key exists, its value is inserted into the
set of arguments given to the compiler after any arguments given with
the additional_flags option.
In DejaGnu 1.6.2 and older, this mechanism did not work reliably and
the unix board configuration was always searched for the
cflags_for_target key, regardless of the host board selected.
Also in DejaGnu 1.6.2 and older, the dest option interacted
very badly with the language-selection options. There was no correct
way to combine these options because the language-specific defaults
would be read from the current target board configuration instead of
the board configuration specified with the dest option. The
closest solution was to always specify the language-selection option
first, but this results in defaults appropriate for the current
target, instead of the target selected with the dest option.