dmd
Compile D programming language source code
TLDR
Build a D source file
Generate code for all template instantiations
Control bounds checking
List information on all available checks
Turn on colored console output
SYNOPSIS
dmd [options] source-files... [linker-options...]
PARAMETERS
-c
Compile only; do not link.
-o
Specify the output file name (e.g., executable or object file).
-g
Generate debug information for use with debuggers like gdb.
-O
Optimize the generated code for performance.
-unittest
Compile and run unit tests embedded in the D source code.
-release
Compile for release builds, disabling debug asserts and enabling optimizations.
-debug
Compile for debug builds, enabling debug asserts and disabling some optimizations.
-I
Add path to the list of directories to search for imported modules.
-L
Pass linker-option directly to the linker.
-m64 / -m32
Target 64-bit or 32-bit architecture, respectively.
-v
Enable verbose output, showing compilation steps and commands.
--help
Display a summary of command-line options.
--version
Display the compiler version information.
DESCRIPTION
dmd is the reference compiler for the D programming language, developed by Walter Bright of Digital Mars. It translates D source code (.d files) into machine code, producing executable binaries, object files, or static/shared libraries.
Known for its fast compilation speed, dmd supports all features of the D language, including classes, structs, templates, modules, mixins, garbage collection, and more. It acts as both a compiler and a linker, invoking the system linker (like ld) to resolve external symbols and create the final executable.
While dmd can be invoked directly for single-file or small projects, larger D projects typically use a build tool and package manager like dub, which wraps dmd and handles dependencies, compilation flags, and linking more efficiently.
CAVEATS
dmd typically generates platform-specific binaries. While dmd is a robust compiler, managing large D projects and their dependencies is often best handled by a dedicated build system like dub rather than direct dmd invocations.
THE D PROGRAMMING LANGUAGE
The D language is a multi-paradigm system programming language that combines imperative, object-oriented, and functional programming concepts. It aims to offer C-like performance and direct access to hardware while providing modern language features and a garbage collector for ease of use and safety.
INTEGRATION WITH BUILD SYSTEMS
Although dmd is the core compiler, D development heavily relies on dub, the D language package manager and build tool. dub simplifies dependency management, compilation, testing, and packaging of D projects, acting as a high-level wrapper around dmd and other D compilers.
HISTORY
dmd (Digital Mars D) was created by Walter Bright and first released in 2001 as the initial and reference implementation of the D programming language. Its development aimed to combine the high performance of C++ with the safety and productivity features of languages like Java and C#. The front-end of dmd was open-sourced in 2007, contributing to the wider adoption and community-driven evolution of the D language.