From 1e3e3df81ef59a4948d1fc3c3511c48ec67ffdf7 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Tue, 21 May 2024 14:53:50 -0400 Subject: [PATCH 1/4] rewrite emit test --- tests/run-make/emit/Makefile | 22 ---------------------- tests/run-make/emit/rmake.rs | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 22 deletions(-) delete mode 100644 tests/run-make/emit/Makefile create mode 100644 tests/run-make/emit/rmake.rs diff --git a/tests/run-make/emit/Makefile b/tests/run-make/emit/Makefile deleted file mode 100644 index b3ca0b79fb0cf..0000000000000 --- a/tests/run-make/emit/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: - $(RUSTC) -Copt-level=0 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs - $(RUSTC) -Copt-level=1 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs - $(RUSTC) -Copt-level=2 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs - $(RUSTC) -Copt-level=3 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs - $(RUSTC) -Copt-level=s --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs - $(RUSTC) -Copt-level=z --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs - $(RUSTC) -Copt-level=0 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs - $(call RUN,test-26235) || exit 1 - $(RUSTC) -Copt-level=1 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs - $(call RUN,test-26235) || exit 1 - $(RUSTC) -Copt-level=2 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs - $(call RUN,test-26235) || exit 1 - $(RUSTC) -Copt-level=3 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs - $(call RUN,test-26235) || exit 1 - $(RUSTC) -Copt-level=s --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs - $(call RUN,test-26235) || exit 1 - $(RUSTC) -Copt-level=z --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs - $(call RUN,test-26235) || exit 1 diff --git a/tests/run-make/emit/rmake.rs b/tests/run-make/emit/rmake.rs new file mode 100644 index 0000000000000..d3ccc7fdc27ad --- /dev/null +++ b/tests/run-make/emit/rmake.rs @@ -0,0 +1,19 @@ +// A bug from 2015 would cause errors when emitting multiple types of files +// in the same rustc call. A fix was created in #30452. This test checks that +// the fix did not accidentally break compilation. +// See https://github.com/rust-lang/rust/pull/30452 + +//@ ignore-cross-compile + +use run_make_support::{run, rustc}; + +fn main() { + let opt_levels = ["0", "1", "2", "3", "s", "z"]; + for level in opt_levels { + rustc().opt_level(level).emit("llvm-bc,llvm-ir,asm,obj,link").input("test-24876.rs"); + } + for level in opt_levels { + rustc().opt_level(level).emit("llvm-bc,llvm-ir,asm,obj,link").input("test-26235.rs"); + run("test-26235"); + } +} From 5db8552b20e6528c6ae3c9247d5bbab962b564f9 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Tue, 21 May 2024 15:05:51 -0400 Subject: [PATCH 2/4] rewrite bare-outfile test --- tests/run-make/bare-outfile/Makefile | 9 --------- tests/run-make/bare-outfile/rmake.rs | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 9 deletions(-) delete mode 100644 tests/run-make/bare-outfile/Makefile create mode 100644 tests/run-make/bare-outfile/rmake.rs diff --git a/tests/run-make/bare-outfile/Makefile b/tests/run-make/bare-outfile/Makefile deleted file mode 100644 index ad6fe4bd167c4..0000000000000 --- a/tests/run-make/bare-outfile/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# This test checks that manually setting the output file as a bare file with no file extension still results in successful compilation. - -# ignore-cross-compile -include ../tools.mk - -all: - cp foo.rs $(TMPDIR) - cd $(TMPDIR) && $(RUSTC) -o foo foo.rs - $(call RUN,foo) diff --git a/tests/run-make/bare-outfile/rmake.rs b/tests/run-make/bare-outfile/rmake.rs new file mode 100644 index 0000000000000..c2b6347f96896 --- /dev/null +++ b/tests/run-make/bare-outfile/rmake.rs @@ -0,0 +1,15 @@ +// This test checks that manually setting the output file as a bare file with no file extension +// still results in successful compilation. + +//@ ignore-cross-compile + +use run_make_support::{run, rustc, tmp_dir}; +use std::fs; +use std::env; + +fn main(){ + fs::copy("foo.rs", tmp_dir()).unwrap(); + env::set_current_dir(tmp_dir()); + rustc().output("foo").input("foo.rs"); + run("foo"); +} From 836c08ed2109348f1304255b9b90c70ddcb4d844 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Tue, 21 May 2024 15:50:57 -0400 Subject: [PATCH 3/4] rewrite mixing-formats test --- tests/run-make/mixing-formats/Makefile | 75 ---------------------- tests/run-make/mixing-formats/rmake.rs | 87 ++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 75 deletions(-) delete mode 100644 tests/run-make/mixing-formats/Makefile create mode 100644 tests/run-make/mixing-formats/rmake.rs diff --git a/tests/run-make/mixing-formats/Makefile b/tests/run-make/mixing-formats/Makefile deleted file mode 100644 index d01978a159953..0000000000000 --- a/tests/run-make/mixing-formats/Makefile +++ /dev/null @@ -1,75 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -# Testing various mixings of rlibs and dylibs. Makes sure that it's possible to -# link an rlib to a dylib. The dependency tree among the file looks like: -# -# foo -# / \ -# bar1 bar2 -# / \ / -# baz baz2 -# -# This is generally testing the permutations of the foo/bar1/bar2 layer against -# the baz/baz2 layer - -all: - # Building just baz - $(RUSTC) --crate-type=rlib foo.rs - $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic - $(RUSTC) --crate-type=dylib,rlib baz.rs -C prefer-dynamic - $(RUSTC) --crate-type=bin baz.rs - rm $(TMPDIR)/* - $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic - $(RUSTC) --crate-type=rlib bar1.rs - $(RUSTC) --crate-type=dylib,rlib baz.rs -C prefer-dynamic - $(RUSTC) --crate-type=bin baz.rs - rm $(TMPDIR)/* - # Building baz2 - $(RUSTC) --crate-type=rlib foo.rs - $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic - $(RUSTC) --crate-type=dylib bar2.rs -C prefer-dynamic - $(RUSTC) --crate-type=dylib baz2.rs && exit 1 || exit 0 - $(RUSTC) --crate-type=bin baz2.rs && exit 1 || exit 0 - rm $(TMPDIR)/* - $(RUSTC) --crate-type=rlib foo.rs - $(RUSTC) --crate-type=rlib bar1.rs - $(RUSTC) --crate-type=dylib bar2.rs -C prefer-dynamic - $(RUSTC) --crate-type=dylib,rlib baz2.rs - $(RUSTC) --crate-type=bin baz2.rs - rm $(TMPDIR)/* - $(RUSTC) --crate-type=rlib foo.rs - $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic - $(RUSTC) --crate-type=rlib bar2.rs - $(RUSTC) --crate-type=dylib,rlib baz2.rs -C prefer-dynamic - $(RUSTC) --crate-type=bin baz2.rs - rm $(TMPDIR)/* - $(RUSTC) --crate-type=rlib foo.rs - $(RUSTC) --crate-type=rlib bar1.rs - $(RUSTC) --crate-type=rlib bar2.rs - $(RUSTC) --crate-type=dylib,rlib baz2.rs -C prefer-dynamic - $(RUSTC) --crate-type=bin baz2.rs - rm $(TMPDIR)/* - $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic - $(RUSTC) --crate-type=rlib bar1.rs - $(RUSTC) --crate-type=rlib bar2.rs - $(RUSTC) --crate-type=dylib,rlib baz2.rs -C prefer-dynamic - $(RUSTC) --crate-type=bin baz2.rs - rm $(TMPDIR)/* - $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic - $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic - $(RUSTC) --crate-type=rlib bar2.rs - $(RUSTC) --crate-type=dylib,rlib baz2.rs - $(RUSTC) --crate-type=bin baz2.rs - rm $(TMPDIR)/* - $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic - $(RUSTC) --crate-type=rlib bar1.rs - $(RUSTC) --crate-type=dylib bar2.rs -C prefer-dynamic - $(RUSTC) --crate-type=dylib,rlib baz2.rs - $(RUSTC) --crate-type=bin baz2.rs - rm $(TMPDIR)/* - $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic - $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic - $(RUSTC) --crate-type=dylib bar2.rs -C prefer-dynamic - $(RUSTC) --crate-type=dylib,rlib baz2.rs - $(RUSTC) --crate-type=bin baz2.rs diff --git a/tests/run-make/mixing-formats/rmake.rs b/tests/run-make/mixing-formats/rmake.rs new file mode 100644 index 0000000000000..c80951a15975f --- /dev/null +++ b/tests/run-make/mixing-formats/rmake.rs @@ -0,0 +1,87 @@ +// Testing various mixings of rlibs and dylibs. Makes sure that it's possible to +// link an rlib to a dylib. The dependency tree among the file looks like: +// +// foo +// / \ +// bar1 bar2 +// / \ / +// baz baz2 +// +// This is generally testing the permutations of the foo/bar1/bar2 layer against +// the baz/baz2 layer + +//@ ignore-cross-compile + +use run_make_support::{rustc, tmp_dir}; +use std::fs; + +fn main() { + // Building just baz + rustc().crate_type("rlib").input("foo.rs").run(); + rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("dylib,rlib").input("baz.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("bin").input("baz.rs").run(); + fs::remove_dir_all(tmp_dir()).unwrap(); + fs::create_dir(tmp_dir()).unwrap(); + rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("rlib").input("bar1.rs").run(); + rustc().crate_type("dylib,rlib").input("baz.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("bin").input("baz.rs").run(); + fs::remove_dir_all(tmp_dir()).unwrap(); + fs::create_dir(tmp_dir()).unwrap(); + // Building baz2 + rustc().crate_type("rlib").input("foo.rs").run(); + rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("dylib").input("bar2.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("dylib").input("baz2.rs").run_fail_assert_exit_code(1); + rustc().crate_type("bin").input("baz2.rs").run_fail_assert_exit_code(1); + fs::remove_dir_all(tmp_dir()).unwrap(); + fs::create_dir(tmp_dir()).unwrap(); + rustc().crate_type("rlib").input("foo.rs").run(); + rustc().crate_type("rlib").input("bar1.rs").run(); + rustc().crate_type("dylib").input("bar2.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("dylib,rlib").input("baz2.rs").run(); + rustc().crate_type("bin").input("baz2.rs").run; + fs::remove_dir_all(tmp_dir()).unwrap(); + fs::create_dir(tmp_dir()).unwrap(); + rustc().crate_type("rlib").input("foo.rs").run(); + rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("rlib").input("bar2.rs").run(); + rustc().crate_type("dylib,rlib").input("baz2.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("bin").input("baz2.rs").run(); + fs::remove_dir_all(tmp_dir()).unwrap(); + fs::create_dir(tmp_dir()).unwrap(); + rustc().crate_type("rlib").input("foo.rs").run(); + rustc().crate_type("rlib").input("bar1.rs").run(); + rustc().crate_type("rlib").input("bar2.rs").run(); + rustc().crate_type("dylib,rlib").input("baz2.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("bin").input("baz2.rs").run(); + fs::remove_dir_all(tmp_dir()).unwrap(); + fs::create_dir(tmp_dir()).unwrap(); + rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("rlib").input("bar1.rs").run(); + rustc().crate_type("rlib").input("bar2.rs").run(); + rustc().crate_type("dylib,rlib").input("baz2.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("bin").input("baz2.rs").run(); + fs::remove_dir_all(tmp_dir()).unwrap(); + fs::create_dir(tmp_dir()).unwrap(); + rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("rlib").input("bar2.rs").run(); + rustc().crate_type("dylib,rlib").input("baz2.rs").run(); + rustc().crate_type("bin").input("baz2.rs").run(); + fs::remove_dir_all(tmp_dir()).unwrap(); + fs::create_dir(tmp_dir()).unwrap(); + rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("rlib").input("bar1.rs").run(); + rustc().crate_type("dylib").input("bar2.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("dylib,rlib").input("baz2.rs").run(); + rustc().crate_type("bin").input("baz2.rs").run(); + fs::remove_dir_all(tmp_dir()).unwrap(); + fs::create_dir(tmp_dir()).unwrap(); + rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("dylib").input("bar2.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("dylib,rlib").input("baz2.rs").run(); + rustc().crate_type("bin").input("baz2.rs").run(); +} From 6e120cf4642bbc1ee1021cf83d0dc013392f47e5 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Tue, 21 May 2024 15:52:00 -0400 Subject: [PATCH 4/4] Remove some allowed-makefiles --- src/tools/run-make-support/src/run.rs | 4 +- .../tidy/src/allowed_run_make_makefiles.txt | 3 - tests/run-make/bare-outfile/rmake.rs | 8 +- tests/run-make/emit/rmake.rs | 8 +- tests/run-make/mixing-formats/rmake.rs | 131 +++++++++--------- 5 files changed, 79 insertions(+), 75 deletions(-) diff --git a/src/tools/run-make-support/src/run.rs b/src/tools/run-make-support/src/run.rs index 9aad91f1b4630..da4f265efc3b9 100644 --- a/src/tools/run-make-support/src/run.rs +++ b/src/tools/run-make-support/src/run.rs @@ -4,12 +4,12 @@ use std::process::{Command, Output}; use crate::is_windows; -use super::{bin_name, handle_failed_output}; +use super::handle_failed_output; fn run_common(name: &str) -> (Command, Output) { let mut bin_path = PathBuf::new(); bin_path.push(env::var("TMPDIR").unwrap()); - bin_path.push(&bin_name(name)); + bin_path.push(name); let ld_lib_path_envvar = env::var("LD_LIB_PATH_ENVVAR").unwrap(); let mut cmd = Command::new(bin_path); cmd.env(&ld_lib_path_envvar, { diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 009200aca15de..06a99725315bc 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -2,7 +2,6 @@ run-make/allocator-shim-circular-deps/Makefile run-make/allow-non-lint-warnings-cmdline/Makefile run-make/archive-duplicate-names/Makefile run-make/atomic-lock-free/Makefile -run-make/bare-outfile/Makefile run-make/branch-protection-check-IBT/Makefile run-make/c-dynamic-dylib/Makefile run-make/c-dynamic-rlib/Makefile @@ -43,7 +42,6 @@ run-make/emit-path-unhashed/Makefile run-make/emit-shared-files/Makefile run-make/emit-stack-sizes/Makefile run-make/emit-to-stdout/Makefile -run-make/emit/Makefile run-make/env-dep-info/Makefile run-make/error-found-staticlib-instead-crate/Makefile run-make/error-writing-dependencies/Makefile @@ -150,7 +148,6 @@ run-make/min-global-align/Makefile run-make/mingw-export-call-convention/Makefile run-make/mismatching-target-triples/Makefile run-make/missing-crate-dependency/Makefile -run-make/mixing-formats/Makefile run-make/mixing-libs/Makefile run-make/msvc-opt-minsize/Makefile run-make/multiple-emits/Makefile diff --git a/tests/run-make/bare-outfile/rmake.rs b/tests/run-make/bare-outfile/rmake.rs index c2b6347f96896..82d0fab5073b8 100644 --- a/tests/run-make/bare-outfile/rmake.rs +++ b/tests/run-make/bare-outfile/rmake.rs @@ -4,12 +4,12 @@ //@ ignore-cross-compile use run_make_support::{run, rustc, tmp_dir}; -use std::fs; use std::env; +use std::fs; -fn main(){ - fs::copy("foo.rs", tmp_dir()).unwrap(); +fn main() { + fs::copy("foo.rs", tmp_dir().join("foo.rs")).unwrap(); env::set_current_dir(tmp_dir()); - rustc().output("foo").input("foo.rs"); + rustc().output("foo").input("foo.rs").run(); run("foo"); } diff --git a/tests/run-make/emit/rmake.rs b/tests/run-make/emit/rmake.rs index d3ccc7fdc27ad..8b3ddb66f9238 100644 --- a/tests/run-make/emit/rmake.rs +++ b/tests/run-make/emit/rmake.rs @@ -1,6 +1,6 @@ // A bug from 2015 would cause errors when emitting multiple types of files -// in the same rustc call. A fix was created in #30452. This test checks that -// the fix did not accidentally break compilation. +// in the same rustc call. A fix was created in #30452. This test checks that rustc still compiles +// a source file successfully when emission of multiple output artifacts are requested. // See https://github.com/rust-lang/rust/pull/30452 //@ ignore-cross-compile @@ -10,10 +10,10 @@ use run_make_support::{run, rustc}; fn main() { let opt_levels = ["0", "1", "2", "3", "s", "z"]; for level in opt_levels { - rustc().opt_level(level).emit("llvm-bc,llvm-ir,asm,obj,link").input("test-24876.rs"); + rustc().opt_level(level).emit("llvm-bc,llvm-ir,asm,obj,link").input("test-24876.rs").run(); } for level in opt_levels { - rustc().opt_level(level).emit("llvm-bc,llvm-ir,asm,obj,link").input("test-26235.rs"); + rustc().opt_level(level).emit("llvm-bc,llvm-ir,asm,obj,link").input("test-26235.rs").run(); run("test-26235"); } } diff --git a/tests/run-make/mixing-formats/rmake.rs b/tests/run-make/mixing-formats/rmake.rs index c80951a15975f..0d40b0325f770 100644 --- a/tests/run-make/mixing-formats/rmake.rs +++ b/tests/run-make/mixing-formats/rmake.rs @@ -15,70 +15,77 @@ use run_make_support::{rustc, tmp_dir}; use std::fs; -fn main() { - // Building just baz - rustc().crate_type("rlib").input("foo.rs").run(); - rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run(); - rustc().crate_type("dylib,rlib").input("baz.rs").arg("-Cprefer-dynamic").run(); - rustc().crate_type("bin").input("baz.rs").run(); - fs::remove_dir_all(tmp_dir()).unwrap(); - fs::create_dir(tmp_dir()).unwrap(); - rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run(); - rustc().crate_type("rlib").input("bar1.rs").run(); - rustc().crate_type("dylib,rlib").input("baz.rs").arg("-Cprefer-dynamic").run(); - rustc().crate_type("bin").input("baz.rs").run(); - fs::remove_dir_all(tmp_dir()).unwrap(); - fs::create_dir(tmp_dir()).unwrap(); - // Building baz2 - rustc().crate_type("rlib").input("foo.rs").run(); - rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run(); - rustc().crate_type("dylib").input("bar2.rs").arg("-Cprefer-dynamic").run(); - rustc().crate_type("dylib").input("baz2.rs").run_fail_assert_exit_code(1); - rustc().crate_type("bin").input("baz2.rs").run_fail_assert_exit_code(1); - fs::remove_dir_all(tmp_dir()).unwrap(); - fs::create_dir(tmp_dir()).unwrap(); - rustc().crate_type("rlib").input("foo.rs").run(); - rustc().crate_type("rlib").input("bar1.rs").run(); - rustc().crate_type("dylib").input("bar2.rs").arg("-Cprefer-dynamic").run(); - rustc().crate_type("dylib,rlib").input("baz2.rs").run(); - rustc().crate_type("bin").input("baz2.rs").run; - fs::remove_dir_all(tmp_dir()).unwrap(); - fs::create_dir(tmp_dir()).unwrap(); - rustc().crate_type("rlib").input("foo.rs").run(); - rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run(); - rustc().crate_type("rlib").input("bar2.rs").run(); - rustc().crate_type("dylib,rlib").input("baz2.rs").arg("-Cprefer-dynamic").run(); - rustc().crate_type("bin").input("baz2.rs").run(); - fs::remove_dir_all(tmp_dir()).unwrap(); - fs::create_dir(tmp_dir()).unwrap(); - rustc().crate_type("rlib").input("foo.rs").run(); - rustc().crate_type("rlib").input("bar1.rs").run(); - rustc().crate_type("rlib").input("bar2.rs").run(); - rustc().crate_type("dylib,rlib").input("baz2.rs").arg("-Cprefer-dynamic").run(); - rustc().crate_type("bin").input("baz2.rs").run(); - fs::remove_dir_all(tmp_dir()).unwrap(); - fs::create_dir(tmp_dir()).unwrap(); - rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run(); - rustc().crate_type("rlib").input("bar1.rs").run(); - rustc().crate_type("rlib").input("bar2.rs").run(); - rustc().crate_type("dylib,rlib").input("baz2.rs").arg("-Cprefer-dynamic").run(); - rustc().crate_type("bin").input("baz2.rs").run(); - fs::remove_dir_all(tmp_dir()).unwrap(); - fs::create_dir(tmp_dir()).unwrap(); - rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run(); - rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run(); - rustc().crate_type("rlib").input("bar2.rs").run(); - rustc().crate_type("dylib,rlib").input("baz2.rs").run(); - rustc().crate_type("bin").input("baz2.rs").run(); - fs::remove_dir_all(tmp_dir()).unwrap(); - fs::create_dir(tmp_dir()).unwrap(); - rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run(); - rustc().crate_type("rlib").input("bar1.rs").run(); - rustc().crate_type("dylib").input("bar2.rs").arg("-Cprefer-dynamic").run(); - rustc().crate_type("dylib,rlib").input("baz2.rs").run(); - rustc().crate_type("bin").input("baz2.rs").run(); +fn test_with_teardown(rustc_calls: impl Fn()) { + rustc_calls(); + //FIXME(Oneirical): This should be replaced with the run-make-support fs wrappers. fs::remove_dir_all(tmp_dir()).unwrap(); fs::create_dir(tmp_dir()).unwrap(); +} + +fn main() { + test_with_teardown(|| { + // Building just baz + rustc().crate_type("rlib").input("foo.rs").run(); + rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("dylib,rlib").input("baz.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("bin").input("baz.rs").run(); + }); + test_with_teardown(|| { + rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("rlib").input("bar1.rs").run(); + rustc().crate_type("dylib,rlib").input("baz.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("bin").input("baz.rs").run(); + }); + test_with_teardown(|| { + // Building baz2 + rustc().crate_type("rlib").input("foo.rs").run(); + rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("dylib").input("bar2.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("dylib").input("baz2.rs").run_fail_assert_exit_code(1); + rustc().crate_type("bin").input("baz2.rs").run_fail_assert_exit_code(1); + }); + test_with_teardown(|| { + rustc().crate_type("rlib").input("foo.rs").run(); + rustc().crate_type("rlib").input("bar1.rs").run(); + rustc().crate_type("dylib").input("bar2.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("dylib,rlib").input("baz2.rs").run(); + rustc().crate_type("bin").input("baz2.rs").run(); + }); + test_with_teardown(|| { + rustc().crate_type("rlib").input("foo.rs").run(); + rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("rlib").input("bar2.rs").run(); + rustc().crate_type("dylib,rlib").input("baz2.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("bin").input("baz2.rs").run(); + }); + test_with_teardown(|| { + rustc().crate_type("rlib").input("foo.rs").run(); + rustc().crate_type("rlib").input("bar1.rs").run(); + rustc().crate_type("rlib").input("bar2.rs").run(); + rustc().crate_type("dylib,rlib").input("baz2.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("bin").input("baz2.rs").run(); + }); + test_with_teardown(|| { + rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("rlib").input("bar1.rs").run(); + rustc().crate_type("rlib").input("bar2.rs").run(); + rustc().crate_type("dylib,rlib").input("baz2.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("bin").input("baz2.rs").run(); + }); + test_with_teardown(|| { + rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("rlib").input("bar2.rs").run(); + rustc().crate_type("dylib,rlib").input("baz2.rs").run(); + rustc().crate_type("bin").input("baz2.rs").run(); + }); + test_with_teardown(|| { + rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("rlib").input("bar1.rs").run(); + rustc().crate_type("dylib").input("bar2.rs").arg("-Cprefer-dynamic").run(); + rustc().crate_type("dylib,rlib").input("baz2.rs").run(); + rustc().crate_type("bin").input("baz2.rs").run(); + }); rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run(); rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run(); rustc().crate_type("dylib").input("bar2.rs").arg("-Cprefer-dynamic").run();