www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - -debug and -release

reply lurker <lurker1024 klassmaster.com> writes:
What does it mean to compile a file with -debug and -release switches? Like so:

$ echo "void main() {}" > test.d
$ dmd -debug -release test.d

Why the compiler accepts both and doesn't complaint?

Thanks.
May 27 2007
next sibling parent reply Sean Kelly <sean f4.ca> writes:
lurker wrote:
 What does it mean to compile a file with -debug and -release switches? Like so:
 
 $ echo "void main() {}" > test.d
 $ dmd -debug -release test.d
 
 Why the compiler accepts both and doesn't complaint?
IIRC the -release flag turns off contracts and array range checking while -debug enables code in debug blocks. I think -release may turn off asserts as well. I think -release is probably a bad name for that particular flag since control of contracts and such isn't really a release option. The name is also confusing because of its application to other languages like C/C++. Sean
May 27 2007
parent reply Manfred Nowak <svv1999 hotmail.com> writes:
Sean Kelly wrote

  I think -release is probably a bad name
Lurker probably has lurked at my other thread. I really think -dmc or -airy are good names. -dmc may stand for "DeMilitarized Code" also. -manfred
May 27 2007
next sibling parent reply Daniel Keep <daniel.keep.lists gmail.com> writes:
Manfred Nowak wrote:
 Sean Kelly wrote
 
  I think -release is probably a bad name
Lurker probably has lurked at my other thread. I really think -dmc or -airy are good names. -dmc may stand for "DeMilitarized Code" also. -manfred
I've never really had a problem with -debug and -release; one enables debugging code and the other strips out testing code for release. Reading the documentation makes it pretty clear what -debug and -release do. On the other hand, -dmc looks like it enables support for DigitalMars C (which doesn't really make any sense), and my first thought when I saw -airy was "...maybe it has something to do with birds?" -- Daniel -- int getRandomNumber() { return 4; // chosen by fair dice roll. // guaranteed to be random. } http://xkcd.com/ v2sw5+8Yhw5ln4+5pr6OFPma8u6+7Lw4Tm6+7l6+7D i28a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP http://hackerkey.com/
May 27 2007
next sibling parent reply Manfred Nowak <svv1999 hotmail.com> writes:
Daniel Keep wrote

 Reading the documentation makes it pretty clear what -debug and
 -release do. 
Alright. But that should hold for every peace of documentation. Under this argument one can use names without any meaning or that language from "1984". I think Walters faible for avoiding negations released this option under the name "-release" to the public. But from formal languages one should know, that some language categories are not closed under complement. Therefore trying to avoid generic complements by always using a positive description might turn out to be hard to understand, because that positive descriptuion might fall into a language category with higher computational needs. -manfred
May 27 2007
parent Derek Parnell <derek psych.ward> writes:
On Sun, 27 May 2007 20:25:18 +0000 (UTC), Manfred Nowak wrote:

 Daniel Keep wrote
 
 Reading the documentation makes it pretty clear what -debug and
 -release do. 
Alright. But that should hold for every peace of documentation.
Of course it should, but because it doesn't apply to some parts of the D documentation does not mean that it therefore doesn't apply to all of the D documentation. The docs re -debug and -release are fairly accurate and complete even though other areas are well below what is needed.
 Under 
 this argument one can use names without any meaning or that language 
 from "1984".
 
 I think Walters faible for avoiding negations released this option 
 under the name "-release" to the public.
 
 But from formal languages one should know, that some language 
 categories are not closed under complement. Therefore trying to avoid 
 generic complements by always using a positive description might turn 
 out to be hard to understand, because that positive descriptuion might 
 fall into a language category with higher computational needs.
Rough translation: "-release" is a poor choice for this functionality. I agree, but I've gotten used to it now. -- Derek Parnell Melbourne, Australia "Justice for David Hicks!" skype: derek.j.parnell
May 27 2007
prev sibling parent reply Charlie <charlie.fats gmail.com> writes:
I dislike how -release strips out contracts, its often valuable to have 
contracts left in even in a release build.  I believe the front end even 
has specific flags for disabling contracts and asserts, I don't think 
Walter accepted the user submitted patch though.

And while we're on the topic whatever happen to Gregor's unittest patch ?

Charlie

Daniel Keep wrote:
 
 Manfred Nowak wrote:
 Sean Kelly wrote

  I think -release is probably a bad name
Lurker probably has lurked at my other thread. I really think -dmc or -airy are good names. -dmc may stand for "DeMilitarized Code" also. -manfred
I've never really had a problem with -debug and -release; one enables debugging code and the other strips out testing code for release. Reading the documentation makes it pretty clear what -debug and -release do. On the other hand, -dmc looks like it enables support for DigitalMars C (which doesn't really make any sense), and my first thought when I saw -airy was "...maybe it has something to do with birds?" -- Daniel
May 27 2007
next sibling parent janderson <askme me.com> writes:
Charlie wrote:
 I dislike how -release strips out contracts, its often valuable to have 
 contracts left in even in a release build.  I believe the front end even 
 has specific flags for disabling contracts and asserts, I don't think 
 Walter accepted the user submitted patch though.
