Skip to content

Commit 85fa90a

Browse files
committed
sess: default to v0 symbol mangling
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 commit changes the default symbol mangling scheme from the legacy scheme to the new Rust mangling scheme. Signed-off-by: David Wood <[email protected]>
1 parent 5a30e43 commit 85fa90a

File tree

8 files changed

+18
-18
lines changed

8 files changed

+18
-18
lines changed

compiler/rustc_session/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1496,7 +1496,7 @@ impl Options {
14961496
}
14971497

14981498
pub fn get_symbol_mangling_version(&self) -> SymbolManglingVersion {
1499-
self.cg.symbol_mangling_version.unwrap_or(SymbolManglingVersion::Legacy)
1499+
self.cg.symbol_mangling_version.unwrap_or(SymbolManglingVersion::V0)
15001500
}
15011501
}
15021502

tests/codegen-llvm/array-from_fn.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#[no_mangle]
99
pub fn iota() -> [u8; 16] {
10-
// OPT-NOT: core..array..Guard
11-
// NORMAL: core..array..Guard
10+
// OPT-NOT: core::array::Guard
11+
// NORMAL: core::array::Guard
1212
std::array::from_fn(|i| i as _)
1313
}

tests/codegen-llvm/no-alloca-inside-if-false.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77

88
#[inline(never)]
99
fn test<const SIZE: usize>() {
10-
// CHECK-LABEL: no_alloca_inside_if_false::test
10+
// CHECK-LABEL: no_alloca_inside_if_false::test::<8192>
1111
// CHECK: start:
12-
// CHECK-NEXT: alloca [{{12|24}} x i8]
13-
// CHECK-NOT: alloca
12+
// CHECK-NEXT: = alloca [{{12|24}} x i8]
13+
// CHECK-NOT: = alloca
1414
if const { SIZE < 4096 } {
1515
let arr = [0u8; SIZE];
1616
std::hint::black_box(&arr);

tests/codegen-llvm/precondition-checks.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313

1414
use std::ptr::NonNull;
1515

16-
// CHECK-LABEL: ; core::ptr::non_null::NonNull<T>::new_unchecked
16+
// CHECK-LABEL: ; <core::ptr::non_null::NonNull<u8>>::new_unchecked
1717
// CHECK-NOT: call
1818
// CHECK: }
1919

2020
// CHECK-LABEL: @nonnull_new
2121
#[no_mangle]
2222
pub unsafe fn nonnull_new(ptr: *mut u8) -> NonNull<u8> {
23-
// CHECK: ; call core::ptr::non_null::NonNull<T>::new_unchecked
23+
// CHECK: ; call <core::ptr::non_null::NonNull<u8>>::new_unchecked
2424
unsafe { NonNull::new_unchecked(ptr) }
2525
}

tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-drop-in-place.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#![crate_type = "lib"]
1111

12-
// CHECK-LABEL: define{{.*}}4core3ptr47drop_in_place$LT$dyn$u20$core..marker..Send$GT$
12+
// CHECK-LABEL: define{{.*}}4core3ptr13drop_in_placeDNtNtB4_6marker4Send
1313
// CHECK-SAME: {{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
1414
// CHECK: call i1 @llvm.type.test(ptr {{%.+}}, metadata !"_ZTSFvPu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops4drop4Dropu6regionEE")
1515

@@ -20,7 +20,7 @@ struct PresentDrop;
2020

2121
impl Drop for PresentDrop {
2222
fn drop(&mut self) {}
23-
// CHECK: define{{.*}}4core3ptr{{[0-9]+}}drop_in_place$LT${{.*}}PresentDrop$GT${{.*}}!type ![[TYPE1]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
23+
// CHECK: define{{.*}}4core3ptr{{[0-9]+}}drop_in_place{{.*}}PresentDrop{{.*}}!type ![[TYPE1]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
2424
}
2525

2626
pub fn foo() {

tests/codegen-llvm/sanitizer/kcfi/naked-function.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl MyTrait for Thing {}
2828
// the shim calls the real function
2929
// CHECK-LABEL: define
3030
// CHECK-SAME: my_naked_function
31-
// CHECK-SAME: reify.shim.fnptr
31+
// CHECK-SAME: reify_fnptr
3232

3333
// CHECK-LABEL: main
3434
#[unsafe(no_mangle)]
@@ -39,7 +39,7 @@ pub fn main() {
3939
// main calls the shim function
4040
// CHECK: call void
4141
// CHECK-SAME: my_naked_function
42-
// CHECK-SAME: reify.shim.fnptr
42+
// CHECK-SAME: reify_fnptr
4343
(F)();
4444
}
4545

tests/ui/panics/short-ice-remove-middle-frames-2.run.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ debug!!!
44
stack backtrace:
55
0: std::panicking::begin_panic
66
1: short_ice_remove_middle_frames_2::eight
7-
2: short_ice_remove_middle_frames_2::seven::{{closure}}
7+
2: short_ice_remove_middle_frames_2::seven::{closure#0}
88
[... omitted 3 frames ...]
99
3: short_ice_remove_middle_frames_2::fifth
10-
4: short_ice_remove_middle_frames_2::fourth::{{closure}}
10+
4: short_ice_remove_middle_frames_2::fourth::{closure#0}
1111
[... omitted 4 frames ...]
1212
5: short_ice_remove_middle_frames_2::first
1313
6: short_ice_remove_middle_frames_2::main
14-
7: core::ops::function::FnOnce::call_once
14+
7: <fn() as core::ops::function::FnOnce<()>>::call_once
1515
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

tests/ui/panics/short-ice-remove-middle-frames.run.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ stack backtrace:
55
0: std::panicking::begin_panic
66
1: short_ice_remove_middle_frames::seven
77
2: short_ice_remove_middle_frames::sixth
8-
3: short_ice_remove_middle_frames::fifth::{{closure}}
8+
3: short_ice_remove_middle_frames::fifth::{closure#0}
99
[... omitted 4 frames ...]
1010
4: short_ice_remove_middle_frames::second
11-
5: short_ice_remove_middle_frames::first::{{closure}}
11+
5: short_ice_remove_middle_frames::first::{closure#0}
1212
6: short_ice_remove_middle_frames::first
1313
7: short_ice_remove_middle_frames::main
14-
8: core::ops::function::FnOnce::call_once
14+
8: <fn() as core::ops::function::FnOnce<()>>::call_once
1515
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

0 commit comments

Comments
 (0)