Skip to content

Commit 0e5f27b

Browse files
committed
rustc_codegen_utils: add harness for dumping/checking symbol names, and mw mangling impl.
1 parent e331507 commit 0e5f27b

File tree

7 files changed

+974
-3
lines changed

7 files changed

+974
-3
lines changed

Cargo.lock

+16
Original file line numberDiff line numberDiff line change
@@ -2699,6 +2699,7 @@ dependencies = [
26992699
"rustc_metadata 0.0.0",
27002700
"rustc_mir 0.0.0",
27012701
"rustc_target 0.0.0",
2702+
"std-mangle-rs 0.1.0 (git+https://github.com/michaelwoerister/std-mangle-rs?rev=2336dcdfcc91db3cdda18eda73aca488773ac6fc)",
27022703
"syntax 0.0.0",
27032704
"syntax_pos 0.0.0",
27042705
]
@@ -3335,6 +3336,14 @@ dependencies = [
33353336
"unwind 0.0.0",
33363337
]
33373338

3339+
[[package]]
3340+
name = "std-mangle-rs"
3341+
version = "0.1.0"
3342+
source = "git+https://github.com/michaelwoerister/std-mangle-rs?rev=2336dcdfcc91db3cdda18eda73aca488773ac6fc#2336dcdfcc91db3cdda18eda73aca488773ac6fc"
3343+
dependencies = [
3344+
"unic-idna-punycode 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
3345+
]
3346+
33383347
[[package]]
33393348
name = "string_cache"
33403349
version = "0.7.3"
@@ -3849,6 +3858,11 @@ name = "ucd-util"
38493858
version = "0.1.3"
38503859
source = "registry+https://github.com/rust-lang/crates.io-index"
38513860

3861+
[[package]]
3862+
name = "unic-idna-punycode"
3863+
version = "0.7.0"
3864+
source = "registry+https://github.com/rust-lang/crates.io-index"
3865+
38523866
[[package]]
38533867
name = "unicase"
38543868
version = "2.4.0"
@@ -4354,6 +4368,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
43544368
"checksum smallvec 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b73ea3738b47563803ef814925e69be00799a8c07420be8b996f8e98fb2336db"
43554369
"checksum socket2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "c4d11a52082057d87cb5caa31ad812f4504b97ab44732cd8359df2e9ff9f48e7"
43564370
"checksum stable_deref_trait 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ffbc596e092fe5f598b12ef46cc03754085ac2f4d8c739ad61c4ae266cc3b3fa"
4371+
"checksum std-mangle-rs 0.1.0 (git+https://github.com/michaelwoerister/std-mangle-rs?rev=2336dcdfcc91db3cdda18eda73aca488773ac6fc)" = "<none>"
43574372
"checksum string_cache 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "25d70109977172b127fe834e5449e5ab1740b9ba49fa18a2020f509174f25423"
43584373
"checksum string_cache_codegen 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1eea1eee654ef80933142157fdad9dd8bc43cf7c74e999e369263496f04ff4da"
43594374
"checksum string_cache_shared 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b1884d1bc09741d466d9b14e6d37ac89d6909cbcac41dd9ae982d4d063bbedfc"
@@ -4397,6 +4412,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
43974412
"checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169"
43984413
"checksum ucd-trie 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "71a9c5b1fe77426cf144cc30e49e955270f5086e31a6441dfa8b32efc09b9d77"
43994414
"checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86"
4415+
"checksum unic-idna-punycode 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b0366615c248bc56ea5ceafe6f71a682f6591e653b1ce61814999302617b8c0"
44004416
"checksum unicase 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a84e5511b2a947f3ae965dcb29b13b7b1691b6e7332cf5dbc1744138d5acb7f6"
44014417
"checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5"
44024418
"checksum unicode-normalization 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "6a0180bc61fc5a987082bfa111f4cc95c4caff7f9799f3e46df09163a937aa25"

src/librustc_codegen_utils/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,7 @@ rustc_target = { path = "../librustc_target" }
2323
rustc_data_structures = { path = "../librustc_data_structures" }
2424
rustc_metadata = { path = "../librustc_metadata" }
2525
rustc_mir = { path = "../librustc_mir" }
26+
27+
[dependencies.std-mangle-rs]
28+
git = "https://github.com/michaelwoerister/std-mangle-rs"
29+
rev = "2336dcdfcc91db3cdda18eda73aca488773ac6fc"

src/librustc_codegen_utils/symbol_names.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ use syntax_pos::symbol::InternedString;
100100

101101
use log::debug;
102102

103+
mod dump;
103104
mod legacy;
105+
mod mw;
104106
mod v0;
105107

106108
pub fn provide(providers: &mut Providers<'_>) {
@@ -219,9 +221,19 @@ fn symbol_name(tcx: TyCtxt<'_, 'tcx, 'tcx>, instance: Instance<'tcx>) -> Interne
219221
};
220222

221223
let mangled = match mangling_version {
222-
SymbolManglingVersion::Legacy => legacy::mangle(tcx, instance, instantiating_crate),
224+
SymbolManglingVersion::Legacy => legacy::mangle(tcx, instance, instantiating_crate, false),
223225
SymbolManglingVersion::V0 => v0::mangle(tcx, instance, instantiating_crate, true),
224226
};
225227

226-
InternedString::intern(&mangled)
228+
let r = InternedString::intern(&mangled);
229+
230+
dump::record(
231+
tcx,
232+
instance,
233+
instantiating_crate,
234+
mangling_version,
235+
mangled,
236+
);
237+
238+
r
227239
}

0 commit comments

Comments
 (0)