I agree in part. I think there should be debug, release, and final. Final should have all assets removed but they should remain in release. If you still want them in final then the user should specify -unittest. In general I see a release as something you release internally to QA and other users. Final is something you send to a publisher or to the public. Another thing. Often I've seen 3 types of runtime-assets. assert //debug only release_assert final_assert
 
 And while we're on the topic whatever happen to Gregor's unittest patch ?
 
 Charlie
 
May 27 2007
prev sibling next sibling parent Manfred Nowak <svv1999 hotmail.com> writes:
Charlie wrote

 its often valuable to have 
 contracts left in even in a release build. 
Are you able to give some reasonings for the value that is lost by disabling contracts, when a binary is given into production? -manfred
May 28 2007
prev sibling parent Lars Ivar Igesund <larsivar igesund.net> writes:
Charlie wrote:
 
 And while we're on the topic whatever happen to Gregor's unittest patch ?
FWIW, Sean committed an alternative solution to the Tango runtime a few days ago. -- Lars Ivar Igesund blog at http://larsivi.net DSource, #d.tango & #D: larsivi Dancing the Tango
May 29 2007
prev sibling parent Myron Alexander <someone somewhere.com> writes:
Manfred Nowak wrote:
 Sean Kelly wrote
 
  I think -release is probably a bad name
Lurker probably has lurked at my other thread. I really think -dmc or -airy are good names. -dmc may stand for "DeMilitarized Code" also. -manfred
Please no. I like my code tight and solid, none of this airy, fluffy code :) On a serious note, I think this is one of those cases where it's a subjective thing. When I saw dmc, I thought "use digital mars c" and "DeMilitarized Code" does not, for me, imply anything. Same for "airy". Regards, Myron.
May 27 2007
prev sibling parent reply Derek Parnell <derek psych.ward> writes:
On Sun, 27 May 2007 14:15:13 -0400, lurker wrote:

 What does it mean to compile a file with -debug and -release switches? Like so:
 
 $ echo "void main() {}" > test.d
 $ dmd -debug -release test.d
 
 Why the compiler accepts both and doesn't complaint?
The compiler accepts both because they are not opposites of each other, despite what one may think just knowing the English terms. "-debug" functionality is almost exactly like the "-version" switch. It actually has nothing intrinsic to with debugging other than identifying sections of code as ones in which the author nominates, and thus presumably intends, to be debugging code. But the code can contain anything at all. These sections of code are brought into the compilation process in exactly the same way as sections identified using the version construct. In fact, one can use "version(XXX){}" and "debug(XXX){}" interchangeably. In other words ... debug(ABC) { ... } is functionally identical to version(ABC) { ... } The purpose of using "debug" rather than "version" is just to highlight to readers of the source code the sections that are intended to be debugging stuff. There is nothing 'magic' about "-debug". "-release" controls whether or not built-in and user-defined checks are excluded from the compilation. If you do not have "-release" the compiler adds array bounds checking, assert() functionality, invariant blocks in classes, and in/out blocks in functions. If you use "-release" such functionality is ignored by the compiler. Presumably the name "release" is being associated with the desire to remove time consuming run time checks in a program that has been debugged and is ready now for production release. -- Derek Parnell Melbourne, Australia "Justice for David Hicks!" skype: derek.j.parnell
May 27 2007
next sibling parent Derek Parnell <derek nomail.afraid.org> writes:
On Mon, 28 May 2007 08:09:39 +1000, Derek Parnell wrote:

