Next: target_link procedure, Previous: target_assemble procedure, Up: Procedures For Target Boards [Contents][Index]
target_compile source destfile type options
source
Source file or other arguments if type is none
.
destfile
Destination file or empty string to request output as return value.
type
Type 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. |
options
List of additional options:
Language-selection options:
ada
Use an Ada compiler.
c++
Use a C++ compiler.
d
Use a compiler for the D language.
f77
Use a compiler for Fortran 77.
f90
Use a compiler for Fortran 90.
go
Use a compiler for Go.
rust
Use 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=dir
Additional directory to search for preprocessor include files. Multiple uses of this option add multiple directories to the search path.
libdir=dir
Additional directory to search for libraries. Multiple uses of this option add multiple directories to the search path.
Target options:
debug
Compile with debugging information. Multiple uses of this option are treated as a single use.
dest=target
Override the current target and compile for target instead. If this option is given multiple times, only the last use is significant.
compiler=command
Override the defaults and use command as the compiler. If this option is given multiple times, only the last use is significant.
linker=command
Override the defaults and use command to build executables. If this option is given multiple times, only the last use is significant.
early_flags=flags
Prepend flags to the set of arguments to be passed to the compiler. Multiple uses of this option specify additional arguments.
additional_flags=flags
Add flags to the set of arguments to be passed to the compiler. Multiple uses of this option specify additional arguments.
optimize=flags
Specify 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=flags
Add 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=script
Specify 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=libs
Specify 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=timeout
Abort 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=file
Instead of returning output emitted on stdout
, place it into
file.
The target_compile
procedure also uses several global Tcl variables as overrides:
CFLAGS_FOR_TARGET
If 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_TARGET
If 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_TARGET
Override 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_TARGET
Override C++ compiler. If the c++
option is given, this
compiler will be used and the compiler
option ignored.
D_FOR_TARGET
Override D language compiler. If the d
option is given, this
compiler will be used and the compiler
option ignored.
F77_FOR_TARGET
Override Fortran 77 compiler. If the f77
option is given, this
compiler will be used and the compiler
option ignored.
F90_FOR_TARGET
Override Fortran 90 compiler. If the f90
option is given, this
compiler will be used and the compiler
option ignored.
GO_FOR_TARGET
Override Go compiler. If the go
option is given, this
compiler will be used and the compiler
option ignored.
GO_LD_FOR_TARGET
Override Go linker. If the go
option is given, this
linker will be used.
RUSTC_FOR_TARGET
Override Rust compiler. If the rust
option is given, this
compiler will be used and the compiler
option ignored.
GNATMAKE_FOR_TARGET
Override 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.
Next: target_link procedure, Previous: target_assemble procedure, Up: Procedures For Target Boards [Contents][Index]