In his day job, Jacob Carlborg is a Ruby backend developer for Derivco Sweden, but he’s been using D on his own time since 2006. He is the maintainer of numerous open source projects, including DStep, a utility that generates D bindings from C and Objective-C headers, DWT, a port of the Java GUI library SWT, and DVM, the topic of another post on this blog. He implemented native Thread Local Storage support for DMD on OS X and contributed, along with Michel Fortin, to the integration of Objective-C in D.
DUB is the official build tool and package manager for the D programming language. Originally written and currently maintained by Sönke Ludwig as part of the vibe.d web framework, its acceptance as an official part of the D toolchain means it is now shipping with the most recent DMD and LDC compilers.
A Quick Introduction to DUB
If you have have the latest DMD or LDC installed, you already have DUB installed as well. If not, or if you want to check for a more recent version, you can get the very latest release, beta or release candidate from the DUB download page.
You can create a new DUB project by executing the dub init
command. This will start an interactive setup that guides you through project creation.
- First decide the format of the package recipe. Two formats are supported: JSON and SDLang. Here we picked SDLang.
- Then specify the name of the project. Press enter to use the default name, which is displayed in brackets and is inferred from the directory
- Do the same for the description, author, license, copyright, and dependencies to select the default values
$ dub init foo Package recipe format (sdl/json) [json]: sdl Name [foo]: Description [A minimal D application.]: Author name [Jacob Carlborg]: License [proprietary]: Copyright string [Copyright © 2017, Jacob Carlborg]: Add dependency (leave empty to skip) []: Successfully created an empty project in '/Users/jacob/tmp/foo'. Package successfully created in foo
After the setup has completed, the following files and directories will have been created:
$ tree foo foo ├── dub.sdl └── source └── app.d 1 directory, 2 files
dub.sdl
is the package recipe file, which provides instructions telling DUB how to build the packagesource
is the default path where DUB looks for D source filesapp.d
contains themain
function and is an example Hello World generated by DUB with the following content:
import std.stdio; void main() { writeln("Edit source/app.d to start your project."); }
The content of the dub.sdl
file is the following:
name "foo" description "A minimal D application." authors "Jacob Carlborg" copyright "Copyright © 2017, Jacob Carlborg" license "proprietary"
All of which was taken from what we specified during project creation. By default, DUB looks for D source files in either source
or src
directories and compiles all files it finds there and in any subdirectories.
To build and run the application, navigate to the project’s root directory, foo
in this case, and invoke dub
:
$ dub Performing "debug" build using dmd for x86_64. foo ~master: building configuration "application"... Linking... Running ./foo Edit source/app.d to start your project.
To build without running, invoke dub build
:
$ dub build Performing "debug" build using dmd for x86_64. foo ~master: building configuration "application"... Linking...
Case Study: DMD as a Library
Recently there has been some progress in making the D compiler (DMD) available as a library. Razvan Nitu has been working on it as part of his D Foundation scholarship at the University Politechnica of Bucharest. He gave a presentation at DConf 2017 (a video of the talk is available, as well as examples in the DMD repository). So I had the idea that as part of the DConf 2017 hackathon I could create a simple DUB package for DMD to make only the lexer and the parser available as a library, something his work has made possible.
Currently DMD is built using make
. There are three Makefiles, one for Posix, one for 32-bit Windows and one for 64-bit Windows (which is only a wrapper of the 32-bit one). I don’t intend to try to completely replicate the Makefiles as a DUB package (they contain some additional tasks besides building the compiler), but instead will start out fresh and only include what’s necessary to build the lexer and parser.
DMD already has all the source code in the src
directory, which is one of the directories DUB searches by default. If we would leave it as is, DUB would include the entirety of DMD, including the backend and other parts we don’t want to include at this point.
The first step is to create the DUB package recipe file. We start simple with only the metadata (here using the SDLang format):
name "dmd" description "The DMD compiler" authors "Walter Bright" copyright "Copyright © 1999-2017, Digital Mars" license "BSL-1.0"
When we have this we need to figure out which files to include in the package. We can do this by invoking DMD with the -deps flag
to generate the imports of a module. A good start is the lexer, which is located in src/ddmd/lexer.d
. We run the following command to output the imports that lexer.d
is using:
$ dmd -deps=deps.txt -o- -Isrc src/ddmd/lexer.d
This will write a file named deps.txt
containing all the imports used by lexer.d
. The -o-
flag is used to tell the compiler not to generate any code. The -I
flag is used to add an import path where the compiler will look for additional modules to import (but not compile). An example of the output looks like this (the long path names have been reduced to save space):
core.attribute (druntime/import/core/attribute.d) : private : object (druntime/import/object.d) object (druntime/import/object.d) : public : core.attribute (druntime/import/core/attribute.d):selector ddmd.lexer (ddmd/lexer.d) : private : object (druntime/import/object.d) core.stdc.ctype (druntime/import/core/stdc/ctype.d) : private : object (druntime/import/object.d) ddmd.root.array (ddmd/root/array.d) : private : object (druntime/import/object.d) ddmd.root.array (ddmd/root/array.d) : private : core.stdc.string (druntime/import/core/stdc/string.d)
The most interesting part of this output, in this case, is the first column, which consists of a long list of module names. What we are interested in here is a unique list of modules that are located in the ddmd
package. All modules in the core
package are part of the D runtime and are already precompiled as a library and automatically linked when compiling a D executable, so these modules don’t need to be compiled. The modules from the ddmd
package can be extracted with some search-and-replace in your favorite text editor or using some standard Unix command lines tools:
$ cat deps.txt | cut -d ' ' -f 1 | grep ddmd | sort | uniq ddmd.console ddmd.entity ddmd.errors ddmd.globals ddmd.id ddmd.identifier ddmd.lexer ddmd.root.array ddmd.root.ctfloat ddmd.root.file ddmd.root.filename ddmd.root.hash ddmd.root.outbuffer ddmd.root.port ddmd.root.rmem ddmd.root.rootobject ddmd.root.stringtable ddmd.tokens ddmd.utf
Here we can see that a set of modules is located in the nested package ddmd.root
. This package contains common functionality used throughout the DMD source code. Since it doesn’t have any dependencies on any code outside the package it’s a good fit to place in a DUB subpackage
. This can be done using the subPackage
directive, as follows:
subPackage { name "root" targetType "library" sourcePaths "src/ddmd/root" }
We specify the name of the subpackage, root
. The targetType
directive is used to tell DUB whether it should build an executable or a library (though it’s optional — DUB will build an executable if it finds an app.d
in the root of the source directory and a library if it doesn’t). Finally, sourcePaths
can be used to specify the paths where DUB should look for the D source files if neither of the default directories is used. Fortunately, we want to include all the files in the src/ddmd/root
, so using sourcePaths
works perfectly fine.
We can verify that the subpackage works and builds by invoking:
$ dub build :root Building package dmd:root in /Users/jacob/development/d/dlang/dmd/ Performing "debug" build using dmd for x86_64. dmd:root ~master: building configuration "library"...
:package-name
is shorthand that tells DUB to build the package-name
subpackage of the current package, in our case the root
subpackage.
After removing all the modules from the root
package from the initial list of dependencies, the following modules remain:
ddmd.console ddmd.entity ddmd.errors ddmd.globals ddmd.id ddmd.identifier ddmd.lexer ddmd.tokens ddmd.utf
The next step is to create a subpackage for the lexer containing the remaning modules.
subPackage { name "lexer" targetType "library" sourcePaths
Again we start by specifying the name of the subpackage and that the target type is a library. Specifying sourcePaths
without any value will set it to an empty list, i.e. no source paths. This is done because there are more files than we want to include in this subpackage in the source directory.
sourceFiles \ "src/ddmd/console.d" \ "src/ddmd/entity.d" \ "src/ddmd/errors.d" \ "src/ddmd/globals.d" \ "src/ddmd/id.d" \ "src/ddmd/identifier.d" \ "src/ddmd/lexer.d" \ "src/ddmd/tokens.d" \ "src/ddmd/utf.d"
The above specifies all source files that should be included in this subpackage. The difference between sourcePaths
and sourceFiles
is that sourcePaths
expects a whole directory of source files that should be included, where sourceFiles
lists only the individual files that should be included. A list in SDLang is written by separating the items with a space. The backslash (\
) is used for line continuation, making it possible spread the list across multiple lines.
The final step of the lexer
subpackage is to add a dependency on the root
subpackage. This is done with the dependency
directive:
dependency "dmd:root" version="*" }
The first parameter for the dependency
directive is the name of another DUB package. The colon is used to separate the package name from the subpackage name. The version
attribute is used to specify which version the package should depend on. The *
is used to indicate that any version of the dependency matches, i.e. the latest version should always be used. When implementing subpackages in any given package, this is generally what should be used. External projects that depend on any DUB package should specify a SemVer version number corresponding to a known release version.
If we build the lexer
subpackage now it will result in an error:
$ dub build :lexer Building package dmd:lexer in /Users/jacob/development/d/dlang/dmd/ Performing "debug" build using dmd for x86_64. dmd:lexer ~master: building configuration "library"... src/ddmd/globals.d(339,21): Error: need -Jpath switch to import text file VERSION dmd failed with exit code 1.
Looking at the file and line of the error shows that it contains the following code:
_version = (import("VERSION") ~ '\0').ptr;
This code contains an import expression. Import expressions differ from import statements (e.g. import std.stdio;
) in that they take a file from the file system and insert its contents into the current module. It’s just as if you copied and pasted the contents yourself. Using an import expression requires that the path where the file is imported from be passed to the compiler as a security mechanism. This can be done using the -J
flag. In this case, we want to use the package root, where we are executing DUB, so we can use a single dot: “.
“. Passing arbitrary flags to the compiler can be done with the dflags
build setting, as follows:
dflags "-J."
Add that to the lexer
subpackage configuration and it will compile correctly:
$ dub build :lexer Building package dmd:lexer in /Users/jacob/development/d/dlang/dmd/ Performing "debug" build using dmd for x86_64. dmd:lexer ~master: building configuration "library"...
For the final subpackage, we have the parser. The parser is located in src/ddmd/parse.d
. To get its dependencies we can use the same approach we used for the lexer. But we will filter out all files that are part of the other subpackages:
$ dmd -deps=deps.txt -Isrc -J. -o- src/ddmd/parse.d $ cat deps.txt | cut -d ' ' -f 1 | grep ddmd | grep -E -v '(root|console|entity|errors|globals|id|identifier|lexer|tokens|utf)' | sort | uniq ddmd.parse
Here, we’re supplying the -v
flag to grep
to filter the results and the -E
flag to enable extended regular expressions. All modules from the root
package and all modules from the lexer
subpackage are filtered out and the only remaining module is the ddmd.parse
module.
The subpackage for the parser will look similar to the other subpackages:
subPackage { name "parser" targetType "library" sourcePaths sourceFiles "src/ddmd/parse.d" dependency "dmd:lexer" version="*" }
Again, we can verify that it’s working by building the subpackage:
$ dub build :parser Building package dmd:parser in /Users/jacob/development/d/dlang/dmd/ Performing "debug" build using dmd for x86_64. dmd:parser ~master: building configuration "library"...
Currently we have three subpackages in the DUB recipe file, but no way to use the main package as a whole. To fix this we add the parser
subpackage as a dependency of the main package. We pick the parser
subpackage as a dependency because it will include the other two subpackages through its own dependencies.
license "BSL-1.0" targetType "none" dependency ":parser" version="*" subPackage { name "root"
In addition to specifying parser
as a dependency, we also specify the target type to be none
. This will avoid building an empty library out of the main package, since it doesn’t contain any source files of its own.
As a final step, we’ll verify that the whole library is working by creating a separate project that uses the DMD DUB package as a dependency. We create a new DUB project in the test
directory, called dub_package
:
$ cd test $ mkdir dub_package $ cd dub_package $ cat > dub.sdl <<EOF > name "dmd-dub-test" > description "Test of the DMD Dub package" > license "BSL 1.0" > > dependency "dmd" path="../../" > EOF $ mkdir source
We create a new file, source/app.d
, with the following content:
void main() { } // lexer unittest { import ddmd.lexer; import ddmd.tokens; immutable expected = [ TOKvoid, TOKidentifier, TOKlparen, TOKrparen, TOKlcurly, TOKrcurly ]; immutable sourceCode = "void test() {} // foobar"; scope lexer = new Lexer("test", sourceCode.ptr, 0, sourceCode.length, 0, 0); lexer.nextToken; TOK[] result; do { result ~= lexer.token.value; } while (lexer.nextToken != TOKeof); assert(result == expected); } // parser unittest { import ddmd.astbase; import ddmd.parse; scope parser = new Parser!ASTBase(null, null, false); assert(parser !is null); }
The above file contains two unit tests, one for the lexer and one for the parser. We can run dub test
to run the unit tests for this package:
$ dub test No source files found in configuration 'library'. Falling back to "dub -b unittest". Performing "unittest" build using dmd for x86_64. dmd:root ~issue-17392-dub: building configuration "library"... dmd:lexer ~issue-17392-dub: building configuration "library"... ../../src/ddmd/globals.d(339,21): Error: file "VERSION" cannot be found or not in a path specified with -J dmd failed with exit code 1.
Which gives us the error that it cannot find the VERSION
file in any string import paths, even though we added the correct directory to the string import paths. If we run the tests with verbose output enabled, using the --verbose
flag we get a hint (the output has been reduced to save space):
dmd:lexer ~issue-17392-dub: building configuration "library"... dmd -J. -lib
Here we see that the compiler is invoked with the -J
. flag, which is what we previously specified in the lexer
subpackage. The problem is that the current directory is now of the dmd-dub-test
DUB package instead of the dmd
DUB package. Looking at the documentation of DUB we can see there’s an environment variable, $PACKAGE_DIR
, that we can use as the string import path instead of hardcoding it to use a single dot. We update the dflags setting of the lexer
subpackage to use the $PACKAGE_DIR
environment variable:
dflags "-J$PACKAGE_DIR" }
Running the tests again shows that the error is fixed, but now we get a new error, a long list of undefined symbols (shortened here):
$ dub test No source files found in configuration 'library'. Falling back to "dub -b unittest". Performing "unittest" build using dmd for x86_64. dmd:root ~issue-17392-dub: building configuration "library"... dmd:lexer ~issue-17392-dub: building configuration "library"... dmd:parser ~issue-17392-dub: building configuration "library"... dmd-dub-test ~master: building configuration "application"... Linking... Undefined symbols for architecture x86_64: "_D4ddmd7astbase12__ModuleInfoZ", referenced from: _D3app12__ModuleInfoZ in dmd-dub-test.o
The reason for this is that we’re importing the ddmd.astbase
module in the test of the parser, but it’s never compiled. We can solve that problem by adding it to the parser
subpackage in the dmd
DUB package. Running dmd
again to show all its dependencies shows that it also depends on the ddmd.astbasevisitor
module. We add these two modules as follows:
sourceFiles \ "src/ddmd/astbase.d" \ "src/ddmd/astbasevisitor.d" \ "src/ddmd/parse.d"
Finally, running the tests again shows that everything is working correctly:
$ dub test No source files found in configuration 'library'. Falling back to "dub -b unittest". Performing "unittest" build using dmd for x86_64. dmd:root ~issue-17392-dub: building configuration "library"... dmd:lexer ~issue-17392-dub: building configuration "library"... dmd:parser ~issue-17392-dub: building configuration "library"... dmd-dub-test ~master: building configuration "application"... Linking... Running ./dmd-dub-test
After verifying that both the lexer and parser are working in a separate DUB package, this is the final result of the package recipe for the dmd
DUB package:
name "dmd" description "The DMD compiler" authors "Walter Bright" copyright "Copyright © 1999-2017, Digital Mars" license "BSL-1.0" targetType "none" dependency ":parser" version="*" subPackage { name "root" targetType "library" sourcePaths "src/ddmd/root" } subPackage { name "lexer" targetType "library" sourcePaths sourceFiles \ "src/ddmd/console.d" \ "src/ddmd/entity.d" \ "src/ddmd/errors.d" \ "src/ddmd/globals.d" \ "src/ddmd/id.d" \ "src/ddmd/identifier.d" \ "src/ddmd/lexer.d" \ "src/ddmd/tokens.d" \ "src/ddmd/utf.d" dflags "-J$PACKAGE_DIR" dependency "dmd:root" version="*" } subPackage { name "parser" targetType "library" sourcePaths sourceFiles \ "src/ddmd/astbase.d" \ "src/ddmd/astbasevisitor.d" \ "src/ddmd/parse.d" dependency "dmd:lexer" version="*" }
All this has now been merged into master and the DUB package is available here: http://code.dlang.org/packages/dmd. Happy hacking!
Share icons does not working for me 🙁
I checked into and they’re working for me now. If you’re still seeing those circular icons, do a forced refresh. You should see the official rectangular share icons from each site.
Hi Jacob!
Great Article, a pleasure to read.
I’ve one question about it:
– What’s the purpose of using “dependency “:parser” version=”*”” at the “main package” level?
I thought it was to allow us to simply type “dub build” and as the ‘main’ package depends on the “parser-subpackage” and this one depends on “dmd:root” subpackage this made the compilation of the library as a result that the parser depends on it (sort of ‘make all’ in make’s jargon).
I’ve tried this dub.sdl structure in one of my packages but when I type “dub build” I get this error: “Main package must have a binary target type, not none. Cannot build.”.
My package builds a library and several tools that link with that library and I would like to build a “default” tool when I type only “dub build” instead of typing “dub :my-default-tool”. Is it possible?
Sorry for the late reply.
The reason for why “dub build” doesn’t work is because the main package is declared with the target type “none”. That’s because the main package itself doesn’t contain any source files. If the target type “none” was not used DUB would build an empty library. Note, that the main package, DMD, can still be used as a dependency without any problem.
If you specify target type “library”, or don’t specify anything at all (and let DUB infer the target type), running “dub build” should just work. Although it will produce an empty library if the main package does not contain any source files.
I checked out stable branch and ran dub build :lexer. I get the following error.
venkat@venkat-U46E /**/DSource/dmd (stable) $ dub build :lexer
Building package dmd:lexer in /**/DSource/dmd/
Performing “debug” build using dmd for x86_64.
dmd:lexer ~stable: building configuration “library”…
src/ddmd/scanmscoff.d(180,10): Error: undefined identifier ‘WORD’
src/ddmd/scanmscoff.d(181,10): Error: undefined identifier ‘WORD’
src/ddmd/scanmscoff.d(182,10): Error: undefined identifier ‘WORD’
src/ddmd/scanmscoff.d(183,10): Error: undefined identifier ‘WORD’
src/ddmd/scanmscoff.d(184,11): Error: undefined identifier ‘DWORD’
src/ddmd/scanmscoff.d(185,15): Error: undefined identifier ‘BYTE’
src/ddmd/scanmscoff.d(185,15): Error: undefined identifier ‘BYTE’
src/ddmd/scanmscoff.d(187,14): Error: undefined identifier ‘DWORD’
src/ddmd/scanmscoff.d(187,14): Error: undefined identifier ‘DWORD’
src/ddmd/scanmscoff.d(188,11): Error: undefined identifier ‘DWORD’
src/ddmd/scanmscoff.d(189,11): Error: undefined identifier ‘DWORD’
src/ddmd/scanmscoff.d(190,11): Error: undefined identifier ‘DWORD’
src/ddmd/scanmscoff.d(196,11): Error: undefined identifier ‘WORD’
src/ddmd/scanmscoff.d(197,11): Error: undefined identifier ‘WORD’
src/ddmd/scanmscoff.d(198,11): Error: undefined identifier ‘DWORD’
src/ddmd/scanmscoff.d(199,11): Error: undefined identifier ‘DWORD’
src/ddmd/scanmscoff.d(200,11): Error: undefined identifier ‘DWORD’
src/ddmd/scanmscoff.d(201,11): Error: undefined identifier ‘WORD’
src/ddmd/scanmscoff.d(202,11): Error: undefined identifier ‘WORD’
src/ddmd/scanmscoff.d(225,24): Error: undefined identifier ‘BYTE’
dmd failed with exit code 1.
That’s strange, I cannot reproduce the issue. “src/ddmd/scanmscoff.d” should not be compiled at all. Only the files explicitly listed in the Dub file [1]. Could you please run Dub again with the “–vverbose” flag to see which files are passed to the compiler?
[1] https://github.com/dlang/dmd/blob/stable/dub.sdl#L22-L30
That was my thought as well. However, it seems to be compiling all the files.
I am using the following versions of dub and dmd.
DMD64 D Compiler v2.070.2
Copyright (c) 1999-2015 by Digital Mars written by Walter Bright
DUB version 0.9.24, built on Aug 19 2015
Here is the what I see.
venkat@venkat-U46E /d/~/DSource/dmd (stable) $ dub build :lexer -v
Using dub registry url ‘http://code.dlang.org/’
Refreshing local packages (refresh existing: true)…
Looking for local package map at /var/lib/dub/packages/local-packages.json
Looking for local package map at /home/venkat/.dub/packages/local-packages.json
Determined package version using GIT: dmd ~stable
Refreshing local packages (refresh existing: false)…
Looking for local package map at /var/lib/dub/packages/local-packages.json
Looking for local package map at /home/venkat/.dub/packages/local-packages.json
Found dependency dmd:parser ~stable
Found dependency dmd:lexer ~stable
Found dependency dmd:root ~stable
Building package dmd:lexer in /media/~/DSource/dmd/
Refreshing local packages (refresh existing: false)…
Looking for local package map at /var/lib/dub/packages/local-packages.json
Looking for local package map at /home/venkat/.dub/packages/local-packages.json
Found dependency dmd:root ~stable
Checking for missing dependencies.
Refreshing local packages (refresh existing: false)…
Looking for local package map at /var/lib/dub/packages/local-packages.json
Looking for local package map at /home/venkat/.dub/packages/local-packages.json
Found dependency dmd:root ~stable
Checking for upgrades.
Using cached upgrade results…
Generating using build
Generate target dmd:lexer (staticLibrary /media/venkat/1cebb435-79c4-4878-a213-91eab3454828/Documents/NetbeansProjects/DSource/dmd dmd_lexer)
Generate target dmd:root (staticLibrary /media/venkat/1cebb435-79c4-4878-a213-91eab3454828/Documents/NetbeansProjects/DSource/dmd dmd_root)
Performing “debug” build using dmd for x86_64.
Target ‘/media/venkat/1cebb435-79c4-4878-a213-91eab3454828/Documents/NetbeansProjects/DSource/dmd/.dub/build/library-debug-linux.posix-x86_64-dmd_2070-F5E60208A394D9D78E0DC6985D792592/libdmd_lexer.a’ doesn’t exist, need rebuild.
dmd:lexer ~stable: building configuration “library”…
dmd -J/media/venkat/1cebb435-79c4-4878-a213-91eab3454828/Documents/NetbeansProjects/DSource/dmd/ -lib -of.dub/build/library-debug-linux.posix-x86_64-dmd_2070-F5E60208A394D9D78E0DC6985D792592/libdmd_lexer.a -debug -g -w -version=Have_dmd_lexer -version=Have_dmd_root -Isrc/ src/ddmd/access.d src/ddmd/aggregate.d src/ddmd/aliasthis.d src/ddmd/apply.d src/ddmd/argtypes.d src/ddmd/arrayop.d src/ddmd/arraytypes.d src/ddmd/astbase.d src/ddmd/astbasevisitor.d src/ddmd/astcodegen.d src/ddmd/asttypename.d src/ddmd/attrib.d src/ddmd/backend/bcomplex.d src/ddmd/backend/cc.d src/ddmd/backend/cdef.d src/ddmd/backend/cgcv.d src/ddmd/backend/code.d src/ddmd/backend/code_x86.d src/ddmd/backend/cv4.d src/ddmd/backend/dt.d src/ddmd/backend/dwarf.d src/ddmd/backend/dwarf2.d src/ddmd/backend/el.d src/ddmd/backend/exh.d src/ddmd/backend/global.d src/ddmd/backend/iasm.d src/ddmd/backend/mach.d src/ddmd/backend/md5.d src/ddmd/backend/mscoff.d src/ddmd/backend/obj.d src/ddmd/backend/oper.d src/ddmd/backend/outbuf.d src/ddmd/backend/rtlsym.d src/ddmd/backend/ty.d src/ddmd/backend/type.d src/ddmd/backend/xmm.d src/ddmd/blockexit.d src/ddmd/builtin.d src/ddmd/canthrow.d src/ddmd/clone.d src/ddmd/complex.d src/ddmd/cond.d src/ddmd/console.d src/ddmd/constfold.d src/ddmd/cppmangle.d src/ddmd/ctfeexpr.d src/ddmd/dcast.d src/ddmd/dclass.d src/ddmd/declaration.d src/ddmd/delegatize.d src/ddmd/denum.d src/ddmd/dimport.d src/ddmd/dinifile.d src/ddmd/dinterpret.d src/ddmd/dmacro.d src/ddmd/dmangle.d src/ddmd/dmodule.d src/ddmd/dmsc.d src/ddmd/doc.d src/ddmd/dscope.d src/ddmd/dstruct.d src/ddmd/dsymbol.d src/ddmd/dsymbolsem.d src/ddmd/dtemplate.d src/ddmd/dversion.d src/ddmd/e2ir.d src/ddmd/eh.d src/ddmd/entity.d src/ddmd/errors.d src/ddmd/escape.d src/ddmd/expression.d src/ddmd/expressionsem.d src/ddmd/func.d src/ddmd/globals.d src/ddmd/glue.d src/ddmd/gluelayer.d src/ddmd/hdrgen.d src/ddmd/iasm.d src/ddmd/id.d src/ddmd/identifier.d src/ddmd/impcnvtab.d src/ddmd/imphint.d src/ddmd/init.d src/ddmd/initsem.d src/ddmd/inline.d src/ddmd/inlinecost.d src/ddmd/intrange.d src/ddmd/irstate.d src/ddmd/json.d src/ddmd/lexer.d src/ddmd/lib.d src/ddmd/libelf.d src/ddmd/libmach.d src/ddmd/libmscoff.d src/ddmd/libomf.d src/ddmd/link.d src/ddmd/mars.d src/ddmd/mtype.d src/ddmd/nogc.d src/ddmd/nspace.d src/ddmd/objc.d src/ddmd/objc_glue.d src/ddmd/objc_glue_stubs.d src/ddmd/opover.d src/ddmd/optimize.d src/ddmd/parse.d src/ddmd/permissivevisitor.d src/ddmd/printast.d src/ddmd/root/aav.d src/ddmd/root/array.d src/ddmd/root/ctfloat.d src/ddmd/root/file.d src/ddmd/root/filename.d src/ddmd/root/hash.d src/ddmd/root/man.d src/ddmd/root/outbuffer.d src/ddmd/root/port.d src/ddmd/root/response.d src/ddmd/root/rmem.d src/ddmd/root/rootobject.d src/ddmd/root/speller.d src/ddmd/root/stringtable.d src/ddmd/s2ir.d src/ddmd/safe.d src/ddmd/sapply.d src/ddmd/scanelf.d src/ddmd/scanmach.d src/ddmd/scanmscoff.d src/ddmd/scanomf.d src/ddmd/semantic.d src/ddmd/sideeffect.d src/ddmd/statement.d src/ddmd/statement_rewrite_walker.d src/ddmd/statementsem.d src/ddmd/staticassert.d src/ddmd/staticcond.d src/ddmd/strictvisitor.d src/ddmd/target.d src/ddmd/templateparamsem.d src/ddmd/tk/dlist.d src/ddmd/tocsym.d src/ddmd/toctype.d src/ddmd/tocvdebug.d src/ddmd/todt.d src/ddmd/toir.d src/ddmd/tokens.d src/ddmd/toobj.d src/ddmd/traits.d src/ddmd/transitivevisitor.d src/ddmd/typesem.d src/ddmd/typinf.d src/ddmd/utf.d src/ddmd/utils.d src/ddmd/visitor.d src/examples/avg.d src/examples/impvisitor.d src/examples/test_parser.d src/examples/testavg.d src/vcbuild/msvc-dmc.d src/vcbuild/msvc-lib.d -vcolumns
src/ddmd/scanmscoff.d(180,10): Error: undefined identifier ‘WORD’
src/ddmd/scanmscoff.d(181,10): Error: undefined identifier ‘WORD’
src/ddmd/scanmscoff.d(182,10): Error: undefined identifier ‘WORD’
src/ddmd/scanmscoff.d(183,10): Error: undefined identifier ‘WORD’
src/ddmd/scanmscoff.d(184,11): Error: undefined identifier ‘DWORD’
src/ddmd/scanmscoff.d(185,15): Error: undefined identifier ‘BYTE’
src/ddmd/scanmscoff.d(185,15): Error: undefined identifier ‘BYTE’
src/ddmd/scanmscoff.d(187,14): Error: undefined identifier ‘DWORD’
src/ddmd/scanmscoff.d(187,14): Error: undefined identifier ‘DWORD’
src/ddmd/scanmscoff.d(188,11): Error: undefined identifier ‘DWORD’
src/ddmd/scanmscoff.d(189,11): Error: undefined identifier ‘DWORD’
src/ddmd/scanmscoff.d(190,11): Error: undefined identifier ‘DWORD’
src/ddmd/scanmscoff.d(196,11): Error: undefined identifier ‘WORD’
src/ddmd/scanmscoff.d(197,11): Error: undefined identifier ‘WORD’
src/ddmd/scanmscoff.d(198,11): Error: undefined identifier ‘DWORD’
src/ddmd/scanmscoff.d(199,11): Error: undefined identifier ‘DWORD’
src/ddmd/scanmscoff.d(200,11): Error: undefined identifier ‘DWORD’
src/ddmd/scanmscoff.d(201,11): Error: undefined identifier ‘WORD’
src/ddmd/scanmscoff.d(202,11): Error: undefined identifier ‘WORD’
src/ddmd/scanmscoff.d(225,24): Error: undefined identifier ‘BYTE’
FAIL .dub/build/library-debug-linux.posix-x86_64-dmd_2070-F5E60208A394D9D78E0DC6985D792592/ dmd_lexer staticLibrary
dmd failed with exit code 1.
Aug 19 2015 is pretty old, could you please try a later version. Either download a later version here [1], or upgrade to the latest version of DMD. These days Dub is bundled with DMD.
[1] http://code.dlang.org/download
That did it. Should’ve thought of it myself, sorry about the nuisance.