authorbors <bors@rust-lang.org> 2024-06-03 18:35:54 UTC
committerbors <bors@rust-lang.org> 2024-06-03 18:35:54 UTC
log7c52d2db6348b038276198e88a835125849f322e
tree016e7b14e0081ac6cc226efb1464d92525902ba2
parenteb5e2449c5a5215927834d67914ce41cccd3f3c9
parent6e120cf4642bbc1ee1021cf83d0dc013392f47e5

Auto merge of #125383 - Oneirical:bundle-them-up, r=jieyouxu

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-msvc

8 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};
44
55use crate::is_windows;
66
7use super::{bin_name, handle_failed_output};
7use super::handle_failed_output;
88
99fn run_common(name: &str) -> (Command, Output) {
1010 let mut bin_path = PathBuf::new();
1111 bin_path.push(env::var("TMPDIR").unwrap());
12 bin_path.push(&bin_name(name));
12 bin_path.push(name);
1313 let ld_lib_path_envvar = env::var("LD_LIB_PATH_ENVVAR").unwrap();
1414 let mut cmd = Command::new(bin_path);
1515 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
22run-make/allow-non-lint-warnings-cmdline/Makefile
33run-make/archive-duplicate-names/Makefile
44run-make/atomic-lock-free/Makefile
5run-make/bare-outfile/Makefile
65run-make/branch-protection-check-IBT/Makefile
76run-make/c-dynamic-dylib/Makefile
87run-make/c-dynamic-rlib/Makefile
......@@ -40,7 +39,6 @@ run-make/emit-path-unhashed/Makefile
4039run-make/emit-shared-files/Makefile
4140run-make/emit-stack-sizes/Makefile
4241run-make/emit-to-stdout/Makefile
43run-make/emit/Makefile
4442run-make/env-dep-info/Makefile
4543run-make/error-found-staticlib-instead-crate/Makefile
4644run-make/error-writing-dependencies/Makefile
......@@ -147,7 +145,6 @@ run-make/min-global-align/Makefile
147145run-make/mingw-export-call-convention/Makefile
148146run-make/mismatching-target-triples/Makefile
149147run-make/missing-crate-dependency/Makefile
150run-make/mixing-formats/Makefile
151148run-make/mixing-libs/Makefile
152149run-make/msvc-opt-minsize/Makefile
153150run-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
4include ../tools.mk
5
6all:
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
6use run_make_support::{run, rustc, tmp_dir};
7use std::env;
8use std::fs;
9
10fn 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
2include ../tools.mk
3
4all:
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
8use run_make_support::{run, rustc};
9
10fn 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
2include ../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
16all:
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
15use run_make_support::{rustc, tmp_dir};
16use std::fs;
17
18fn 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
25fn 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}