rust/compiler
bors 683dd08db5 Auto merge of #89917 - davidtwco:issue-60705-stabilize-rust-symbol-mangling-scheme, r=wesleywiser
sess: default to v0 symbol mangling on nightly

cc rust-lang/rust#60705 rust-lang/compiler-team#938

Rust's current mangling scheme depends on compiler internals; loses information about generic parameters (and other things) which makes for a worse experience when using external tools that need to interact with Rust symbol names; is inconsistent; and can contain `.` characters which aren't universally supported. Therefore, Rust has defined its own symbol mangling scheme which is defined in terms of the Rust language, not the compiler implementation; encodes information about generic parameters in a reversible way; has a consistent definition; and generates symbols that only use the characters `A-Z`, `a-z`, `0-9`, and `_`.

Support for the new Rust symbol mangling scheme has been added to upstream tools that will need to interact with Rust symbols (e.g. debuggers).

This pull request changes the default symbol mangling scheme from the legacy scheme to the new Rust mangling scheme on nightly.

The following pull requests implemented v0 mangling in rustc (if I'm missing any, let me know):

- rust-lang/rust#57967
- rust-lang/rust#63559
- rust-lang/rust#75675
- rust-lang/rust#77452
- rust-lang/rust#77554
- rust-lang/rust#83767
- rust-lang/rust#87194
- rust-lang/rust#87789

Rust's symbol mangling scheme has support in the following external tools:

- `binutils`/`gdb` (GNU `libiberty`)
    - [[PATCH] Move rust_{is_mangled,demangle_sym} to a private libiberty header.
](https://gcc.gnu.org/pipermail/gcc-patches/2019-June/523011.html) committed as 979526c9ce
    - [[PATCH] Simplify and generalize rust-demangle's unescaping logic.
](https://gcc.gnu.org/pipermail/gcc-patches/2019-August/527835.html) committed as 42bf58bb13
    - [[PATCH] Remove some restrictions from rust-demangle.
](https://gcc.gnu.org/pipermail/gcc-patches/2019-September/530445.html) committed as e1cb00db67
    - [[PATCH] Refactor rust-demangle to be independent of C++ demangling.
](https://gcc.gnu.org/pipermail/gcc-patches/2019-November/533719.html) ([original submission](https://gcc.gnu.org/pipermail/gcc-patches/2019-October/532388.html)) committed as 32fc3719e0
    - [[PATCH] Support the new ("v0") mangling scheme in rust-demangle.
](https://gcc.gnu.org/pipermail/gcc-patches/2020-November/558905.html) ([original submission](https://gcc.gnu.org/pipermail/gcc-patches/2020-March/542012.html)) committed as 84096498a7
- `lldb`/`llvm-objdump`/`llvm-nm`/`llvm-symbolizer`/`llvm-cxxfilt`/etc
  - 7310403e3c
  - c8c2b4629f
  - 0a2d4f3f24
- Linux `perf`
- `valgrind`
  - [Update demangler to support Rust v0 name mangling.](https://bugs.kde.org/show_bug.cgi?id=431306)

https://github.com/rust-lang/rust/pull/85530#issuecomment-857855379 contains a summary of the most recent crater run of the v0 mangling, and the remaining issues from that were fixed by rust-lang/rust#87194 (confirmed by follow-up crater run, https://github.com/rust-lang/rust/pull/85530#issuecomment-883679416).

`@rustbot` label +T-compiler
r? `@michaelwoerister`
2025-11-20 04:26:30 +00:00
..
rustc Revert "Rollup merge of #146627 - madsmtm:jemalloc-simplify, r=jdonszelmann" 2025-11-13 10:29:26 +01:00
rustc_abi Rollup merge of #145954 - RalfJung:syscall-c-variadics, r=jackh726 2025-11-16 20:30:53 +11:00
rustc_arena Allow internal_features lint in doc tests 2025-11-05 11:25:29 +00:00
rustc_ast Give all impls a constness 2025-11-18 09:20:21 +00:00
rustc_ast_ir Implement &pin patterns and ref pin bindings 2025-11-10 09:57:08 +08:00
rustc_ast_lowering Give all impls a constness 2025-11-18 09:20:21 +00:00
rustc_ast_passes Forbid const fn within const impls 2025-11-18 16:00:18 +00:00
rustc_ast_pretty Give all impls a constness 2025-11-18 09:20:21 +00:00
rustc_attr_parsing Rollup merge of #148484 - JonathanBrouwer:wip_attr_style, r=jdonszelmann 2025-11-18 16:52:11 +01:00
rustc_baked_icu_data Unify the configuration of the compiler docs 2025-11-05 11:25:27 +00:00
rustc_borrowck Replace OffsetOf by an actual sum. 2025-11-18 00:10:03 +00:00
rustc_builtin_macros Give all impls a constness 2025-11-18 09:20:21 +00:00
rustc_codegen_cranelift Replace OffsetOf by an actual sum. 2025-11-18 00:10:03 +00:00
rustc_codegen_gcc Auto merge of #148481 - GuillaumeGomez:subtree-update_cg_gcc_2025-11-04, r=GuillaumeGomez 2025-11-13 18:00:02 +00:00
rustc_codegen_llvm Auto merge of #149013 - Zalathar:rollup-io1ddhc, r=Zalathar 2025-11-17 07:49:48 +00:00
rustc_codegen_ssa Replace OffsetOf by an actual sum. 2025-11-18 00:10:03 +00:00
rustc_const_eval Auto merge of #148434 - oli-obk:inherent-const-impl, r=fee1-dead 2025-11-19 02:23:56 +00:00
rustc_data_structures Auto merge of #148818 - Zalathar:rollup-4vujcg0, r=Zalathar 2025-11-11 13:30:50 +00:00
rustc_driver Unify the configuration of the compiler docs 2025-11-05 11:25:27 +00:00
rustc_driver_impl Fix new function_casts_as_integer lint errors in core, std, panic_unwind and compiler crates 2025-11-10 16:38:28 +01:00
rustc_error_codes Unify the configuration of the compiler docs 2025-11-05 11:25:27 +00:00
rustc_error_messages Unify the configuration of the compiler docs 2025-11-05 11:25:27 +00:00
rustc_errors flush_delayed: add note about stashed diagnostics 2025-11-17 12:09:57 +01:00
rustc_expand Give all impls a constness 2025-11-18 09:20:21 +00:00
rustc_feature Rollup merge of #148484 - JonathanBrouwer:wip_attr_style, r=jdonszelmann 2025-11-18 16:52:11 +01:00
rustc_fluent_macro Unify the configuration of the compiler docs 2025-11-05 11:25:27 +00:00
rustc_fs_util
rustc_graphviz Allow internal_features lint in doc tests 2025-11-05 11:25:29 +00:00
rustc_hashes
rustc_hir Auto merge of #149054 - oli-obk:min-encode, r=fee1-dead 2025-11-19 12:06:14 +00:00
rustc_hir_analysis Auto merge of #148434 - oli-obk:inherent-const-impl, r=fee1-dead 2025-11-19 02:23:56 +00:00
rustc_hir_id
rustc_hir_pretty Give all impls a constness 2025-11-18 09:20:21 +00:00
rustc_hir_typeck Rollup merge of #147171 - Qelxiros:hashmap_diag, r=fee1-dead 2025-11-19 09:48:05 +01:00
rustc_incremental Unify the configuration of the compiler docs 2025-11-05 11:25:27 +00:00
rustc_index Unify the configuration of the compiler docs 2025-11-05 11:25:27 +00:00
rustc_index_macros
rustc_infer Unify the configuration of the compiler docs 2025-11-05 11:25:27 +00:00
rustc_interface fix(span): track unnormalized source len for dep-info 2025-11-15 09:05:08 -05:00
rustc_lexer
rustc_lint Rollup merge of #147421 - Kivooeo:ice-fix51621, r=chenyukang 2025-11-19 09:48:06 +01:00
rustc_lint_defs c_variadic: Add future-incompatibility warning for ... arguments without a pattern outside of extern blocks 2025-11-10 14:33:56 +01:00
rustc_llvm Remove unused LLVMModuleRef argument 2025-11-12 15:46:08 +00:00
rustc_log
rustc_macros
rustc_metadata Auto merge of #149054 - oli-obk:min-encode, r=fee1-dead 2025-11-19 12:06:14 +00:00
rustc_middle Auto merge of #149054 - oli-obk:min-encode, r=fee1-dead 2025-11-19 12:06:14 +00:00
rustc_mir_build Replace OffsetOf by an actual sum. 2025-11-18 00:10:03 +00:00
rustc_mir_dataflow Replace OffsetOf by an actual sum. 2025-11-18 00:10:03 +00:00
rustc_mir_transform Replace OffsetOf by an actual sum. 2025-11-18 00:10:03 +00:00
rustc_monomorphize error on non-rustic ABIs using unsized parameters 2025-11-05 12:12:10 +01:00
rustc_next_trait_solver move GAT inference prevention hack 2025-11-12 14:59:28 +01:00
rustc_parse Allow inherent const impl blocks 2025-11-18 16:00:18 +00:00
rustc_parse_format Allow internal_features lint in doc tests 2025-11-05 11:25:29 +00:00
rustc_passes Auto merge of #148434 - oli-obk:inherent-const-impl, r=fee1-dead 2025-11-19 02:23:56 +00:00
rustc_pattern_analysis fix: Do not ICE when missing match arm with ill-formed subty is met 2025-11-13 01:36:35 +09:00
rustc_privacy Unify the configuration of the compiler docs 2025-11-05 11:25:27 +00:00
rustc_proc_macro
rustc_public Replace OffsetOf by an actual sum. 2025-11-18 00:10:03 +00:00
rustc_public_bridge Allow internal_features lint in doc tests 2025-11-05 11:25:29 +00:00
rustc_query_impl Lock shards while collecting active jobs. 2025-11-14 09:01:22 +08:00
rustc_query_system fix(span): track unnormalized source len for dep-info 2025-11-15 09:05:08 -05:00
rustc_resolve Remove unnecessary lifetime in with_generic_param_rib 2025-11-14 20:30:26 +07:00
rustc_sanitizers
rustc_serialize Allow internal_features lint in doc tests 2025-11-05 11:25:29 +00:00
rustc_session sess: default to v0 symbol mangling 2025-11-19 11:55:09 +00:00
rustc_span Rollup merge of #147171 - Qelxiros:hashmap_diag, r=fee1-dead 2025-11-19 09:48:05 +01:00
rustc_symbol_mangling Unify the configuration of the compiler docs 2025-11-05 11:25:27 +00:00
rustc_target Rollup merge of #148999 - moturus:remote-test-server, r=jieyouxu 2025-11-17 16:41:05 +11:00
rustc_thread_pool
rustc_trait_selection Rollup merge of #148698 - tiif:const_query_cycle, r=BoxyUwU 2025-11-17 18:07:33 +01:00
rustc_traits add const_of_item query and use it in normalization 2025-11-08 13:50:47 -05:00
rustc_transmute
rustc_ty_utils Replace OffsetOf by an actual sum. 2025-11-18 00:10:03 +00:00
rustc_type_ir Auto merge of #135634 - joboet:trivial-clone, r=Mark-Simulacrum 2025-11-10 15:41:43 +00:00
rustc_type_ir_macros compiler: Fix a couple issues around cargo feature unification 2025-10-31 14:14:05 -04:00
rustc_windows_rc