www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - compiler flag for "preview all"

reply Bruce Carneal <bcarneal gmail.com> writes:
One of the ideas floated at beerconf was that of a single 
compiler flag activating all "preview" options.  For reference 
there are 11 preview options available to the ldc user currently, 
and the set changes over time so.  A "preview all" flag would be 
very useful to anyone wanting to test as far in to the 
foreseeable future as possible.

The ldc and dmd documentation say that the preview=all flag will 
list all available preview options, but in my testing both ldc 
1.22.0 and dmd 2.091.1 treat preview=all as an error.  They *do* 
list the preview options without error when given preview=?.  
IOW, the preview=all formulation could be used for conveniently 
peering in to the future. At beerconf Iain indicated that he may 
have already implemented the capability on a private copy so gdc 
would also be a go if I read him correctly.

So, any objections to preview=all meaning "enable all known 
preview items"?  If not, I'd ask that one of the compiler command 
line maintainers make the request for the change or let me know 
how I might do so.

PS: Also at beerconf Stefan Koch opined that turning on all 
preview options might not be possible due to incompatibilities of 
some sort which, if true, would be an excellent reason for adding 
the capability.
Jun 29 2020
next sibling parent reply rikki cattermole <rikki cattermole.co.nz> writes:
-preview=d3

dmd3 = dmd2 -preview=d3

Any major breaking changes would not be turned on in D2.

Not a new idea ;)
Jun 29 2020
parent Bruce Carneal <bcarneal gmail.com> writes:
On Monday, 29 June 2020 at 23:43:11 UTC, rikki cattermole wrote:
 -preview=d3

 dmd3 = dmd2 -preview=d3

 Any major breaking changes would not be turned on in D2.

 Not a new idea ;)
Well, the scope is a little different. preview=all would refer to currently implemented preview features which are, presumably, less controversial than a d3 moniker would imply. Implementing -preview=all could be as simple as replacing a string within args[] with a table of strings (which table probably already exists). But yeah, same general idea. A simpler way for us to test against possible futures.
Jun 29 2020
prev sibling next sibling parent reply Bruce Carneal <bcarneal gmail.com> writes:
On Monday, 29 June 2020 at 23:31:16 UTC, Bruce Carneal wrote:
 One of the ideas floated at beerconf was that of a single 
 compiler flag activating all "preview" options.
[snip]
 PS: Also at beerconf Stefan Koch opined that turning on all 
 preview options might not be possible due to incompatibilities 
 of some sort which, if true, would be an excellent reason for 
 adding the capability.
Stefan was right. ldc 1.22.0 seg faults when compiling with all preview flags set, manually, and trivially exercising dip 1008 by itself. Could be that there are several additional fatal combinations. I suggest that the compiler writers extend their test suites to exercise at least the "all previews enabled" + small-N-utilized permutations.
Jun 29 2020
parent reply Bruce Carneal <bcarneal gmail.com> writes:
On Tuesday, 30 June 2020 at 01:05:22 UTC, Bruce Carneal wrote:
 On Monday, 29 June 2020 at 23:31:16 UTC, Bruce Carneal wrote:
 One of the ideas floated at beerconf was that of a single 
 compiler flag activating all "preview" options.
[snip]
 PS: Also at beerconf Stefan Koch opined that turning on all 
 preview options might not be possible due to incompatibilities 
 of some sort which, if true, would be an excellent reason for 
 adding the capability.
Stefan was right. ldc 1.22.0 seg faults when compiling with all preview flags set, manually, and trivially exercising dip 1008 by itself. Could be that there are several additional fatal combinations. I suggest that the compiler writers extend their test suites to exercise at least the "all previews enabled" + small-N-utilized permutations.
Turns out you can trigger the seg fault by just enabling dip 1008 and dip 1021. Not sure how many other such preview-combo seg faults are there to be isolated and fixed but seems like a systematic sweep of the combinations should be part of the compiler test suite. Playing "combinatoric seg fault roulette" doesn't sound like fun for anybody. My guess is that these preview-combo errors can be isolated to the front end.
Jun 29 2020
parent reply Bruce Carneal <bcarneal gmail.com> writes:
On Tuesday, 30 June 2020 at 01:29:16 UTC, Bruce Carneal wrote:
 On Tuesday, 30 June 2020 at 01:05:22 UTC, Bruce Carneal wrote:

 Turns out you can trigger the seg fault by just enabling dip 
 1008 and dip 1021.
