Skip to content

Commit 386d425

Browse files
committed
[TEMPORARY] rustc_codegen_utils: add harness for dumping/checking symbol names, and mw mangling impl.
1 parent 26898a0 commit 386d425

File tree

6 files changed

+930
-1
lines changed

6 files changed

+930
-1
lines changed

Cargo.lock

+23
Original file line numberDiff line numberDiff line change
@@ -2371,6 +2371,11 @@ dependencies = [
23712371
"rustc-std-workspace-core 1.0.0",
23722372
]
23732373

2374+
[[package]]
2375+
name = "rustc-demangle"
2376+
version = "0.1.13"
2377+
source = "git+https://github.com/eddyb/rustc-demangle?rev=20d5bcc9bcea0d9413540916dd5f9fdadc7012f7#20d5bcc9bcea0d9413540916dd5f9fdadc7012f7"
2378+
23742379
[[package]]
23752380
name = "rustc-hash"
23762381
version = "1.0.1"
@@ -2531,11 +2536,13 @@ dependencies = [
25312536
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
25322537
"punycode 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
25332538
"rustc 0.0.0",
2539+
"rustc-demangle 0.1.13 (git+https://github.com/eddyb/rustc-demangle?rev=20d5bcc9bcea0d9413540916dd5f9fdadc7012f7)",
25342540
"rustc_data_structures 0.0.0",
25352541
"rustc_incremental 0.0.0",
25362542
"rustc_metadata 0.0.0",
25372543
"rustc_mir 0.0.0",
25382544
"rustc_target 0.0.0",
2545+
"std-mangle-rs 0.1.0 (git+https://github.com/michaelwoerister/std-mangle-rs?rev=2336dcdfcc91db3cdda18eda73aca488773ac6fc)",
25392546
"syntax 0.0.0",
25402547
"syntax_pos 0.0.0",
25412548
]
@@ -3095,6 +3102,14 @@ dependencies = [
30953102
"unwind 0.0.0",
30963103
]
30973104

3105+
[[package]]
3106+
name = "std-mangle-rs"
3107+
version = "0.1.0"
3108+
source = "git+https://github.com/michaelwoerister/std-mangle-rs?rev=2336dcdfcc91db3cdda18eda73aca488773ac6fc#2336dcdfcc91db3cdda18eda73aca488773ac6fc"
3109+
dependencies = [
3110+
"unic-idna-punycode 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
3111+
]
3112+
30983113
[[package]]
30993114
name = "string_cache"
31003115
version = "0.7.3"
@@ -3554,6 +3569,11 @@ name = "ucd-util"
35543569
version = "0.1.3"
35553570
source = "registry+https://github.com/rust-lang/crates.io-index"
35563571

3572+
[[package]]
3573+
name = "unic-idna-punycode"
3574+
version = "0.7.0"
3575+
source = "registry+https://github.com/rust-lang/crates.io-index"
3576+
35573577
[[package]]
35583578
name = "unicode-bidi"
35593579
version = "0.3.4"
@@ -3987,6 +4007,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
39874007
"checksum rustc-ap-syntax 306.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1adc189e5e4500a4167b9afa04e67067f40d0039e0e05870c977bebb561f065a"
39884008
"checksum rustc-ap-syntax_pos 306.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4d42c430dbb0be4377bfe6aa5099074c63ac8796b24098562c2e2154aecc5652"
39894009
"checksum rustc-demangle 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "82ae957aa1b3055d8e086486723c0ccd3d7b8fa190ae8fa2e35543b6171c810e"
4010+
"checksum rustc-demangle 0.1.13 (git+https://github.com/eddyb/rustc-demangle?rev=20d5bcc9bcea0d9413540916dd5f9fdadc7012f7)" = "<none>"
39904011
"checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8"
39914012
"checksum rustc-rayon 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c6d5a683c6ba4ed37959097e88d71c9e8e26659a3cb5be8b389078e7ad45306"
39924013
"checksum rustc-rayon-core 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40f06724db71e18d68b3b946fdf890ca8c921d9edccc1404fdfdb537b0d12649"
@@ -4014,6 +4035,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
40144035
"checksum smallvec 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b73ea3738b47563803ef814925e69be00799a8c07420be8b996f8e98fb2336db"
40154036
"checksum socket2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "c4d11a52082057d87cb5caa31ad812f4504b97ab44732cd8359df2e9ff9f48e7"
40164037
"checksum stable_deref_trait 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ffbc596e092fe5f598b12ef46cc03754085ac2f4d8c739ad61c4ae266cc3b3fa"
4038+
"checksum std-mangle-rs 0.1.0 (git+https://github.com/michaelwoerister/std-mangle-rs?rev=2336dcdfcc91db3cdda18eda73aca488773ac6fc)" = "<none>"
40174039
"checksum string_cache 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "25d70109977172b127fe834e5449e5ab1740b9ba49fa18a2020f509174f25423"
40184040
"checksum string_cache_codegen 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "35293b05cf1494e8ddd042a7df6756bf18d07f42d234f32e71dce8a7aabb0191"
40194041
"checksum string_cache_shared 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b1884d1bc09741d466d9b14e6d37ac89d6909cbcac41dd9ae982d4d063bbedfc"
@@ -4051,6 +4073,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
40514073
"checksum toml-query 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6854664bfc6df0360c695480836ee90e2d0c965f06db291d10be9344792d43e8"
40524074
"checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169"
40534075
"checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86"
4076+
"checksum unic-idna-punycode 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b0366615c248bc56ea5ceafe6f71a682f6591e653b1ce61814999302617b8c0"
40544077
"checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5"
40554078
"checksum unicode-normalization 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "6a0180bc61fc5a987082bfa111f4cc95c4caff7f9799f3e46df09163a937aa25"
40564079
"checksum unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa6024fc12ddfd1c6dbc14a80fa2324d4568849869b779f6bd37e5e4c03344d1"

src/librustc_codegen_utils/Cargo.toml

+8
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,11 @@ rustc_data_structures = { path = "../librustc_data_structures" }
2222
rustc_metadata = { path = "../librustc_metadata" }
2323
rustc_mir = { path = "../librustc_mir" }
2424
rustc_incremental = { path = "../librustc_incremental" }
25+
26+
[dependencies.std-mangle-rs]
27+
git = "https://github.com/michaelwoerister/std-mangle-rs"
28+
rev = "2336dcdfcc91db3cdda18eda73aca488773ac6fc"
29+
30+
[dependencies.rustc-demangle]
31+
git = "https://github.com/eddyb/rustc-demangle"
32+
rev = "20d5bcc9bcea0d9413540916dd5f9fdadc7012f7"

src/librustc_codegen_utils/symbol_names.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ use syntax_pos::symbol::Symbol;
106106
use std::fmt::{self, Write};
107107
use std::mem::{self, discriminant};
108108

109+
mod dump;
110+
mod mw;
109111
mod new;
110112

111113
pub fn provide(providers: &mut Providers) {
@@ -338,7 +340,11 @@ fn compute_mangled_symbol_name(tcx: TyCtxt<'_, 'tcx, 'tcx>, instance: Instance<'
338340
sanitize(&mut buf.temp_buf, "{{vtable-shim}}");
339341
}
340342

341-
buf.finish(hash)
343+
let mangled_symbol = buf.finish(hash);
344+
345+
return dump::record(tcx, instance, &mangled_symbol, hash);
346+
347+
// mangled_symbol
342348
}
343349

344350
// Follow C++ namespace-mangling style, see

0 commit comments

Comments
 (0)