Furthermore, to illustrate the similarities between -version and -debug ...

  module xyz;
  debug { import std.stdio; }
  void main()
  {
      debug { std.stdio.writefln("Starting"); }
  }
  ----------
  dmd -debug xyz.d

is identical in function to ...

  module xyz;
  version(debug) { import std.stdio; }
  void main()
  {
      version(debug) { std.stdio.writefln("Starting"); }
  }
  ----------
  dmd -version=debug xyz.d


So it could be said that "-debug" is sort of a shorthand for
"-version(debug)".

-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Justice for David Hicks!"
28/05/2007 11:52:15 AM
May 27 2007
prev sibling parent reply Don Clugston <dac nospam.com.au> writes:
Derek Parnell wrote:
 On Sun, 27 May 2007 14:15:13 -0400, lurker wrote:
 
 What does it mean to compile a file with -debug and -release switches? Like so:

 $ echo "void main() {}" > test.d
 $ dmd -debug -release test.d

 Why the compiler accepts both and doesn't complaint?
The compiler accepts both because they are not opposites of each other, despite what one may think just knowing the English terms. "-debug" functionality is almost exactly like the "-version" switch. It actually has nothing intrinsic to with debugging other than identifying sections of code as ones in which the author nominates, and thus presumably intends, to be debugging code. But the code can contain anything at all. These sections of code are brought into the compilation process in exactly the same way as sections identified using the version construct. In fact, one can use "version(XXX){}" and "debug(XXX){}" interchangeably. In other words ... debug(ABC) { ... } is functionally identical to version(ABC) { ... } The purpose of using "debug" rather than "version" is just to highlight to readers of the source code the sections that are intended to be debugging stuff. There is nothing 'magic' about "-debug".
 
 "-release" controls whether or not built-in and user-defined checks are
 excluded from the compilation. If you do not have "-release" the compiler
 adds array bounds checking, assert() functionality, invariant blocks in
 classes, and in/out blocks in functions. If you use "-release" such
 functionality is ignored by the compiler. Presumably the name "release" is
 being associated with the desire to remove time consuming run time checks
 in a program that has been debugged and is ready now for production
 release.
Maybe something like -nochecks would be a better name for -release. At least, the command line description should change -quiet suppress unnecessary messages -release compile release version That's really not helpful! How about: -release do not generate runtime checks I only just discovered that assert(0) is _not_ disabled by -release. I didn't find that mentioned in the documentation.
May 29 2007
parent reply Regan Heath <regan netmail.co.nz> writes:
Don Clugston Wrote:
 I only just discovered that assert(0) is _not_ disabled by -release. I 
 didn't find that mentioned in the documentation.
Perhaps we want a table of things with the various compile flags which enable/disable them in the docs. Similar to the comparison table for structs, classes, etc. Regan Heath
May 29 2007
parent Tomas Lindquist Olsen <tomas famolsen.dk> writes:
Regan Heath wrote:

 Don Clugston Wrote:
 I only just discovered that assert(0) is _not_ disabled by -release. I
 didn't find that mentioned in the documentation.
Perhaps we want a table of things with the various compile flags which enable/disable them in the docs. Similar to the comparison table for structs, classes, etc. Regan Heath
Until that happens, you can look inside the 'dmd/mars.c' file of the dmd frontend source code. The options parsing happens here and it's fairly easy to follow. For example the -release flag does this: ... snip ... else if (strcmp(p + 1, "release") == 0) global.params.release = 1; ... snip ... if (global.params.release) { global.params.useInvariants = 0; global.params.useIn = 0; global.params.useOut = 0; global.params.useAssert = 0; global.params.useArrayBounds = 0; global.params.useSwitchError = 0; }
May 30 2007