World Library  
Flag as Inappropriate
Email this Article

Tiny C Compiler

Tiny C Compiler
Developer(s) Fabrice Bellard
Stable release 0.9.26 / February 15, 2013 (2013-02-15)
Written in C and Assembly
Operating system Linux, Unix, Windows
Type C compiler
License GNU Lesser General Public License
Website //tcc.orgbellard

The Tiny C Compiler (aka TCC, tCc, or TinyCC) is an x86 and ARM processor C compiler created by Fabrice Bellard. It is designed to work for slow computers with little disk space (e.g. on rescue disks). Windows operating system support was added in version 0.9.23 (17 Jun 2005). TCC is distributed under the GNU Lesser General Public License (LGPL).

TCC claims to implement all of ANSI C (C89/C90),[1] much of the C99 ISO standard,[2] and many GNU C extensions including inline assembly.


  • Features 1
  • Compiled program performance 2
  • Uses 3
  • History 4
  • Current status 5
  • See also 6
  • References 7
  • External links 8


TCC has a number of features which differentiate it from other current C compilers:

  • Its small file size (about 100 KB for the x86 TCC executable) and memory footprint allow it to be used directly from a single 1.44 M floppy disk, such as a rescue disk.
  • TCC is intended to produce native x86, x86-64 and ARM code very quickly; according to Bellard, it compiles, assembles and links about nine times faster than GCC does.[3]
  • TCC has a number of compiler-specific language features intended to improve its practicality, such as an optional memory and bound checker, for improved code stability.
  • TCC allows programs to be run automatically at compile time using a command-line switch. This allows programs to be run as a shell script under Unix-like systems which support the shebang interpreter directive syntax.

Compiled program performance

Although the TCC compiler itself is exceptionally fast, there is an inherent trade off between this size of the compiler and the performance of the code which TCC produces.

TCC does perform a few optimizations, such as constant propagation for all operations, multiplications and divisions are optimized to shifts when appropriate, and comparison operators are specially optimized (by maintaining a special cache for the processor flags). It also does some simple register allocation, which prevents many extraneous save/load pairs inside a single statement.

But in general, TCC's implementation emphasizes smallness instead of optimally-performing results. TCC generates code in a single pass, and does not perform most of the optimizations performed by other compilers such as GCC. TCC compiles every statement on its own, and at the end of each statement register values are written back to the stack and must be re-read even if the next line uses the values in registers (creating extraneous save/load pairs between statements). TCC uses only some of the available registers (e.g., on x86 it never uses ebx, esi, or edi because they need to be preserved across function calls).[4]

Here are two benchmark examples:

  • Rough benchmarks of a recursive Fibonacci algorithm on a 1.8 GHz Intel Centrino laptop with 512 MB RAM yields a noticeable difference in results between Microsoft Visual C++ compiler 13.10.3052 and TCC. To calculate the 49th Fibonacci number, it took a TCC-compiled program approximately 18% longer than the MS Visual C++ compiled program.
  • With a tcc modified to compile GCC, running cc1 (the GCC C compiler) on itself required 518 seconds when compiled using GCC 3.4.2, 558 seconds using GCC 2.95.3, 545 using Microsoft C compiler, and 1145 seconds using tcc. The level of optimization in each compiler was -O1 or similar.[5]


Well-known uses of tcc include:

  • TCCBOOT,[6] a hack where TCC loads and boots a Linux kernel from source in about 10 seconds. That is to say, it is a "boot loader" which reads Linux kernel source code from disk, writes executable instructions to memory, and begins running it. This did require changes to the Linux build process.
  • TCC was used to demonstrate a defense against the trust attack.[7]
  • TCC has been used to compile GCC, though various patches were required to make this work.[8]
  • Cinpy[9] is a Python library that allows you to implement functions with C in Python modules. The functions are compiled with TCC at runtime. The results are made callable in Python through the ctypes library.
  • Comes installed on JavaScript Linux[10] (also by Bellard).
  • Has been used as a reference for the compiled version of the super micro-max chess program source.[11]


TCC has its origins in the Obfuscated Tiny C Compiler (OTCC), a program Bellard wrote to win the International Obfuscated C Code Contest (IOCCC) in 2001. Since that time, Bellard expanded and un-obfuscated the program to produce tcc.[12]

Current status

TCC has an active mailing list, and Fabrice Bellard's current version is available through Git. However, official tcc development slowed due to Bellard's work on other projects.[3]

Rob Landley created a fork of tcc[13] that incorporated various patches from others, using the Mercurial SCM; Landley's Mercurial branch[14] showed its current status while the project was active. The project was discontinued on October 4, 2007 and recontinued as a fork on October 27, 2007 [13] then discontinued again[15] on September 5, 2008. Since then, TCC has received two updates; one on 20 May 2009, and 15 Feb 2013.

Various others have distributed patches or download sites of various improved versions of tcc, such as Dave Dodge's collection of unofficial tcc patches,[16] Debian and kfreebsd downstream patches,[17] and grischka's gcc patches.[5] grischka's Public Git Hosting [18] contains a mob branch[19] with recent contributions, including a shared build, cross-compilers, and SELinux compatibility.

See also


  1. ^ Tiny C Compiler Reference Documentation accessed on 2008-08-07
  2. ^ According to the project's TODO list complex types are the only missing C99 feature. Variable Length Arrays have been added in TCC 0.9.26
  3. ^ a b Tiny C Compiler homepage
  4. ^ Glöckner, Daniel. Re: Tinycc-devel (no subject), September 8, 2006.
  5. ^ a b grischka, GCC by TCC (some fixes), 29 Sep 2005
  6. ^ TCCBOOT
  7. ^ Wheeler, David A. Countering Trusting Trust through Diverse Double-Compiling. ACSAC.
  8. ^ tinycc-devel (thread)
  9. ^ Cinpy
  10. ^ JavaScript Linux
  11. ^ Super Micro-Max Chess Engine
  12. ^ Bellard, Fabrice. Obfuscated Tiny C Compiler
  13. ^ a b Rob Landley's TCC fork that went inactive
  14. ^ Landley's Mercurial branch
  15. ^ tinycc-devel (message)
  16. ^ Dave Dodge's collection of unofficial tcc patches
  17. ^ Debian and kfreebsd downstream patches
  18. ^ grischka, Public Git Hosting for tcc
  19. ^ grischka, mob branch for tcc

External links

  • Official website
  • TCC's active mailing list
  • Source code repository
This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.

Copyright © World Library Foundation. All rights reserved. eBooks from Project Gutenberg are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.