[Issue 879] support for --gc-sections

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Jul 5 16:36:40 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=879

--- Comment #20 from David Nadlinger <code at klickverbot.at> ---
(In reply to Martin Nowak from comment #19)
> Actually this doesn't work with ld.gold because dmd only uses a single ctor
> per DSO (COMDAT) and ld.gold will merge the ctors before checking their
> references.
> So I only end up with the .minfo* sections of the first object file.

This was the reason for me to switch to emitting one ctor per module (due to an
LLVM implementation quirk, the situation was a bit different and I already ran
into this problem with ld.bfd, but it was more or less the same). Of course,
it's an ugly and hacky approach, but it seems to work for now.

The more beautiful option (doesn't apply to the
pin-required-EH-tables-from-function, of course) seems to be to use a custom
linker script for generating the bracketing symbols as well as KEEP()ing the
.minfo section. Because of INSERT and implicit linker scripts, this probably
could be made to work, but ensuring that this also works with ld.gold and
doesn't break any user expectations was a can of worms I decided not to open
just yet.

--


More information about the Digitalmars-d-bugs mailing list