Skip to content

Commit 2450aeb

Browse files
committed
rewrite dump-mono-stats to rmake format
1 parent 8dc816e commit 2450aeb

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
@@ -99,6 +99,13 @@ impl Rustc {
9999
self
100100
}
101101

102+
/// Specify the path where monomorphization stats will be dumped..
103+
pub fn dump_mono_stats<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
104+
let path = path.as_ref().to_string_lossy();
105+
self.cmd.arg(format!("-Zdump-mono-stats={path}"));
106+
self
107+
}
108+
102109
/// Specify path to the input file.
103110
pub fn input<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
104111
self.cmd.arg(path.as_ref());
@@ -179,7 +186,11 @@ impl Rustc {
179186
}
180187

181188
/// Add a directory to the library search path with a restriction. Equivalent to `-L KIND=PATH` in rustc.
182-
pub fn specific_library_search_path<P: AsRef<Path>>(&mut self, kind: &str, path: P) -> &mut Self {
189+
pub fn specific_library_search_path<P: AsRef<Path>>(
190+
&mut self,
191+
kind: &str,
192+
path: P,
193+
) -> &mut Self {
183194
assert!(["dependency", "native", "all", "framework", "crate"].contains(&kind));
184195
let path = path.as_ref().to_string_lossy();
185196
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)