DMD producing huge binaries

Anon via Digitalmars-d digitalmars-d at puremagic.com
Sun May 22 15:46:09 PDT 2016


On Sunday, 22 May 2016 at 21:40:07 UTC, Andrei Alexandrescu wrote:
> On 05/21/2016 06:27 PM, Anon wrote:
>> On Saturday, 21 May 2016 at 20:50:56 UTC, Walter Bright wrote:
>>> On 5/21/2016 1:49 PM, Walter Bright wrote:
>>>> We already have a compressor in the compiler source for 
>>>> compressing
>>>> names:
>>>>
>>>> https://github.com/dlang/dmd/blob/master/src/backend/compress.c
>>>>
>>>> A faster one would certainly be nice. Anyone game?
>>>
>>> Note how well it does:
>>>
>>> https://issues.dlang.org/show_bug.cgi?id=15831#c5
>>
>> The underlying symbols are still growing exponentially. Nobody 
>> has the
>> RAM for that, regardless of what size the resultant binary is.
>>
>> Compressing the symbol names is a bandage. The compiler needs 
>> a new kidney.
>
> My understanding is that the encoding "auto" return in the 
> mangling makes any exponential growth disappear. Is that the 
> case? -- Andrei

No:

auto foo(T)(T x)
{
     struct Vold { T payload; }
     return Vold(x);
}

foo(5)
_D3mod10__T3fooTiZ3fooFNaNbNiNfiZS3mod10__T3fooTiZ3fooFiZ4Vold

foo(5).foo
_D3mod38__T3fooTS3mod10__T3fooTiZ3fooFiZ4VoldZ3fooFNaNbNiNfS3mod10__T3fooTiZ3fooFiZ4VoldZS3mod38__T3fooTS3mod10__T3fooTiZ3fooFiZ4VoldZ3fooFS3mod10__T3fooTiZ3fooFiZ4VoldZ4Vold

foo(5).foo.foo
_D3mod94__T3fooTS3mod38__T3fooTS3mod10__T3fooTiZ3fooFiZ4VoldZ3fooFS3mod10__T3fooTiZ3fooFiZ4VoldZ4VoldZ3fooFNaNbNiNfS3mod38__T3fooTS3mod10__T3fooTiZ3fooFiZ4VoldZ3fooFS3mod10__T3fooTiZ3fooFiZ4VoldZ4VoldZS3mod94__T3fooTS3mod38__T3fooTS3mod10__T3fooTiZ3fooFiZ4VoldZ3fooFS3mod10__T3fooTiZ3fooFiZ4VoldZ4VoldZ3fooFS3mod38__T3fooTS3mod10__T3fooTiZ3fooFiZ4VoldZ3fooFS3mod10__T3fooTiZ3fooFiZ4VoldZ4VoldZ4Vold

Lengths: 62 | 174 | 398

Just dropping the return types to a single character ($) shrinks 
the names, but it doesn't solve the core of the problem. Still 
exponential:

foo(5)
_D3mod1010__T3fooTiZ3fooFNaNbNiNfiZ($)

foo(5).foo
_D3mod38__T3fooT(S3mod10__T3fooTiZ3fooFiZ4Vold)Z3fooFNaNbNiNf(S3mod10__T3fooTiZ3fooFiZ4Vold)Z{$}

foo(5).foo.foo
_D3mod94__T3fooT{S3mod38__T3fooT(S3mod10__T3fooTiZ3fooFiZ4Vold)Z3fooF(S3mod10__T3fooTiZ3fooFiZ4Vold)Z4Vold}Z3fooFNaNbNiNf{S3mod38__T3fooT(S3mod10__T3fooTiZ3fooFiZ4Vold)Z3fooF(S3mod10__T3fooTiZ3fooFiZ4Vold)Z4Vold}Z$

Lengths: 36 | 90 | 202

Note: the part inside () is the return type of the first. The 
part in {} is the return type of the second. I left those in for 
illustrative purposes.


More information about the Digitalmars-d mailing list