|
| 1 | +// rust should produce artifact notifications about files it was asked to --emit. |
| 2 | +// |
| 3 | +// It should work in incremental mode both on the first pass where files are generated as well |
| 4 | +// as on subsequent passes where they are taken from the incremental cache |
| 5 | +// |
| 6 | +// See <https://internals.rust-lang.org/t/easier-access-to-files-generated-by-emit-foo/20477> |
| 7 | +extern crate run_make_support; |
| 8 | + |
| 9 | +use run_make_support::{rustc, tmp_dir}; |
| 10 | + |
| 11 | +fn main() { |
| 12 | + let inc_dir = tmp_dir(); |
| 13 | + |
| 14 | + // With single codegen unit files are renamed to match the source file name |
| 15 | + for _ in 0..=1 { |
| 16 | + let output = rustc() |
| 17 | + .input("lib.rs") |
| 18 | + .emit("obj,asm,llvm-ir,llvm-bc,mir") |
| 19 | + .codegen_units(1) |
| 20 | + .json("artifacts") |
| 21 | + .error_format("json") |
| 22 | + .incremental(&inc_dir) |
| 23 | + .run(); |
| 24 | + let stderr = String::from_utf8_lossy(&output.stderr); |
| 25 | + for file in &["lib.o", "lib.ll", "lib.bc", "lib.s"] { |
| 26 | + assert!(stderr.contains(file), "No {:?} in {:?}", file, stderr); |
| 27 | + } |
| 28 | + } |
| 29 | + |
| 30 | + // with multiple codegen units files keep codegen unit id part. |
| 31 | + for _ in 0..=1 { |
| 32 | + let output = rustc() |
| 33 | + .input("lib.rs") |
| 34 | + .emit("obj,asm,llvm-ir,llvm-bc,mir") |
| 35 | + .codegen_units(2) |
| 36 | + .json("artifacts") |
| 37 | + .error_format("json") |
| 38 | + .incremental(&inc_dir) |
| 39 | + .run(); |
| 40 | + let stderr = String::from_utf8_lossy(&output.stderr); |
| 41 | + for file in &["rcgu.o", "rcgu.ll", "rcgu.bc", "rcgu.s"] { |
| 42 | + assert!(stderr.contains(file), "No {:?} in {:?}", file, stderr); |
| 43 | + } |
| 44 | + } |
| 45 | +} |
0 commit comments