Skip to content

Commit a4c0bf5

Browse files
committed
switch to v0 mangling by default on stable
Following #89117, rustc has defaulted to the v0 mangling scheme by default (since Nov 20th 2025). This surfaced two bugs: - #138261 was a small ICE (found via fuzzing) where an implementation-internal namespace was missing for global assembly - this occurs with names instantiated within global assembly (that can happen inside constants) - #134479 only occurs with unstable `generic_const_exprs` Since there have been three-to-four months for users to find bugs with this mangling scheme on nightly, that the scheme has been waiting many years to be stabilised, and has been used successfully internally at Microsoft, Meta and Google for many years, this patch proposes stabilising the v0 mangling scheme on stable. This patch does not propose removing the legacy mangling, it will remain usable on nightly as an escape-hatch if there are remaining bugs (though admittedly it would require switching to nightly for those on stable) - it is anticipated that this would be unlikely given current testing undergone by v0. Legacy mangling can be removed in another follow-up.
1 parent f60a0f1 commit a4c0bf5

4 files changed

Lines changed: 7 additions & 21 deletions

File tree

compiler/rustc_session/src/config.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,11 +1483,7 @@ impl Options {
14831483
}
14841484

14851485
pub fn get_symbol_mangling_version(&self) -> SymbolManglingVersion {
1486-
self.cg.symbol_mangling_version.unwrap_or(if self.unstable_features.is_nightly_build() {
1487-
SymbolManglingVersion::V0
1488-
} else {
1489-
SymbolManglingVersion::Legacy
1490-
})
1486+
self.cg.symbol_mangling_version.unwrap_or(SymbolManglingVersion::V0)
14911487
}
14921488

14931489
#[inline]

compiler/rustc_session/src/options.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2194,7 +2194,7 @@ options! {
21942194
"tell the linker which information to strip (`none` (default), `debuginfo` or `symbols`)"),
21952195
symbol_mangling_version: Option<SymbolManglingVersion> = (None,
21962196
parse_symbol_mangling_version, [TRACKED],
2197-
"which mangling version to use for symbol names ('legacy' (default), 'v0', or 'hashed')"),
2197+
"which mangling version to use for symbol names ('legacy', 'v0' (default), or 'hashed')"),
21982198
target_cpu: Option<String> = (None, parse_opt_string, [TRACKED],
21992199
"select target processor (`rustc --print target-cpus` for details)"),
22002200
target_feature: String = (String::new(), parse_target_feature, [TRACKED],

src/bootstrap/src/core/builder/cargo.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -664,16 +664,6 @@ impl Builder<'_> {
664664
rustflags.arg(sysroot_str);
665665
}
666666

667-
let use_new_symbol_mangling = self.config.rust_new_symbol_mangling.or_else(|| {
668-
if mode != Mode::Std {
669-
// The compiler and tools default to the new scheme
670-
Some(true)
671-
} else {
672-
// std follows the flag's default, which per compiler-team#938 is v0 on nightly
673-
None
674-
}
675-
});
676-
677667
// By default, windows-rs depends on a native library that doesn't get copied into the
678668
// sysroot. Passing this cfg enables raw-dylib support instead, which makes the native
679669
// library unnecessary. This can be removed when windows-rs enables raw-dylib
@@ -683,7 +673,8 @@ impl Builder<'_> {
683673
rustflags.arg("--cfg=windows_raw_dylib");
684674
}
685675

686-
if let Some(usm) = use_new_symbol_mangling {
676+
// When unset, follow the default of the compiler flag - the compiler, tools and std use v0
677+
if let Some(usm) = self.config.rust_new_symbol_mangling {
687678
rustflags.arg(if usm {
688679
"-Csymbol-mangling-version=v0"
689680
} else {

src/doc/rustc/src/symbol-mangling/index.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ foo::example_function
4646

4747
## Mangling versions
4848

49-
`rustc` supports different mangling versions which encode the names in different ways.
50-
The legacy version (which is currently the default on beta/stable) is not described here.
51-
The "v0" mangling scheme addresses several limitations of the legacy format,
52-
and is described in the [v0 Symbol Format](v0.md) chapter.
49+
There is currently one stable mangling scheme version - `v0`. On nightly builds, rustc supports
50+
switching back to the `legacy` mangling scheme using [`-C symbol-mangling-version`]. The `v0`
51+
mangling scheme is described in the [v0 Symbol Format](v0.md) chapter.

0 commit comments

Comments
 (0)