forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#122597 - pacak:master, r=bjorn3
Show files produced by `--emit foo` in json artifact notifications Right now it is possible to ask `rustc` to save some intermediate representation into one or more files with `--emit=foo`, but figuring out what exactly was produced is difficult. This pull request adds information about `llvm_ir` and `asm` intermediate files into notifications produced by `--json=artifacts`. Related discussion: https://internals.rust-lang.org/t/easier-access-to-files-generated-by-emit-foo/20477 Motivation - `cargo-show-asm` parses those intermediate files and presents them in a user friendly way, but right now I have to apply some dirty hacks. Hacks make behavior confusing: hintron/computer-enhance#35 This pull request introduces a new behavior: now `rustc` will emit a new artifact notification for every artifact type user asked to `--emit`, for example for `--emit asm` those will include all the `.s` files. Most users won't notice this behavior, to be affected by it all of the following must hold: - user must use `rustc` binary directly (when `cargo` invokes `rustc` - it consumes artifact notifications and doesn't emit anything) - user must specify both `--emit xxx` and `--json artifacts` - user must refuse to handle unknown artifact types - user must disable incremental compilation (or deal with it better than cargo does, or use a workaround like `save-temps`) in order not to hit rust-lang#88829 / rust-lang#89149
- Loading branch information
Showing
7 changed files
with
140 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
fn one() -> usize { | ||
1 | ||
} | ||
|
||
pub mod a { | ||
pub fn two() -> usize { | ||
::one() + ::one() | ||
} | ||
} | ||
|
||
pub mod b { | ||
pub fn three() -> usize { | ||
::one() + ::a::two() | ||
} | ||
} | ||
|
||
#[inline(never)] | ||
pub fn main() { | ||
a::two(); | ||
b::three(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// rust should produce artifact notifications about files it was asked to --emit. | ||
// | ||
// It should work in incremental mode both on the first pass where files are generated as well | ||
// as on subsequent passes where they are taken from the incremental cache | ||
// | ||
// See <https://internals.rust-lang.org/t/easier-access-to-files-generated-by-emit-foo/20477> | ||
extern crate run_make_support; | ||
|
||
use run_make_support::{rustc, tmp_dir}; | ||
|
||
fn main() { | ||
let inc_dir = tmp_dir(); | ||
|
||
// With single codegen unit files are renamed to match the source file name | ||
for _ in 0..=1 { | ||
let output = rustc() | ||
.input("lib.rs") | ||
.emit("obj,asm,llvm-ir,llvm-bc,mir") | ||
.codegen_units(1) | ||
.json("artifacts") | ||
.error_format("json") | ||
.incremental(&inc_dir) | ||
.run(); | ||
let stderr = String::from_utf8_lossy(&output.stderr); | ||
for file in &["lib.o", "lib.ll", "lib.bc", "lib.s"] { | ||
assert!(stderr.contains(file), "No {:?} in {:?}", file, stderr); | ||
} | ||
} | ||
|
||
// with multiple codegen units files keep codegen unit id part. | ||
for _ in 0..=1 { | ||
let output = rustc() | ||
.input("lib.rs") | ||
.emit("obj,asm,llvm-ir,llvm-bc,mir") | ||
.codegen_units(2) | ||
.json("artifacts") | ||
.error_format("json") | ||
.incremental(&inc_dir) | ||
.run(); | ||
let stderr = String::from_utf8_lossy(&output.stderr); | ||
for file in &["rcgu.o", "rcgu.ll", "rcgu.bc", "rcgu.s"] { | ||
assert!(stderr.contains(file), "No {:?} in {:?}", file, stderr); | ||
} | ||
} | ||
} |