CLI tool
TinyCC/tinycc avatar
TinyCC/tinycc

TinyCC: The Compact C Compiler That Runs C Source Directly

Unofficial mirror of mob development branch

3,041 stars567 forksCLGPL-2.1

At a glance

What is it?
TinyCC is a minimal ANSI C compiler that covers i386, x86-64, ARM, AArch64, and RISC-V 64-bit targets, built for speed and small footprint. It compiles C source without a separate link step, and supports treating C files as directly executable scripts.
Who is it for?
Engineers who need a fast compile loop for test harnesses, rescue disk utilities, or embedded tooling where binary size matters will get genuine value from TinyCC. The scripting mode is a practical option for C programs that replace shell scripts.
Can I use it commercially?
Yes, with conditions. LGPL-2.1 is a weak copyleft licence: you can use it inside commercial and closed-source software, but if you distribute changes to its own files, you must publish those changes under the same licence.
Is it still maintained?
Yes. The repository last received commits 4 days ago.
What is it written in?
Mainly C, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 30, 2026, and from our analysis. They are not legal advice.

Editorial analysis

What TinyCC Solves and Who It Is For

TinyCC is a C compiler created by Fabrice Bellard with one central design constraint: stay small enough to run on a rescue disk while still compiling real ANSI C programs. It generates machine code for i386, x86-64, ARM (32-bit), AArch64, and RISC-V 64-bit targets, and can link against any C dynamic library directly.

The primary audience is engineers who need fast iteration on C code without the startup overhead of a full optimizing compiler, systems programmers building utilities for constrained environments, and anyone who wants to run C files like shell scripts. TinyCC is not a drop-in replacement for production builds, but it closes the gap between writing a C function and seeing it execute.

Compilation Speed and Direct Execution

The README states that TinyCC compiles and links about 10 times faster than gcc -O0. This gap comes from a deliberate design choice: TinyCC performs no optimization. It reads C source, generates machine code in a single pass, and exits. There are no intermediate representations, no multi-pass register allocation, and no link-time optimization.

The direct execution mode is the most distinctive feature. Pass a .c file to tcc with the -run flag, and TinyCC compiles it in memory and runs it immediately, with no object file or binary written to disk. This makes the tool practical for one-off C programs in the way Python or Perl scripts work. The command-line arguments are passed through to main as argc and argv, matching standard ANSI C behavior.

Building and Installing TinyCC from the mob Branch

This GitHub repository is an unofficial mirror of the mob (main development) branch. There are no GitHub releases, so the only path to a binary is building from source. The build sequence on Linux and macOS is:

bash
./configure
make
make test
make install

The configure step accepts options; run ./configure --help to see available flags. By default, TinyCC installs to /usr/local/bin. On BSD systems, use gmake in place of make. The Windows build has separate instructions in tcc-win32.txt in the repository root.

The makeinfo tool must be present to build the HTML documentation. If you only need the compiler binary, the documentation target can be skipped. The make test target runs tcctest.c, an automated test suite designed to catch subtle code generator bugs.

Using C Files as Executable Scripts

TinyCC supports C scripting through a shebang line at the top of a .c file. Add the following as the first line:

bash
#!/usr/local/bin/tcc -run

After marking the file executable, run it directly from the command line:

bash
chmod a+x your_script

The README notes that ex1.c and ex4.c in the examples/ directory can be launched this way. The ex4.c example is notable because it uses standard X11 headers, confirming that the scripting mode works with real system libraries and is not limited to toy programs.

The <tcclib.h> include file is available for programs that need minimal libc support without pulling in full standard headers. The README notes that standard headers compile more slowly, making tcclib.h the practical choice for programs targeting floppy disks or other environments where compile time matters most.

Optional Memory and Bound Checking

TinyCC includes an optional memory and bound checker. When enabled, it instruments pointer accesses and detects out-of-bounds reads and writes at run time. The README states that bound-checked code can be mixed freely with standard unchecked code, so you can enable the checker on specific modules without recompiling everything.

