0

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

ikel
  • 518
  • 2
  • 6
  • 27

1 Answers1

1

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

Adam D. Ruppe
  • 25,382
  • 4
  • 41
  • 60
  • Thanks @Adam. I looked into the [dub commandline page](https://dub.pm/commandline) earlier and missed it. I can now see `-b` allows me to pass `release-nobounds`. I'll do as per your suggestion to use *gdc* or *ldc* instead of introducing security holes. Oh, I've purchased your book too, **D Cookbook**, and thanks for making it available. – ikel Nov 03 '22 at 04:03