Skip to main content
TinyCC supports cross-compilation for multiple target architectures, allowing you to build executables for different platforms from a single development environment.

Supported architectures

TinyCC can cross-compile for the following target architectures:
  • i386 - 32-bit x86 (Linux, Windows)
  • x86_64 - 64-bit x86 (Linux, Windows, macOS)
  • ARM - 32-bit ARM (Linux, Windows CE)
  • ARM64 - 64-bit ARM/AArch64 (Linux, macOS, BSD)
  • RISC-V 64 - 64-bit RISC-V (Linux)
Cross-compilation support varies by host platform. Not all target architectures can be built from all host systems.

Building cross-compilers

1

Enable cross-compilation during configuration

When configuring TinyCC, enable cross-compiler builds:
This enables building all supported cross-compilers.
2

Build all cross-compilers

Build all cross-compilers and their runtime libraries:
This creates executables like i386-tcc, x86_64-tcc, arm-tcc, arm64-tcc, and riscv64-tcc.
3

Build specific cross-compiler (optional)

To build only a specific cross-compiler:
4

Install cross-compilers

Install the cross-compilers to your system:

Using cross-compilers

Basic cross-compilation

Use the architecture-specific TCC binary to cross-compile:

Target-specific switches

Platform-specific targets

Windows (PE) executables

Cross-compile Windows executables from Linux:

macOS (Mach-O) executables

Cross-compile macOS binaries:

ARM platforms

Configuration options

System root and include paths

Specify custom system root and library paths for cross-compilation:

Triplet configuration

Set the target triplet for library and include directory detection:
The triplet configuration helps TCC automatically locate system libraries and headers in multiarch systems.

Runtime library (libtcc1.a)

Each cross-compiler requires its own runtime library:
The runtime library provides:
  • Integer division and modulo operations
  • 64-bit integer operations on 32-bit platforms
  • Floating-point operations
  • Memory operations (memset, memcpy)

Limitations

Cross-compilation limitations:
  • Host and target endianness must match (big-endian to big-endian, little-endian to little-endian)
  • Position-independent code (PIC) for shared libraries may have limitations on some targets
  • Some platform-specific features may require native compilation
  • Windows cross-compilation from Linux requires mingw headers

Advanced cross-compilation

Custom cross-compiler configuration

Create config-extra.mak to customize cross-compiler paths:
TCC replaces {B} with the TCC directory and {R} with CONFIG_SYSROOT.

Multiple target builds

Build for multiple targets in sequence:

Troubleshooting

Missing headers or libraries

If cross-compilation fails due to missing headers:

Testing cross-compiled binaries

Test cross-compiled binaries using QEMU:

See also