This is a practical debugging tool for C programs that would otherwise produce silent memory corruption. The checker adds run-time overhead to checked code and is not intended for production builds. The full documentation for enabling and configuring the bound checker is in tcc-doc.html within the repository.

Constraints and Cases Where TinyCC Falls Short

TinyCC's design priorities create genuine constraints. The README states the compiler is heading toward full ISOC99 compliance, which means some C99 constructs may not be fully supported yet. C11 and C17 features are not mentioned in the available documentation. Engineers porting existing codebases should verify conformance against their specific language usage before committing.

There are no optimization levels. TinyCC produces unoptimized code by design. The 10x faster compile time stated in the README comes at the cost of slower output binaries, making it unsuitable for performance-sensitive production code.

The mob branch is a development branch with no versioned releases on GitHub and no binary download. Engineers who need a stable, tested release should check the upstream repository at http://repo.or.cz/w/tinycc.git or look for a packaged version in their operating system's package manager.

TinyCC Against GCC, Clang, and LGPL-2.1 Licensing

GCC is the natural comparison point. GCC is a full optimizing compiler supporting a wider set of architectures and languages including C++, Fortran, and others. It is the standard for production builds on Linux and produces significantly faster output binaries than TinyCC. TinyCC does not compete on output quality; it competes on compile speed and the size of the compiler binary itself.

LLVM Clang offers faster incremental compilation than GCC and better diagnostics, but it is still a full optimizing toolchain with a larger footprint. For environments where the compiler itself must be tiny, such as a rescue disk or a very small container, TinyCC occupies a niche neither GCC nor Clang fills.

The licensing difference is concrete: TinyCC is distributed under the GNU Lesser General Public License version 2.1. Code compiled with TinyCC does not inherit the LGPL; the license applies to the compiler and its runtime library. This matters specifically when libtcc.a or the shared libtcc library is embedded in another product, which requires attention to the LGPL's linking and disclosure requirements.

The last push to this repository was on 2026-09-26, confirming that the mob branch receives recent commits.

Editorial conclusion

Engineers who need a fast compile loop for test harnesses, rescue disk utilities, or embedded tooling where binary size matters will get genuine value from TinyCC. The scripting mode is a practical option for C programs that replace shell scripts. Those who need optimization passes, C++ support, or a stable versioned release should stay with GCC or Clang. Before adopting TinyCC, verify that your target architecture is covered by checking the architecture-specific source files (arm-gen.c, riscv64-gen.c, and so on) and run make test to confirm the build passes on your host.

Frequently asked questions

What is TinyCC?

TinyCC (tcc) is a compact ANSI C compiler created by Fabrice Bellard that targets i386, x86-64, ARM, AArch64, and RISC-V 64-bit architectures. It is designed to be small enough to run on a rescue disk and, according to the README, compiles and links code about 10 times faster than GCC at -O0.

How do I install TinyCC?

Build TinyCC from source by running ./configure, then make, then make install. On BSD systems, use gmake instead of make. The compiler installs to /usr/local/bin by default. Windows users should follow the instructions in tcc-win32.txt in the repository root.

How does TinyCC work?

TinyCC reads C source and generates machine code in a single pass with no intermediate representation and no optimization. With the -run flag, it compiles directly in memory and executes the program without writing any file to disk.

Is TinyCC safe to use?

TinyCC includes an optional bound checker that instruments pointer accesses and detects out-of-bounds reads and writes at run time. The README states that bound-checked code can be mixed freely with unchecked code. The checker adds overhead and is intended for debugging, not production builds.

How does TinyCC compare to GCC?

The README states TinyCC compiles and links about 10 times faster than GCC at -O0, but it produces unoptimized code and has no optimization levels. GCC covers more architectures and languages, produces faster output binaries, and has versioned releases. TinyCC is the right fit when compiler size and compile speed matter more than output performance.

Official sources

  1. Issues
  2. License: LGPL-2.1
  3. Project website
  4. README
  5. TinyCC/tinycc on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/tinycc-tinycc.svg)](https://hysenlabs.com/projects/tinycc-tinycc)