Name
tcc — User interface to the TDF system
Synopsis
tcc
tcc
tcc
Most options are common to both -ch and to normal use. For brevity, these are not repeated above:
[ -startup str ] [ -H ] [ -w ] [ -dump ] [ -info ] [ -message str ] [ -q | -quiet ] [ -v | -verbose ]
[ -show_errors ] [ -vb ] [ -vd ] [ -ve ] [ -vt ] [ -Idir ] [ -Jdir ] [ -Ldir ] [ -Nident:dir ]
[ -temp dir ] [ -work dir ] [ -Bstr ] [ -Eletter:file ] [ -G ] [ -Kstr,... ] [ -M | -MA ] [ -Ostr ] [ -P ] [ -Yfile ]
[ -Sletter,file,... ] [ -S | -Wletter,str,... ] [ -Wletter:str | -Xstr ] [ -X:str ] [ -Zstr ] [ -b ] [ -g ] [ -p ]
[ -dn | -dy ] [ -cc ] [ -cc_only ] [ -doletter file ] [ -hstr ] [ -jstr ] [ -keep_errors ] [ -make_up_names ]
[ -lstr ] [ -nepc ] [ -not_ansi ] [ -o file ] [ -s ] [ -sletter:suffix ] [ -special str ] [ -sym ] [ -sym: str ]
[ -wsl ] [ -target str ] [ -tidy ] [ -ustr ] [ -zstr ]
Description
tcc is the user interface to the TDF system. It is more fully documented in the TCC Users' Guide.
tcc accepts several types of arguments as file. The formats of these files are automatically inferred from their names:
| Suffix | Context | Format |
|---|---|---|
| .c | – | C source files |
| .i | – | Preprocessed C source files |
| .C | -Yc++ only | C++ source files |
| .I | -Yc++ only | Preprocessed C++ source files |
| .j | – | Target-independent TDF capsules |
| .ta | – | Archives of target-independent TDF capsules |
| .t | – | Target-dependent TDF capsules |
| .s | – | Assembly source files |
| .d | – | TenDRA dump files |
| .K | -Yc++ only | C++ spec files |
| .p | -Ytnc only | TDF notation source files (AKA TDF text) |
| .tpl | -Ypl_tdf only | PL_TDF source files |
| other | – | Binary object files (typically *.o and *.a |
tcc's purpose is to provide a convenient interface through which these files may be converted from one format to another. This is a broad function, and encompasses many situations; the exact details of each of these situations are beyond the scope of this manual. These are covered in depth in the TCC Users' Guide.
tcc is configured almost entirely at runtime—many of the options passed on the command line (in particular the -Y and -X options) draw their configurations from files on the filesystem. Alternate files may be specified, to provide a mechanism for user-specific customisation. This is discussed in tccenv.
Input and Output Files
tcc identifies the file type of the input files it is passed by means of their file suffix. The recognised file suffixes are as follows:
| Suffix | Code | Context | Description |
|---|---|---|---|
| .c | c | – | C source file |
| .i | i | – | Preprocessed C source file |
| .j | j | – | Target independent TDF capsule |
| .t | t | – | Target dependent TDF capsule |
| .s | s | – | Assembly source file |
| .o | o | – | Binary object file |
| .k | k | -im only | C spec file |
| .p | p | -Ytnc only | TDF notation source file |
| .ta | A | – | TDF archive |
| .tpl | P | -Ypl_tdf only | PL_TDF source file |
| .G | G | Mips only | Binasm source file |
| .T | T | Mips only | Assembler source file |
| other | – | – | Binary object file |
Each file type is assigned an identifying letter, usually corresponding to its file suffix, which may be used in various command-line options. For example, -Fs instructs tcc to halt the compilation after creating the assembly source files, and is therefore equivalent to -S. Similarly -Po instructs it to preserve any binary object files it creates. There are a couple of special file type codes which may be used with the -P option. The option -Pa causes all intermediate files to be created, whereas -Ph causes the start-up file, tcc_startup.h, used by tcc to be preserved. The -P option can also be used to specify that intermediate files of various forms should not be preserved. For example, the option -P-o indicates that binary object files should not be preserved.
Most output file names are derived from the input file names with a simple substitution of file suffix, however certain output files (and other files) have default names. These are as follows:
| Filename | Description |
|---|---|
| a.j | Default merged TDF capsule name (with -M option) |
| a.out | Default executable name in binary object linking phase |
| a.ta | Default output TDF archive name |
| a.k | Default output file in intermodular checks linking phase |
| tcc_startup.h | Start-up file used by tcc for -D and -U options. |
| tcc_endup.h | End-up file used by tcc |
If there is a single output file, its name may be specified using the -o option. The default output filenames can also be overridden. For example, -doj b.j sets the default merged TDF capsule name to b.j.
Compilation Phases
The various compilation phases under the control of tcc may be summarised as follows:
| Executable | Code | Action | Description | |
|---|---|---|---|---|
tdfc | c | .c | .j | C to TDF producer |
| .i | .j | |||
| .c | .j + .k | (in intermodular checking mode) | ||
| .i | .j + .k | |||
tld | L | .j | .t | C to TDF producer |
| n ×ばつ .j | .j | (in TDF merging mode) | ||
trans | t | .t | .s | TDF translator |
as | a | .s | .o | System assembler |
ld | l | n ×ばつ .o | exec | System linker |
| – | J | n ×ばつ .j | .ta | Archive builder (built into tcc) |
| – | J | .ta | n ×ばつ .j | Archive splitter (built into tcc) |
tdfcpp | p | .c | .i | C preprocessor |
spec_linker | S | n ×ばつ .k | .k | C spec linker |
disp | d | .j | .p | TDF pretty printer |
| .t | .p | |||
tnc | n | .p | .j | TDF notation compiler |
tnc -p | n | .j | .p | Reverse TDF notation compiler |
| .t | .p | |||
tpl | P | .tpl | .j | PL_TDF compiler |
trans.mips | t | .t | .G + .T | TDF to Mips translator |
asl | A | .G + .T | .o | Auxillary assembler (Mips only) |
cc | C | (various) | System C compiler (specified with -cc option) | |
Each compilation phase is assigned a code letter which is used to identify that phase in various command-line options. For example, in order to pass the -x option to tdfc2 the -Wc, -x command-line option may be used. Similarly, to set the tld executable an option of the form -EL: /usr/local/bin/tld may be used.
Compilation Stages
The compilation process is as follows.
-
TDF archives are split into their constituent target independent capsules.
-
C source files (including preprocessed C) are compiled into target independent TDF capsules using tdfc2. (tcpplus does the same for C++ source files when -Yc++ is specified.)
-
Target independent TDF capsules are linked, using tld, with the TDF libraries to produce target dependent TDF capsules.
-
Target dependent TDF capsules are translated into assembly source files using one of trans.mips (q.v.—things are not quite so simple in this case), trans.x86 etc.
-
Assembly source files are compiled into binary object files using as(1).
-
Binary object files are linked with the precompiled libraries, using ld(1), to produce a final executable.
With the exception of binary object files, intermediate files are not preserved unless explicitly instructed.
The standard file suffixes .c, .i, .C, .I, .j, .t, .s, .o, .d, .k, and .K, together with .p (pretty-printed TDF capsule) and .tpl (PL_TDF source file), are used to indicate file types in some options. Also the various compilation phases are identified by letters in some options. These are:
| Code | Context | Phase |
|---|---|---|
c | – | C to TDF producer |
p | – | C preprocessor |
x | -Yc++ only | C++ to TDF producer |
g | -Yc++ only | C++ preprocessor |
L | – | TDF linker (or builder) |
t | – | TDF translator |
a | – | System assembler |
l | – | System linker |
S | – | C++ spec linker |
e | -Ycompact only | Compact-output error reporter |
u | – | TenDRA dump file linker |
d | – | TDF pretty-printer |
Depending on the options given, compilation may halt at any stage. The options which effect halting are:
- -E
-
Invokes the C preprocessor only, putting the result into a file with a .i suffix if other options indicate that preprocessed C files are to be preserved, or onto the standard output otherwise. Similarly, C++ source files are preprocessed and put into files with .I suffixes.
- -Fletter
-
Tells tcc to stop after producing the files indicated by letter, and to preserve these files. letter is a single character corresponding to the suffix of the files to be preserved.
- -P
-
Invokes the C preprocessor only, putting the result into a file with a .i suffix. The C++ preprocessor is similarly invoked for C++ source files, putting the result into a file with a .I suffix.
- -S
-
Tells tcc to stop after producing an assembly source file. This is equivalent to -Fs.
- -c
-
Tells tcc to stop after producing the binary object files. This is equivalent to -Fo.
- -d
-
Halts the compilation after the creation of the dump files. This is equivalent to -Fd.
- -disp
-
Runs the TDF pretty-printer on all files at stage 2 or 3 and then terminates. The results are put into files with .p suffixes.
- -disp_t
-
Runs the pretty-printer on all files at stage 3 and then terminates. This differs from the -disp option in that it displays the TDF after linking with the target-dependent TDF libraries rather than before. The output is put into a file with a .p suffix.
- -i
-
Tells tcc to stop after producing the target independent TDF capsules. This is equivalent to -Fj.
- -k
-
In intermodular checking mode, halts the compilation after the creation of the C++ spec files. This is equivalent to -FK.
- -prod
-
Specifies that tcc should stop after producing the target independent TDF capsules and combine them into a TDF archive. The default archive name is a.ta.
Command-line Options
The following options are accepted by tcc. They can be given by command-line options or the TCCOPTS system variable. The spaces in the option descriptions are optional, they show where two-part or multi-part options can be split over more than one command-line argument.
| Option | Effect |
|---|---|
| -o string | Specifies output file name |
| -D string=string | Defines a macro |
| -D string | Defines a macro to be 1 |
| -Fstring | Halts the compilation at the given stage |
| -I string | Specifies an include file directory |
| -L string | Specifies a system library directory |
| -N string: string | Specifies an include file directory (with mode) |
| -Ostring | Switches optimisation level |
| -Pstring... | Causes intermediate files to be preserved |
| -S | Halts compilation after creating .s files |
| -T string | Specifies a command-line token |
| -U string | Undefines a macro |
| -Wstring, string, ... | Passed an option to a compilation tool |
| -Wstring: string | Passed an option to a compilation tool |
| -X: string, ... | Specifies a compilation option |
| -Xstring | Specifies a compilation mode |
| -Y string | Reads an environment |
| -c | Halts compilation after creating .o files |
| -d | Halts compilation after creating .d files |
| -dry | Causes a dry run |
| -e string | Specifies a producer end-up file |
| -f string | Specifies a producer start-up file |
| -g | Produces debugging information (default format) |
| -g1 | Produces debugging information (old format) |
| -g2 | Produces debugging information (new format) |
| -g3 | Produces debugging information (new format) |
| -k | Halts compilation after creating .k and .K files |
| -l string | Specifies a system library |
| -not_ansi | Allows some non-ANSI C features |
| -nepc | Switches off extra portability checks |
| -sym | Enables symbol table dump linking |
| -sym:string | Enables symbol table dump linking with flags |
| -v | Specifies verbose mode |
| -vb | Specifies fairly verbose mode |
| -vd | Dump the env information tcc got hold of |
| -ve | Verbose information about tool chain environment |
| -vt | Verbose information about tool chain invocation |
| -no_shuffle | Turns off shuffle ranking of cmd line args |
| -y string=string | Sets an env directory variable |
| -J string | Specifies a TDF library directory |
| -M | Causes all .j files to be merged |
| -MA | As -M, but with hiding |
| -ch | Invokes checker mode |
| -disp | Causes all .j files to be pretty printed |
| -disp_t | Causes all .t files to be pretty printed |
| -i | Halts compilation after creating .j files |
| -im | Enables intermodular checks |
| -j string | Specifies a TDF library |
| -prod | Causes a TDF archive to be produced |
| -A - | Unasserts all built-in predicates |
| -A string | Asserts a predicate |
| -B string | Passed to the system linker |
| -C | Preserves comments when preprocessing |
| -E | Causes C source files to be preprocessed |
| -Estring: string | Specifies an executable to be used |
| -H | Causes included files to be printed |
| -Sstring, string, ... | Specifies input files |
| -Sstring: string | Specifies input files |
| -V | Causes all tools to print their version numbers |
| -cc | Forces the system compiler to be used |
| -cc_only | Forces only the system compiler to be used |
| -dostring string | Sets a default output file name |
| -dump | Dumps the current status |
| -ignore_case | Ignores case in file names |
| -im0 | Disables intermodular checks |
| -info | Causes API information to be printed |
| -keep_errors | Causes files to be preserved on errors |
| -make_up_names | Makes up names for intermediate files |
| -message string | Causes tcc to print a message |
| -p | Causes profiling information to be produced |
| -q | Specifies quiet mode |
| -quiet | Equivalent to -q |
| -query | Causes a list of options to be printed |
| -sstring: string | Specifies a suffix override |
| -show_errors | Causes error producing commands to be shown |
| -special string | Allows various internal options |
| -startup string | Specifies a start-up option |
| -target string | Provided for cc(1) compatibility |
| -temp string | Specifies the temporary directory |
| -tidy | Causes tcc to tidy up as it goes along |
| -time | Causes all commands to be timed |
| -verbose | Equivalent to -v |
| -version | Causes tcc to print its version number |
| -w | Suppresses tcc warnings |
| -work string | Specifies the work directory |
| -G | Provided for cc(1) compatibility |
| -K string, ... | Provided for cc(1) compatibility |
| -Zstring | Provided for cc(1) compatibility |
| -b | Suppresses -lc in system linking |
| -dn | Passed to the system linker |
| -dy | Passed to the system linker |
| -h string | Passed to the system linker |
| -no_startup_options | Suppresses start-up options |
| -s | Passed to the system linker |
| -u string | Passed to the system linker |
| -wsl | Causes string literals to be made writable |
| -z string | Passed to the system linker |
| -# | Equivalent to -v |
| -## | Equivalent to -v |
| -### | Equivalent to -dry |
| -- string, ... | Communicates directly with the option interpreter |
The following two tables list the producer and archiver options which can be passed using the -Wc, opt and -WJ, opt options, respectively.
| Option | Description |
|---|---|
| -D macro | Defines the macro macro to be 1 |
| -D macro=defn | Defines the macro macro to be defn |
| -E number | Sets maximum number of allowed errors (default 20) |
| -H | Causes #include'd files to be printed as they are processed |
| -I dir | Specifies the additional include file directory dir |
| -U macro | Undefines the macro macro |
| -e file | Specifies the end-up file file |
| -f file | Specifies the start-up file file |
| -nepc | Switches off extra portability, and certian other, checks |
| -not_ansi | Allows a selection of non-ISO/ANSI C features |
| Option | Default | Description |
|---|---|---|
| -copy or -c | ✗ | Copies files into archives |
| -full or -f | ✓ | Uses full pathnames for archive links |
| -link or -l | ✓ | Links files into archives |
| -names or -n | ✓ | Uses real names for copied files |
| -no_names or -nn | ✓ | Makes up names for copied files |
| -no_options or -no | ✗ | Does not interpret any archived options |
| -options or -o | ✓ | Interprets any archived options |
| -short or -s | ✗ | Uses short pathnames for archive links |
Options
The following options are supported by tcc. All options are scanned before input files are dealt with. The system variable TCCOPTS may be used to specify a list of options which are processed before the first command-line option.
- -Astr
-
Asserts the predicate str.
- -Bstr
-
Passed to the system linker. The valid values of str are target dependent.
- -Dmacro
- -Dmacro=defn
-
Where str is of the form macro or macro=defn, is equivalent to inserting the preprocessor directives
#define macro 1or#define macro defnat the start of each C source file. This is implemented by tcc writing this directive into a start-up file. - -Eletter:file
-
Causes file to be invoked as the executable for the compilation stage given by letter.
- -H
-
Causes the names of files included by a
#includedirective to be printed. - -Idir
-
Tells the producers and preprocessors to search the directory dir for included files. The directories are searched in the order given, followed by the system default directories.
- -Jdir
-
Tells the TDF linker to search the directory dir for TDF libraries. The linker searches the directories in the order given, followed by the system default directories.
- -Kstr,...
-
Provided for cc(1) compatibility. Specifies various installer options.
- -Ldir
-
Tells the system linker to search the directory dir for libraries. It searches the directories in the order given, followed by the system default directories.
- -M
- -MA
-
Specifies that the TDF linker should link all the given target independent TDF capsules into one. This is done between stages 2 and 3 above. The default name for the produced capsule is a.j.
The -MA form additionally hides all the defined tag and token names from the resultant TDF, except the tag "main". -MA should only be used to compile complete programs.
- -Nident:dir
-
As -Idir except that the identifier ident is associated with the directory dir in the producer.
- -Ostr
-
This flag has no effect other than to cancel any previous diagnostics flag and is included only for compatibility with other compilers. All TDF optimisations are on by default. All optimisations are believed to be correct; any bug which occurs in the fully-optimised state is a genuine bug.
- -P
-
Tells tcc to preserve those files indicated by letter. Each letter is a single character corresponding to the suffix of the files to be preserved. The tcc startup-file can be preserved as tcc_startup.h using -Ph. All intermediate files can be preserved using -Pa.
- -Sletter,file,...
- -Sletter:file
-
The specifies that the list of input files file all have type letter, where letter is a single character giving the normal suffix of the file type. This gives an alternative method of passing input files to tcc, one which does not depend on it having to recognise suffixes to find the type of a file.
The -Sletter:file form is similar to the option above, but specifies a single input file, file (which may contain a comma).
- -Ustr
-
Is equivalent to inserting the preprocessor directive
#undef strat the start of each C source file. This is implemented by tcc writing this directive into a start-up file. The only macros built into the C to TDF producer are__LINE__,__FILE__,__DATE__,__TIME__,__STDC__,__ANDF__and__TenDRA__. - -V
-
Causes all tools invoked by tcc to print their version numbers.
- -Wletter,str,...
- -Wletter:str
-
This passes the list of options str to the compilation phase indicated by letter.
The -Wletter:str form is similar to the option above, but specifies a single file str (which may contain a comma).
- -Xstr
-
Specifies a compilation mode. The mode may be one of of the following:
Mode Meaning aLenient ANSI cStrict ANSI (default) pStrict ANSI with some extra checks sStrict ANSI with many extra checks tTraditional (pre-ANSI) C - -X:str
-
Specifies an individual compilation option. See the TCC Users' Guide for details.
- -Yfile
-
Specifies the environment to use. An environment is a file telling tcc to modify its defaults. If the full pathname of env is not given, the file is searched for along the tcc environments path which is a list of directories separated by colons. This search path can be printed using -vd.
There are certain standard environments, for example, ansi, representing the ANSI API (this is the default API environment), posix represents the POSIX API, xpg3 the XPG3 API, and so on. The system environment allows tcc to behave like cc(1), using the system header files etc. See the TCC Users' Guide and tccenv manual page for more details about environments.
- -Zstr
-
Provided for cc(1) compatibility. Specifies various installer options.
- -api_check
-
Causes tcc to create an API usage analysis file, with default name a.api.
- -api_check_out file
-
If an API usage analysis file is produced, call it file.
- -b
-
Stops the library libc.a being used by the linker by default.
- -cc
-
Causes tcc to invoke cc(1) for its code production, using the C to TDF producer as a checking front-end to cc(1). This allows the checking capabilities of the front-end of the TDF compiler to be exploited on machines where no TDF back-end is available.
- -cc_only
-
Causes tcc to invoke cc(1) only.
- -ch
-
Causes tcc to operate as a stand-alone static checker. Intermodular checks are enabled in this mode.
- -dn
- -dy
-
Passed to the system linker.
- -doletter file
-
Sets the name of the default output file of type letter to file. For example, -doh can be used to set the name of the preserved start-up file.
- -dry
-
Makes tcc print information on what system commands it would execute with the given files and options (as in verbose mode) but not actually perform them.
- -dump
-
Causes tcc to dump its current status. This option is only used during the actual compilation of tcc.
- -efile
-
Is equivalent to inserting the preprocessor directive
#include "file"at the end of each C source file. - -ffile
-
Is equivalent to inserting the preprocessor directive
#include "file"at the start of each C source file. - -g
-
Tells tcc to produce diagnostic information compatible with the system debugger.
- -hstr
-
Passed to the system linker.
- -im
-
Enables intermodular checks.
- -im0
-
Disables intermodular checks.
- -info
-
Causes tcc to print information on the current API.
- -jstr
-
Tells the TDF linker to use the TDF library str.tl.
- -keep_errors
-
By default, if an error occurs during the production of a file, tcc will remove it. This option will preserve such files.
- -lstr
-
Tells the system linker to use the library libstr.a.
- -make_up_names
-
Causes tcc to make up names for all intermediate files rather than forming them from the basenames of the input files.
- -message str
-
Causes tcc to print the message str.
- -nepc
-
Tells the C to TDF producer to allow certain non-portable constructs through.
- -not_ansi
-
Tells the C to TDF producer to allow certain non-ANSI features through.
- -no_startup_options
-
Ensures that no start-up or end-up options are passed to the C to TDF producer (unlikely to be useful).
- -o file
-
If a final executable is produced, call it file (the default is a.out). Otherwise, if only one file is preserved, call it file.
- -p
-
Produces profiling data for use with prof/gprof(1) on those machines for which this command is available.
- -q
- -quiet
-
Specifies that tcc should work silently. This is the default.
- -query
-
Causes tcc to print a list of all the options it recognises, together with a brief description of each. Since this list is automatically generated it is likely to be more accurate than this manual page.
- -s
-
Passed to the system linker.
- -sletter:suffix
-
Specifies that files with suffix suffix are interpreted as having type indicated by letter.
- -show_errors
-
Makes tcc report on the command it was executing when an error occurred.
- -special str
-
Allows various internal options to be specified.
- -startup str
-
Causes str to be printed to the tcc built-in start-up file.
- -sym
- -sym: str
-
Enables dump-linking (with mode specified by options in str, if present).
- -target str
-
No effect (allowed for compatibility with cc(1) on some systems).
- -temp dir
-
Specifies that tcc should use dir as its temporary directory.
- -tidy
-
Causes tcc to remove its intermediate files when they are no longer required rather than waiting to the end of the compilation.
- -ustr
-
Passed to the system linker.
- -v
- -verbose
-
Specifies that tcc should work in verbose mode, sending information on what system commands it is executing to the standard output.
- -vb
-
Causes the name of each input file to be printed as it is processed.
- -vd
-
Causes a dump of the environment information tcc got hold of.
- -ve
-
Causes verbose information about tool chain environment to be printed.
- -vt
-
Causes verbose information about tool chain invocation to be printed.
- -version
-
Makes tcc report its version number.
- -w
-
Suppresses all tcc warning messages.
- -work dir
-
Specifies that all preserved intermediate files are placed in the directory dir rather than where they are placed by default, in the current working directory.
- -wsl
-
Tells the TDF translator to make all string literals writable.
- -zstr
-
Passed to the system linker.
Files
- file.c
-
C source file
- file.i
-
Preprocessed C source file
- file.C
-
C++ source file (only if -Yc++ is specified)
- file.I
-
Preprocessed C++ source file (only if -Yc++ is specified)
- file.j
-
Target independent TDF capsule
- file.t
-
Target dependent TDF capsule
- file.s
-
Assembly source file
- file.o
-
Binary object file
- file.d
-
TenDRA dump file
- file.K
-
C++ spec file (only if -Yc++ is specified)
- file.p
-
Pretty-printed TDF capsule
- file.tpl
-
PL_TDF source file (only if -Ypl_tdf is specified)
- file.ta
-
TDF archive
- file.G
-
Binasm source file (Mips and Alpha only)
- file.T
-
Assembler symbol table (Mips and Alpha only)
- a.out
-
Default executable name
- a.ta
-
Default TDF archive name
- a.d
-
Default dump file name
- a.api
-
Default API usage analysis file name
- a.j
-
Default output file for merge-TDF-capsules option
- tcc_startup.h
-
Name of preserved tcc start-up file
- /tmp/tcc*
-
Temporary directory (this may be changed using the TMPDIR system variable, see tempnam(1)).
See Also
as(1), cc(1), ld(1), prof/gprof(1), disp, tdfc2, tcpplus, tld, trans, tccenv, tccmodes.