| author | bors <bors@rust-lang.org> 2024-06-03 18:35:54 UTC |
| committer | bors <bors@rust-lang.org> 2024-06-03 18:35:54 UTC |
| log | 7c52d2db6348b038276198e88a835125849f322e |
| tree | 016e7b14e0081ac6cc226efb1464d92525902ba2 |
| parent | eb5e2449c5a5215927834d67914ce41cccd3f3c9 |
| parent | 6e120cf4642bbc1ee1021cf83d0dc013392f47e5 |
Rewrite `emit`, `mixing-formats` and `bare-outfile` `run-make` tests in `rmake.rs` format
Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).
try-job: x86_64-msvc8 files changed, 130 insertions(+), 111 deletions(-)
src/tools/run-make-support/src/run.rs+2-2| ... | ... | @@ -4,12 +4,12 @@ use std::process::{Command, Output}; |
| 4 | 4 | |
| 5 | 5 | use crate::is_windows; |
| 6 | 6 | |
| 7 | use super::{bin_name, handle_failed_output}; | |
| 7 | use super::handle_failed_output; | |
| 8 | 8 | |
| 9 | 9 | fn run_common(name: &str) -> (Command, Output) { |
| 10 | 10 | let mut bin_path = PathBuf::new(); |
| 11 | 11 | bin_path.push(env::var("TMPDIR").unwrap()); |
| 12 | bin_path.push(&bin_name(name)); | |
| 12 | bin_path.push(name); | |
| 13 | 13 | let ld_lib_path_envvar = env::var("LD_LIB_PATH_ENVVAR").unwrap(); |
| 14 | 14 | let mut cmd = Command::new(bin_path); |
| 15 | 15 | cmd.env(&ld_lib_path_envvar, { |
src/tools/tidy/src/allowed_run_make_makefiles.txt-3| ... | ... | @@ -2,7 +2,6 @@ run-make/allocator-shim-circular-deps/Makefile |
| 2 | 2 | run-make/allow-non-lint-warnings-cmdline/Makefile |
| 3 | 3 | run-make/archive-duplicate-names/Makefile |
| 4 | 4 | run-make/atomic-lock-free/Makefile |
| 5 | run-make/bare-outfile/Makefile | |
| 6 | 5 | run-make/branch-protection-check-IBT/Makefile |
| 7 | 6 | run-make/c-dynamic-dylib/Makefile |
| 8 | 7 | run-make/c-dynamic-rlib/Makefile |
| ... | ... | @@ -40,7 +39,6 @@ run-make/emit-path-unhashed/Makefile |
| 40 | 39 | run-make/emit-shared-files/Makefile |
| 41 | 40 | run-make/emit-stack-sizes/Makefile |
| 42 | 41 | run-make/emit-to-stdout/Makefile |
| 43 | run-make/emit/Makefile | |
| 44 | 42 | run-make/env-dep-info/Makefile |
| 45 | 43 | run-make/error-found-staticlib-instead-crate/Makefile |
| 46 | 44 | run-make/error-writing-dependencies/Makefile |
| ... | ... | @@ -147,7 +145,6 @@ run-make/min-global-align/Makefile |
| 147 | 145 | run-make/mingw-export-call-convention/Makefile |
| 148 | 146 | run-make/mismatching-target-triples/Makefile |
| 149 | 147 | run-make/missing-crate-dependency/Makefile |
| 150 | run-make/mixing-formats/Makefile | |
| 151 | 148 | run-make/mixing-libs/Makefile |
| 152 | 149 | run-make/msvc-opt-minsize/Makefile |
| 153 | 150 | run-make/multiple-emits/Makefile |
tests/run-make/bare-outfile/Makefile deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | # This test checks that manually setting the output file as a bare file with no file extension still results in successful compilation. | |
| 2 | ||
| 3 | # ignore-cross-compile | |
| 4 | include ../tools.mk | |
| 5 | ||
| 6 | all: | |
| 7 | 	cp foo.rs $(TMPDIR) | |
| 8 | 	cd $(TMPDIR) && $(RUSTC) -o foo foo.rs | |
| 9 | 	$(call RUN,foo) |
tests/run-make/bare-outfile/rmake.rs created+15| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | // This test checks that manually setting the output file as a bare file with no file extension | |
| 2 | // still results in successful compilation. | |
| 3 | ||
| 4 | //@ ignore-cross-compile | |
| 5 | ||
| 6 | use run_make_support::{run, rustc, tmp_dir}; | |
| 7 | use std::env; | |
| 8 | use std::fs; | |
| 9 | ||
| 10 | fn main() { | |
| 11 | fs::copy("foo.rs", tmp_dir().join("foo.rs")).unwrap(); | |
| 12 | env::set_current_dir(tmp_dir()); | |
| 13 | rustc().output("foo").input("foo.rs").run(); | |
| 14 | run("foo"); | |
| 15 | } |
tests/run-make/emit/Makefile deleted-22| ... | ... | @@ -1,22 +0,0 @@ |
| 1 | # ignore-cross-compile | |
| 2 | include ../tools.mk | |
| 3 | ||
| 4 | all: | |
| 5 | 	$(RUSTC) -Copt-level=0 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs | |
| 6 | 	$(RUSTC) -Copt-level=1 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs | |
| 7 | 	$(RUSTC) -Copt-level=2 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs | |
| 8 | 	$(RUSTC) -Copt-level=3 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs | |
| 9 | 	$(RUSTC) -Copt-level=s --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs | |
| 10 | 	$(RUSTC) -Copt-level=z --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs | |
| 11 | 	$(RUSTC) -Copt-level=0 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs | |
| 12 | 	$(call RUN,test-26235) || exit 1 | |
| 13 | 	$(RUSTC) -Copt-level=1 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs | |
| 14 | 	$(call RUN,test-26235) || exit 1 | |
| 15 | 	$(RUSTC) -Copt-level=2 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs | |
| 16 | 	$(call RUN,test-26235) || exit 1 | |
| 17 | 	$(RUSTC) -Copt-level=3 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs | |
| 18 | 	$(call RUN,test-26235) || exit 1 | |
| 19 | 	$(RUSTC) -Copt-level=s --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs | |
| 20 | 	$(call RUN,test-26235) || exit 1 | |
| 21 | 	$(RUSTC) -Copt-level=z --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs | |
| 22 | 	$(call RUN,test-26235) || exit 1 |
tests/run-make/emit/rmake.rs created+19| ... | ... | @@ -0,0 +1,19 @@ |
| 1 | // A bug from 2015 would cause errors when emitting multiple types of files | |
| 2 | // in the same rustc call. A fix was created in #30452. This test checks that rustc still compiles | |
| 3 | // a source file successfully when emission of multiple output artifacts are requested. | |
| 4 | // See https://github.com/rust-lang/rust/pull/30452 | |
| 5 | ||
| 6 | //@ ignore-cross-compile | |
| 7 | ||
| 8 | use run_make_support::{run, rustc}; | |
| 9 | ||
| 10 | fn main() { | |
| 11 | let opt_levels = ["0", "1", "2", "3", "s", "z"]; | |
| 12 | for level in opt_levels { | |
| 13 | rustc().opt_level(level).emit("llvm-bc,llvm-ir,asm,obj,link").input("test-24876.rs").run(); | |
| 14 | } | |
| 15 | for level in opt_levels { | |
| 16 | rustc().opt_level(level).emit("llvm-bc,llvm-ir,asm,obj,link").input("test-26235.rs").run(); | |
| 17 | run("test-26235"); | |
| 18 | } | |
| 19 | } |
tests/run-make/mixing-formats/Makefile deleted-75| ... | ... | @@ -1,75 +0,0 @@ |
| 1 | # ignore-cross-compile | |
| 2 | include ../tools.mk | |
| 3 | ||
| 4 | # Testing various mixings of rlibs and dylibs. Makes sure that it's possible to | |
| 5 | # link an rlib to a dylib. The dependency tree among the file looks like: | |
| 6 | # | |
| 7 | #				foo | |
| 8 | #			 / \ | |
| 9 | #			 bar1 bar2 | |
| 10 | #			 / \ / | |
| 11 | #			 baz baz2 | |
| 12 | # | |
| 13 | # This is generally testing the permutations of the foo/bar1/bar2 layer against | |
| 14 | # the baz/baz2 layer | |
| 15 | ||
| 16 | all: | |
| 17 | 	# Building just baz | |
| 18 | 	$(RUSTC) --crate-type=rlib foo.rs | |
| 19 | 	$(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic | |
| 20 | 	$(RUSTC) --crate-type=dylib,rlib baz.rs -C prefer-dynamic | |
| 21 | 	$(RUSTC) --crate-type=bin baz.rs | |
| 22 | 	rm $(TMPDIR)/* | |
| 23 | 	$(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic | |
| 24 | 	$(RUSTC) --crate-type=rlib bar1.rs | |
| 25 | 	$(RUSTC) --crate-type=dylib,rlib baz.rs -C prefer-dynamic | |
| 26 | 	$(RUSTC) --crate-type=bin baz.rs | |
| 27 | 	rm $(TMPDIR)/* | |
| 28 | 	# Building baz2 | |
| 29 | 	$(RUSTC) --crate-type=rlib foo.rs | |
| 30 | 	$(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic | |
| 31 | 	$(RUSTC) --crate-type=dylib bar2.rs -C prefer-dynamic | |
| 32 | 	$(RUSTC) --crate-type=dylib baz2.rs && exit 1 || exit 0 | |
| 33 | 	$(RUSTC) --crate-type=bin baz2.rs && exit 1 || exit 0 | |
| 34 | 	rm $(TMPDIR)/* | |
| 35 | 	$(RUSTC) --crate-type=rlib foo.rs | |
| 36 | 	$(RUSTC) --crate-type=rlib bar1.rs | |
| 37 | 	$(RUSTC) --crate-type=dylib bar2.rs -C prefer-dynamic | |
| 38 | 	$(RUSTC) --crate-type=dylib,rlib baz2.rs | |
| 39 | 	$(RUSTC) --crate-type=bin baz2.rs | |
| 40 | 	rm $(TMPDIR)/* | |
| 41 | 	$(RUSTC) --crate-type=rlib foo.rs | |
| 42 | 	$(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic | |
| 43 | 	$(RUSTC) --crate-type=rlib bar2.rs | |
| 44 | 	$(RUSTC) --crate-type=dylib,rlib baz2.rs -C prefer-dynamic | |
| 45 | 	$(RUSTC) --crate-type=bin baz2.rs | |
| 46 | 	rm $(TMPDIR)/* | |
| 47 | 	$(RUSTC) --crate-type=rlib foo.rs | |
| 48 | 	$(RUSTC) --crate-type=rlib bar1.rs | |
| 49 | 	$(RUSTC) --crate-type=rlib bar2.rs | |
| 50 | 	$(RUSTC) --crate-type=dylib,rlib baz2.rs -C prefer-dynamic | |
| 51 | 	$(RUSTC) --crate-type=bin baz2.rs | |
| 52 | 	rm $(TMPDIR)/* | |
| 53 | 	$(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic | |
| 54 | 	$(RUSTC) --crate-type=rlib bar1.rs | |
| 55 | 	$(RUSTC) --crate-type=rlib bar2.rs | |
| 56 | 	$(RUSTC) --crate-type=dylib,rlib baz2.rs -C prefer-dynamic | |
| 57 | 	$(RUSTC) --crate-type=bin baz2.rs | |
| 58 | 	rm $(TMPDIR)/* | |
| 59 | 	$(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic | |
| 60 | 	$(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic | |
| 61 | 	$(RUSTC) --crate-type=rlib bar2.rs | |
| 62 | 	$(RUSTC) --crate-type=dylib,rlib baz2.rs | |
| 63 | 	$(RUSTC) --crate-type=bin baz2.rs | |
| 64 | 	rm $(TMPDIR)/* | |
| 65 | 	$(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic | |
| 66 | 	$(RUSTC) --crate-type=rlib bar1.rs | |
| 67 | 	$(RUSTC) --crate-type=dylib bar2.rs -C prefer-dynamic | |
| 68 | 	$(RUSTC) --crate-type=dylib,rlib baz2.rs | |
| 69 | 	$(RUSTC) --crate-type=bin baz2.rs | |
| 70 | 	rm $(TMPDIR)/* | |
| 71 | 	$(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic | |
| 72 | 	$(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic | |
| 73 | 	$(RUSTC) --crate-type=dylib bar2.rs -C prefer-dynamic | |
| 74 | 	$(RUSTC) --crate-type=dylib,rlib baz2.rs | |
| 75 | 	$(RUSTC) --crate-type=bin baz2.rs |
tests/run-make/mixing-formats/rmake.rs created+94| ... | ... | @@ -0,0 +1,94 @@ |
| 1 | // Testing various mixings of rlibs and dylibs. Makes sure that it's possible to | |
| 2 | // link an rlib to a dylib. The dependency tree among the file looks like: | |
| 3 | // | |
| 4 | // foo | |
| 5 | // / \ | |
| 6 | // bar1 bar2 | |
| 7 | // / \ / | |
| 8 | // baz baz2 | |
| 9 | // | |
| 10 | // This is generally testing the permutations of the foo/bar1/bar2 layer against | |
| 11 | // the baz/baz2 layer | |
| 12 | ||
| 13 | //@ ignore-cross-compile | |
| 14 | ||
| 15 | use run_make_support::{rustc, tmp_dir}; | |
| 16 | use std::fs; | |
| 17 | ||
| 18 | fn test_with_teardown(rustc_calls: impl Fn()) { | |
| 19 | rustc_calls(); | |
| 20 | //FIXME(Oneirical): This should be replaced with the run-make-support fs wrappers. | |
| 21 | fs::remove_dir_all(tmp_dir()).unwrap(); | |
| 22 | fs::create_dir(tmp_dir()).unwrap(); | |
| 23 | } | |
| 24 | ||
| 25 | fn main() { | |
| 26 | test_with_teardown(|| { | |
| 27 | // Building just baz | |
| 28 | rustc().crate_type("rlib").input("foo.rs").run(); | |
| 29 | rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run(); | |
| 30 | rustc().crate_type("dylib,rlib").input("baz.rs").arg("-Cprefer-dynamic").run(); | |
| 31 | rustc().crate_type("bin").input("baz.rs").run(); | |
| 32 | }); | |
| 33 | test_with_teardown(|| { | |
| 34 | rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run(); | |
| 35 | rustc().crate_type("rlib").input("bar1.rs").run(); | |
| 36 | rustc().crate_type("dylib,rlib").input("baz.rs").arg("-Cprefer-dynamic").run(); | |
| 37 | rustc().crate_type("bin").input("baz.rs").run(); | |
| 38 | }); | |
| 39 | test_with_teardown(|| { | |
| 40 | // Building baz2 | |
| 41 | rustc().crate_type("rlib").input("foo.rs").run(); | |
| 42 | rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run(); | |
| 43 | rustc().crate_type("dylib").input("bar2.rs").arg("-Cprefer-dynamic").run(); | |
| 44 | rustc().crate_type("dylib").input("baz2.rs").run_fail_assert_exit_code(1); | |
| 45 | rustc().crate_type("bin").input("baz2.rs").run_fail_assert_exit_code(1); | |
| 46 | }); | |
| 47 | test_with_teardown(|| { | |
| 48 | rustc().crate_type("rlib").input("foo.rs").run(); | |
| 49 | rustc().crate_type("rlib").input("bar1.rs").run(); | |
| 50 | rustc().crate_type("dylib").input("bar2.rs").arg("-Cprefer-dynamic").run(); | |
| 51 | rustc().crate_type("dylib,rlib").input("baz2.rs").run(); | |
| 52 | rustc().crate_type("bin").input("baz2.rs").run(); | |
| 53 | }); | |
| 54 | test_with_teardown(|| { | |
| 55 | rustc().crate_type("rlib").input("foo.rs").run(); | |
| 56 | rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run(); | |
| 57 | rustc().crate_type("rlib").input("bar2.rs").run(); | |
| 58 | rustc().crate_type("dylib,rlib").input("baz2.rs").arg("-Cprefer-dynamic").run(); | |
| 59 | rustc().crate_type("bin").input("baz2.rs").run(); | |
| 60 | }); | |
| 61 | test_with_teardown(|| { | |
| 62 | rustc().crate_type("rlib").input("foo.rs").run(); | |
| 63 | rustc().crate_type("rlib").input("bar1.rs").run(); | |
| 64 | rustc().crate_type("rlib").input("bar2.rs").run(); | |
| 65 | rustc().crate_type("dylib,rlib").input("baz2.rs").arg("-Cprefer-dynamic").run(); | |
| 66 | rustc().crate_type("bin").input("baz2.rs").run(); | |
| 67 | }); | |
| 68 | test_with_teardown(|| { | |
| 69 | rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run(); | |
| 70 | rustc().crate_type("rlib").input("bar1.rs").run(); | |
| 71 | rustc().crate_type("rlib").input("bar2.rs").run(); | |
| 72 | rustc().crate_type("dylib,rlib").input("baz2.rs").arg("-Cprefer-dynamic").run(); | |
| 73 | rustc().crate_type("bin").input("baz2.rs").run(); | |
| 74 | }); | |
| 75 | test_with_teardown(|| { | |
| 76 | rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run(); | |
| 77 | rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run(); | |
| 78 | rustc().crate_type("rlib").input("bar2.rs").run(); | |
| 79 | rustc().crate_type("dylib,rlib").input("baz2.rs").run(); | |
| 80 | rustc().crate_type("bin").input("baz2.rs").run(); | |
| 81 | }); | |
| 82 | test_with_teardown(|| { | |
| 83 | rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run(); | |
| 84 | rustc().crate_type("rlib").input("bar1.rs").run(); | |
| 85 | rustc().crate_type("dylib").input("bar2.rs").arg("-Cprefer-dynamic").run(); | |
| 86 | rustc().crate_type("dylib,rlib").input("baz2.rs").run(); | |
| 87 | rustc().crate_type("bin").input("baz2.rs").run(); | |
| 88 | }); | |
| 89 | rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run(); | |
| 90 | rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run(); | |
| 91 | rustc().crate_type("dylib").input("bar2.rs").arg("-Cprefer-dynamic").run(); | |
| 92 | rustc().crate_type("dylib,rlib").input("baz2.rs").run(); | |
| 93 | rustc().crate_type("bin").input("baz2.rs").run(); | |
| 94 | } |