NAME
dmd - Digital Mars D2.x Compiler
SYNOPSIS
dmd files ... [ -switch ... ]
DESCRIPTION
dmd Compiles source code written in the D programming language.
OPTIONS
- file, file.d, file.htm, file.html
-
D source files to compile
- file.di
-
D interface files
- file.o
-
Object files to link in
- file.a
-
Library files to link in
- @cmdfile
-
A file to read more command-line arguments from, which may contain # single-line comments
- -allinst
-
Generate code for all template instantiations
- -betterC
-
Omit generating some runtime information and helper functions
- -boundscheck=[on|safeonly|off]
-
Bounds checks on, in @safe only, or off
- -c
-
Compile only, do not link
- -check=[assert|bounds|in|invariant|out|switch][=[on|off]]
-
Enable or disable specific checks
- -check=[h|help|?]
-
List information on all available checks
- -checkaction=[D|C|halt|context]
-
Behavior on assert/boundscheck/finalswitch failure
- -checkaction=[h|help|?]
-
List information on all available check actions
- -color
-
Turn colored console output on
- -color=[on|off|auto]
-
Force colored console output on or off, or only when not redirected (default)
- -conf=filename
-
Use config file at filename
- -cov
-
Perform code coverage and generate `.lst` file
- -cov=ctfe
-
Include code executed during CTFE in coverage report
- -cov=nnn
-
Require at least nnn% code coverage
- -cpp=filename
-
Use filename as the name of the C preprocessor to use for ImportC files
- -D
-
Generate documentation
- -Dddirectory
-
Write documentation file to directory
- -Dffilename
-
Write documentation file to filename
- -d
-
Silently allow deprecated features and symbols
- -de
-
Issue an error when deprecated features or symbols are used (halt compilation)
- -dw
-
Issue a message when deprecated features or symbols are used (default)
- -debug
-
Compile in debug code
- -debug=ident
-
Compile in debug code identified by ident
- -debuglib=libname
-
Set symbolic debug library to libname
- -defaultlib=libname
-
Set default library to libname
- -deps
-
Print module dependencies (imports/file/version/debug/lib)
- -deps=filename
-
Write module dependencies to filename (only imports)
- -dllimport=[none|defaultLibsOnly|externalOnly|all]
-
Windows only: select symbols to dllimport
- -edition[=NNNN[filename]]
-
Set language edition to year NNNN, apply to filename
- -extern-std=standard
-
Set C++ name mangling compatibility with standard
- -extern-std=[h|help|?]
-
List all supported standards
- -fIBT
-
Generate Indirect Branch Tracking code
- -fPIC
-
Generate position independent code
- -fPIE
-
Generate position independent executables
- -ftime-trace
-
Turn on compile time profiler, generate JSON file with results
- -ftime-trace-granularity=μsecs
-
Minimum time granularity (in microseconds) traced by time profiler (default: 500)
- -ftime-trace-file=filename
-
Specify output file for `-ftime-trace`
- -g
-
Add symbolic debug info
- -gdwarf=version
-
Add DWARF symbolic debug info (default: 3)
- -gf
-
Emit debug info for all referenced types
- -gs
-
Always emit stack frame
- -gx
-
Add stack stomp code
- -H
-
Generate 'header' file
- -Hd=directory
-
Write 'header' file to directory
- -Hf=filename
-
Write 'header' file to filename
- -HC=[silent|verbose]
-
Write C++ 'header' equivalent to stdout
- -HC=[?|h|help]
-
List available options for C++ 'header' file generation
- -HCd=directory
-
Write C++ 'header' file to directory
- -HCf=filename
-
Write C++ 'header' file to filename instead of stdout
- --help
-
Print help and exit
- -I=directory
-
Look for imports also in directory
- -extI=directory
-
Look for imports that are out of the currently compiling binary, used to set the module as DllImport
- -i[=pattern]
-
Include imported modules in the compilation
- -identifiers=[UAX31|c99|c11|all]
-
Specify the non-ASCII tables for D identifiers
- -identifiers-importc=[UAX31|c99|c11|all]
-
Specify the non-ASCII tables for ImportC identifiers
- -ignore
-
Deprecated flag, unsupported pragmas are always ignored now
- -inline
-
Do function inlining
- -J=directory
-
Look for string imports also in directory
- -L=linkerflag
-
Pass linkerflag to link
- -lib
-
Generate library rather than object files
- -lowmem
-
Enable garbage collection for the compiler
- -m32
-
Generate 32 bit code
- -m64
-
Generate 64 bit code
- -main
-
Add default main() if not present already (e.g. for unittesting)
- -makedeps[=filename]
-
Print dependencies in Makefile compatible format to filename or stdout.
- -man
-
Open web browser on manual page
- -map
-
Generate linker .map file
- -mcpu=[baseline|avx|native]
-
Set the target architecture for code generation
- -mcpu=[h|help|?]
-
List all architecture options
- -mixin=filename
-
Expand and save mixins to file specified by filename
- -mv=package.module=filespec
-
Use filespec as source file for package.module
- -noboundscheck
-
No array bounds checking (deprecated, use `-boundscheck=off`)
- -nothrow
-
Assume no Exceptions will be thrown
- -nothrow-optimizations
-
Allow skipping destructors when an Error unwinds through a nothrow function
- -O
-
Optimize
- -o-
-
Do not write object file
- -od=directory
-
Write object & library files to directory
- -of=filename
-
Name output file to filename
- -op
-
Preserve source path for output files
- -oq
-
Write object files with fully qualified file names
- -os=os
-
Sets target operating system to os
- -P=preprocessorflag
-
Pass preprocessorflag to C preprocessor
- -preview=name
-
Enable an upcoming language change identified by name
- -preview=[h|help|?]
-
List all upcoming language changes
- -profile
-
Profile runtime performance of generated code
- -profile=gc
-
Profile runtime allocations
- -release
-
Contracts and asserts are not emitted, and bounds checking is performed only in @safe functions
- -revert=name
-
Revert language change identified by name
- -revert=[h|help|?]
-
List all revertable language changes
- -run
-
Compile, link, and run the program srcfile
- -target=triple
-
Use triple as arch-[vendor-]os[-cenv[-<cppenv]]
- -transition=name
-
Help with language change identified by name
- -transition=[h|help|?]
-
List all language changes
- -unittest
-
Compile in unit tests
- -v
-
Verbose
- -vasm
-
List generated assembler for each function
- -vcolumns
-
Print character (column) numbers in diagnostics
- -verror-style=[digitalmars|gnu|sarif]
-
Set the style for file/line number annotations on compiler messages
- -verror-supplements=num
-
Limit the number of supplemental messages for each error (0 means unlimited)
- -verrors=num
-
Limit the number of error/deprecation messages (0 means unlimited)
- -verrors=[context|simple]
-
Set the verbosity of error messages
- -verrors=spec
-
Show errors from speculative compiles such as `__traits(compiles, ...)`
- --version
-
Print compiler version and exit
- -version=ident
-
Compile in version code identified by ident
- -vgc
-
List all GC allocations including hidden ones
- -visibility=[default|hidden|public]
-
Default visibility of symbols
- -vtls
-
List all variables going into thread local storage
- -vtemplates[=list-instances]
-
List statistics on template instantiations
- -w
-
Warnings as errors (compilation will halt)
- -wi
-
Warnings as messages (compilation will continue)
- -wo
-
Warnings about use of obsolete features (compilation will continue)
- -X
-
Generate JSON file
- -Xf=filename
-
Write JSON file to filename
- -Xcc=driverflag
-
Pass driverflag to linker driver (cc)
TRANSITIONS
Language changes listed by -transition=id:
- field
-
List all non-mutable fields which occupy an object instance
- complex
-
Give deprecation messages about all usages of complex or imaginary types
- tls
-
List all variables going into thread local storage
- in
-
List all usages of 'in' on parameter
LINKING
Linking is done directly by the dmd compiler after a successful compile. To prevent dmd from running the linker, use the -c switch.
The actual linking is done by running gcc. This ensures compatibility with modules compiled with gcc.
FILES
- /etc/dmd.conf
-
System wide dmd config file. See dmd.conf(5) for details.
ENVIRONMENT
The D compiler dmd uses the following environment variables:
- DFLAGS
-
The value of DFLAGS is treated as if it were appended on the command line to dmd.
AUTHOR
Copyright (c) 1999-2026 by The D Language Foundation written by Walter Bright
ONLINE DOCUMENTATION
https://dlang.org/dmd.html ⟨https://dlang.org/dmd.html⟩
SEE ALSO
dmd.conf(5) rdmd(1) dumpobj(1) obj2asm(1) gcc(1)