Skip to content

Commit e2c4662

Browse files
committed
rewrite dump-mono-stats to rmake format
1 parent 3a7fe4c commit e2c4662

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

src/tools/run-make-support/src/rustc.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ impl Rustc {
9494
self
9595
}
9696

97+
/// Specify the path where monomorphization stats will be dumped..
98+
pub fn dump_mono_stats<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
99+
let path = path.as_ref().to_string_lossy();
100+
self.cmd.arg(format!("-Zdump-mono-stats={path}"));
101+
self
102+
}
103+
97104
/// Specify path to the input file.
98105
pub fn input<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
99106
self.cmd.arg(path.as_ref());
@@ -167,7 +174,11 @@ impl Rustc {
167174
}
168175

169176
/// Add a directory to the library search path with a restriction. Equivalent to `-L KIND=PATH` in rustc.
170-
pub fn specific_library_search_path<P: AsRef<Path>>(&mut self, kind: &str, path: P) -> &mut Self {
177+
pub fn specific_library_search_path<P: AsRef<Path>>(
178+
&mut self,
179+
kind: &str,
180+
path: P,
181+
) -> &mut Self {
171182
assert!(["dependency", "native", "all", "framework", "crate"].contains(&kind));
172183
let path = path.as_ref().to_string_lossy();
173184
self.cmd.arg(format!("-L{kind}={path}"));

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ run-make/dep-info-doesnt-run-much/Makefile
3131
run-make/dep-info-spaces/Makefile
3232
run-make/dep-info/Makefile
3333
run-make/dump-ice-to-disk/Makefile
34-
run-make/dump-mono-stats/Makefile
3534
run-make/duplicate-output-flavors/Makefile
3635
run-make/dylib-chain/Makefile
3736
run-make/emit-path-unhashed/Makefile

tests/run-make/dump-mono-stats/Makefile

-5
This file was deleted.
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// A flag named dump-mono-stats was added to the compiler in 2022, which
2+
// collects stats on instantiation of items and their associated costs.
3+
// This test checks that the output stat file exists, and that it contains
4+
// a specific expected string.
5+
// See https://github.com/rust-lang/rust/pull/105481
6+
7+
use run_make_support::{cwd, fs_wrapper, rustc};
8+
9+
fn main() {
10+
rustc().crate_type("lib").input("foo.rs").dump_mono_stats(cwd()).arg("-Zdump-mono-stats-format=json").run();
11+
assert!(fs_wrapper::read_to_string("foo.mono_items.json").contains("\"name\":\"bar\"");
12+
}

0 commit comments

Comments
 (0)