www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - What's the difference between DMD's `-preview` and `-transition`?

reply Mike Franklin <slavo5150 yahoo.com> writes:
I'm planning a PR to fix 
https://issues.dlang.org/show_bug.cgi?id=6952.

The problem, as documented in issue report, is that DMD currently 
prepends `-Xlinker` to any `-L` command-line arguments (e.g `dmd 
-L-static` invokes gcc as `gcc -Xlinker -static`).  This means 
that it is impossible to pass certain gcc-specific arguments such 
as `-static`, `-nodefaultlibs`, `-nostartfiles`, etc. directly to 
`gcc`. We need to be able to invoke gcc as `gcc -static`, not 
`gcc -Xlinker - static`).

By modifying the current behavior to no longer prepend `-Xlinker` 
to `-L` command-line arguments, users will be able pass arguments 
directly to gcc (e.g. `dmd -L-static`) or simulate the current 
behavior by explicitly appending `-Xlinker` themselves (e.g. `dmd 
-L-Xlinker -L-T=script.ld`).  Both classes of users will have 
what they need.

Unfortunately, changing the current behavior could break build 
scripts that rely on `-Xlinker` being prepended to any `-L` 
command-line argument, so I need some way for users to opt-in to 
the new behavior while allowing a path forward to, someday, 
deprecate the current behavior.

For the scenario described above, should I add a 
`-preview=fixLinkerInvocation` or a 
`-transition=fixLinkerInvocation` option?

Thanks for the help.

Mike
Aug 19 2019
next sibling parent Walter Bright <newshound2 digitalmars.com> writes:
-transition is the old way.

The new way is:

-preview=Feature means enable Feature to try it out before it becomes the
default.

-revert=Feature means disable Feature that has become the default, because your 
code is not ready yet for Feature.
Aug 19 2019
prev sibling parent Seb <seb wilzba.ch> writes:
On Tuesday, 20 August 2019 at 05:33:44 UTC, Mike Franklin wrote:
 I'm planning a PR to fix 
 https://issues.dlang.org/show_bug.cgi?id=6952.

 The problem, as documented in issue report, is that DMD 
 currently prepends `-Xlinker` to any `-L` command-line 
 arguments (e.g `dmd -L-static` invokes gcc as `gcc -Xlinker 
 -static`).  This means that it is impossible to pass certain 
 gcc-specific arguments such as `-static`, `-nodefaultlibs`, 
 `-nostartfiles`, etc. directly to `gcc`. We need to be able to 
 invoke gcc as `gcc -static`, not `gcc -Xlinker - static`).

 By modifying the current behavior to no longer prepend 
 `-Xlinker` to `-L` command-line arguments, users will be able 
 pass arguments directly to gcc (e.g. `dmd -L-static`) or 
 simulate the current behavior by explicitly appending 
 `-Xlinker` themselves (e.g. `dmd -L-Xlinker -L-T=script.ld`).  
 Both classes of users will have what they need.

 Unfortunately, changing the current behavior could break build 
 scripts that rely on `-Xlinker` being prepended to any `-L` 
 command-line argument, so I need some way for users to opt-in 
 to the new behavior while allowing a path forward to, someday, 
 deprecate the current behavior.

 For the scenario described above, should I add a 
 `-preview=fixLinkerInvocation` or a 
 `-transition=fixLinkerInvocation` option?

 Thanks for the help.

 Mike
-preview: enable new features or deprecations -transition: print _verbose_ debug info e.g. which code lines need to be fixed. Examples: - tls: list of all variables in TLS - vmarkdown: list of all instances of markdown replacement - field: list of all non-mutable fields in an object instance ... tl;dr: go with -preview=fixLinkerInvocation
Aug 20 2019