Skip to content

Commit

Permalink
rewrite dump-mono-stats to rmake format
Browse files Browse the repository at this point in the history
  • Loading branch information
Oneirical committed Jun 11, 2024
1 parent 8dc816e commit 2450aeb
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
13 changes: 12 additions & 1 deletion src/tools/run-make-support/src/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ impl Rustc {
self
}

/// Specify the path where monomorphization stats will be dumped..
pub fn dump_mono_stats<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
let path = path.as_ref().to_string_lossy();
self.cmd.arg(format!("-Zdump-mono-stats={path}"));
self
}

/// Specify path to the input file.
pub fn input<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
self.cmd.arg(path.as_ref());
Expand Down Expand Up @@ -179,7 +186,11 @@ impl Rustc {
}

/// Add a directory to the library search path with a restriction. Equivalent to `-L KIND=PATH` in rustc.
pub fn specific_library_search_path<P: AsRef<Path>>(&mut self, kind: &str, path: P) -> &mut Self {
pub fn specific_library_search_path<P: AsRef<Path>>(
&mut self,
kind: &str,
path: P,
) -> &mut Self {
assert!(["dependency", "native", "all", "framework", "crate"].contains(&kind));
let path = path.as_ref().to_string_lossy();
self.cmd.arg(format!("-L{kind}={path}"));
Expand Down
1 change: 0 additions & 1 deletion src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ run-make/dep-info-doesnt-run-much/Makefile
run-make/dep-info-spaces/Makefile
run-make/dep-info/Makefile
run-make/dump-ice-to-disk/Makefile
run-make/dump-mono-stats/Makefile
run-make/duplicate-output-flavors/Makefile
run-make/dylib-chain/Makefile
run-make/emit-path-unhashed/Makefile
Expand Down
5 changes: 0 additions & 5 deletions tests/run-make/dump-mono-stats/Makefile

This file was deleted.

12 changes: 12 additions & 0 deletions tests/run-make/dump-mono-stats/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// A flag named dump-mono-stats was added to the compiler in 2022, which
// collects stats on instantiation of items and their associated costs.
// This test checks that the output stat file exists, and that it contains
// a specific expected string.
// See https://github.com/rust-lang/rust/pull/105481

use run_make_support::{cwd, fs_wrapper, rustc};

fn main() {
rustc().crate_type("lib").input("foo.rs").dump_mono_stats(cwd()).arg("-Zdump-mono-stats-format=json").run();
assert!(fs_wrapper::read_to_string("foo.mono_items.json").contains("\"name\":\"bar\"");
}

0 comments on commit 2450aeb

Please sign in to comment.