Hi Eddy, On Thu, Dec 02, 2021 at 07:35:17PM +0200, Eduard-Mihai Burtescu wrote: > On Thu, Dec 2, 2021, at 19:17, Mark Wielaard wrote: > > Rust v0 symbols can have a .suffix because if compiler transformations. > > For some context, the suffix comes from LLVM (I believe as part of > its LTO). If this were a semantic part of a Rust symbol, it would > have an encoding within v0 (as we already do for e.g. shims).
The same is true for gccrs or the libgccjit backend, gcc might clone the symbol name and make it unique by appending some .suffix name. > That also means that for consistency, suffixes like these should be > handled uniformly for both v0 and legacy (as rustc-demangle does), > since LLVM doesn't distinguish. The problem with the legacy mangling is that dot '.' is a valid character. That is why the patch only handles the v0 mangling case (where dot '.' isn't valid). > You may even be able to get Clang to generate C++ mangled symbols > with ".llvm." suffixes, with enough application of LTO. This is not > unlike GCC ".clone" suffixes, AFAIK. Sadly I don't think there's a > way to handle both as "outside the symbol", without hardcoding > ".llvm." in the implementation. We could use the scheme used by c++ where the .suffix is added as " [clone .suffix]", it even handles multiple dots, where something like _Z3fooi.part.9.165493.constprop.775.31805 demangles to foo(int) [clone .part.9.165493] [clone .constprop.775.31805] I just don't think that is very useful and a little confusing. > I don't recall the libiberty demangling API having any provisions > for the demangler deciding that a mangled symbol "stops early", > which would maybe allow for a more general solution. No, there indeed is no interface. We might introduce a new option flag for treating '.' as end of symbol. But do we really need that flexibility? > Despite all that, if it helps in practice, I would still not mind > this patch landing in its current form, I just wanted to share my > perspective on the larger issue. Thanks for that. Do you happen to know what other rust demanglers do? Cheers, Mark