Binary Size: function-sections, data-sections, etc.

Artur Skawina art.08.09 at gmail.com
Wed Dec 21 15:49:48 PST 2011


On 12/22/11 00:06, Sean Kelly wrote:
> http://d.puremagic.com/issues/show_bug.cgi?id=879

Thanks for that link.
The exception testcase (from one of the duplicates) seems to work here.
(at least w/ gdc, as i don't have dmd here to test)

-----
import std.stdio;

/* gcfuncdata2.d is a copy of this module, w/o main() */
import gcfuncdata2;

auto p(S...)(S args) { return stdout.writeln(__FILE__~": ", args); }

void main(string[] args){
   p("main");
   
   try {
      throw new Exception("muh");
   } catch (Exception e) {
      p(e);
   }
}

static this() { p("module ctor1"); }
static this() { p("module ctor2"); }
shared static this() { p("shared module ctor1"); }
shared static this() { p("shared module ctor2"); }

static ~this() { p("module dtor1"); }
static ~this() { p("module dtor2"); }
shared static ~this() { p("shared module dtor1"); }
shared static ~this() { p("shared module dtor2"); }

unittest { p("unittest1"); }
unittest { p("unittest2"); }

class blah {
   static this() { p("class static ctor1"); }
   shared static this() { p("class shared static ctor1"); }
   static ~this() { p("class static dtor1"); }
   shared static ~this() { p("class shared static dtor1"); }
}

-----

results in:

$ ./gcfuncdata1
gcfuncdata2.d: shared module ctor1
gcfuncdata2.d: shared module ctor2
gcfuncdata2.d: class shared static ctor1
gcfuncdata1.d: shared module ctor1
gcfuncdata1.d: shared module ctor2
gcfuncdata1.d: class shared static ctor1
gcfuncdata2.d: module ctor1
gcfuncdata2.d: module ctor2
gcfuncdata2.d: class static ctor1
gcfuncdata1.d: module ctor1
gcfuncdata1.d: module ctor2
gcfuncdata1.d: class static ctor1
gcfuncdata2.d: unittest1
gcfuncdata2.d: unittest2
gcfuncdata1.d: unittest1
gcfuncdata1.d: unittest2
gcfuncdata1.d: main
gcfuncdata1.d: object.Exception at gcfuncdata1.d(12): muh
gcfuncdata1.d: class static dtor1
gcfuncdata1.d: module dtor2
gcfuncdata1.d: module dtor1
gcfuncdata2.d: class static dtor1
gcfuncdata2.d: module dtor2
gcfuncdata2.d: module dtor1
gcfuncdata1.d: class shared static dtor1
gcfuncdata1.d: shared module dtor2
gcfuncdata1.d: shared module dtor1
gcfuncdata2.d: class shared static dtor1
gcfuncdata2.d: shared module dtor2
gcfuncdata2.d: shared module dtor1



More information about the Digitalmars-d mailing list