-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removal of C++ name mangling is not correctly applied #14205
Comments
I remember when this change was made in upstream llvm. Here is the discussion we had at the time: https://reviews.llvm.org/D44316. I think the idea was based on the fact that the name section is supposed to contain "user visible names" for functions and that mangled names are not very helpful to users when they see them in backtrace. Also, since the mangling conventions is language specific, its not easy for devtools to do any kind of universal demangling when it shows backtraces. I agree that adding an option to control this could make sense, especially if we want to be able to use the names section for analysis. We do have a Maybe easier and more universal to just add a |
@dschuff @sunfishcode @kripken @RReverser what do you think? Should we add an option for keeping the name section mangled? Or even switch the default back to mangled? |
Would this mean that the name section would then have the compile time (.o time) names like
I don't particularly mind what the default is, so needing a
We did already use
I.e. one is unable to correlate the object file contents together with the symbol map. |
+1 for |
Oh.. I forgot we already have |
Should we make it the default for emscripten? i.e. How useful is it having human readable stack traced generated by the VM? |
I like the idea of the linker flag too. So for the question of defaults... Maybe the "right" thing to do is have the browser devtools do the demangling when it shows stack traces. There is some precedent for that kind of thing (e.g. Chrome has some smarts for async functions). Then if you captured the trace programmatically you'd get mangled names, which is probably what you'd want. |
I think there are a couple of issues with expecting the engine to be able to do demangling:
|
cc @pfaffe My initial thought here would be that the names section should contain mangled names, and that it's the debugger's responsibility to demangle. But thinking about it more, the DWARF data already contains the mangled names and the primary use of the names section is when DWARF data isn't readily available, and in that case, it might be some generic tool looking at the names that doesn't understanding C++ name demangling. |
I think keeping demangled names in the name section makes more sense too, given that it can be mangled by pretty much any scheme from any language and, unlike in DWARF, we don't have information on which language it was. |
@juj, can you try the existing Also, not that the strange
Perhaps |
I am a bit hard pressed on time to test that out - when I have a chance to jump back on this, I'll give this a try (we disabled object file analysis support for now)
Ah yea, that would be useful to UTF-8 decode the prints. |
In wasm backend, someone decided that the traditional C++ name mangling would not be applied. This has caused numerous issues into the toolchain and to the users of the toolchain in the past. After #13477 I was hopeful that would have been the last of it, but here we go again:
Run with
We see that when the code is still at the object file stage, the C++ name mangling is still applied, and e.g. the constructor
Foo::Foo
has a name_ZN3FooC2Eii
. After the linking has occurred, the constructor instead has changed its name toFoo::Foo\28int\2c\20int\29
.This is preventing our tooling from analyzing which object files contribute which symbols (for size analysis) into the final output.
Is there a way that we could restore the proper C++ name mangling like the way it used to be? Maybe with a custom flag? This has been a major source of headache. Alternatively, is there a way that the symbols in .o files would have unmangled names also? (or maybe both solutions?)
The text was updated successfully, but these errors were encountered: