How do I pass build optimisation when using `dub run`?

89 views Asked by At

Is it possible to use D's O optimisation when using dub run command line?

The package manager is absolutely fantastic, and just wondering if it is possible to pass along the following switches.

-O -release -inline -boundscheck=off

1

There are 1 answers

1
Adam D. Ruppe On BEST ANSWER

You should really never use those switches. dmd's optimizer is near useless, its inliner barely works, -release introduces undefined behavior, and -boundscheck=off introduces security holes to your application. There's a reason none of them are default!

If you want effective optimization and inlining, use gdc or ldc instead, as they are D's optimizing compilers.

That said, dub will pass those switches if you use dub build -b release-nobounds. See the options in the docs here:

https://dub.pm/commandline