Skip to content

Commit 9ef2ef7

Browse files
authored
Unrolled build for rust-lang#125880
Rollup merge of rust-lang#125880 - Zalathar:demangler, r=oli-obk Remove `src/tools/rust-demangler` `rust-demangler` is a small binary that reads a list of mangled symbols from stdin, demangles them (using the `rustc-demangle` library crate), and prints the demangled symbols to stdout. It was added as part of the initial implementation of coverage instrumentation in 2020/2021, so that coverage tests could pass it to `llvm-cov --Xdemangler` when generating coverage reports. It has been largely untouched since then. As of rust-lang#125816 it is no longer used by coverage tests, and has no remaining in-tree uses. There is code in bootstrap to build and package the demangler, but it's unclear where the resulting binaries actually end up, or whether there's any reasonable way for `rustup` users to obtain them. --- For users needing a command-line demangler, `rustfilt` exists and is more actively maintained. It's also quite easy to use the `rustc-demangle` library to build a custom command-line demangler if necessary, with only a few lines of code. The tool's name (`rust-demangler`) is easily confused with the name of the library crate `rustc-demangle`, so removing the tool will eliminate that confusion. There also doesn't appear to be much reason to use `rust-demangler` over `rustfilt`. --- This PR therefore removes the tool, and removes all of its associated code from bootstrap. MCP filed: rust-lang/compiler-team#754
2 parents 5978f35 + fd4fe7d commit 9ef2ef7

File tree

16 files changed

+5
-450
lines changed

16 files changed

+5
-450
lines changed

Cargo.lock

-8
Original file line numberDiff line numberDiff line change
@@ -3479,14 +3479,6 @@ dependencies = [
34793479
"wasmparser",
34803480
]
34813481

