RejectedSoftware Forums

Sign up

How to: Add compiler flags with Dub ?

How to add compiler flags like -O3 -boundscheck -betterC etc with dub ?
(and with different compilers)

Re: How to: Add compiler flags with Dub ?

On 2017-06-01 13:22, Patric Dexheimer wrote:

How to add compiler flags like -O3 -boundscheck -betterC etc with dub ?
(and with different compilers)

Dub has a set of predefined build types, like debug and release builds
[1]. The "release" build type will turn on the release mode (-release),
optimizations and inlining. I recommend trying to use any of the build
options [4] first if there is a matching option for the flag you want to
use.

To set any types of flags use the "dflags" build setting [2].

To specify flags for a specific compiler or platform you can use the
"platform" attribute [3], for example:

dflags "-betterC"
dflags "-O3" platform="ldc" // only applies to the LDC compiler

[1] http://code.dlang.org/package-format?lang=sdl#build-types
[2] http://code.dlang.org/package-format?lang=sdl#build-settings
[3] http://code.dlang.org/package-format?lang=sdl#platform-specs
[4] http://code.dlang.org/package-format?lang=sdl#build-options

/Jacob Carlborg