This particular combinatoric crash was written up and submitted as a dmd bug, issue 20994.
Jun 29 2020
parent rikki cattermole <rikki cattermole.co.nz> writes:
https://issues.dlang.org/show_bug.cgi?id=20994
Jun 29 2020
prev sibling next sibling parent reply Mathias LANG <geod24 gmail.com> writes:
On Monday, 29 June 2020 at 23:31:16 UTC, Bruce Carneal wrote:
 One of the ideas floated at beerconf was that of a single 
 compiler flag activating all "preview" options.  [...]

 The ldc and dmd documentation say that the preview=all flag 
 will list all available preview options, but in my testing both 
 ldc 1.22.0 and dmd 2.091.1 treat preview=all as an error. [...]
It was always intended to work this way, but it seems to have broken at some point. Well, next release: https://github.com/dlang/dmd/pull/11348
Jun 29 2020
parent Bruce Carneal <bcarneal gmail.com> writes:
On Tuesday, 30 June 2020 at 04:23:23 UTC, Mathias LANG wrote:
 On Monday, 29 June 2020 at 23:31:16 UTC, Bruce Carneal wrote:
 One of the ideas floated at beerconf was that of a single 
 compiler flag activating all "preview" options.  [...]

 The ldc and dmd documentation say that the preview=all flag 
 will list all available preview options, but in my testing 
 both ldc 1.22.0 and dmd 2.091.1 treat preview=all as an error. 
 [...]
It was always intended to work this way, but it seems to have broken at some point. Well, next release: https://github.com/dlang/dmd/pull/11348
Thanks Mathias. Nicely localized fix and quickly done. It'll still trigger 20994 and others of its ilk of course but that's a good thing.
Jun 29 2020
prev sibling parent reply Dennis <dkorpel gmail.com> writes:
On Monday, 29 June 2020 at 23:31:16 UTC, Bruce Carneal wrote:
 So, any objections to preview=all meaning "enable all known 
 preview items"?
I wouldn't object, but I wouldn't find 'all *known* preview items' useful since the status of the switches varies a lot. I personally try to enable dip25, dip1000, fieldwise, markdown, fixAliasThis, intpromote, and dtorfields for my projects. I especially like markdown in DDoc, and dip25+dip1000 enabling safe use of stack memory. I don't use the following switches: nosharedaccess: tried it, but it gave some compile errors I couldn't be bothered to fix rvaluerefparam: cool feature, but DIP is in 'GitHub gist' state (not even draft review), so it's not certain this will actually become part of the language dip1008: I don't need nogc Exceptions it, from what I heard it's in a buggy state dip1021: useless switch that gives 100% false positives (see DIP review). I tried to enable it, it gave a compile error in Phobos std.uni.CowArray, and ended in a dmd segfault
Jun 30 2020
next sibling parent Bruce Carneal <bcarneal gmail.com> writes:
On Tuesday, 30 June 2020 at 19:55:40 UTC, Dennis wrote:
 On Monday, 29 June 2020 at 23:31:16 UTC, Bruce Carneal wrote:
 So, any objections to preview=all meaning "enable all known 
 preview items"?
I wouldn't object, but I wouldn't find 'all *known* preview items' useful since the status of the switches varies a lot. I personally try to enable dip25, dip1000, fieldwise, markdown, fixAliasThis, intpromote, and dtorfields for my projects. I especially like markdown in DDoc, and dip25+dip1000 enabling safe use of stack memory. I don't use the following switches: nosharedaccess: tried it, but it gave some compile errors I couldn't be bothered to fix rvaluerefparam: cool feature, but DIP is in 'GitHub gist' state (not even draft review), so it's not certain this will actually become part of the language dip1008: I don't need nogc Exceptions it, from what I heard it's in a buggy state dip1021: useless switch that gives 100% false positives (see DIP review). I tried to enable it, it gave a compile error in Phobos std.uni.CowArray, and ended in a dmd segfault
For me, the marquee use case of --preview=all is automated compiler testing. It should help build an ICE machine. Given the less-than-baked status of many of the components I'd expect all prudent developers will agree with you that preview features should be used cautiously if at all. Still, if you want to look over the horizon you can. At the least the bugs uncovered can be fed to the compiler crew.
Jun 30 2020
prev sibling parent Max Samukha <maxsamukha gmail.com> writes:
On Tuesday, 30 June 2020 at 19:55:40 UTC, Dennis wrote:

 nosharedaccess: tried it, but it gave some compile errors I 
 couldn't be bothered to fix
 rvaluerefparam: cool feature, but DIP is in 'GitHub gist' state 
 (not even draft review), so it's not certain this will actually 
 become part of the language
 dip1008: I don't need  nogc Exceptions it, from what I heard 
 it's in a buggy state
 dip1021: useless switch that gives 100% false positives (see 
 DIP review). I tried to enable it, it gave a compile error in 
 Phobos std.uni.CowArray, and ended in a dmd segfault
"-revert" could enable previously disabled previews: dmd -preview=enableAll -revert=1008,1021
Jun 30 2020