3482-
[[package]]
3483-
name = "rust-demangler"
3484-
version = "0.0.1"
3485-
dependencies = [
3486-
"regex",
3487-
"rustc-demangle",
3488-
]
3489-
34903482
[[package]]
34913483
name = "rustbook"
34923484
version = "0.1.0"

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ members = [
2323
"src/tools/remote-test-client",
2424
"src/tools/remote-test-server",
2525
"src/tools/rust-installer",
26-
"src/tools/rust-demangler",
2726
"src/tools/rustdoc",
2827
"src/tools/rls",
2928
"src/tools/rustfmt",

config.example.toml

+1-3
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,7 @@
321321
#
322322
# If `extended = false`, the only one of these built by default is rustdoc.
323323
#
324-
# If `extended = true`, they're all included, with the exception of
325-
# rust-demangler which additionally requires `profiler = true` to be set.
324+
# If `extended = true`, they are all included.
326325
#
327326
# If any enabled tool fails to build, the installation fails.
328327
#tools = [
@@ -334,7 +333,6 @@
334333
# "rust-analyzer-proc-macro-srv",
335334
# "analysis",
336335
# "src",
337-
# "rust-demangler", # if profiler = true
338336
#]
339337

340338
# Verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose, 3 == print environment variables on each rustc invocation

src/bootstrap/src/core/build_steps/clippy.rs

-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ lint_any!(
322322
RemoteTestServer, "src/tools/remote-test-server", "remote-test-server";
323323
Rls, "src/tools/rls", "rls";
324324
RustAnalyzer, "src/tools/rust-analyzer", "rust-analyzer";
325-
RustDemangler, "src/tools/rust-demangler", "rust-demangler";
326325
Rustdoc, "src/tools/rustdoc", "clippy";
327326
Rustfmt, "src/tools/rustfmt", "rustfmt";
328327
RustInstaller, "src/tools/rust-installer", "rust-installer";

src/bootstrap/src/core/build_steps/dist.rs

+3-90
Original file line numberDiff line numberDiff line change
@@ -1459,62 +1459,6 @@ impl Step for Rustfmt {
14591459
}
14601460
}
14611461

1462-
#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
1463-
pub struct RustDemangler {
1464-
pub compiler: Compiler,
1465-
pub target: TargetSelection,
1466-
}
1467-
1468-
impl Step for RustDemangler {
1469-
type Output = Option<GeneratedTarball>;
1470-
const DEFAULT: bool = true;
1471-
const ONLY_HOSTS: bool = true;
1472-
1473-
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1474-
// While other tools use `should_build_extended_tool` to decide whether to be run by
1475-
// default or not, `rust-demangler` must be build when *either* it's enabled as a tool like
1476-
// the other ones or if `profiler = true`. Because we don't know the target at this stage
1477-
// we run the step by default when only `extended = true`, and decide whether to actually
1478-
// run it or not later.
1479-
let default = run.builder.config.extended;
1480-
run.alias("rust-demangler").default_condition(default)
1481-
}
1482-
1483-
fn make_run(run: RunConfig<'_>) {
1484-
run.builder.ensure(RustDemangler {
1485-
compiler: run.builder.compiler_for(
1486-
run.builder.top_stage,
1487-
run.builder.config.build,
1488-
run.target,
1489-
),
1490-
target: run.target,
1491-
});
1492-
}
1493-
1494-
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
1495-
let compiler = self.compiler;
1496-
let target = self.target;
1497-
1498-
// Only build this extended tool if explicitly included in `tools`, or if `profiler = true`
1499-
let condition = should_build_extended_tool(builder, "rust-demangler")
1500-
|| builder.config.profiler_enabled(target);
1501-
if builder.config.extended && !condition {
1502-
return None;
1503-
}
1504-
1505-
let rust_demangler =
1506-
builder.ensure(tool::RustDemangler { compiler, target, extra_features: Vec::new() });
1507-
1508-
// Prepare the image directory
1509-
let mut tarball = Tarball::new(builder, "rust-demangler", &target.triple);
1510-
tarball.set_overlay(OverlayKind::RustDemangler);
1511-
tarball.is_preview(true);
1512-
tarball.add_file(rust_demangler, "bin", 0o755);
1513-
tarball.add_legal_and_readme_to("share/doc/rust-demangler");
1514-
Some(tarball.generate())
1515-
}
1516-
}
1517-
15181462
#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
15191463
pub struct Extended {
15201464
stage: u32,
@@ -1572,7 +1516,6 @@ impl Step for Extended {
15721516

15731517
add_component!("rust-docs" => Docs { host: target });
15741518
add_component!("rust-json-docs" => JsonDocs { host: target });
1575-
add_component!("rust-demangler"=> RustDemangler { compiler, target });
15761519
add_component!("cargo" => Cargo { compiler, target });
15771520
add_component!("rustfmt" => Rustfmt { compiler, target });
15781521
add_component!("rls" => Rls { compiler, target });
@@ -1636,7 +1579,7 @@ impl Step for Extended {
16361579

16371580
let xform = |p: &Path| {
16381581
let mut contents = t!(fs::read_to_string(p));
1639-
for tool in &["rust-demangler", "miri", "rust-docs"] {
1582+
for tool in &["miri", "rust-docs"] {
16401583
if !built_tools.contains(tool) {
16411584
contents = filter(&contents, tool);
16421585
}
@@ -1677,7 +1620,7 @@ impl Step for Extended {
16771620
prepare("rust-analysis");
16781621
prepare("clippy");
16791622
prepare("rust-analyzer");
1680-
for tool in &["rust-docs", "rust-demangler", "miri", "rustc-codegen-cranelift"] {
1623+
for tool in &["rust-docs", "miri", "rustc-codegen-cranelift"] {
16811624
if built_tools.contains(tool) {
16821625
prepare(tool);
16831626
}
@@ -1717,8 +1660,6 @@ impl Step for Extended {
17171660
"rust-analyzer-preview".to_string()
17181661
} else if name == "clippy" {
17191662
"clippy-preview".to_string()
1720-
} else if name == "rust-demangler" {
1721-
"rust-demangler-preview".to_string()
17221663
} else if name == "miri" {
17231664
"miri-preview".to_string()
17241665
} else if name == "rustc-codegen-cranelift" {
@@ -1738,7 +1679,7 @@ impl Step for Extended {
17381679
prepare("cargo");
17391680
prepare("rust-analysis");
17401681
prepare("rust-std");
1741-
for tool in &["clippy", "rust-analyzer", "rust-docs", "rust-demangler", "miri"] {
1682+
for tool in &["clippy", "rust-analyzer", "rust-docs", "miri"] {
17421683
if built_tools.contains(tool) {
17431684
prepare(tool);
17441685
}
@@ -1862,25 +1803,6 @@ impl Step for Extended {
18621803
.arg(etc.join("msi/remove-duplicates.xsl")),
18631804
);
18641805
}
1865-
if built_tools.contains("rust-demangler") {
1866-
builder.run(
1867-
Command::new(&heat)
1868-
.current_dir(&exe)
1869-
.arg("dir")
1870-
.arg("rust-demangler")
1871-
.args(heat_flags)
1872-
.arg("-cg")
1873-
.arg("RustDemanglerGroup")
1874-
.arg("-dr")
1875-
.arg("RustDemangler")
1876-
.arg("-var")
1877-
.arg("var.RustDemanglerDir")
1878-
.arg("-out")
1879-
.arg(exe.join("RustDemanglerGroup.wxs"))
1880-
.arg("-t")
1881-
.arg(etc.join("msi/remove-duplicates.xsl")),
1882-
);
1883-
}
18841806
if built_tools.contains("miri") {
18851807
builder.run(
18861808
Command::new(&heat)
@@ -1958,9 +1880,6 @@ impl Step for Extended {
19581880
if built_tools.contains("rust-docs") {
19591881
cmd.arg("-dDocsDir=rust-docs");
19601882
}
1961-
if built_tools.contains("rust-demangler") {
1962-
cmd.arg("-dRustDemanglerDir=rust-demangler");
1963-
}
19641883
if built_tools.contains("rust-analyzer") {
19651884
cmd.arg("-dRustAnalyzerDir=rust-analyzer");
19661885
}
@@ -1987,9 +1906,6 @@ impl Step for Extended {
19871906
if built_tools.contains("miri") {
19881907
candle("MiriGroup.wxs".as_ref());
19891908
}
1990-
if built_tools.contains("rust-demangler") {
1991-
candle("RustDemanglerGroup.wxs".as_ref());
1992-
}
19931909
if built_tools.contains("rust-analyzer") {
19941910
candle("RustAnalyzerGroup.wxs".as_ref());
19951911
}
@@ -2031,9 +1947,6 @@ impl Step for Extended {
20311947
if built_tools.contains("rust-analyzer") {
20321948
cmd.arg("RustAnalyzerGroup.wixobj");
20331949
}
2034-
if built_tools.contains("rust-demangler") {
2035-
cmd.arg("RustDemanglerGroup.wixobj");
2036-
}
20371950
if built_tools.contains("rust-docs") {
20381951
cmd.arg("DocsGroup.wixobj");
20391952
}

src/bootstrap/src/core/build_steps/install.rs

-16
Original file line numberDiff line numberDiff line change
@@ -265,22 +265,6 @@ install!((self, builder, _config),
265265
);
266266
}
267267
};
268-
RustDemangler, alias = "rust-demangler", Self::should_build(_config), only_hosts: true, {
269-
// NOTE: Even though `should_build` may return true for `extended` default tools,
270-
// dist::RustDemangler may still return None, unless the target-dependent `profiler` config
271-
// is also true, or the `tools` array explicitly includes "rust-demangler".
272-
if let Some(tarball) = builder.ensure(dist::RustDemangler {
273-
compiler: self.compiler,
274-
target: self.target
275-
}) {
276-
install_sh(builder, "rust-demangler", self.compiler.stage, Some(self.target), &tarball);
277-
} else {
278-
builder.info(
279-
&format!("skipping Install RustDemangler stage{} ({})",
280-
self.compiler.stage, self.target),
281-
);
282-
}
283-
};
284268
Rustc, path = "compiler/rustc", true, only_hosts: true, {
285269
let tarball = builder.ensure(dist::Rustc {
286270
compiler: builder.compiler(builder.top_stage, self.target),

src/bootstrap/src/core/build_steps/test.rs

-59
Original file line numberDiff line numberDiff line change
@@ -432,65 +432,6 @@ impl Step for Rustfmt {
432432
}
433433
}
434434

435-
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
436-
pub struct RustDemangler {
437-
stage: u32,
438-
host: TargetSelection,
439-
}
440-
441-
impl Step for RustDemangler {
442-
type Output = ();
443-
const ONLY_HOSTS: bool = true;
444-
445-
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
446-
run.path("src/tools/rust-demangler")
447-
}
448-
449-
fn make_run(run: RunConfig<'_>) {
450-
run.builder.ensure(RustDemangler { stage: run.builder.top_stage, host: run.target });
451-
}
452-
453-
/// Runs `cargo test` for rust-demangler.
454-
fn run(self, builder: &Builder<'_>) {
455-
let stage = self.stage;
456-
let host = self.host;
457-
let compiler = builder.compiler(stage, host);
458-
459-
let rust_demangler = builder.ensure(tool::RustDemangler {
460-
compiler,
461-
target: self.host,
462-
extra_features: Vec::new(),
463-
});
464-
let mut cargo = tool::prepare_tool_cargo(
465-
builder,
466-
compiler,
467-
Mode::ToolRustc,
468-
host,
469-
"test",
470-
"src/tools/rust-demangler",
471-
SourceType::InTree,
472-
&[],
473-
);
474-
475-
let dir = testdir(builder, compiler.host);
476-
t!(fs::create_dir_all(dir));
477-
478-
cargo.env("RUST_DEMANGLER_DRIVER_PATH", rust_demangler);
479-
cargo.add_rustc_lib_path(builder);
480-
481-
run_cargo_test(
482-
cargo,
483-
&[],
484-
&[],
485-
"rust-demangler",
486-
"rust-demangler",
487-
compiler,
488-
host,
489-
builder,
490-
);
491-
}
492-
}
493-
494435
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
495436
pub struct Miri {
496437
target: TargetSelection,

src/bootstrap/src/core/build_steps/tool.rs

-1
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,6 @@ tool_extended!((self, builder),
964964
// But `builder.cargo` doesn't know how to handle ToolBootstrap in stages other than 0,
965965
// and this is close enough for now.
966966
Rls, "src/tools/rls", "rls", stable=true, tool_std=true;
967-
RustDemangler, "src/tools/rust-demangler", "rust-demangler", stable=false, tool_std=true;
968967
Rustfmt, "src/tools/rustfmt", "rustfmt", stable=true, add_bins_to_sysroot = ["rustfmt", "cargo-fmt"];
969968
);
970969

src/bootstrap/src/core/builder.rs

-5
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,6 @@ impl<'a> Builder<'a> {
736736
tool::Rls,
737737
tool::RustAnalyzer,
738738
tool::RustAnalyzerProcMacroSrv,
739-
tool::RustDemangler,
740739
tool::Rustdoc,
741740
tool::Clippy,
742741
tool::CargoClippy,
@@ -774,7 +773,6 @@ impl<'a> Builder<'a> {
774773
clippy::RemoteTestServer,
775774
clippy::Rls,
776775
clippy::RustAnalyzer,
777-
clippy::RustDemangler,
778776
clippy::Rustdoc,
779777
clippy::Rustfmt,
780778
clippy::RustInstaller,
@@ -842,7 +840,6 @@ impl<'a> Builder<'a> {
842840
test::Miri,
843841
test::CargoMiri,
844842
test::Clippy,
845-
test::RustDemangler,
846843
test::CompiletestTest,
847844
test::CrateRunMakeSupport,
848845
test::RustdocJSStd,
@@ -903,7 +900,6 @@ impl<'a> Builder<'a> {
903900
dist::Rls,
904901
dist::RustAnalyzer,
905902
dist::Rustfmt,
906-
dist::RustDemangler,
907903
dist::Clippy,
908904
dist::Miri,
909905
dist::LlvmTools,
@@ -930,7 +926,6 @@ impl<'a> Builder<'a> {
930926
install::Cargo,
931927
install::RustAnalyzer,
932928
install::Rustfmt,
933-
install::RustDemangler,
934929
install::Clippy,
935930
install::Miri,
936931
install::LlvmTools,

src/bootstrap/src/utils/tarball.rs

-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ pub(crate) enum OverlayKind {
2323
Clippy,
2424
Miri,
2525
Rustfmt,
26-
RustDemangler,
2726
Rls,
2827
RustAnalyzer,
2928
RustcCodegenCranelift,
@@ -58,9 +57,6 @@ impl OverlayKind {
5857
"src/tools/rustfmt/LICENSE-APACHE",
5958
"src/tools/rustfmt/LICENSE-MIT",
6059
],
61-
OverlayKind::RustDemangler => {
62-
&["src/tools/rust-demangler/README.md", "LICENSE-APACHE", "LICENSE-MIT"]
63-
}
6460
OverlayKind::Rls => &["src/tools/rls/README.md", "LICENSE-APACHE", "LICENSE-MIT"],
6561
OverlayKind::RustAnalyzer => &[
6662
"src/tools/rust-analyzer/README.md",
@@ -85,7 +81,6 @@ impl OverlayKind {
8581
match self {
8682
OverlayKind::Rust => builder.rust_version(),
8783
OverlayKind::Llvm => builder.rust_version(),
88-
OverlayKind::RustDemangler => builder.release_num("rust-demangler"),
8984
OverlayKind::Cargo => {
9085
builder.cargo_info.version(builder, &builder.release_num("cargo"))
9186
}

src/doc/rustc/src/instrument-coverage.md

+1-7
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,6 @@ One option for a Rust demangler is [`rustfilt`], which can be installed with:
4949
cargo install rustfilt
5050
```
5151
52-
Another option, if you are building from the Rust compiler source distribution, is to use the `rust-demangler` tool included in the Rust source distribution, which can be built with:
53-
54-
```shell
55-
$ ./x.py build rust-demangler
56-
```
57-
5852
[`rustfilt`]: https://crates.io/crates/rustfilt
5953

6054
## Compiling with coverage enabled
@@ -164,7 +158,7 @@ $ llvm-cov show -Xdemangler=rustfilt target/debug/examples/formatjson5 \
164158

165159
Some of the more notable options in this example include:
166160

167-
- `--Xdemangler=rustfilt` - the command name or path used to demangle Rust symbols (`rustfilt` in the example, but this could also be a path to the `rust-demangler` tool)
161+
- `--Xdemangler=rustfilt` - the command name or path used to demangle Rust symbols (`rustfilt` in the example)
168162
- `target/debug/examples/formatjson5` - the instrumented binary (from which to extract the coverage map)
169163
- `--instr-profile=<path-to-file>.profdata` - the location of the `.profdata` file created by `llvm-profdata merge` (from the `.profraw` file generated by the instrumented binary)
170164
- `--name=<exact-function-name>` - to show coverage for a specific function (or, consider using another filter option, such as `--name-regex=<pattern>`)

0 commit comments

Comments
 (0)