.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.45) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Required to disable full justification in groff 1.23.0. .if n .ds AD l .\" ======================================================================== .\" .IX Title "TCC-DOC 1" .TH TCC-DOC 1 2026-02-02 0.9.28rc "Tiny C Compiler" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME tcc \- Tiny C Compiler .SH SYNOPSIS .IX Header "SYNOPSIS" usage: tcc [options] [\fIinfile1\fR \fIinfile2\fR...] [\fB\-run\fR \fIinfile\fR \fIargs\fR...] .SH DESCRIPTION .IX Header "DESCRIPTION" TCC options are very much like gcc options. The main difference is that TCC can also execute directly the resulting program and give it runtime arguments. .PP Here are some examples to understand the logic: .ie n .IP """\fBtcc \-run a.c\fR""" 4 .el .IP "\f(CW\fR\f(CBtcc \-run a.c\fR\f(CW\fR" 4 .IX Item "tcc -run a.c" Compile \fIa.c\fR and execute it directly .ie n .IP """\fBtcc \-run a.c arg1\fR""" 4 .el .IP "\f(CW\fR\f(CBtcc \-run a.c arg1\fR\f(CW\fR" 4 .IX Item "tcc -run a.c arg1" Compile a.c and execute it directly. arg1 is given as first argument to the \f(CWmain()\fR of a.c. .ie n .IP """\fBtcc a.c \-run b.c arg1\fR""" 4 .el .IP "\f(CW\fR\f(CBtcc a.c \-run b.c arg1\fR\f(CW\fR" 4 .IX Item "tcc a.c -run b.c arg1" Compile \fIa.c\fR and \fIb.c\fR, link them together and execute them. arg1 is given as first argument to the \f(CWmain()\fR of the resulting program. .ie n .IP """\fBtcc \-o myprog a.c b.c\fR""" 4 .el .IP "\f(CW\fR\f(CBtcc \-o myprog a.c b.c\fR\f(CW\fR" 4 .IX Item "tcc -o myprog a.c b.c" Compile \fIa.c\fR and \fIb.c\fR, link them and generate the executable \fImyprog\fR. .ie n .IP """\fBtcc \-o myprog a.o b.o\fR""" 4 .el .IP "\f(CW\fR\f(CBtcc \-o myprog a.o b.o\fR\f(CW\fR" 4 .IX Item "tcc -o myprog a.o b.o" link \fIa.o\fR and \fIb.o\fR together and generate the executable \fImyprog\fR. .ie n .IP """\fBtcc \-c a.c\fR""" 4 .el .IP "\f(CW\fR\f(CBtcc \-c a.c\fR\f(CW\fR" 4 .IX Item "tcc -c a.c" Compile \fIa.c\fR and generate object file \fIa.o\fR. .ie n .IP """\fBtcc \-c asmfile.S\fR""" 4 .el .IP "\f(CW\fR\f(CBtcc \-c asmfile.S\fR\f(CW\fR" 4 .IX Item "tcc -c asmfile.S" Preprocess with C preprocess and assemble \fIasmfile.S\fR and generate object file \fIasmfile.o\fR. .ie n .IP """\fBtcc \-c asmfile.s\fR""" 4 .el .IP "\f(CW\fR\f(CBtcc \-c asmfile.s\fR\f(CW\fR" 4 .IX Item "tcc -c asmfile.s" Assemble (but not preprocess) \fIasmfile.s\fR and generate object file \&\fIasmfile.o\fR. .ie n .IP """\fBtcc \-r \-o ab.o a.c b.c\fR""" 4 .el .IP "\f(CW\fR\f(CBtcc \-r \-o ab.o a.c b.c\fR\f(CW\fR" 4 .IX Item "tcc -r -o ab.o a.c b.c" Compile \fIa.c\fR and \fIb.c\fR, link them together and generate the object file \fIab.o\fR. .PP Scripting: .PP TCC can be invoked from \fIscripts\fR, just as shell scripts. You just need to add \f(CW\*(C`#!/usr/local/bin/tcc \-run\*(C'\fR at the start of your C source: .PP .Vb 2 \& #!/usr/local/bin/tcc \-run \& #include \& \& int main() \& { \& printf("Hello World\en"); \& return 0; \& } .Ve .PP TCC can read C source code from \fIstandard input\fR when \fB\-\fR is used in place of \fBinfile\fR. Example: .PP .Vb 1 \& echo \*(Aqmain(){puts("hello");}\*(Aq | tcc \-run \- .Ve .SH OPTIONS .IX Header "OPTIONS" .IP \fB\-c\fR 4 .IX Item "-c" Generate an object file. .IP "\fB\-o outfile\fR" 4 .IX Item "-o outfile" Put object file, executable, or dll into output file \fIoutfile\fR. .IP "\fB\-run source [args...]\fR" 4 .IX Item "-run source [args...]" Compile file \fIsource\fR and run it with the command line arguments \&\fIargs\fR. In order to be able to give more than one argument to a script, several TCC options can be given \fIafter\fR the \&\fB\-run\fR option, separated by spaces: .Sp .Vb 1 \& tcc "\-run \-L/usr/X11R6/lib \-lX11" ex4.c .Ve .Sp In a script, it gives the following header: .Sp .Vb 1 \& #!/usr/local/bin/tcc \-run \-L/usr/X11R6/lib \-lX11 .Ve .IP \fB\-v\fR 4 .IX Item "-v" Display TCC version. .IP \fB\-vv\fR 4 .IX Item "-vv" Show included files. As sole argument, print search dirs. \-vvv shows tries too. .IP \fB\-bench\fR 4 .IX Item "-bench" Display compilation statistics. .PP Preprocessor options: .IP \fB\-Idir\fR 4 .IX Item "-Idir" Specify an additional include path. Include paths are searched in the order they are specified. .Sp System include paths are always searched after. The default system include paths are: \fI/usr/local/include\fR, \fI/usr/include\fR and \fIPREFIX/lib/tcc/include\fR. (\fIPREFIX\fR is usually \&\fI/usr\fR or \fI/usr/local\fR). .IP "\fB\-isystem dir\fR" 4 .IX Item "-isystem dir" Specify a system include path to be added to the defaults. .IP \fB\-nostdinc\fR 4 .IX Item "-nostdinc" Do not search the default system include paths; only search include paths provided on the command line. .IP "\fB\-include file\fR" 4 .IX Item "-include file" Include \fBfile\fR above each input file. .IP \fB\-Dsym[=val]\fR 4 .IX Item "-Dsym[=val]" Define preprocessor symbol \fBsym\fR to val. If val is not present, its value is \fB1\fR. Function\-like macros can also be defined: \fB\-DF(a)=a+1\fR .IP \fB\-Usym\fR 4 .IX Item "-Usym" Undefine preprocessor symbol \fBsym\fR. .IP \fB\-E\fR 4 .IX Item "-E" Preprocess only, to stdout or file (with \-o). .IP \fB\-P\fR 4 .IX Item "-P" Do not output \f(CW\*(C`#line\*(C'\fR directives. .IP \fB\-P1\fR 4 .IX Item "-P1" Output alternative \f(CW\*(C`#line\*(C'\fR directives. .IP "\fB\-dD, \-dM\fR" 4 .IX Item "-dD, -dM" Output \f(CW\*(C`#define\*(C'\fR directives. .IP \fB\-Wp,\-opt\fR 4 .IX Item "-Wp,-opt" Same as \fB\-opt\fR. .PP Compilation flags: .PP Note: each of the following options has a negative form beginning with \&\fB\-fno\-\fR. .IP \fB\-funsigned\-char\fR 4 .IX Item "-funsigned-char" Let the \f(CW\*(C`char\*(C'\fR type be unsigned. .IP \fB\-fsigned\-char\fR 4 .IX Item "-fsigned-char" Let the \f(CW\*(C`char\*(C'\fR type be signed. .IP \fB\-fno\-common\fR 4 .IX Item "-fno-common" Do not generate common symbols for uninitialized data. .IP \fB\-fleading\-underscore\fR 4 .IX Item "-fleading-underscore" Add a leading underscore at the beginning of each C symbol. .IP \fB\-fms\-extensions\fR 4 .IX Item "-fms-extensions" Allow a MS C compiler extensions to the language. Currently this assumes a nested named structure declaration without an identifier behaves like an unnamed one. .IP \fB\-fdollars\-in\-identifiers\fR 4 .IX Item "-fdollars-in-identifiers" Allow dollar signs in identifiers .IP \fB\-freverse\-funcargs\fR 4 .IX Item "-freverse-funcargs" Evaluate function arguments right to left. .IP \fB\-fgnu89\-inline\fR 4 .IX Item "-fgnu89-inline" \&\f(CW\*(C`extern inline\*(C'\fR is like \f(CW\*(C`static inline\*(C'\fR. .IP \fB\-fasynchronous\-unwind\-tables\fR 4 .IX Item "-fasynchronous-unwind-tables" Create eh_frame section [on] .IP \fB\-ftest\-coverage\fR 4 .IX Item "-ftest-coverage" Create code coverage code. After running the resulting code an executable.tcov or sofile.tcov file is generated with code coverage. .PP Warning options: .IP \fB\-w\fR 4 .IX Item "-w" Disable all warnings. .PP Note: each of the following warning options has a negative form beginning with \&\fB\-Wno\-\fR. .IP \fB\-Wimplicit\-function\-declaration\fR 4 .IX Item "-Wimplicit-function-declaration" Warn about implicit function declaration (missing prototype). .IP \fB\-Wdiscarded\-qualifiers\fR 4 .IX Item "-Wdiscarded-qualifiers" Warn when const is dropped. .IP \fB\-Wunsupported\fR 4 .IX Item "-Wunsupported" Warn about unsupported GCC features that are ignored by TCC. .IP \fB\-Wwrite\-strings\fR 4 .IX Item "-Wwrite-strings" Make string constants be of type \f(CW\*(C`const char *\*(C'\fR instead of \f(CW\*(C`char *\*(C'\fR. .IP \fB\-Werror\fR 4 .IX Item "-Werror" Abort compilation if a warning is issued. Can be given an option to enable the specified warning and turn it into an error, for example \&\fB\-Werror=unsupported\fR. .IP \fB\-Wall\fR 4 .IX Item "-Wall" Activate some useful warnings (\fB\-Wimplicit\-function\-declaration\fR, \&\fB\-Wdiscard\-qualifiers\fR). .PP Linker options: .IP \fB\-Ldir\fR 4 .IX Item "-Ldir" Specify an additional static library path for the \fB\-l\fR option. The default library paths are \fI/usr/local/lib\fR, \fI/usr/lib\fR and \fI/lib\fR. .IP \fB\-lxxx\fR 4 .IX Item "-lxxx" Link your program with dynamic library libxxx.so or static library libxxx.a. The library is searched in the paths specified by the \&\fB\-L\fR option and \fBLIBRARY_PATH\fR variable. .IP \fB\-Bdir\fR 4 .IX Item "-Bdir" Set the path where the tcc internal libraries (and include files) can be found (default is \fIPREFIX/lib/tcc\fR). .IP \fB\-shared\fR 4 .IX Item "-shared" Generate a shared library instead of an executable. .IP "\fB\-soname name\fR" 4 .IX Item "-soname name" set name for shared library to be used at runtime .IP \fB\-static\fR 4 .IX Item "-static" Generate a statically linked executable (default is a shared linked executable). .IP \fB\-rdynamic\fR 4 .IX Item "-rdynamic" Export global symbols to the dynamic linker. It is useful when a library opened with \f(CWdlopen()\fR needs to access executable symbols. .IP \fB\-r\fR 4 .IX Item "-r" Generate an object file combining all input files. .IP \fB\-nostdlib\fR 4 .IX Item "-nostdlib" Don\*(Aqt implicitly link with libc, the C runtime files, and libtcc1. .IP \fB\-Wl,\-nostdlib\fR 4 .IX Item "-Wl,-nostdlib" Don\*(Aqt search the default paths for libraries (\fI/usr/local/lib\fR, \&\fI/usr/lib\fR and \fI/lib\fR). Only the paths specified with \fB\-L\fR and \fBLIBRARY_PATH\fR are searched. .IP \fB\-Wl,\-rpath=path\fR 4 .IX Item "-Wl,-rpath=path" Put custom search path for dynamic libraries into executable. .IP \fB\-Wl,\-Ipath\fR 4 .IX Item "-Wl,-Ipath" .PD 0 .IP \fB\-Wl,\-\-dynamic\-linker=path\fR 4 .IX Item "-Wl,--dynamic-linker=path" .PD Set the ELF interpreter (dynamic linker). This defaults to the value of the environment variable \fBLD_SO\fR if set, or a compiled\-in default. .IP \fB\-Wl,\-\-enable\-new\-dtags\fR 4 .IX Item "-Wl,--enable-new-dtags" When putting a custom search path for dynamic libraries into the executable, create the new ELF dynamic tag DT_RUNPATH instead of the old legacy DT_RPATH. .IP \fB\-Wl,\-\-oformat=fmt\fR 4 .IX Item "-Wl,--oformat=fmt" Use \fIfmt\fR as output format. The supported output formats are: .RS 4 .ie n .IP """elf32\-i386""" 4 .el .IP \f(CWelf32\-i386\fR 4 .IX Item "elf32-i386" ELF output format (default) .ie n .IP """binary""" 4 .el .IP \f(CWbinary\fR 4 .IX Item "binary" Binary image (only for executable output) .ie n .IP """coff""" 4 .el .IP \f(CWcoff\fR 4 .IX Item "coff" COFF output format (only for executable output for TMS320C67xx target) .RE .RS 4 .RE .IP \fB\-Wl,\-\-export\-all\-symbols\fR 4 .IX Item "-Wl,--export-all-symbols" .PD 0 .IP \fB\-Wl,\-\-export\-dynamic\fR 4 .IX Item "-Wl,--export-dynamic" .PD Export global symbols to the dynamic linker. It is useful when a library opened with \f(CWdlopen()\fR needs to access executable symbols. .IP \fB\-Wl,\-subsystem=console/gui/wince/...\fR 4 .IX Item "-Wl,-subsystem=console/gui/wince/..." Set type for PE (Windows) executables. .IP "\fB\-Wl,\-[Ttext=# | section\-alignment=# | file\-alignment=# | image\-base=# | stack=#]\fR" 4 .IX Item "-Wl,-[Ttext=# | section-alignment=# | file-alignment=# | image-base=# | stack=#]" Modify executable layout. .IP \fB\-Wl,\-Bsymbolic\fR 4 .IX Item "-Wl,-Bsymbolic" Set DT_SYMBOLIC tag. .IP \fB\-Wl,\-(no\-)whole\-archive\fR 4 .IX Item "-Wl,-(no-)whole-archive" Turn on/off linking of all objects in archives. .PP Debugger options: .IP \fB\-g\fR 4 .IX Item "-g" Generate run time stab debug information so that you get clear run time error messages: \f(CW\*(C` test.c:68: in function \*(Aqtest5()\*(Aq: dereferencing invalid pointer\*(C'\fR instead of the laconic \f(CW\*(C`Segmentation fault\*(C'\fR. .IP \fB\-gdwarf[\-x]\fR 4 .IX Item "-gdwarf[-x]" Generate run time dwarf debug information instead of stab debug information. .IP \fB\-b\fR 4 .IX Item "-b" Generate additional support code to check memory allocations and array/pointer bounds. \fB\-g\fR is implied. .IP \fB\-bt[N]\fR 4 .IX Item "-bt[N]" Display N callers in stack traces. This is useful with \fB\-g\fR or \fB\-b\fR. When activated, \f(CW\*(C`_\|_TCC_BACKTRACE_\|_\*(C'\fR is defined. .Sp With executables, additional support for stack traces is included. A function \f(CW\*(C` int tcc_backtrace(const char *fmt, ...); \*(C'\fR is provided to trigger a stack trace with a message on demand. .PP Misc options: .IP \fB\-std=version\fR 4 .IX Item "-std=version" Define \f(CW\*(C`_\|_STDC_VERSION_\|_\*(C'\fR: \f(CW201112\fR if \fBversion\fR is c11 or gnu11; \f(CW199901\fR otherwise. .IP \fB\-x[c|a|b|n]\fR 4 .IX Item "-x[c|a|b|n]" Specify content of next input file: respectively C, assembly, binary, or none. .IP \fB\-O[n]\fR 4 .IX Item "-O[n]" Same as \fB\-D_\|_OPTIMIZE_\|_\fR except for \-O0. .IP \fB\-pthread\fR 4 .IX Item "-pthread" Preprocess with \fB\-D_REENTRANT\fR, link with \fB\-lpthread\fR. .IP \fB\-M\fR 4 .IX Item "-M" Just output makefile fragment with dependencies .IP \fB\-MM\fR 4 .IX Item "-MM" Like \-M except mention only user header files, not system header files. .IP \fB\-MD\fR 4 .IX Item "-MD" Generate makefile fragment with dependencies. .IP \fB\-MMD\fR 4 .IX Item "-MMD" Like \-MD except mention only user header files, not system header files. .IP "\fB\-MF depfile\fR" 4 .IX Item "-MF depfile" Use \fIdepfile\fR as output for \-MD. .IP \fB\-MP\fR 4 .IX Item "-MP" Mention all dependencies as targets too. .IP \fB\-print\-search\-dirs\fR 4 .IX Item "-print-search-dirs" Print the configured installation directory and a list of library and include directories tcc will search. .IP \fB\-dumpversion\fR 4 .IX Item "-dumpversion" Print version. .IP \fB\-dt\fR 4 .IX Item "-dt" With \fB\-run\fR/\fB\-E\fR: auto\-define \*(Aqtest_...\*(Aq macros .PP Target specific options: .IP \fB\-mms\-bitfields\fR 4 .IX Item "-mms-bitfields" Use an algorithm for bitfield alignment consistent with MSVC. Default is gcc\*(Aqs algorithm. .IP "\fB\-mfloat\-abi (ARM only)\fR" 4 .IX Item "-mfloat-abi (ARM only)" Select the float ABI. Possible values: \f(CW\*(C`softfp\*(C'\fR and \f(CW\*(C`hard\*(C'\fR .IP \fB\-mno\-sse\fR 4 .IX Item "-mno-sse" Do not use sse registers on x86_64 .IP "\fB\-m32, \-m64\fR" 4 .IX Item "-m32, -m64" Pass command line to the i386/x86_64 cross compiler. .PP Note: GCC options \fB\-fx\fR and \fB\-mx\fR are ignored. .SH ENVIRONMENT .IX Header "ENVIRONMENT" Environment variables that affect how tcc operates. .IP \fBCPATH\fR 4 .IX Item "CPATH" .PD 0 .IP \fBC_INCLUDE_PATH\fR 4 .IX Item "C_INCLUDE_PATH" .PD A colon\-separated list of directories searched for include files, directories given with \fB\-I\fR are searched first. .IP \fBLIBRARY_PATH\fR 4 .IX Item "LIBRARY_PATH" A colon\-separated list of directories searched for libraries for the \&\fB\-l\fR option, directories given with \fB\-L\fR are searched first. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBcpp\fR\|(1), \&\fBgcc\fR\|(1) .SH AUTHOR .IX Header "AUTHOR" Fabrice Bellard