Cosmopolitan Libc and the cosmocc toolchain let you compile C or C++ into small native executables that run on Linux, macOS, Windows, BSD systems, and BIOS without a VM.
Overview
Cosmopolitan Libc targets portable native binaries by reconfiguring stock GCC and Clang to emit a POSIX-oriented polyglot format. The same build can run on Linux, macOS, Windows, FreeBSD, OpenBSD, NetBSD, and BIOS with native performance and a small footprint.
Developers obtain cosmocc releases to compile programs locally. The runtime can log system calls or function traces for troubleshooting, and the toolchain can build many autotools-based third-party projects. Optional build modes shrink binaries further or narrow support to a single platform family.
The project can be built from source on supported platforms, with an optional system-wide APE loader on Linux for faster launches via binfmt_misc. Documentation covers APIs, debugging with GDB, and platform-specific setup for shells, WSL, and Linux interpreter registration.
Supported hardware and OS baselines are documented in platform notes, including minimum CPU and operating system versions per target.
Key features
- cosmocc compiler releases for portable builds
- Single binary runs on major desktop OSes
- Built-in strace-style syscall logging
- Optional tiny binary build modes
- Autotools project compatibility
- APE loader for Linux binfmt_misc
- GDB debugging workflow
- Source builds via project Makefile
Use cases
- Shipping one C binary across operating systems
- Reducing deployment size for CLI tools
- Building autotools projects with cosmocc