Jump to page: 1 2
Thread overview
D's Newfangled Name Mangling
Dec 20, 2017
Mike Parker
Dec 20, 2017
David Gileadi
Dec 20, 2017
Ali Çehreli
Dec 21, 2017
Mike Parker
Dec 22, 2017
Joakim
Dec 20, 2017
Johan Engelen
Dec 21, 2017
Rainer Schuetze
Dec 21, 2017
Andrej Mitrovic
Dec 21, 2017
ketmar
Dec 22, 2017
Joakim
December 20, 2017
Many thanks to Rainer for his insightful new article for the D Blog outlining the new name mangling algorithm. He talks about the old implementation and its limitations before going into the details of the new one. It's a topic I had never considered digging into before, even when the big Voldemort issue first popped up, but now I find it interesting.

The blog
https://dlang.org/blog/2017/12/20/ds-newfangled-name-mangling/

Reddit
https://www.reddit.com/r/programming/comments/7l1h36/ds_newfangled_name_mangling/
December 20, 2017
On 12/20/17 6:57 AM, Mike Parker wrote:
> Many thanks to Rainer for his insightful new article for the D Blog outlining the new name mangling algorithm. He talks about the old implementation and its limitations before going into the details of the new one. It's a topic I had never considered digging into before, even when the big Voldemort issue first popped up, but now I find it interesting.
> 
> The blog
> https://dlang.org/blog/2017/12/20/ds-newfangled-name-mangling/
> 
> Reddit
> https://www.reddit.com/r/programming/comments/7l1h36/ds_newfangled_name_mangling/ 

I really enjoyed this!

Typo: "This is were I stepped in..." -> "..where.."
December 20, 2017
On Wednesday, 20 December 2017 at 13:57:20 UTC, Mike Parker wrote:
> Many thanks to Rainer for his insightful new article for the D Blog outlining the new name mangling algorithm.

Nice!

"D and C++ avoid this problem by adding more information to the symbol name, i.e. they encode into a symbol name the scope in which the symbol is defined, the function argument types, and the return type. "

I would change it to "... and the return type (D only)". C++ does not include the return type in the mangle for normal functions (it does for templates). An important difference, concerning the earlier remark about programs crashing when "fail to update and recompile all source files that use the new declarartion"

-Johan

December 20, 2017
On 12/20/2017 07:41 AM, David Gileadi wrote:
> On 12/20/17 6:57 AM, Mike Parker wrote:
>> Many thanks to Rainer for his insightful new article for the D Blog outlining the new name mangling algorithm. He talks about the old implementation and its limitations before going into the details of the new one. It's a topic I had never considered digging into before, even when the big Voldemort issue first popped up, but now I find it interesting.
>>
>> The blog
>> https://dlang.org/blog/2017/12/20/ds-newfangled-name-mangling/
>>
>> Reddit
>> https://www.reddit.com/r/programming/comments/7l1h36/ds_newfangled_name_mangling/ 
> 
> 
> I really enjoyed this!
> 
> Typo: "This is were I stepped in..." -> "..where.."

Yeah, an excellent post. Strangely, I could find just one typo myself. :)

Its rather simple ->
It's rather simple

Ali
December 21, 2017
On Wednesday, 20 December 2017 at 19:16:03 UTC, Ali Çehreli wrote:
> On 12/20/2017 07:41 AM, David Gileadi wrote:

>> 
>> Typo: "This is were I stepped in..." -> "..where.."
>
> Yeah, an excellent post. Strangely, I could find just one typo myself. :)
>
> Its rather simple ->
> It's rather simple
>

Thanks, guys!

December 21, 2017

On 20.12.2017 19:42, Johan Engelen wrote:
> On Wednesday, 20 December 2017 at 13:57:20 UTC, Mike Parker wrote:
>> Many thanks to Rainer for his insightful new article for the D Blog outlining the new name mangling algorithm.
> 
> Nice!

Thanks.

> 
> "D and C++ avoid this problem by adding more information to the symbol name, i.e. they encode into a symbol name the scope in which the symbol is defined, the function argument types, and the return type. "
> 
> I would change it to "... and the return type (D only)". C++ does not include the return type in the mangle for normal functions (it does for templates). An important difference, concerning the earlier remark about programs crashing when "fail to update and recompile all source files that use the new declarartion"

AFAICT that's for the Itanium C++ ABI only, the VC mangling always encodes the return type, too.

I also noticed that gcc doesn't encode the inferred type of an "auto" return type for templates (available with C++17; or was it in C++14 already?).
December 21, 2017
On Wednesday, 20 December 2017 at 13:57:20 UTC, Mike Parker wrote:
> The blog
> https://dlang.org/blog/2017/12/20/ds-newfangled-name-mangling/

> it won’t catch every error; for example, structs, classes and other user defined types are mangled > by name only, so that a change to their definition will still pass unnoticed by the linker.

Wouldn't it be possible to append the hash of the struct's type definition to make the changes to the struct's definition noticeable during linking?

e.g.:

-----
module test;

struct S
{
    int x;
    float y;
}

void foo ( S s ) { }
-----

You might create a hash this way:

hash = Fnv1a(mangle(Tint32), mangle(Tfloat32));

And then foo's name mangle changes from:
_D4test3fooFS4test1SZv

to:
_D4test3fooFS4test1S<hash>Zv

It may not be 100% fool-proof yet though, because we'd also have to hash a bunch of other things like align() attributes.

Or is this is overkill?
December 21, 2017
Andrej Mitrovic wrote:

ah, 'cmon, we can hash the whole source file! let's move build system's work to linker! ;-)

sorry, but this is really overkill. tracking changed files and rebuilding 'em on demand is something your build system should do.
December 22, 2017
On Thursday, 21 December 2017 at 06:53:35 UTC, Mike Parker wrote:
> On Wednesday, 20 December 2017 at 19:16:03 UTC, Ali Çehreli wrote:
>> On 12/20/2017 07:41 AM, David Gileadi wrote:
>
>>> 
>>> Typo: "This is were I stepped in..." -> "..where.."
>>
>> Yeah, an excellent post. Strangely, I could find just one typo myself. :)
>>
>> Its rather simple ->
>> It's rather simple
>>
>
> Thanks, guys!

Still making my way through this long post, but

that make this information accessible faster -> that make accessing this information faster
December 22, 2017
On 12/20/17 8:57 AM, Mike Parker wrote:
> Many thanks to Rainer for his insightful new article for the D Blog outlining the new name mangling algorithm. He talks about the old implementation and its limitations before going into the details of the new one. It's a topic I had never considered digging into before, even when the big Voldemort issue first popped up, but now I find it interesting.
> 
> The blog
> https://dlang.org/blog/2017/12/20/ds-newfangled-name-mangling/
> 
> Reddit
> https://www.reddit.com/r/programming/comments/7l1h36/ds_newfangled_name_mangling/ 

Hi folks, the discussion in the announce forum is most welcome but statistically very few people read the forum. Please direct discussions to the reddit group, which enjoys a broader audience. Sadly right now the sparse reddit discussion makes the reception look worse than it actually was. -- Andrei
« First   ‹ Prev
1 2