Skip to content

Commit f0adc2b

Browse files
committed
rewrite reproducible-build-2 to rmake
1 parent 99f77a2 commit f0adc2b

File tree

4 files changed

+59
-28
lines changed

4 files changed

+59
-28
lines changed

src/tools/run-make-support/src/fs_wrapper.rs

+14
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@ pub fn copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) {
1818
));
1919
}
2020

21+
/// An extension of copy which can copy a directory recursively.
22+
pub fn copy_dir_all<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) {
23+
create_dir_all(&to);
24+
for entry in read_dir(from) {
25+
let entry = entry.unwrap();
26+
let ty = entry.file_type().unwrap();
27+
if ty.is_dir() {
28+
copy_dir_all(entry.path(), to.as_ref().join(entry.file_name()));
29+
} else {
30+
copy(entry.path(), to.as_ref().join(entry.file_name()));
31+
}
32+
}
33+
}
34+
2135
/// A wrapper around [`std::fs::File::create`] which includes the file path in the panic message..
2236
#[track_caller]
2337
pub fn create_file<P: AsRef<Path>>(path: P) {

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ run-make/raw-dylib-stdcall-ordinal/Makefile
149149
run-make/redundant-libs/Makefile
150150
run-make/remap-path-prefix-dwarf/Makefile
151151
run-make/remap-path-prefix/Makefile
152-
run-make/reproducible-build-2/Makefile
153152
run-make/reproducible-build/Makefile
154153
run-make/return-non-c-like-enum-from-c/Makefile
155154
run-make/return-non-c-like-enum/Makefile

tests/run-make/reproducible-build-2/Makefile

-27
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Builds with fat link-time-optimizations and the --sysroot flag used to be
2+
// non-deterministic - that means, compiling twice with no changes would create
3+
// slightly different outputs. This has been fixed by #63352 and #63505.
4+
// Test 1: Compile with fat-lto twice, check that both compilation outputs are identical.
5+
// Test 2: Compile with sysroot, then change the sysroot path from absolute to relative.
6+
// Outputs should be identical.
7+
// See https://github.com/rust-lang/rust/issues/34902
8+
9+
//FIXME(Oneirical): excluded ignore-musl ignore-windows ignore-cross-compile
10+
11+
use run_make_support::{fs_wrapper, rust_lib_name, rustc};
12+
13+
fn main() {
14+
// test 1: fat lto
15+
rustc().input("reproducible-build-aux.rs").run();
16+
rustc().input("reproducible-build.rs").arg("-Clto=fat").run();
17+
fs_wrapper::rename("reproducible-build", "reproducible-build-a");
18+
rustc().input("reproducible-build.rs").arg("-Clto=fat").run();
19+
assert_eq!(fs_wrapper::read("reproducible-build"), fs_wrapper::read("reproducible-build-a"));
20+
21+
// test 2: sysroot
22+
let sysroot = rustc().print("sysroot").run().stdout_utf8();
23+
let sysroot = sysroot.trim();
24+
25+
rustc().input("reproducible-build-aux.rs").run();
26+
rustc()
27+
.input("reproducible-build.rs")
28+
.crate_type("rlib")
29+
.sysroot(&sysroot)
30+
.arg(format!("--remap-path-prefix={sysroot}=/sysroot"))
31+
.run();
32+
fs_wrapper::copy_dir_all(&sysroot, "sysroot");
33+
fs_wrapper::rename(rust_lib_name("reproducible_build"), rust_lib_name("foo"));
34+
rustc()
35+
.input("reproducible-build.rs")
36+
.crate_type("rlib")
37+
.sysroot("sysroot")
38+
.arg("--remap-path-prefix=/sysroot=/sysroot")
39+
.run();
40+
41+
assert_eq!(
42+
fs_wrapper::read(rust_lib_name("reproducible_build")),
43+
fs_wrapper::read(rust_lib_name("foo"))
44+
);
45+
}

0 commit comments

Comments
 (0)