Why is mangling different for separate compilation?

Atila Neves via Digitalmars-d digitalmars-d at puremagic.com
Fri Feb 26 07:07:50 PST 2016


On Friday, 26 February 2016 at 14:56:04 UTC, Jacob Carlborg wrote:
> On 2016-02-26 13:45, Atila Neves wrote:
>> foo.d:
>> -----
>> void main() {
>>      import bar;
>>      foreach(ut; __traits(getUnitTests, bar)) ut();
>> }
>> -----
>>
>> bar.d:
>> -----
>> unittest { assert(1 == 2); }
>> -----
>>
>>
>> # compile all at once
>> dmd -unittest foo.d bar.d # fine
>>
>>
>> # compile separately
>> dmd -c -unittest foo.d
>> dmd -c -unittest bar.d
>> dmd foo.o bar.o
>> foo.o:foo.d:function _Dmain: error: undefined reference to
>> '_D3bar16__unittestL2_531FZv'
>> collect2: error: ld returned 1 exit status
>> --- errorlevel 1
>>
>>
>> objdump shows me that bar.o has a '_D3bar14__unittestL2_1FZv' 
>> symbol,
>> which is nearly, but not quite, what foo.o is trying to call.
>
> What is the mangling when it succeeds.

_D3bar14__unittestL1_1FZv

Atila


More information about the Digitalmars-d mailing list