July 08, 2014
On Tuesday, 8 July 2014 at 23:23:40 UTC, David Nadlinger wrote:
> The __bss_start/_end symbols have somehow turned LOCAL, whereas they should be globally visible to override the ones defined in libdruntime.so.

Sorry for the monologue, but this might be related: https://sourceware.org/bugzilla/show_bug.cgi?id=13683

David
July 09, 2014
On 08/07/14 19:54, David Nadlinger wrote:
> Hi all,
>
> I am excited to share news about two changes that recently made their
> way into the development version of LDC, changes that might be
> interesting for many of you Linux users out there.
>
> The first is that LDC now supports linker-level dead code elimination on
> Linux. If you happen to be familiar with the
> -f{function,data}-sections/--gc-sections options of the GNU toolchain,
> their equivalent is now enabled by default. For a set of small-ish
> programs that make use of different parts of Phobos, I've seen
> executable size improvements of close to 4x (!) in my tests. However, as
> --gc-sections is known to occasionally cause trouble with third-party
> code that relies on specific linker behavior, this optimization can be
> disabled with a new LDC switch, -disable-linker-strip-dead.

Is this only for Linux or Posix in general?

-- 
/Jacob Carlborg
July 09, 2014
On Tuesday, 8 July 2014 at 20:40:02 UTC, Walter Bright wrote:
> On 7/8/2014 1:39 PM, Walter Bright wrote:
>> This is all great news, congratulations!
>>
>> On the gc-sections front, Martin had gotten it to work for DMD on Linux but then
>> had to back it out because it failed with the ld.gold linker.
>>
>> If it works for ldc with ld.gold, can you please help explain what went wrong
>> for dmd?
>
> https://github.com/D-Programming-Language/dmd/pull/3715

