Git Product home page Git Product logo

Comments (3)

narpfel avatar narpfel commented on June 14, 2024 1

rustc has two name mangling schemes, legacy (the default for now) and v0 (which will become the default at some point in the future).

legacy disambiguates duplicate symbol names (such as the call_once methods of different closures) by including a unique-per-symbol hash in each name. CE’s demangler could include this hash, but doesn’t currently. FWIW, c++filt includes the hash by default.

v0 was designed so that a demangled name should be unique by itself. (Note: It still uses a hash to disambiguate crates with the same name.)

Always including the hash might make sense for legacy mangling, but for v0 it’s mostly unnecessary information (duplicate crates in different versions are rare on CE, also the v0 RFC recommends omitting the crate-id), so I’d suggest a new checkbox Options...Include disambiguating hashes in identifiers (wording TBD) that controls whether hashes are included. Another wording could be Verbose demangling, which is what c++filt calls this.

v0 demanglings for a closure’s call_once method without and with crate-ids:

<example::get_multiplier::{closure#0} as core::ops::function::FnOnce<(u32, u32)>>::call_once:
<example[e8d519bf5b4bcf09]::get_multiplier::{closure#0} as core[5a612027cd243909]::ops::function::FnOnce<(u32, u32)>>::call_once:

As a workaround, -C symbol-mangling-version=v0 can be passed to the compiler: https://godbolt.org/z/zxEf7P6rj

from compiler-explorer.

partouf avatar partouf commented on June 14, 2024

Using v0 if available seems to make a lot more sense to me.
It's not easy to add something like a counter as it will require a lot more logic, or we would have to make them unique by adding the hash to the demangled name.

(for reference, demangler is here https://github.com/compiler-explorer/tools/blob/main/rust/src/main.rs (we might need to rebuild this anyway) - but the names are passed 1 by 1 by this TS code https://github.com/compiler-explorer/compiler-explorer/tree/main/lib/demangler)

(we use this for c++ (demanglerType=cpp) -> https://github.com/compiler-explorer/compiler-explorer/blob/main/lib/demangler/cpp.ts to add extra text to the demangled names)

from compiler-explorer.

narpfel avatar narpfel commented on June 14, 2024

I implemented the checkbox I proposed in #6265.

Also, this issue has come up before: #1754.

from compiler-explorer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.