tcc
is designed
to implement, let us move on to describe the details of this implementation.
The basic compilation path is shown in Fig. 3, which corresponds to
Fig. 2.
FIGURE 3. Basic tcc Compilation Path
TOOL INPUT OUTPUT 1. C producer (tdfc) c C source target ind. TDF 2. TDF linker (tld) L target ind. TDF target dep. TDF 3. TDF translator (trans) t target dep. TDF assembly source 4. assembler (as) a assembly source binary object 5. system linker (ld) l binary object executableThe executable name of the TDF translator varies, depending on the target machine. It will normally start, or end, however, in
trans
.
These stages are documented in more detail in sections 5.1 to
5.5.
The code letters for the various compilation stages can be used in
the -Wtool, opt, ... command-line
option to tcc
. This passes the option(s) opt directly
to the executable in the compilation stage identified by the letter
tool. For example, -Wl, -x will cause the system linker
to be invoked with the -x option. Similarly the -Etool:
file allows the executable to be invoked at the compilation
stage tool to be specified as file. This allows the
tcc
user access to the compilation tools in a very direct
manner.
3.3. Input File Types
This compilation path may be joined at any point, and terminated at
any point. The latter possibility is discussed below. For the former,
tcc
determines, for each input file it is given, to which
of the file types it knows (C source, target independent TDF, etc.)
this file belongs. This determines where in the compilation path described
this file will start. The method used to determine the type of a file
is the normal filename suffix convention:
(for a complete list see 7.1). Thus, for example, we speak of
".c
are understood to be C source
files,.j
are understood to be target independent
TDF capsules,.t
are understood to be target dependent
TDF capsules,.s
are understood to be assembly
source files,.o
are understood to be binary object
files,.j
files" as a shorthand for "target
independent TDF capsules". Each file type recognised by tcc
is assigned an identifying letter. For convenience, this corresponds
to the suffix identifying the file type (c
for C source
files, j
for target independent TDF capsules etc.).
There is an alternative method of specifying input files, by means
of the -Stype, file, ... command-line
option. This specifies that the file file should be treated
as an input file of the type corresponding to the letter type,
regardless of its actual suffix. Thus, for example, -Sc, file
specifies that file should be regarded as a C source (or .c
)
file.
For most purposes these intermediate files are not required to be
preserved; if we are compiling a single C source file to an executable,
then the only output file we are interested in is the executable,
not the intermediate files created during the compilation process.
For this reason
By default, all preserved files are stored in the current working
directory. However the -work dir command-line option
specifies that they should be stored in the directory dir.
The compilation can also be halted at any stage. The -Ftype
option to
If the compilation has precisely one end product output file, then
the name of this file can be specified to be file by means
of the -o file command-line option. If a -o file
option is given when there is more than one end product, then the
first such file produced will be called file, and all such
files produced subsequently will cause
FIGURE 4. Full tcc Compilation Path
In order to create a TDF archive,
The routines for splitting and building TDF archives are built into
The only unresolved issue in this case is, if the -M option
is given, to what
To summarise,
3.4. Intermediate and Output Files
During the compilation, tcc
makes up names for the output
files of each of the compilation phases. These names are based on
the input file name, but with the input file suffix replaced by the
output file suffix (unless the -make_up_names command-line
option is given, in which case the intermediate files are given names
of the form
_tccnnnn.x
, where nnnn
is a number which
is incremented for each intermediate file produced, and x
is the suffix corresponding to the output file type). Thus if the
input file file.c
is given, this will be transformed
into file.j
by the producer, which in turn will be transformed
into file.t
by the TDF linker, and so on. The system
linker output file name can not be deduced in the same way since it
is the result of linking a number of .o
files. By default, as with cc
, this file is called a.out
.tcc
creates a temporary directory in
which to put these intermediate files, and removes this directory
when the compilation is complete. All intermediate files are put into
this temporary directory except:
cc
).tcc
can be made to preserve intermediate files of various
types by means of the -Ptype... command-line option,
which specifies a list of letters corresponding to the file types
to be preserved. Thus for example -Pjt specifies that all TDF
capsules produced, whether target independent or target dependent,
(i.e. all .j
and .t
files) should be preserved.
The special form -Pa specifies that all intermediate files
should be preserved. It is also possible to specify that a certain
file type should not be preserved by preceding the corresponding letter
by - in the -P option. The only really useful application
of this is to use -P-o to cancel the cc
convention
on preserving binary object files mentioned above.tcc
tells it to stop the compilation after
creating the files of the type corresponding to the letter type.
Because any files of this type which are produced will be an end product
of the compilation, they will automatically be preserved. For example,
-Fo halts the compilation after the creation of the binary
object, or .o
, files (i.e. just before the system linking),
and preserves all such files produced. A number of other tcc
options are equivalent to options of the form -Ftype:
If more than one -F option (including the equivalent options
just listed) is given, then cc
compatibility),cc
compatibility).tcc
issues a warning. The
stage coming first in the compilation path takes priority.tcc
to issue a
warning.
3.5. Other Compilation Paths
So far we have been discussing the main tcc
compilation
path from C source to executable. This is however only part of the
picture. The full complexity (almost) of all the possible compilation
paths supported by tcc
is shown in Fig. 4. This differs
from Fig. 3 in that it only shows the left hand, or program, half
of the main compilation diagram. The solid arrows show the default
compilation paths; the shaded arrows are only followed if tcc
is so instructed by means of command-line options. Let us consider
those paths in this diagram which have not so far been mentioned.3.5.2. TDF Archives
The second new file type introduced in Fig. 4 is the TDF archive.
This is recognised by tcc
by means of the .ta
file suffix. Basically a TDF archive is a set of target independent
TDF capsules (this is slightly simplified, see section 5.2.3 for
more details). Any input TDF archives are automatically split into
their constituent target independent capsules. These then join the
main compilation path in the normal way.tcc
must be given the
-prod command-line option. It will combine all the target independent
TDF capsules it has into an archive, and the compilation will then
halt. By default this archive is called a.ta
, but another
name may be specified using the -o option.tcc
, and are not implemented by a separate compilation
tool (in particular, TDF archives are not ar
archives).
Really TDF archives are a tcc
-specific construction;
they are not part of TDF proper..j
files do the -Fj and the
-Pj options refer? In fact, tcc
takes them to
refer to the merged TDF capsule rather than the capsules which are
merged to form it. The -Pa option, however, will cause both
sets of capsules to be preserved.tcc
has an extra three file types, and
an extra three compilation tools (not including the TDF archive creating
and splitting routines which are built into tcc
). These
are:
and:.i
are understood to be preprocessed
C source files,.ta
are understood to be TDF archives,.p
are understood to be TDF notation
source files,
TOOL INPUT OUTPUT
6. C preprocessor (tdfcpp) c C source preproc. C source
7a. pretty printer (disp) d TDF capsule TDF notation
7b. reverse notation (tnc -p) d TDF capsule TDF notation
8. notation compiler (tnc) d TDF notation TDF capsule
(see 7.1 and 7.2
Occasionally an unclear error message may be printed by one of the
compilation tools. In this case the -show_errors option to
For purposes of configuration control, the -version flag will
cause
Part of the TenDRA Web.3.6. Finding out what tcc is doing
With so many different file types and alternative compilation paths,
it is often useful to be able to keep track of what tcc
is doing. There are several command-line options which do this. The
simplest is -v which specifies that tcc
should
print each command in the compilation process on the standard output
before it is executed. The -vb option is similar, but only
causes the name of each input file to be printed as it is processed.
Finally the -dry option specifies that the commands should
be printed (as with -v) but not actually executed. This can
be used to experiment with tcc
to find out what it would
do in various circumstances.tcc
might be useful. It causes tcc
to print
the command it was executing when the error occurred. By default,
if an error occurs during the construction of an output file, the
file is removed by tcc
. It can however be preserved for
examination using the -keep_errors option. This applies not
only to normal errors, but also to exceptional errors such as the
user interrupting tcc
by pressing ^C
, or
one of the compilation tools crashing. In the latter case, tcc
will also remove any core file produced, unless the -keep_errors
option is specified.tcc
to print its version number. This will typically
be of the form:
tcc: Version: 4.0, Revision: 1.5, Machine: hp
giving the version and revision number, plus the target machine identifier.
The -V flag will also cause each compilation tool to print
its version number (if appropriate) as it is invoked.
Crown
Copyright © 1998.