Big +1.
I’ll give you a +2 if the mangling library of rustc would be implemented in the nursery and would come with a cross-validated demangling library that extracts all information from a symbol and comes with tools to build the dictionaries for compression/decompression.
What I learned writing cargo asm/cargo llvm-ir is that everybody that needs demangling either writes a Rust demangler by hand, or tapes their own solution on top of rustcdemangle because that library isn’t enough for their purposes.
It would be really nice to have a solid library for this.
@Centril
To what extent is the goal here to stabilize a symbol mangling scheme and thus make it a part of “the spec”?
I would say “to no extend”. I suggest wording this RFC as a better name mangling scheme for rustc only (whether this evolves in a de-facto standard or not time will tell). Putting name mangling in the Rust spec would require a lot of work (*) and deliver very little value without a full ABI.
(*) we would need a mangling scheme that would work on all past, present, and future platforms that Rust targets. If we put a name mangling scheme in the spec, and a future platform does not support it, then we won’t be able to target this platform with Rust. Name mangling is something that screams “implementation defined”, as in, the spec might mention name mangling, and might mention guarantees about name mangling (e.g. the type of mapping), but nothing specific about how it works on each platforms.
@gbutler
I think it would be better to not derail this discussion with a discussion about a stable Rust ABI. If you are interested in this, it might be worth it to discuss that in parallel in a different issue. Name mangling would be just a small piece of that discussion.