Tiny C Compiler

Last updated

Tiny C Compiler
Developer(s) Fabrice Bellard
Stable release
0.9.27 / 17 December 2017;5 years ago (2017-12-17)
Repository repo.or.cz/w/tinycc.git
Written in C and Assembly [ citation needed ]
Operating system Linux, Unix, Windows
PredecessorOTCC, Obfuscated Tiny C Compiler [1]
Type C compiler
License LGPLv2.1
Website www.tinycc.org

The Tiny C Compiler (a.k.a. TCC, tCc, or TinyCC) is an x86, X86-64 and ARM processor C compiler initially written 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 June 2005). TCC is distributed under the GNU Lesser General Public License.


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


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

Compiled program performance

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. 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). [5]

TCC performs 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.

Here are two benchmark examples:

  1. 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 MS Visual C++ program approximately 18% longer than the TCC compiled program.[ citation needed ]
  2. A test compared different C compilers by using them to compile the GNU C Compiler (GCC) itself, and then using the resulting compilers to compile GCC again. Compared to GCC 3.4.2, a TCC modified to compile GCC was able to compile the compiler ten times faster, but the resulting .exe it produced was 57% larger, and much slower, taking 2.2 times as long to compile GCC again. [6]

    The results were: Running cc1 (the GCC C compiler) on itself required 518 seconds when compiled using GCC 3.4.2, 545 seconds using Microsoft C compiler, and 1145 seconds using TCC. To create these compilers in the first place, GCC (3.4.2) took 744 seconds to compile the GCC compiler, whereas TCC took only 73 seconds. The level of optimization in each compiler was -O1 or similar.



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

At some time prior to 4 February 2012 Fabrice Bellard updated the project's official web page to report that he was no longer working on TCC. [15]