If you pay attention to my comment there, original PR has never actually changed a single bit about generated binaries :(
July 09, 2014
On Tuesday, 8 July 2014 at 17:54:48 UTC, David Nadlinger wrote:
> Hi all,
>
> I am excited to share news about two changes that recently made their way into the development version of LDC, changes that might be interesting for many of you Linux users out there.
>
> The first is that LDC now supports linker-level dead code elimination on Linux. If you happen to be familiar with the -f{function,data}-sections/--gc-sections options of the GNU toolchain, their equivalent is now enabled by default. For a set of small-ish programs that make use of different parts of Phobos, I've seen executable size improvements of close to 4x (!) in my tests. However, as --gc-sections is known to occasionally cause trouble with third-party code that relies on specific linker behavior, this optimization can be disabled with a new LDC switch, -disable-linker-strip-dead.
>
> And secondly, proper support for building druntime/Phobos as shared libraries and loading D shared objects dynamically has now arrived in LDC! As you might be aware, Martin Nowak has spent a considerable amount of effort on adding runtime loading capabilities to DMD and druntime during the last year or so. LDC now offers the same level of functionality, to a good part based on Martin's solid work. To build a copy of LDC with druntime/Phobos as a shared library, which is also required for proper runtime loading, simply pass -DBUILD_SHARED_LIBS=ON to CMake. Oh, and for now this is Linux-only too, sorry.
>
> Even though I am currently not aware of any remaining issues, there are likely a few rough edges still. To be able to confidently ship these features as part of the next release, we'd very much appreciate early feedback. Just grab LDC from Git master and let us know how things went over on digitalmars.D.ldc. If you run into a specific bug, you can also directly open a ticket at https://github.com/ldc-developers/ldc/issues.
>
> Cheers,
> David

Those are probably best news from D world I have heard in last few months! Has anyone tried that on largish projects? Using GDC with --gc-sections has resulted in broken binaries sometimes but most likely it was the same ModuleInfo issue. Wonder how reliable it is in LDC.
July 09, 2014
On Tuesday, 8 July 2014 at 23:15:18 UTC, Joseph Rushton Wakeling wrote:
> On Tuesday, 8 July 2014 at 22:44:30 UTC, David Nadlinger wrote:
>> As strange as it might sound, I'm actually rather relieved that you ran into this issue. I previously thought Martin's collision detection code was at fault (see https://github.com/D-Programming-Language/druntime/pull/791#issuecomment-48090942), but suddenly couldn't reproduce the issue any longer. I'll look into it.
>
> Thanks -- let me know if there's anything you'd like me to test.

A few lost hairs and an implementation of weak symbols later, this should now be fixed in Git master.

In other words, there are currently no known issues with shared libraries, so everybody test away. ;)

David
July 10, 2014
On Wednesday, 9 July 2014 at 06:44:10 UTC, Jacob Carlborg wrote:
> On 08/07/14 19:54, David Nadlinger wrote:
>> The first is that LDC now supports linker-level dead code elimination on
>> Linux. […]
>
> Is this only for Linux or Posix in general?

So far it is only enabled on Linux, as I made the necessary adjustments to the druntime module registration code and so on while working on shared library support there.

That being said, supporting this should be considerably easier for platforms that still use the "old" __Dmodule_ref module registration mechanism, as the latter doesn't depend on unreferenced symbols in a magic section being kept by the linker. I can't think of any issues that would preclude using e.g. the equivalent linker option on OS X (-dead_strip) right now, or ---gc-sections on FreeBSD.

But as with all improvements, this simply depends on somebody to sit down and make it happen. Getting the thing to work shouldn't be too hard, and I'd be happy to help anyone attempting this if any tough issues crop up, but if you are just waiting for me to find the time to investigate other platforms, you'll probably be in for quite a wait.

Cheers,
David
July 10, 2014
On Wednesday, 9 July 2014 at 10:01:15 UTC, Dicebot wrote:
> Those are probably best news from D world I have heard in last few months! Has anyone tried that on largish projects? Using GDC with --gc-sections has resulted in broken binaries sometimes but most likely it was the same ModuleInfo issue. Wonder how reliable it is in LDC.

So far, I'm not aware of any conceptual problems or implementation issues. I tested it on a some larger projects using Thrift and a few other libraries. But as always, there might be some odd cases out there I simply missed, especially as linker behavior tends to vary quite a bit between different versions of binutils (and interestingly also different distributions, as some tend to come with patched versions or adjusted defaults).

All in all, I can only encourage you to test this on your own projects and report any issues. This is also the idea behind turning the feature on by default for now. Note that in contrast to GDC, we actually consider any issues caused by this to be a bug (Iain and I agree to disagree on this).

David
July 10, 2014
LDC is officially my favorite D compiler from now <3

..now I only need to finish D2 migration of our code base *caugh*

July 10, 2014
On 10 July 2014 15:00, David Nadlinger via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
> On Wednesday, 9 July 2014 at 10:01:15 UTC, Dicebot wrote:
>>
>> Those are probably best news from D world I have heard in last few months! Has anyone tried that on largish projects? Using GDC with --gc-sections has resulted in broken binaries sometimes but most likely it was the same ModuleInfo issue. Wonder how reliable it is in LDC.
>
>
> So far, I'm not aware of any conceptual problems or implementation issues. I tested it on a some larger projects using Thrift and a few other libraries. But as always, there might be some odd cases out there I simply missed, especially as linker behavior tends to vary quite a bit between different versions of binutils (and interestingly also different distributions, as some tend to come with patched versions or adjusted defaults).
>
> All in all, I can only encourage you to test this on your own projects and report any issues. This is also the idea behind turning the feature on by default for now. Note that in contrast to GDC, we actually consider any issues caused by this to be a bug (Iain and I agree to disagree on this).
>
> David

Indeed we do!

Instead I am consulting with the GCC devs to fix LTO support. >:)

Iain
July 10, 2014
On 2014-07-10 15:51, David Nadlinger wrote:

> So far it is only enabled on Linux, as I made the necessary adjustments
> to the druntime module registration code and so on while working on
> shared library support there.
>
> That being said, supporting this should be considerably easier for
> platforms that still use the "old" __Dmodule_ref module registration
> mechanism, as the latter doesn't depend on unreferenced symbols in a
> magic section being kept by the linker. I can't think of any issues that
> would preclude using e.g. the equivalent linker option on OS X
> (-dead_strip) right now, or ---gc-sections on FreeBSD.
>
> But as with all improvements, this simply depends on somebody to sit
> down and make it happen. Getting the thing to work shouldn't be too
> hard, and I'd be happy to help anyone attempting this if any tough
> issues crop up, but if you are just waiting for me to find the time to
> investigate other platforms, you'll probably be in for quite a wait.

I see, thanks.

-- 
/Jacob Carlborg