www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - D's Newfangled Name Mangling

reply Mike Parker <aldacron gmail.com> writes:
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/
Dec 20 2017
next sibling parent reply David Gileadi <gileadisNOSPM gmail.com> writes:
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_newfa
gled_name_mangling/ 
I really enjoyed this! Typo: "This is were I stepped in..." -> "..where.."
Dec 20 2017
parent reply =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
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_newfa
gled_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
Dec 20 2017
parent reply Mike Parker <aldacron gmail.com> writes:
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!
Dec 20 2017
parent Joakim <dlang joakim.fea.st> writes:
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
Dec 22 2017
prev sibling next sibling parent reply Johan Engelen <j j.nl> writes:
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
Dec 20 2017
parent Rainer Schuetze <r.sagitario gmx.de> writes:
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?).
Dec 21 2017
prev sibling next sibling parent reply Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
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?
Dec 21 2017
parent ketmar <ketmar ketmar.no-ip.org> writes:
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.
Dec 21 2017
prev sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
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_newfa
gled_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
Dec 22 2017
parent Joakim <dlang joakim.fea.st> writes:
On Friday, 22 December 2017 at 14:34:56 UTC, Andrei Alexandrescu 
wrote:
 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
We mostly just post corrections and technical suggestions in here, which are more likely to be seen. Anyway, the post has already done well on proggit, made top 25 most-liked of the last week and top 10 dlang.org posts of the last year: https://www.reddit.com/r/programming/top/?sort=top&t=week https://www.reddit.com/domain/dlang.org/top/?sort=top&t=year
Dec 22 2017