|
| 1 | +// When rustc received 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 | +// A fix was delivered, which resets codegen-units to 1 when necessary, |
| 4 | +// but as it directly affected the way codegen-units are manipulated, |
| 5 | +// this test was created to check that this fix did not cause compilation failures. |
| 6 | +// See https://github.com/rust-lang/rust/issues/30063 |
| 7 | + |
| 8 | +//@ ignore-cross-compile |
| 9 | + |
| 10 | +use run_make_support::{rustc, tmp_dir}; |
| 11 | +use std::fs; |
| 12 | + |
| 13 | +fn compile(output_file: &str, emit: Option<&str>) { |
| 14 | + let mut rustc = rustc(); |
| 15 | + let rustc = rustc.codegen_units(4).output(tmp_dir().join(output_file)).input("foo.rs"); |
| 16 | + if let Some(emit) = emit { |
| 17 | + rustc.emit(emit); |
| 18 | + } |
| 19 | + rustc.run(); |
| 20 | +} |
| 21 | + |
| 22 | +fn main() { |
| 23 | + let flags = [ |
| 24 | + ("foo-output", None), |
| 25 | + ("asm-output", Some("asm")), |
| 26 | + ("bc-output", Some("llvm-bc")), |
| 27 | + ("ir-output", Some("llvm-ir")), |
| 28 | + ("link-output", Some("link")), |
| 29 | + ("obj-output", Some("obj")), |
| 30 | + ("dep-output", Some("dep-info")), |
| 31 | + ("multi-output", Some("asm,obj")), |
| 32 | + ]; |
| 33 | + for (output_file, emit) in flags { |
| 34 | + fs::remove_file(output_file).unwrap_or_default(); |
| 35 | + compile(output_file, emit); |
| 36 | + fs::remove_file(output_file); |
| 37 | + } |
| 38 | +} |
0 commit comments