TCC-DOC(1)
π NAME π
Okay bestie, welcome to the TCC-DOC(1) manual β the whole vibe is tcc, aka the Tiny C Compiler. She's tiny, she's iconic, and she's about to make C feel a little more main-character. π
β¨ SYNOPSIS β¨
usage: tcc [options] [infile1 infile2...] [-run infile args...]
πΈ DESCRIPTION πΈ
TCC options are very much like gcc options β fr fr. The main difference? TCC can also execute directly the resulting program and give it runtime arguments. That's the plot twist, and it's honestly kind of iconic. β¨
Here are some examples to understand the logic:
tcc -run a.cβ Compilea.cand execute it directlytcc -run a.c arg1β Compilea.cand execute it directly.arg1is given as first argument to themain()ofa.c.tcc a.c -run b.c arg1β Compilea.candb.c, link them together and execute them.arg1is given as first argument to themain()of the resulting program.tcc -o myprog a.c b.cβ Compilea.candb.c, link them and generate the executablemyprog.tcc -o myprog a.o b.oβ linka.oandb.otogether and generate the executablemyprog.tcc -c a.cβ Compilea.cand generate object filea.o.tcc -c asmfile.Sβ Preprocess with C preprocess and assembleasmfile.Sand generate object fileasmfile.o.tcc -c asmfile.sβ Assemble (but not preprocess)asmfile.sand generate object fileasmfile.o.tcc -r -o ab.o a.c b.cβ Compilea.candb.c, link them together and generate the object fileab.o.
πͺ Scripting πͺ
TCC can be invoked from scripts, just as shell scripts. You just need to add #!/usr/local/bin/tcc -run at the start of your C source:
#!/usr/local/bin/tcc -run
#include <stdio.h>
int main()
{
printf("Hello World\n");
return 0;
}
TCC can read C source code from standard input when - is used in place of infile. Example:
echo 'main(){puts("hello");}' | tcc -run -
π OPTIONS π
-cβ Generate an object file.-ooutfile β Put object file, executable, or dll into output file outfile.-runsource[args...]β Compile file source and run it with the command line arguments args. In order to be able to give more than one argument to a script, several TCC options can be given after the-runoption, separated by spaces:
tcc "-run -L/usr/X11R6/lib -lX11" ex4.c
In a script, it gives the following header:
#!/usr/local/bin/tcc -run -L/usr/X11R6/lib -lX11
-vβ Display TCC version.-vvβ Show included files. As sole argument, print search dirs.-vvvshows tries too.-benchβ Display compilation statistics.
π§Ό Preprocessor options π§Ό
-Idirβ Specify an additional include path. Include paths are searched in the order they are specified.
System include paths are always searched after. The default system include paths are: /usr/local/include, /usr/include and PREFIX/lib/tcc/include. (PREFIX is usually /usr or /usr/local).
-isystemdir β Specify a system include path to be added to the defaults.-nostdincβ Do not search the default system include paths; only search include paths provided on the command line.-includefile β Include file above each input file.-Dsym[=val]β Define preprocessor symbol sym to val. If val is not present, its value is1. Function-like macros can also be defined:-DF(a)=a+1-Usymβ Undefine preprocessor symbol sym.-Eβ Preprocess only, to stdout or file (with-o).-Pβ Do not output"#line"directives.-P1β Output alternative"#line"directives.-dD,-dMβ Output"#define"directives.-Wp,-optβ Same as-opt.
π Compilation flags π
Note: each of the following options has a negative form beginning with -fno-.
-funsigned-charβ Let the"char"type be unsigned.-fsigned-charβ Let the"char"type be signed.-fno-commonβ Do not generate common symbols for uninitialized data.-fleading-underscoreβ Add a leading underscore at the beginning of each C symbol.-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.-fdollars-in-identifiersβ Allow dollar signs in identifiers-freverse-funcargsβ Evaluate function arguments right to left.-fgnu89-inlineβ"extern inline"is like"static inline".-fasynchronous-unwind-tablesβ Createeh_framesection[on]-ftest-coverageβ Create code coverage code. After running the resulting code anexecutable.tcovorsofile.tcovfile is generated with code coverage.
β οΈ Warning options β οΈ
-wβ Disable all warnings.
Note: each of the following warning options has a negative form beginning with -Wno-.
-Wimplicit-function-declarationβ Warn about implicit function declaration (missing prototype).-Wdiscarded-qualifiersβ Warn whenconstis dropped.-Wunsupportedβ Warn about unsupported GCC features that are ignored by TCC.-Wwrite-stringsβ Make string constants be of type"const char *"instead of"char *".-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-Werror=unsupported.-Wallβ Activate some useful warnings (-Wimplicit-function-declaration,-Wdiscard-qualifiers).
π Linker options π
-Ldirβ Specify an additional static library path for the-loption. The default library paths are/usr/local/lib,/usr/liband/lib.-lxxxβ Link your program with dynamic librarylibxxx.soor static librarylibxxx.a. The library is searched in the paths specified by the-Loption andLIBRARY_PATHvariable.-Bdirβ Set the path where the tcc internal libraries (and include files) can be found (default isPREFIX/lib/tcc).-sharedβ Generate a shared library instead of an executable.-sonamename β set name for shared library to be used at runtime-staticβ Generate a statically linked executable (default is a shared linked executable).-rdynamicβ Export global symbols to the dynamic linker. It is useful when a library opened withdlopen()needs to access executable symbols.-rβ Generate an object file combining all input files.-nostdlibβ Don't implicitly link with libc, the C runtime files, andlibtcc1.-Wl,-nostdlibβ Don't search the default paths for libraries (/usr/local/lib,/usr/liband/lib). Only the paths specified with-LandLIBRARY_PATHare searched.-Wl,-rpath=pathβ Put custom search path for dynamic libraries into executable.-Wl,-Ipath,-Wl,--dynamic-linker=pathβ Set the ELF interpreter (dynamic linker). This defaults to the value of the environment variableLD_SOif set, or a compiled-in default.-Wl,--enable-new-dtagsβ When putting a custom search path for dynamic libraries into the executable, create the new ELF dynamic tagDT_RUNPATHinstead of the old legacyDT_RPATH.-Wl,--oformat=fmtβ Use fmt as output format. The supported output formats are:"elf32-i386"β ELF output format (default)"binary"β Binary image (only for executable output)"coff"β COFF output format (only for executable output for TMS320C67xx target)
-Wl,--export-all-symbols,-Wl,--export-dynamicβ Export global symbols to the dynamic linker. It is useful when a library opened withdlopen()needs to access executable symbols.-Wl,-subsystem=console/gui/wince/...β Set type for PE (Windows) executables.-Wl,-[Ttext=# | section-alignment=# | file-alignment=# | image-base=# | stack=#]β Modify executable layout.-Wl,-Bsymbolicβ SetDT_SYMBOLICtag.-Wl,-(no-)whole-archiveβ Turn on/off linking of all objects in archives.
π Debugger options π
-gβ Generate run time stab debug information so that you get clear run time error messages:test.c:68: in function 'test5()': dereferencing invalid pointerinstead of the laconicSegmentation fault.-gdwarf[-x]β Generate run time dwarf debug information instead of stab debug information.-bβ Generate additional support code to check memory allocations and array/pointer bounds.-gis implied.-bt[N]β DisplayNcallers in stack traces. This is useful with-gor-b. When activated,"__TCC_BACKTRACE__"is defined.
With executables, additional support for stack traces is included. A function
int tcc_backtrace(const char *fmt, ...);
is provided to trigger a stack trace with a message on demand.
π§ Misc options π§
-std=versionβ Define"__STDC_VERSION__":201112if version isc11orgnu11;199901otherwise.-x[c|a|b|n]β Specify content of next input file: respectively C, assembly, binary, or none.-O[n]β Same as-D__OPTIMIZE__except for-O0.-pthreadβ Preprocess with-D_REENTRANT, link with-lpthread.-Mβ Just output makefile fragment with dependencies-MMβ Like-Mexcept mention only user header files, not system header files.-MDβ Generate makefile fragment with dependencies.-MMDβ Like-MDexcept mention only user header files, not system header files.-MFdepfile β Use depfile as output for-MD.-MPβ Mention all dependencies as targets too.-print-search-dirsβ Print the configured installation directory and a list of library and include directories tcc will search.-dumpversionβ Print version.-dtβ With-run/-E: auto-define'test_...'macros
π― Target specific options π―
-mms-bitfieldsβ Use an algorithm for bitfield alignment consistent with MSVC. Default is gcc's algorithm.-mfloat-abi(ARM only) β Select the float ABI. Possible values:"softfp"and"hard"-mno-sseβ Do not use sse registers on x86_64-m32,-m64β Pass command line to the i386/x86_64 cross compiler.
Note: GCC options -fx and -mx are ignored.
π ENVIRONMENT π
Environment variables that affect how tcc operates.
CPATH,C_INCLUDE_PATHβ A colon-separated list of directories searched for include files, directories given with-Iare searched first.LIBRARY_PATHβ A colon-separated list of directories searched for libraries for the-loption, directories given with-Lare searched first.
π SEE ALSO π
π AUTHOR π
Fabrice Bellard
Okay, this page is from the TCC-DOC(1) manual, version 0.9.28rc, dated 2026-02-02 πβ¨π«Ά
π¦ where this page comes from
- arch rolling: tcc 0.9.27.r1337.gb39cbc70-1 Β· LGPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms