|
| 1 | +// When rustc receives 4 codegen-units, an output path and an emit flag all simultaneously, |
| 2 | +// this could cause an annoying recompilation issue, uselessly lengthening the build process. |
| 3 | +// This test tries to reproduce this issue with varied emit flags - if it passes, the codegen-units |
| 4 | +// are being appropriately reset to 1 after each pass. |
| 5 | +// See https://github.com/rust-lang/rust/issues/30063 |
| 6 | + |
| 7 | +//@ ignore-cross-compile |
| 8 | + |
| 9 | +use run_make_support::{rustc, tmp_dir}; |
| 10 | +use std::fs; |
| 11 | + |
| 12 | +fn compile(emit: Option<&str>, output_dir: &str) { |
| 13 | + let mut rustc = rustc().codegen_units(4).output(tmp_dir().join(output_dir)).input("foo.rs"); |
| 14 | + if let Some(emit) = emit { |
| 15 | + rustc.emit(emit); |
| 16 | + } |
| 17 | + rustc.run(); |
| 18 | +} |
| 19 | + |
| 20 | +fn main { |
| 21 | + let flags = [ |
| 22 | + ("foo-output", None), |
| 23 | + ("asm-output", Some("asm")), |
| 24 | + ("bc-output", Some("llvm-bc")), |
| 25 | + ("ir-output", Some("llvm-ir")), |
| 26 | + ("link-output", Some("link")), |
| 27 | + ("obj-output", Some("obj")), |
| 28 | + ("dep-output", Some("dep-info")), |
| 29 | + ("multi-output", Some("asm,obj")) |
| 30 | + ]; |
| 31 | + for (output_dir, emit) in flags { |
| 32 | + fs::remove_file(output_dir).unwrap_or_default(); |
| 33 | + compile(emit, output_dir); |
| 34 | + fs::remove_file(output_dir); |
| 35 | + } |
| 36 | +} |
0 commit comments