Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

1082 lines (921 sloc) 27.791 kb
Ddoc
$(D_S dmd - $(WINDOWS Windows)$(LINUX Linux)$(OSX Mac OS X)$(FREEBSD FreeBSD) D Compiler,
$(UL
$(WINDOWS $(LI dmd for $(LINK2 dmd-linux.html, Linux)))
$(WINDOWS $(LI dmd for $(LINK2 dmd-osx.html, OSX)))
$(WINDOWS $(LI dmd for $(LINK2 dmd-freebsd.html, FreeBSD)))
$(LINUX $(LI dmd for $(LINK2 dmd-windows.html, Windows)))
$(LINUX $(LI dmd for $(LINK2 dmd-osx.html, OSX)))
$(LINUX $(LI dmd for $(LINK2 dmd-freebsd.html, FreeBSD)))
$(OSX $(LI dmd for $(LINK2 dmd-windows.html, Windows)))
$(OSX $(LI dmd for $(LINK2 dmd-linux.html, Linux)))
$(OSX $(LI dmd for $(LINK2 dmd-freebsd.html, FreeBSD)))
$(FREEBSD $(LI dmd for $(LINK2 dmd-windows.html, Windows)))
$(FREEBSD $(LI dmd for $(LINK2 dmd-linux.html, Linux)))
$(FREEBSD $(LI dmd for $(LINK2 dmd-osx.html, OSX)))
$(LI $(LINK2 #requirements, Requirements and Downloads))
$(LI $(LINK2 #files, Files))
$(LI $(LINK2 #installation, Installation))
$(WINDOWS $(LI $(LINK2 #example, Example)))
$(LI $(LINK2 #switches, Compiler Arguments and Switches))
$(LI $(LINK2 #linking, Linking))
$(LI $(LINK2 #environment, Environment Variables))
$(WINDOWS $(LI $(LINK2 #sc_ini, sc.ini Initialization File)))
$(UNIX $(LI $(DMD_CONF) Initialization File))
$(WINDOWS $(LI $(LINK2 #problems, Common Installation Problems)))
$(LI $(LINK2 #differences, Differences between Windows and Linux versions))
$(LI $(LINK2 #interface_files, D Interface Files))
$(LI $(LINK2 #library, Building Libraries))
$(LI $(LINK2 #compiling_dmd, Compiling dmd))
$(LI $(LINK2 #compiling_phobos, Compiling Phobos))
)
<h2>$(LNAME2 requirements, Requirements and Downloads)</h2>
$(OL
$(LI $(LINK2 http://www.digitalmars.com/d/download.html, Download D Compiler))
$(WINDOWS
$(LI 32 bit Windows (Win32) operating system, such as Windows XP)
$(LI Download
<a href="http://ftp.digitalmars.com/dmc.zip" title="download dmc.zip">
dmc.zip (C and C++ compiler)</a> for Win32
(not required, but it complements dmd for Windows)
)
)
$(LINUX
$(LI 32 bit x86 Linux operating system (will work on 64 bit Linux))
$(LI Gnu C compiler (gcc))
)
$(OSX
$(LI 32 bit x86 Mac OSX operating system)
$(LI Gnu C compiler (gcc))
)
$(FREEBSD
$(LI 32 bit x86 FreeBSD 7.1 operating system)
$(LI Gnu C compiler (gcc))
)
)
<h2>$(LNAME2 files, Files)</h2>
$(DL
$(DT $(TT $(DMDDIR)$(SEP)src$(SEP)phobos$(SEP))
$(DD D runtime library source)
)
$(DT $(TT $(DMDDIR)$(SEP)src$(SEP)dmd$(SEP))
$(DD D compiler front end source under dual (GPL and Artistic) license)
)
$(DT $(TT $(DMDDIR)$(SEP)html$(SEP)d$(SEP))
$(DD Documentation)
)
$(DT $(TT $(DMDDIR)$(SEP)samples$(SEP)d$(SEP))
$(DD Sample D programs)
)
$(WINDOWS
$(DT $(TT $(DMDDIR)\windows\bin\dmd.exe)
$(DD D compiler executable)
)
$(DT $(TT $(DMDDIR)\windows\bin\$(LINK2 http://www.digitalmars.com/ctg/shell.html, shell.exe))
$(DD Simple command line shell)
)
$(DT $(TT $(DMDDIR)\windows\bin\sc.ini)
$(DD Global compiler settings)
)
$(DT $(TT $(DMDDIR)\windows\lib\$(LIB))
$(DD D runtime library)
)
)
$(LINUX
$(DT $(TT $(DMDDIR)/linux/bin/dmd)
$(DD D compiler executable)
)
$(DT $(TT $(DMDDIR)/linux/bin/$(DUMPOBJ))
$(DD Elf file dumper)
)
$(DT $(TT $(DMDDIR)/linux/bin/$(OBJ2ASM))
$(DD Elf file disassembler)
)
$(DT $(TT $(DMDDIR)/linux/bin/$(SHELL))
$(DD Simple command line shell)
)
$(DT $(TT $(DMDDIR)/linux/bin/$(DMD_CONF))
$(DD Global compiler settings (copy to $(TT /etc/dmd.conf)))
)
$(DT $(TT $(DMDDIR)/linux/lib/$(LIB))
$(DD D runtime library (copy to $(TT /usr/lib/$(LIB))))
)
)
$(FREEBSD
$(DT $(TT $(DMDDIR)/freebsd/bin/dmd)
$(DD D compiler executable)
)
$(DT $(TT $(DMDDIR)/freebsd/bin/$(DUMPOBJ))
$(DD Elf file dumper)
)
$(DT $(TT $(DMDDIR)/freebsd/bin/$(OBJ2ASM))
$(DD Elf file disassembler)
)
$(DT $(TT $(DMDDIR)/freebsd/bin/$(SHELL))
$(DD Simple command line shell)
)
$(DT $(TT $(DMDDIR)/freebsd/bin/$(DMD_CONF))
$(DD Global compiler settings (copy to $(TT /etc/dmd.conf)))
)
$(DT $(TT $(DMDDIR)/freebsd/lib/$(LIB))
$(DD D runtime library (copy to $(TT /usr/lib/$(LIB))))
)
)
$(OSX
$(DT $(TT $(DMDDIR)/osx/bin/dmd)
$(DD D compiler executable)
)
$(DT $(TT $(DMDDIR)/osx/bin/$(DUMPOBJ))
$(DD Mach-O file dumper)
)
$(DT $(TT $(DMDDIR)/osx/bin/$(OBJ2ASM))
$(DD Mach-O file disassembler)
)
$(DT $(TT $(DMDDIR)/osx/bin/$(SHELL))
$(DD Simple command line shell)
)
$(DT $(TT $(DMDDIR)/osx/bin/$(DMD_CONF))
$(DD Global compiler settings (copy to $(TT /etc/dmd.conf)))
)
$(DT $(TT $(DMDDIR)/osx/lib/$(LIB))
$(DD D runtime library (copy to $(TT /usr/lib/$(LIB))))
)
)
)
<h2>$(LNAME2 installation, Installation)</h2>
$(WINDOWS
$(P Open a console window (for Windows XP this is done by
clicking on [Start][Command Prompt]).
All the tools are command line tools, which means
they are run from a console window.
Switch to the root directory.
Unzip the files in the root directory.
$(TT dmd.zip) will create
a $(TT $(DMDDIR)) directory with all the files in it.
$(TT dmc.zip) will create
a $(TT \dm) directory with all the files in it.
)
$(P A typical session might look like:)
$(CONSOLE
C:\Documents and Settings\Your Name&gt;cd \
C:\&gt;unzip dmd.zip
C:\&gt;unzip dmc.zip
)
)
$(LINUX
$(LI Unzip the archive into your home directory.
It will create
a $(TT ~/dmd) directory with all the files in it.
All the tools are command line tools, which means
they are run from a console window.)
$(LI Copy $(TT $(DMD_CONF)) to $(TT /etc):
$(CONSOLE
cp $(DMDDIR)/linux/bin/$(DMD_CONF) /etc
)
)
$(LI Put $(TT $(DMDDIR)/linux/bin) on your $(B PATH),
or copy the linux executables
to $(TT /usr/local/bin))
$(LI Copy the library to $(TT /usr/lib):
$(CONSOLE
cp $(DMDDIR)/linux/lib/$(LIB) /usr/lib
)
)
)
$(FREEBSD
$(LI Unzip the archive into your home directory.
It will create
a $(TT ~/dmd) directory with all the files in it.
All the tools are command line tools, which means
they are run from a console window.)
$(LI Copy $(TT $(DMD_CONF)) to $(TT /etc):
$(CONSOLE
cp $(DMDDIR)/freebsd/bin/dmd.conf /etc
)
)
$(LI Put $(TT $(DMDDIR)/freebsd/bin) on your $(B PATH),
or copy the FreeBSD executables
to $(TT /usr/local/bin))
$(LI Copy the library to $(TT /usr/lib):
$(CONSOLE
cp $(DMDDIR)/freebsd/lib/$(LIB) /usr/lib
)
)
)
$(OSX
$(LI Put the dmd zip file into your home directory,
and unzip it:
$(CONSOLE
unzip dmd.$(I VERSION).zip
)
where $(I VERSION) is the particular version of the zip file.
)
$(LI It will create
a $(TT ~/$(DMDDIR)) directory with all the files in it.
All the tools are command line tools, which means
they are run from a console window.)
$(LI Verify that this works by creating $(TT hello.d) in your home directory
with these contents:
---
import std.stdio;
void main() {
writeln("hello world!");
}
---
and compile and run it with:
$(CONSOLE
$(DMDDIR)/osx/bin/dmd hello
./hello
)
and it should print:
$(CONSOLE
hello world!
)
)
$(LI To install a global copy:)
$(LI Copy binaries to $(TT /usr/local/bin):
$(CONSOLE
sudo cp $(DMDDIR)/osx/bin/{dmd,$(DUMPOBJ),$(OBJ2ASM),$(SHELL)$(V2 ,rdmd)} /usr/local/bin
sudo cp $(DMDDIR)/osx/bin/dmdx.conf /usr/local/bin/$(DMD_CONF)
)
)
$(LI Copy the library to $(TT /usr/lib):
$(CONSOLE
sudo cp $(DMDDIR)/osx/lib/$(LIB) /usr/lib
)
)
)
$(LINUX
<h3>Installing dmd on 64 bit Linux</h3>
$(P Since dmd is a 32 bit compiler, the 32 bit gnu libraries must be installed:)
$(CONSOLE
sudo apt-get install gcc-multilib g++-multilib libc6-i386 libc6-dev-i386
)
$(P The $(TT ia32-libs) package has more 32 bit libraries, and may
optionally also be installed:)
$(CONSOLE
sudo apt-get install ia32-libs
)
$(P If you are using the .deb package for one-click install, it may
give you an error about it being only for i386. To force it to install:
)
$(CONSOLE
sudo dpkg -i --force-architecture dmd_X.XXX-0_i386.deb
)
$(P where X.XXX is the version number of the package.
)
)
$(WINDOWS
<h2>Example</h2>
$(P Run:)
$(CONSOLE
$(DMDDIR)$(SEP)$(OS)$(SEP)bin$(SEP)$(SHELL) all.sh
)
$(P in the $(TT $(DMDDIR)$(SEP)samples$(SEP)d) directory for several small examples.)
)
<h2>$(LNAME2 switches, Compiler Arguments and Switches)</h2>
$(DL
$(DT $(B dmd) $(I files)... -$(I switches)...
$(DD )
)
$(DT $(I files)...
$(DD
$(TABLE2 File Extensions,
$(TR
$(TH Extension)
$(TH File Type)
)
$(TR
$(TD $(I none))
$(TD D source files)
)
$(TR
$(TD $(B .d))
$(TD D source files)
)
$(TR
$(TD $(B .dd))
$(TD $(LINK2 ddoc.html, Ddoc) source files)
)
$(TR
$(TD $(B .di))
$(TD $(LINK2 #interface_files, D interface files))
)
$(TR
$(TD $(B .$(OBJEXT)))
$(TD Object files to link in)
)
$(TR
$(TD $(B .$(LIBEXT)))
$(TD Object code libraries to search)
)
$(WINDOWS
$(TR
$(TD $(B .exe))
$(TD Output executable file)
)
$(TR
$(TD $(B .def))
$(TD $(LINK2 http://www.digitalmars.com/ctg/ctgDefFiles.html, module definition file))
)
$(TR
$(TD $(B .res))
$(TD resource file)
)
)
)
)
)
$(SWITCH $(B @)$(I cmdfile),
If $(I cmdfile) is an environment variable,
read the compiler arguments and switches from
the value of that variable.
Otherwise, read compiler arguments and switches from
the text file $(I cmdfile)
)
$(SWITCH $(B -c),
compile only, do not link
)
$(SWITCH $(B -cov),
instrument for $(LINK2 code_coverage.html, code coverage analysis)
)
$(SWITCH $(B -D),
generate $(LINK2 ddoc.html, documentation) from source
)
$(SWITCH $(B -Dd)$(I docdir),
write documentation file to $(I docdir) directory
)
$(SWITCH $(B -Df)$(I filename),
write documentation file to $(I filename)
)
$(SWITCH $(B -d),
allow deprecated features
)
$(SWITCH $(B -debug),
compile in $(LINK2 version.html#debug, debug) code
)
$(SWITCH $(B -debug=)$(I level),
compile in $(LINK2 version.html#debug, debug level) &lt;= $(I level)
)
$(SWITCH $(B -debug=)$(I ident),
compile in $(LINK2 version.html#debug, debug identifier) $(I ident)
)
$(SWITCH $(B -debuglib=)$(I libname),
link in $(I libname) as the default library when
compiling for symbolic debugging instead of $(B $(LIB))
)
$(SWITCH $(B -defaultlib=)$(I libname),
link in $(I libname) as the default library when
not compiling for symbolic debugging instead of $(B $(LIB))
)
$(SWITCH $(B -deps=)$(I filename),
write module dependencies as text to $(I filename)
)
$(OSX
$(SWITCH $(B -dylib),
generate dylib library
)
)
$(UNIX
$(SWITCH $(B -fPIC),
generate Position Independent Code (which is used
for building shared libraries).
$(OSX This is always on for OSX.)
)
)
$(SWITCH $(B -g),
$(WINDOWS
add CodeView 4 symbolic debug info with
$(LINK2 abi.html#codeview, D extensions)
for debuggers such as
$(LINK2 http://ddbg.mainia.de/releases.html, Ddbg)
)
$(UNIX
add Dwarf symbolic debug info with
$(LINK2 abi.html#dwarf, D extensions)
for debuggers $(LINUX such as
$(LINK2 http://www.zerobugs.org/, ZeroBUGS))
)
)
$(SWITCH $(B -gc),
$(WINDOWS
add CodeView 4 symbolic debug info in C format
for debuggers such as
$(TT $(DMDDIR)\bin\windbg)
)
$(UNIX
add Dwarf symbolic debug info in C format
for debuggers such as
$(TT gdb)
)
)
$(SWITCH $(B -H),
generate $(LINK2 #interface_files, D interface file)
)
$(SWITCH $(B -Hd)$(I dir),
write D interface file to $(I dir) directory
)
$(SWITCH $(B -Hf)$(I filename),
write D interface file to $(I filename)
)
$(SWITCH $(B --help),
print brief help to console
)
$(SWITCH $(B -inline),
inline expand functions at the discretion of the compiler.
This can improve performance, at the expense of making
it more difficult to use a debugger on it.
)
$(SWITCH $(B -I)$(I path),
where to look for
$(LINK2 module.html#ImportDeclaration, imports).
$(I path) is a ; separated
list of paths. Multiple $(B -I)'s can be used, and the paths
are searched in the same order.
)
$(SWITCH $(B -ignore),
ignore unsupported pragmas
)
$(SWITCH $(B -J)$(I path),
where to look for files for
$(LINK2 expression.html#ImportExpression, $(I ImportExpression))s.
This switch is required in order to use $(I ImportExpression)s.
$(I path) is a ; separated
list of paths. Multiple $(B -J)'s can be used, and the paths
are searched in the same order.
)
$(SWITCH $(B -L)$(I linkerflag),
pass $(I linkerflag) to the
$(WINDOWS $(LINK2 http://www.digitalmars.com/ctg/optlink.html, linker))
$(UNIX linker), for example,
$(WINDOWS $(TT -L/ma/li))$(UNIX $(TT -L-M))
)
$(SWITCH $(B -lib),
generate library file as output instead of object file(s).
All compiled source files, as well as object files and library
files specified on the command line, are inserted into
the output library.
Compiled source modules may be partitioned into several object
modules to improve granularity.
The name of the library is taken from the name of the first
source module to be compiled. This can be overridden with
the $(B -of) switch.
)
$(SWITCH $(B -man),
$(WINDOWS
open default browser on this page
)
$(LINUX
open browser specified by the $(B BROWSER)
environment variable on this page. If $(B BROWSER) is
undefined, $(B x-www-browser) is assumed.
)
$(FREEBSD
open browser specified by the $(B BROWSER)
environment variable on this page. If $(B BROWSER) is
undefined, $(B x-www-browser) is assumed.
)
$(OSX
open browser specified by the $(B BROWSER)
environment variable on this page. If $(B BROWSER) is
undefined, $(B Safari) is assumed.
)
)
$(V2
$(SWITCH $(B -noboundscheck),
turns off all array bounds checking, even for safe functions
)
)
$(WINDOWS
$(SWITCH $(B -nofloat),
Prevents emission of $(B __fltused) reference in
object files, even if floating point code is present.
Useful for library code.
)
)
$(SWITCH $(B -O),
Optimize generated code. For fastest executables, compile
with the $(B -O -release -inline) switches together.
)
$(SWITCH $(B -o-),
Suppress generation of object file. Useful in
conjuction with $(B -D) or $(B -H) flags.
)
$(SWITCH $(B -od)$(I objdir),
$(DD write object files relative to directory $(I objdir)
instead of to the current directory)
)
$(SWITCH $(B -of)$(I filename),
Set output file name to $(I filename) in the output
directory. The output file can be an object file,
executable file, or library file depending on the other
switches.
)
$(SWITCH $(B -op),
normally the path for $(B .d) source files is stripped
off when generating an object file name. $(B -op) will leave
it on.
)
$(SWITCH $(B -profile),
$(LINK2 http://www.digitalmars.com/ctg/trace.html, profile)
the runtime performance
of the generated code
)
$(SWITCH $(B -quiet),
suppress non-essential compiler messages
)
$(SWITCH $(B -release),
$(V1 compile release version, which means not generating
code for contracts, asserts and array bounds checking)
$(V2 compile release version, which means not generating
code for contracts and asserts. Array bounds checking
is not done for system and trusted functions.)
)
$(SWITCH $(B -run) $(I srcfile args...)
compile, link, and run the program $(I srcfile) with the
rest of the
command line, $(I args...), as the arguments to the program.
No .$(OBJEXT) or executable file is left behind.
)
$(COMMENT
$(SWITCH $(B -safe),
Statically checks the modules being compiled to ensure they
conform to the $(LINK2 safed.html, safe memory model).
)
)
$(SWITCH $(B -unittest),
compile in $(LINK2 unittest.html, unittest) code, turns on asserts, and sets the
$(TT unittest) $(LINK2 version.html#PredefinedVersions, version identifier)
)
$(SWITCH $(B -v),
verbose
)
$(V2
$(SWITCH $(B -vtls),
print informational messages identifying variables defaulting
to thread local storage. Handy for migrating to shared model.
)
)
$(SWITCH $(B -version=)$(I level),
compile in $(LINK2 version.html#version, version level) >= $(I level)
)
$(SWITCH $(B -version=)$(I ident),
compile in $(LINK2 version.html#version, version identifier) $(I ident)
)
$(SWITCH $(B -w),
enable $(LINK2 warnings.html, warnings)
)
$(SWITCH $(B -wi),
enable $(LINK2 warnings.html, informational warnings (i.e. compilation
still proceeds normally))
)
)
$(WINDOWS
$(P Empty switches, i.e. "", are ignored.)
)
<h2>$(LNAME2 linking, Linking)</h2>
$(P Linking is done directly by the $(B dmd) compiler after a successful
compile. To prevent $(B dmd) from running the linker, use the
$(B -c) switch.
)
$(WINDOWS
$(P The programs must be linked with the D runtime library $(B phobos.lib),
followed by the C runtime library $(B snn.lib).
This is done automatically as long as the directories for the
libraries are on the LIB environment variable path. A typical
way to set LIB would be:
)
$(CONSOLE
set LIB=$(DMDDIR)\lib;\dm\lib
)
$(P If the $(B dmd) command is used to both compile and link
to an executable, it will make certain optimizations that are
valid only for Windows executable files. Do not use the resulting
.obj files in a DLL.
To compile modules into .obj files that can be used in an exe or
DLL, compile with $(B -c).
)
$(P Linking is done using the
$(LINK2 http://www.digitalmars.com/ctg/optlink.html, optlink) linker.
)
)
$(UNIX
$(P The actual linking is done by running $(B gcc).
This ensures compatibility with modules compiled with $(B gcc).
)
)
<h2>$(LNAME2 environment, Environment Variables)</h2>
$(P The D compiler dmd uses the following environment variables:
)
$(DL
$(WINDOWS
<dt>$(B DFLAGS)
<dd>The value of $(B DFLAGS) is treated as if it were appended to the
command line to $(B dmd.exe).
<dt>$(B LIB)
<dd>The linker uses $(B LIB) to search for library files. For D, it will
normally be set to:
$(CONSOLE
set LIB=$(DMDDIR)\lib;\dm\lib
)
<dt>$(B LINKCMD)
<dd> $(B dmd) normally runs the linker by looking for $(B link.exe)
along the $(B PATH). To use a specific linker instead, set the
$(B LINKCMD) environment variable to it. For example:
$(CONSOLE
set LINKCMD=\dmd\windows\bin\link
)
<dt>$(B PATH)
<dd>If the linker is not found in the same directory as $(B dmd.exe)
is in, the $(B PATH) is searched for it.
$(B Note:) other linkers named
$(B link.exe) will likely not work.
Make sure the Digital Mars $(B link.exe)
is found first in the $(B PATH) before other $(B link.exe)'s,
or use $(B LINKCMD) to specifically identify which linker
to use.
)
$(UNIX
<dt>$(B CC)
<dd> $(B dmd) normally runs the linker by looking for $(B gcc)
along the $(B PATH). To use a specific linker instead, set the
$(B CC) environment variable to it. For example:
$(CONSOLE
set CC=gcc
)
$(DT $(B BROWSER)
$(DD This sets the browser used to open the manual page with
the $(B -man) switch. It defaults to $(TT x-www-browser).
)
)
<dt>$(B DFLAGS)
<dd>The value of $(B DFLAGS) is treated as if it were appended to the
command line to $(B dmd).
)
)
$(WINDOWS
<h2>$(LNAME2 sc_ini, sc.ini Initialization File)</h2>
$(P $(B dmd) will look for the initialization file $(B sc.ini) in the
following sequence of directories:
)
$(OL
$(LI current working directory)
$(LI directory specified by the $(B HOME) environment variable)
$(LI directory $(B dmd.exe) resides in)
)
$(P If found, environment variable
settings in the file will override any existing settings.
This is handy to make $(B dmd) independent of programs with
conflicting use of environment variables.
)
<h3>Initialization File Format</h3>
$(P Comments are lines that begin with $(TT ;) and are ignored.
)
$(P Environment variables follow the $(TT [Environment]) section
heading, in $(I NAME)=$(I value) pairs.
The $(I NAME)s are treated as upper case.
Comments are lines that start with ;.
For example:
)
$(SCINI
; sc.ini file for dmd
; Names enclosed by %% are searched for in the existing environment
; and inserted. The special name %@P% is replaced with the path
; to this file.
[Environment]
LIB="%@P%\..\lib";\dm\lib
$(V1 DFLAGS="-I%@P%\..\src\phobos")
$(V2 DFLAGS="-I%@P%\..\src\phobos" "-I%@P%\..\src\druntime\import")
LINKCMD="%@P%\..\..\dm\bin"
DDOCFILE=mysettings.ddoc
)
<h3>Location Independence of sc.ini</h3>
$(P The $(B %@P%) is replaced with the path to $(TT sc.ini).
Thus, if the fully qualified file name $(TT sc.ini) is
$(TT c:$(DMDDIR)\bin\sc.ini), then $(B %@P%) will be replaced with
$(TT c:$(DMDDIR)\bin), and the above $(TT sc.ini) will be
interpreted as:
)
$(SCINI
[Environment]
LIB="c:$(DMDDIR)\bin\..\lib";\dm\lib
$(V1 DFLAGS="-Ic:$(DMDDIR)\bin\..\src\phobos")
$(V2 DFLAGS="-Ic:$(DMDDIR)\bin\..\src\phobos" "-Ic:$(DMDDIR)\bin\..\src\druntime\import")
LINKCMD="c:$(DMDDIR)\bin\..\..\dm\bin"
DDOCFILE=mysettings.ddoc
)
$(P This enables your dmd setup to be moved around without having
to re-edit $(TT sc.ini).
)
)
$(UNIX
<h2>$(LNAME2 dmd_conf, dmd.conf Initialization File)</h2>
$(P The dmd file $(TT dmd.conf) is the same as $(TT sc.ini)
for Windows, it's just that the file has a different name,
enabling a setup common to both Windows and this system to be created
without having to re-edit the file.)
$(P $(B dmd) will look for the initialization file $(TT dmd.conf) in the
following sequence of directories:)
$(OL
$(LI current working directory)
$(LI directory specified by the $(B HOME) environment variable)
$(LI directory $(B dmd) resides in)
$(LI $(TT /etc/))
)
$(P If found, environment variable
settings in the file will override any existing settings.
This is handy to make $(B dmd) independent of programs with
conflicting use of environment variables.
)
$(P Environment variables follow the $(TT [Environment]) section
heading, in $(I NAME)=$(I value) pairs.
The $(I NAME)s are treated as upper case.
Comments are lines that start with ;.
For example:
)
$(SCINI
; dmd.conf file for dmd
; Names enclosed by %% are searched for in the existing environment
; and inserted. The special name %@P% is replaced with the path
; to this file.
[Environment]
$(V1 DFLAGS=-I%@P%/../src/phobos)
$(V2 DFLAGS=-I%@P%/../src/phobos -I%@P%/../src/druntime/import)
)
)
$(WINDOWS
<h2>$(LNAME2 problems, Common Installation Problems)</h2>
$(UL
$(LI Using Cygwin's $(B unzip) utility has been known to cause
strange problems.
)
$(LI Running the compiler under Cygwin's command shell has
been also known to cause problems. Try getting it to work
under the regular Windows shell $(B cmd.exe) before trying Cygwin's.
)
$(LI Installing $(B dmd) and $(B dmc) into directory paths with spaces
in them causes problems.
)
)
)
<hr>
<h2>$(LNAME2 differences, Differences between Windows and Linux versions)</h2>
$(UL
$(LI String literals are read-only under Linux.
Attempting to write to them
will cause a segment violation.)
)
<hr>
<h2>$(LNAME2 interface_files, D Interface Files)</h2>
$(P When an import declaration is processed in a D source file,
the compiler searches for the D source file corresponding to
the import, and processes that source file to extract the
information needed from it. Alternatively, the compiler can
instead look for a corresponding $(I D interface file).
A D interface file contains only what an import of the module
needs, rather than the whole implementation of that module.
)
$(P The advantages of using a D interface file for imports rather
than a D source file are:
)
$(UL
$(LI D interface files are often significantly smaller and much
faster to process than the corresponding D source file.)
$(LI They can be used to hide the source code, for example,
one can ship an object code library along with D interface files
rather than the complete source code.)
)
$(P D interface files can be created by the compiler from a
D source file by using the $(B -H) switch to the compiler.
D interface files have the $(B .di) file extension.
When the compiler resolves an import declaration, it first looks
for a $(B .di) D interface file, then it looks for a D source
file.
)
$(P D interface files bear some analogous similarities to C++
header files. But they are not required in the way that C++
header files are, and they are not part of the D language.
They are a feature of the compiler, and serve only as an optimization
of the build process.
)
<h2>$(LNAME2 executable, Building Executables)</h2>
$(P $(B dmd) can build an executable much faster if as many of the
source files as possible are put on the command line.)
$(P Another advantage to putting multiple source files on the same
invocation of $(B dmd) is that $(B dmd) will be able to do some level
of cross-module optimizations, such as function inlining across modules.
)
<h2>$(LNAME2 library, Building Libraries)</h2>
$(P There are three ways to build a library. For example,
given $(TT foo.d) and $(TT bar.d) which are to be compiled, and existing
object file $(TT bar.$(OBJEXT)) and existing library
$(TT def.$(LIBEXT)) which are
all to be combined into a library $(TT foo.$(LIBEXT)):)
$(OL
$(LI Compile modules separately and then run the librarian on them:
$(WINDOWS
$(CONSOLE
dmd -c foo.d
dmd -c bar.d
$(LINK2 http://www.digitalmars.com/ctg/lib.html, lib) -c -p32 foo.lib foo.obj bar.obj abc.obj def.lib
del foo.obj bar.obj
)
)
$(UNIX
$(CONSOLE
dmd -c foo.d
dmd -c bar.d
rm -f foo.a
ar -r foo.a foo.o bar.o abc.o def.a
rm foo.o bar.o
)
)
This option is typical when using a makefile to avoid compiling
modules that have already been compiled.
)
$(LI Compile modules together and then run the librarian on them:
$(WINDOWS
$(CONSOLE
dmd -c foo.d bar.d
$(LINK2 http://www.digitalmars.com/ctg/lib.html, lib) -c -p32 foo.lib foo.obj bar.obj abc.obj def.lib
del foo.obj bar.obj
)
)
$(UNIX
$(CONSOLE
dmd -c foo.d bar.d
rm -f foo.a
ar -r foo.a foo.o bar.o abc.o def.a
rm foo.o bar.o
)
)
)
$(LI Use $(B dmd) to compile and build library in one operation:
$(CONSOLE
dmd -lib foo.d bar.d abc.$(OBJEXT) def.$(LIBEXT)
)
No object files are written to disk, it's all done in memory.
Using $(B -lib) also has the advantage that modules may be compiled
into multiple object files rather than exactly one per module.
This improves granularity of the library without having to break
up the modules.
)
)
<h2>$(LNAME2 compiling_dmd, Compiling dmd)</h2>
$(P Complete source code is provided to build the compiler.
Follow these steps:)
$(WINDOWS
$(CONSOLE
cd $(DMDDIR)\src\dmd
make -f win32.mak
)
)
$(UNIX
$(CONSOLE
cd ~/$(DMDDIR)/src/dmd
make -f $(OS).mak
)
)
<h2>$(LNAME2 compiling_phobos, Compiling Phobos)</h2>
$(P Complete source code is provided to build Phobos, the D runtime library.
Follow these steps:)
$(V1
$(WINDOWS
$(CONSOLE
cd $(DMDDIR)\src\phobos
make -f win32.mak DMD=$(DMDDIR)\$(OS)\bin\dmd
)
)
$(UNIX
$(CONSOLE
cd ~/$(DMDDIR)/src/phobos
make -f $(OS).mak DMD=~/$(DMDDIR)/$(OS)/bin/dmd
)
)
)
$(V2
$(WINDOWS
$(CONSOLE
cd $(DMDDIR)\src\druntime
make -f win32.mak DMD=$(DMDDIR)\$(OS)\bin\dmd
cd ..\phobos
make -f win32.mak DMD=$(DMDDIR)\$(OS)\bin\dmd
)
)
$(UNIX
$(CONSOLE
cd ~/$(DMDDIR)/src/druntime
make -f posix.mak DMD=~/$(DMDDIR)/$(OS)/bin/dmd
cd ../phobos
make -f $(OS).mak DMD=~/$(DMDDIR)/$(OS)/bin/dmd
)
)
)
)
Macros:
TITLE=DMD Compiler for $(WINDOWS Windows)$(LINUX Linux)$(OSX OSX)$(FREEBSD FreeBSD)
WIKI=DCompiler
CATEGORY_TOOLS=$0
LIB=$(WINDOWS phobos.lib)$(UNIX $(V1 libphobos.a)$(V2 libphobos2.a))
DMD_CONF=$(LINK2 #dmd_conf, dmd.conf)
SWITCH=$(DT $1)$(DD $+)
Jump to Line
Something went wrong with that request. Please try again.