Since Bellard's departure from the project, various people and groups have distributed patches or maintained forks of TCC to build upon or fix issues with TCC. This includes Dave Dodge's collection of unofficial tcc patches, [16] Debian and kfreebsd downstream patches, [17] and grischka's gcc patches. [6] Grischka also set up a public Git repository for the project [18] that contains a mob branch [19] where numerous contributions, including a shared build, cross-compilers, and SELinux compatibility were added. Grischka's GIT repository later became the official TCC repository (linked to by Fabrice Bellard's Savannah project page [20] ).

Current status

As of December 2017 both the official TCC mailing list [21] and the official Git repository (as linked to by Fabrice Bellard's Savannah project page [22] ) show active discussion and development by many developers and interested users. In December 2017, grischka announced on the mailing list that TCC version 0.9.27 was released. [23]

See also

Related Research Articles

<span class="mw-page-title-main">GNU Compiler Collection</span> Free and open-source compiler for various programming languages

The GNU Compiler Collection (GCC) is an optimizing compiler produced by the GNU Project supporting various programming languages, hardware architectures and operating systems. The Free Software Foundation (FSF) distributes GCC as free software under the GNU General Public License. GCC is a key component of the GNU toolchain and the standard compiler for most projects related to GNU and the Linux kernel. With roughly 15 million lines of code in 2019, GCC is one of the biggest free programs in existence. It has played an important role in the growth of free software, as both a tool and an example.

<span class="mw-page-title-main">Linux distribution</span> Operating system based on the Linux kernel

A Linux distribution is an operating system made from a software collection that includes the Linux kernel, and often a package management system. Linux users usually obtain their operating system by downloading one of the Linux distributions, which are available for a wide variety of systems ranging from embedded devices and personal computers to powerful supercomputers.

<span class="mw-page-title-main">LLVM</span> Compiler backend for multiple programming languages

LLVM is a set of compiler and toolchain technologies that can be used to develop a frontend for any programming language and a backend for any instruction set architecture. LLVM is designed around a language-independent intermediate representation (IR) that serves as a portable, high-level assembly language that can be optimized with a variety of transformations over multiple passes. The name LLVM originally stood for Low Level Virtual Machine, though the project has expanded and the name is no longer officially an initialism.

Fabrice Bellard is a French computer programmer known for writing FFmpeg, QEMU, and the Tiny C Compiler. He developed Bellard's formula for calculating single digits of pi. In 2012, Bellard co-founded Amarisoft, a telecommunications company, with Franck Spinelli.

Technical variations of Linux distributions include support for different hardware devices and systems or software package configurations. Organizational differences may be motivated by historical reasons. Other criteria include security, including how quickly security upgrades are available; ease of package management; and number of packages available.

<span class="mw-page-title-main">QEMU</span> Free virtualization and emulation software

QEMU is a free and open-source emulator. It emulates a computer's processor through dynamic binary translation and provides a set of different hardware and device models for the machine, enabling it to run a variety of guest operating systems. It can interoperate with Kernel-based Virtual Machine (KVM) to run virtual machines at near-native speed. QEMU can also do emulation for user-level processes, allowing applications compiled for one architecture to run on another.

In C and related programming languages, long double refers to a floating-point data type that is often more precise than double precision though the language standard only requires it to be at least as precise as double. As with C's other floating-point types, it may not necessarily map to an IEEE format.

<span class="mw-page-title-main">Debian–Mozilla trademark dispute</span> Mozilla-derived software for Debian like Iceweasel, Iceowl, etc.

In 2006, a branding issue developed when Mike Connor, representing the Mozilla Corporation, requested that the Debian Project comply with Mozilla standards for use of the Thunderbird trademark when redistributing the Thunderbird software. At issue were modifications not approved by the Mozilla Foundation, when the name for the software remained the same.

LatticeMico32 is a 32-bit microprocessor reduced instruction set computer (RISC) soft core from Lattice Semiconductor optimized for field-programmable gate arrays (FPGAs). It uses a Harvard architecture, which means the instruction and data buses are separate. Bus arbitration logic can be used to combine the two buses, if desired.

<span class="mw-page-title-main">GNU IceCat</span> Firefox derivative recommending only free software

GNU IceCat, formerly known as GNU IceWeasel, is a completely free version of the Mozilla Firefox web browser distributed by the GNU Project. It is compatible with Linux, Windows, Android and macOS.

Clang is a compiler front end for the C, C++, Objective-C, and Objective-C++ programming languages, as well as the OpenMP, OpenCL, RenderScript, CUDA, SYCL, and HIP frameworks. It acts as a drop-in replacement for the GNU Compiler Collection (GCC), supporting most of its compilation flags and unofficial language extensions. It includes a static analyzer, and several code analysis tools.

Oracle Developer Studio, formerly named Oracle Solaris Studio, Sun Studio, Sun WorkShop, Forte Developer, and SunPro Compilers, is the Oracle Corporation's flagship software development product for the Solaris and Linux operating systems. It includes optimizing C, C++, and Fortran compilers, libraries, and performance analysis and debugging tools, for Solaris on SPARC and x86 platforms, and Linux on x86/x64 platforms, including multi-core systems.

<span class="mw-page-title-main">Linux kernel</span> Operating system kernel

The Linux kernel is a free and open-source, monolithic, modular, multitasking, Unix-like operating system kernel. It was originally written in 1991 by Linus Torvalds for his i386-based PC, and it was soon adopted as the kernel for the GNU operating system, which was written to be a free (libre) replacement for Unix.

<span class="mw-page-title-main">Linux-libre</span> Version of the Linux kernel without proprietary code

Linux-libre is a modified version of the Linux kernel that contains no binary blobs, obfuscated code, or code released under proprietary licenses. In the Linux kernel, they are mostly used for proprietary firmware images. While generally redistributable, binary blobs do not give the user the freedom to audit, modify, or, consequently, redistribute their modified versions. The GNU Project keeps Linux-libre in synchronization with the mainline Linux kernel.

<span class="mw-page-title-main">GNU Guix</span> Purely functional package manager for the GNU system

GNU Guix is a functional cross-platform package manager and a tool to instantiate and manage Unix-like operating systems, based on the Nix package manager. Configuration and package recipes are written in Guile Scheme. GNU Guix is the default package manager of the GNU Guix System distribution.

Mingw-w64 is a free and open source software development environment to create (cross-compile) Microsoft Windows PE applications. It was forked in 2005–2010 from MinGW.

Intel MPX are discontinued set of extensions to the x86 instruction set architecture. With compiler, runtime library and operating system support, Intel MPX claimed to enhance security to software by checking pointer references whose normal compile-time intentions are maliciously exploited at runtime due to buffer overflows. In practice, there have been too many flaws discovered in the design for it to be useful, and support has been deprecated or removed from most compilers and operating systems. Intel has listed MPX as removed in 2019 and onward hardware in section 2.5 of its Intel® 64 and IA-32 Architectures Software Developer's Manual Volume 1.

Advanced Matrix Extensions (AMX), also known as Intel Advanced Matrix Extensions, are extensions to the x86 instruction set architecture (ISA) for microprocessors from Intel designed to work on matrices to accelerate artificial intelligence (AI) / machine learning (ML) -related workloads.

<span class="mw-page-title-main">GNU Guix System</span> Rolling release distribution of the GNU operating system built around the GNU Guix package manager

GNU Guix System or Guix System is a rolling release, free and open source Linux distribution built around the GNU Guix package manager. It enables a declarative operating system configuration and allows reliable system upgrades which the user can rollback. It uses the GNU Shepherd init system and the Linux-libre kernel, with support of the GNU Hurd kernel under development. On February 3, 2015, the Free Software Foundation added the distribution to its list of endorsed free Linux distributions. The Guix package manager and the Guix System drew inspiration from and were based on the Nix package manager and NixOS respectively.


  1. 1 2 3 Bellard, Fabrice. Obfuscated Tiny C Compiler, winning entry of IOCCC 2001. https://bellard.org/otcc/ and at the Internet Archive at https://web.archive.org/web/20130721162702/http://www.ioccc.org/2001/
  2. Tiny C Compiler Reference Documentation accessed on 2008-08-07
  3. 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
  4. "TCC : Tiny C Compiler". bellard.org. Retrieved 27 March 2023.
  5. Glöckner, Daniel. Re: Tinycc-devel (no subject), 8 September 2006.
  6. 1 2 grischka, GCC by TCC (some fixes), 29 September 2005
  7. "TCCBOOT: TinyCC Boot Loader". bellard.org. Retrieved 27 March 2023.
  8. "tinycc-devel (thread)". lists.gnu.org. Retrieved 27 March 2023.
  9. Wheeler, David A. Countering Trusting Trust through Diverse Double-Compiling . ACSAC.
  10. "Guix Further Reduces Bootstrap Seed to 25% — 2020 — Blog — GNU Guix".
  11. "Bootstrappable builds". bootstrappable.org. Retrieved 29 March 2023.
  12. "Cinpy". Archived from the original on 20 November 2008. Retrieved 27 March 2023.
  13. "JSLinux". bellard.org. Retrieved 27 March 2023.
  14. "Super Micro Chess". SourceForge. Retrieved 27 March 2023.
  15. "TCC : Tiny C Compiler". 4 February 2012. Archived from the original on 4 February 2012. Retrieved 27 March 2023.
  16. "Unofficial tcc Patches". www.dododge.net. Archived from the original on 31 March 2007. Retrieved 27 March 2023.
  17. "Debian -- Details of package tcc in sid". packages.debian.org. Retrieved 27 March 2023.
  18. grischka, Public Git Hosting for tcc
  19. grischka, mob branch for tcc
  20. "Tiny C Compiler - Summary [Savannah]". savannah.nongnu.org. Retrieved 27 March 2023.
  21. "tinycc-devel Archives". lists.gnu.org. Retrieved 27 March 2023.
  22. "Public Git Hosting - tinycc.git/summary". repo.or.cz. Retrieved 27 March 2023.
  23. "[Tinycc-devel] TCC version 0.9.27 is out". lists.nongnu.org. Retrieved 27 March 2023.