Thread overview | ||||||
---|---|---|---|---|---|---|
|
April 19, 2011 libraries on windows | ||||
---|---|---|---|---|
| ||||
--- 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 |
April 19, 2011 Re: libraries on windows | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | == 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). |
April 20, 2011 Re: libraries on windows | ||||
---|---|---|---|---|
| ||||
Posted in reply to Iain Buclaw | 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.
|
April 20, 2011 Re: libraries on windows | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | == 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.
|
Copyright © 1999-2021 by the D Language Foundation