Compiler for the Deterministic C language.
  • C++ 88.5%
  • Python 7.4%
  • TypeScript 2.1%
  • Makefile 0.5%
  • Lua 0.3%
  • Other 0.9%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
personne-admin e973ae9606 ci: fall back to the ibiblio FreeDOS mirror in the job image
download.freedos.org stays unreachable from GitHub runners even with
retries. The job image now tries it briefly and then downloads the same
FreeDOS 1.4 floppy archive from the official ibiblio mirror; the pinned
archive and image checksums are unchanged.
2026-11-19 15:19:29 +01:00
.github/workflows feat: install learndc from the msi with a start menu shortcut and a path entry 2026-11-15 13:31:48 +00:00
.vscode Initial Commit 2026-06-04 22:14:42 +02:00
ci ci: fall back to the ibiblio FreeDOS mirror in the job image 2026-11-19 15:19:29 +01:00
compiler fix: select libdcext's SEH handler with a COMDAT trampoline 2026-11-19 13:41:59 +01:00
dccd feat: configure dccd from the nearest project.dcon before the first dpm build 2026-11-15 21:44:54 +00:00
dcdoc feat: add the typeof type operator 2026-10-28 18:58:26 +01:00
docs fix: select libdcext's SEH handler with a COMDAT trampoline 2026-11-19 13:41:59 +01:00
dpm feat: add dpm compile-commands to print the dcc commands of every product without building 2026-11-15 21:44:49 +00:00
driver feat: structured exception handling for x86_64-coff 2026-11-19 10:41:01 +01:00
integrations/gitea feat: structured exception handling for x86_64-coff 2026-11-19 10:41:01 +01:00
learndc fix: render learndc TUI snapshots at true color regardless of the terminal 2026-11-19 11:10:04 +01:00
libdcext fix: wrap errors for the emitting function in residual ? propagation 2026-11-19 11:40:21 +01:00
mk feat: structured exception handling for x86_64-coff 2026-11-19 10:41:01 +01:00
neovim feat: configure dccd from the nearest project.dcon before the first dpm build 2026-11-15 21:44:54 +00:00
packaging/arch chore: update the arch package version to r1152.g10e09bdd 2026-11-19 12:18:40 +01:00
tests fix: select libdcext's SEH handler with a COMDAT trampoline 2026-11-19 13:41:59 +01:00
tools/codegen feat: write whole-program i8086 flat images 2026-10-21 16:09:55 +02:00
vscode feat: structured exception handling for x86_64-coff 2026-11-19 10:41:01 +01:00
zig feat: add compile command database output 2026-10-08 13:22:59 +02:00
.clang-format Initial Commit 2026-06-04 22:14:42 +02:00
.clang-tidy Initial Commit 2026-06-04 22:14:42 +02:00
.dockerignore chore: bump version to v0.2.0 2026-09-07 16:00:29 +02:00
.gitignore feat: cross-compile dcc/dccd for Windows with LLVM backend and MSI packaging 2026-09-06 21:50:59 +02:00
build.zig refactor: update project metadata 2026-09-06 11:19:54 +02:00
build.zig.zon chore: bump version sites to 0.3.0 2026-09-11 16:30:57 +02:00
CHANGELOG.md feat: add -fwhole-program for reachable whole-graph output 2026-10-14 11:04:35 +02:00
flake.lock feat: add Nix flake support 2026-09-06 11:19:46 +02:00
flake.nix fix: package a working nix toolchain 2026-11-15 18:21:47 +00:00
GNUmakefile feat: install learndc from the msi with a start menu shortcut and a path entry 2026-11-15 13:31:48 +00:00
LICENSE refactor: update project metadata 2026-09-06 11:19:54 +02:00
README.md feat: document learndc for learners and content authors 2026-11-15 11:29:29 +00:00
TODO fix: trap after calls that reach unreachable in the llvm backend 2026-10-06 21:05:37 +02:00

dc

dc is a small systems language with an LLVM backend, built with a freestanding-first mindset: no hosted OS, no libc, and no implicit runtime are assumed unless you ask for them. It targets the space C/C++ usually occupies, but without C's implicit conversions and without pulling in a C++-style OOP type system to get generics and basic ergonomics.

The core design choices follow from that:

  • No implicit conversions. Integer literals are typed from context; a value that doesn't fit its target type is a compile error, not silent truncation.
  • No constructors, inheritance, or member functions on structs. Structs are plain data; behavior is free functions, called using UFCS (p.length() instead of length(p)) when convenient.
  • Templates, constraints (if Concept(T)), and variadics give you generic code without runtime cost or a class hierarchy.
  • Codegen-affecting choices (stack protector, frame pointer, calling convention, alignment, sections, atomics) are explicit attributes and driver flags, not compiler heuristics.
  • Minimal implicit control flow. There is no operator overloading or destructors, all control flow transfers are explicit with call syntax, compiler-aided cleanup is available via the defer keyword.

See docs/spec.md for the language reference. It's a living draft, the implementation moves faster than the document, but I try to keep it in sync after every major feature addition or a large number of smaller improvements.

Status

Solo project, pre-release. The language, ABI, and CLI surface are all expected to keep moving. Treat anything here as subject to change.

Installation

Debian

