Only emit forward compatible v0 symbol names with graceful degradation · Issue #737 · rust-lang/compiler-team (original) (raw)

Proposal

The long time it takes for downstream tooling like GDB, perf, or valgrind to pick up support for changes in the v0 symbol mangling grammar has been the only real reason why v0 mangling is not the standard yet. This is not the fault of these tools, but rather a side effect of long-lived Linux distros sticking to a particular version of these tools for many years. This MCP proposes to mitigate the problem by using the existing v0 grammar in a way that allows graceful degradation:

The overall effect is that of graceful degradation. Old demanglers will show a mostly correct name, except for the generic parameters or types they don't understand.

Example

The symbol name my_crate::foo<{ (1i64, 2i64, 3i64) }> is mangled to _RINxC8my_crate3fooKTx1_x2_x3_EE according to the const generics additions proposed in rust-lang/rfcs#3161. Current demanglers will just fail to demangle this.

With the mitigation, it would be mangled to _RINxC8my_crate3fooC13_KTx1_x2_x3_EE (notice the added C13_ before the generic parameter). A current demangler will demangle this as my_crate::foo<_KTx1_x2_x3_E>. A newer demangler will be able to fully reconstruct the original my_crate::foo<{ (1i64, 2i64, 3i64) }>.

I expect that for complex symbol names with deeply nested generic arguments, getting a best effort demangling is a welcome improvement over just the mangled name.

The proposed solution is one possibility (inspired by @eddyb's proposol for dealing with f16 in rust-lang/rust#122106 (comment)). I'd be happy to hear other ideas.

Mentors or Reviewers

None yet.

Process

The main points of the Major Change Process are as follows:

You can read more about Major Change Proposals on forge.

Comments

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.