www.digitalmars.com         C & C++   DMDScript  

D.gnu - libraries on windows

reply Kagamin <spam here.lot> writes:
---
struct BL{int OAT=42;}
BL[1024][64][4] bloat;

void foo()
{
	bloat[0][0][0].OAT=1;
}

void goo(){}
---

I compile this file and archive it to a library and then link to another file.
If goo is used, bloat also gets into executable, which is not true for dmd.

Is this expected behavior or do I miss some options? Does gdc work the same on
Linux?

I use
ar -cru test2.a test2.o
gdc -v2 test.d test2.a -o test.exe -s -Os
Apr 19 2011
parent reply Iain Buclaw <ibuclaw ubuntu.com> writes:
== Quote from Kagamin (spam here.lot)'s article
 ---
 struct BL{int OAT=42;}
 BL[1024][64][4] bloat;
 void foo()
 {
 	bloat[0][0][0].OAT=1;
 }
 void goo(){}
 ---
 I compile this file and archive it to a library and then link to another file.
 If goo is used, bloat also gets into executable, which is not true for dmd.
 Is this expected behavior or do I miss some options? Does gdc work the same on
Linux?
 I use
 ar -cru test2.a test2.o
 gdc -v2 test.d test2.a -o test.exe -s -Os
I was about to test until I noticed that compiling the test2 file took a noticeably longer time to generate - so I corrected that speed demon by half first. =) Anyway, yes I believe this would be the expected behaviour. GDC has a slightly different strategy than DMD to ensure symbols that are supposed to be only linked once are done so correctly. If size matters, usually you'd strip all executables too (as well as using -Os).
Apr 19 2011
parent reply Kagamin <spam here.lot> writes:
Iain Buclaw Wrote:

 Anyway, yes I believe this would be the expected behaviour. GDC has a slightly
 different strategy than DMD to ensure symbols that are supposed to be only
linked
 once are done so correctly.
Haha, just by making sure they're always linked? :) What is this strategy? I mean, wouldn't linker do it for you? I doubt it can link a symbol twice, it will complain about duplicate symbols.
Apr 19 2011
parent Iain Buclaw <ibuclaw ubuntu.com> writes:
== Quote from Kagamin (spam here.lot)'s article
 Iain Buclaw Wrote:
 Anyway, yes I believe this would be the expected behaviour. GDC has a slightly
 different strategy than DMD to ensure symbols that are supposed to be only
linked
 once are done so correctly.
Haha, just by making sure they're always linked? :) What is this strategy? I mean, wouldn't linker do it for you? I doubt it can
link a symbol twice, it will complain about duplicate symbols. GDC marks decls as one-only, which for linux, puts symbols in a .gnu.linkonce section.
Apr 20 2011