Prebuilt Debian packages are available from GitHub Releases.

Download the appropriate .deb package and install it with:

sudo apt install ./dcc_*.deb

Windows

Prebuilt Windows MSI installers (dcc-<version>-x86_64.msi) are available from GitHub Releases. Run the installer to set up dcc, dccd, dpm, and standard library headers. The installer also ships the native ld.lld.exe linker with its runtime DLLs and license notices, plus the Windows import libraries libdcext needs, so dcc -flibdcext windows hello.dc -o hello.exe and dpm build write PE executables without a separate SDK. A custom installation directory works the same way. The VS Code extension discovers MSI installations without manual PATH editing; see server discovery and diagnostics.

Arch Linux

Arch users can build the package using the provided PKGBUILD:

git clone https://github.com/Personne-admin/dcc.git
cd dcc/packaging/arch
makepkg -si

Nix / NixOS

dcc provides a Nix flake and can be installed directly from GitHub:

nix profile install github:Personne-admin/dcc

For development, enter the provided development shell with:

nix develop github:Personne-admin/dcc

On NixOS, the flake package can also be added directly to environment.systemPackages.

From source

On other distributions, dcc can be built directly from source. A C++26-capable Clang with module support, LLVM, Python 3, and GNU Make are required.

See the build instructions below.

Getting started

With dcc and dpm installed (or build/bin on PATH after a source build), create and run a project:

dpm new hello
cd hello
dpm run

dpm new writes project.dcon, src/main.dc and .gitignore from the built-in executable template and works offline. dpm run builds the hosted program with libdcext and runs it, which prints Hello, world!. Use dpm build to build without running and dpm test to run the tests under tests/ (a new project has none yet, so it reports that and succeeds).

Continue with the beginner guide, which explains the generated Status(Error) main, arrays and formatted output. DPM manifests, templates and tasks are described in docs/dpm-templates.md and docs/dpm-tasks.md.

Learn DC interactively

If you would rather learn the language by doing small exercises, learndc is an offline companion tool: it creates an exercise project, runs your code and shows what differs from the expected result. It is optional and does not replace dpm new and dpm run. See docs/learndc.md; authors of exercises start at docs/learndc-authoring.md.

Targets

  • x86_64-elf: Linux executables, hosted with -flibdcext or freestanding; LLVM and custom backends.
  • x86_64-coff: Windows PE executables with -flibdcext windows; LLVM and custom backends.
  • x86-elf: freestanding 32-bit ELF executables with the LLVM backend. The program defines _start; libdcext is not available for 32-bit x86.
  • x86-coff: 32-bit COFF objects with the LLVM backend; PE32 executables are not supported.
  • i8086-binary and i8086-mz: flat/COM and MZ images with the custom backend.

Building the compiler

Build dependencies: a C++26-capable clang with module support, LLVM, GNU Make.

make            # builds the driver, dccd, and libdcext
make test       # builds and runs the test suite
make install    # installs dcc, dccd, and libdcext to PREFIX (default /usr/local)

Warning: If you wish to correctly install into a custom PREFIX, set the environment variable for both the make and make install invocations to ensure that the compiler has correct defaults.

ENABLE_LLVM, ENABLE_ASAN, and BUILD_TYPE are overridable via make VAR=value; see GNUmakefile for the full list of targets.

Freestanding by default

A dc program has no implicit prelude: no allocator, no I/O, nothing assumed about the host. This is intentional, dc is meant to be as usable for a kernel or a microcontroller as for a regular userspace binary.

libdcext is the opt-in hosted standard library. It's only linked in and its prelude only injected when you pass -flibdcext to the driver. Its Error type combines known standard-library errors without allocation; see standard errors. Hosted modules can use Array(T), print and println without imports or allocator setup; see hosted library basics for cleanup and error handling. Without -flibdcext, you get exactly the language and core::* compiler intrinsics, nothing else.

DPM projects enable libdcext for hosted products automatically; see Getting started.

Whole-program output

By default dcc -S and dcc -c on an entry module emit only that module's own functions and globals. Calls into imported modules stay extern references, so the output can't be assembled or linked on its own.

-fwhole-program lowers every module in the import graph into one output with the usual mangled names. Only reachable code is kept. The roots are the entry module's public functions and globals, every @nomangle function definition in the graph, and symbols named by module-level asm. Reachability then follows references (calls, function and global addresses, initializers) across modules. Imported symbols with no definition in the graph stay extern.

Under -flibdcext, whole-program builds compile the library from its installed sources, including the selected startup code, so no library archive is needed. An object from -fwhole-program -c -flibdcext links with dcc like any other object. Separate (non-whole-program) builds link the static libdcext archive instead.

Tooling

dccd is the language server: completion, formatting, semantic tokens, inlay hints, and workspace symbols, all over LSP.

The vscode/ extension (DC Language Support) wraps dccd for syntax highlighting and editor integration in VS Code. The first-party Neovim integration uses native Neovim 0.11+ LSP APIs on Linux and Windows, with no external plugin dependencies.

Projects that already use the Zig build system can call dcc through the SDK in zig/dcc_sdk.zig; dpm is the primary build tool and Zig is not needed to build or use dcc.

License

GPLv3 or later. See LICENSE.