Skip to content

Commit 31604f2

Browse files
committed
rewrite reproducible-build to rmake
1 parent 0b5eb7b commit 31604f2

File tree

3 files changed

+170
-141
lines changed

3 files changed

+170
-141
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ run-make/raw-dylib-c/Makefile
4242
run-make/redundant-libs/Makefile
4343
run-make/remap-path-prefix-dwarf/Makefile
4444
run-make/reproducible-build-2/Makefile
45-
run-make/reproducible-build/Makefile
4645
run-make/rlib-format-packed-bundled-libs/Makefile
4746
run-make/simd-ffi/Makefile
4847
run-make/split-debuginfo/Makefile

tests/run-make/reproducible-build/Makefile

-140
This file was deleted.
+170
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
// This test case makes sure that two identical invocations of the compiler
2+
// (i.e. same code base, same compile-flags, same compiler-versions, etc.)
3+
// produce the same output. In the past, symbol names of monomorphized functions
4+
// were not deterministic (which we want to avoid).
5+
//
6+
// The test tries to exercise as many different paths into symbol name
7+
// generation as possible:
8+
//
9+
// - regular functions
10+
// - generic functions
11+
// - methods
12+
// - statics
13+
// - closures
14+
// - enum variant constructors
15+
// - tuple struct constructors
16+
// - drop glue
17+
// - FnOnce adapters
18+
// - Trait object shims
19+
// - Fn Pointer shims
20+
// See https://github.com/rust-lang/rust/pull/32293
21+
22+
// FIXME(Oneirical): ignore-musl
23+
// FIXME(Oneirical): two of these test blocks will apparently fail on windows
24+
// FIXME(Oneirical): try it on test-various
25+
// # TODO: Builds of `bin` crate types are not deterministic with debuginfo=2 on
26+
// # Windows.
27+
// # See: https://github.com/rust-lang/rust/pull/87320#issuecomment-920105533
28+
// # Issue: https://github.com/rust-lang/rust/issues/88982
29+
30+
use run_make_support::{bin_name, cwd, diff, rfs, rust_lib_name, rustc};
31+
32+
fn main() {
33+
rustc().input("linker.rs").opt().run();
34+
rustc().input("reproducible-build-aux.rs").run();
35+
eprintln!("{:#?}", rfs::shallow_find_dir_entries(cwd()));
36+
rustc().input("reproducible-build.rs").linker(&bin_name("linker")).run();
37+
rustc().input("reproducible-build.rs").linker(&bin_name("linker")).run();
38+
diff().actual_file("linker-arguments1").expected_file("linker-arguments2").run();
39+
rustc().input("linker.rs").opt().run();
40+
rustc().arg("-g").input("reproducible-build-aux.rs").run();
41+
rustc().arg("-g").input("reproducible-build.rs").linker(&bin_name("linker")).run();
42+
rustc().arg("-g").input("reproducible-build.rs").linker(&bin_name("linker")).run();
43+
diff().actual_file("linker-arguments1").expected_file("linker-arguments2").run();
44+
rustc().input("linker.rs").opt().run();
45+
rustc().opt().input("reproducible-build-aux.rs").run();
46+
rustc().opt().input("reproducible-build.rs").linker(&bin_name("linker")).run();
47+
rustc().opt().input("reproducible-build.rs").linker(&bin_name("linker")).run();
48+
diff().actual_file("linker-arguments1").expected_file("linker-arguments2").run();
49+
50+
rustc().input("reproducible-build-aux.rs").run();
51+
rustc().input("reproducible-build.rs").crate_type("rlib").library_search_path("b").run();
52+
rfs::copy(rust_lib_name("reproducible_build"), rust_lib_name("foo"));
53+
rustc().input("reproducible-build.rs").crate_type("rlib").library_search_path("a").run();
54+
assert_eq!(rfs::read(rust_lib_name("reproducible_build")), rfs::read(rust_lib_name("foo")));
55+
56+
rustc().input("reproducible-build-aux.rs").run();
57+
rustc()
58+
.input("reproducible-build.rs")
59+
.crate_type("rlib")
60+
.arg("--remap-path-prefix=/a=/c")
61+
.run();
62+
rfs::copy(rust_lib_name("reproducible_build"), rust_lib_name("foo"));
63+
rustc()
64+
.input("reproducible-build.rs")
65+
.crate_type("rlib")
66+
.arg("--remap-path-prefix=/b=/c")
67+
.run();
68+
assert_eq!(rfs::read(rust_lib_name("reproducible_build")), rfs::read(rust_lib_name("foo")));
69+
70+
rustc().input("reproducible-build-aux.rs").run();
71+
rfs::create_dir("test");
72+
rfs::copy("reproducible-build.rs", "test/reproducible-build.rs");
73+
rustc()
74+
.input("reproducible-build.rs")
75+
.crate_type("bin")
76+
.arg(&format!("--remap-path-prefix={}=/b", cwd().display()))
77+
.run();
78+
rfs::copy("reproducible_build", "foo");
79+
rustc()
80+
.input("test/reproducible-build.rs")
81+
.crate_type("bin")
82+
.arg("--remap-path-prefix=/test=/b")
83+
.run();
84+
assert_eq!(rfs::read("reproducible_build"), rfs::read("foo"));
85+
86+
rustc().input("reproducible-build-aux.rs").run();
87+
rfs::create_dir("test");
88+
rfs::copy("reproducible-build.rs", "test/reproducible-build.rs");
89+
rustc()
90+
.input("reproducible-build.rs")
91+
.crate_type("rlib")
92+
.arg(&format!("--remap-path-prefix={}=/b", cwd().display()))
93+
.run();
94+
rfs::copy(rust_lib_name("reproducible_build"), rust_lib_name("foo"));
95+
rustc()
96+
.input("test/reproducible-build.rs")
97+
.crate_type("rlib")
98+
.arg("--remap-path-prefix=/test=/b")
99+
.run();
100+
assert_eq!(rfs::read(rust_lib_name("reproducible_build")), rfs::read(rust_lib_name("foo")));
101+
102+
rustc().input("reproducible-build-aux.rs").run();
103+
rfs::create_dir("test");
104+
rfs::copy("reproducible-build.rs", "test/reproducible-build.rs");
105+
rustc()
106+
.input("reproducible-build.rs")
107+
.crate_type("bin")
108+
.arg("-Zremap-path-prefix=.")
109+
.arg("-Cdebuginfo=2")
110+
.run();
111+
rfs::copy("reproducible_build", "first");
112+
rustc()
113+
.input("test/reproducible-build.rs")
114+
.crate_type("bin")
115+
.arg("-Zremap-path-prefix=.")
116+
.arg("-Cdebuginfo=2")
117+
.run();
118+
assert_eq!(rfs::read("first"), rfs::read("reproducible_build"));
119+
120+
rustc().input("reproducible-build-aux.rs").run();
121+
rfs::create_dir("test");
122+
rfs::copy("reproducible-build.rs", "test/reproducible-build.rs");
123+
rustc()
124+
.input("reproducible-build.rs")
125+
.crate_type("rlib")
126+
.arg("-Zremap-path-prefix=.")
127+
.arg("-Cdebuginfo=2")
128+
.run();
129+
rfs::copy("reproducible_build", "first");
130+
rustc()
131+
.input("test/reproducible-build.rs")
132+
.crate_type("rlib")
133+
.arg("-Zremap-path-prefix=.")
134+
.arg("-Cdebuginfo=2")
135+
.run();
136+
assert_eq!(rfs::read(rust_lib_name("first")), rfs::read(rust_lib_name("reproducible_build")));
137+
138+
rustc().input("reproducible-build-aux.rs").run();
139+
rfs::create_dir("test");
140+
rfs::copy("reproducible-build.rs", "test/reproducible-build.rs");
141+
rustc()
142+
.input("reproducible-build.rs")
143+
.crate_type("rlib")
144+
.arg("-Zremap-path-prefix=")
145+
.arg("-Cdebuginfo=2")
146+
.run();
147+
rfs::copy(rust_lib_name("reproducible_build"), rust_lib_name("first"));
148+
rustc()
149+
.input("test/reproducible-build.rs")
150+
.crate_type("rlib")
151+
.arg("-Zremap-path-prefix=")
152+
.arg("-Cdebuginfo=2")
153+
.run();
154+
assert_eq!(rfs::read(rust_lib_name("first")), rfs::read(rust_lib_name("reproducible_build")));
155+
156+
rustc().input("reproducible-build-aux.rs").run();
157+
rustc()
158+
.input("reproducible-build.rs")
159+
.crate_type("rlib")
160+
.extern_("reproducible_build_aux", rust_lib_name("reproducible_build_aux"))
161+
.run();
162+
rfs::copy(rust_lib_name("reproducible_build"), rust_lib_name("foo"));
163+
rfs::copy(rust_lib_name("reproducible_build_aux"), rust_lib_name("bar"));
164+
rustc()
165+
.input("reproducible-build.rs")
166+
.crate_type("rlib")
167+
.extern_("reproducible_build_aux", rust_lib_name("bar"))
168+
.run();
169+
assert_eq!(rfs::read(rust_lib_name("foo")), rfs::read(rust_lib_name("reproducible_build")));
170+
}

0 commit comments

Comments
 (0)