We should deprecate -release

Jonathan M Davis newsgroup.d at jmdavisprog.com
Wed Jul 17 17:52:02 UTC 2024


On Wednesday, July 17, 2024 9:51:29 AM MDT Walter Bright via Digitalmars-d 
wrote:
> On 7/15/2024 11:20 AM, Richard (Rikki) Andrew Cattermole wrote:
> > Right, but it's dmd we are talking about.
> >
> > A compiler that no matter what switches are set internally or externally
> > cannot compete with ldc or gdc.
>
> People benchmark it anyway.
>
> > It is better to slap a message both in the version/help message of the
> > compiler and on the site that says "don't use dmd for reviewing of
> > performance of D use ldc/gdc instead".
>
> People doing benchmarks do not read the site. That's the whole problem.
>
> > Given this, it is better to simply remove the switch as it fools people
> > into doing unsafe things that give them a very bad day.
>
> People don't develop code using a -release switch. Those spending time
> coding in D (rather than spending as little time as possible writing a
> benchmark) will be likely to spend time reading what a switch does before
> using it.
>
> I've been in this business a long time. What people should do and what they
> do do is rarely aligned. People who do comparative benchmarks spend as
> little time as possible benchmarking a language/compiler they are not
> familiar with.
>
> Have you ever read the descriptions of all the compiler switches on gcc or
> VC?
>
> Me neither.

While your approach here might make good sense if -release actually provided
an optimized build, it really doesn't. While it will help somewhat with
giving more performant code, since it does strip out some code, it doesn't
include any actual optimization passes, meaning that it's really not going
to make dmd look much better in benchmarks. Maybe if it included -O, it
would help in the way that you're looking for, but as things stand, I don't
think that it really does. Rather, in practice, what happens is that a
number of programmers assume that -release is what they're supposed to use
for release builds, and that's what they use it for. Folks who are are more
involved with D and/or who use it professionally are more likely to have
taken the time to figure out exactly which switches they want to be using,
but a lot of programmers won't, and dub is set up to use -release as part of
its default release target, meaning that D programmers in general are going
to get it unless they go to extra effort to avoid it (which is obviously an
issue with dub and not the compiler, but it goes to show that whoever made
that choice thought that -release was for release builds, and it affects
everyone using dub).

Regardless, arguably, the main problem here is that -release turns off
bounds checking for non- at safe code, and in practice, that's a _lot_ of D
code. It's that behavior that sometimes causes folks like Steven to tell
people to not use -release. The fact that assertions and contracts are
removed is probably just fine, particularly since that's usually what folks
are looking for with a release build, whereas arguably, removing those
bounds checks is enough of an @safety issue that it shouldn't be happening
without the programmer explicitly asking for it (and lumping it into a
switch that does a bunch of other stuff makes it very easy to ask for it
without intending to). And no, -release doesn't remove _all_ bounds
checking, since @safe code still has bounds checking with -release, but a
_lot_ of code doesn't, since a lot of code isn't @safe. So, we're arguably
providing the wrong defaults with -release right now.

So, I'm not sure that I agree with Steven that we should remove -release
(though I'd certainly be fine with that), but I _do_ think that we should
seriously consider changing exactly what it does if we're going to keep it.

- Jonathan M Davis





More information about the Digitalmars-d mailing list