Skip to content

Commit b485dd1

Browse files
committed
rewrite reproducible-build-2 to rmake
1 parent c0e3298 commit b485dd1

File tree

4 files changed

+67
-28
lines changed

4 files changed

+67
-28
lines changed

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

+22
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,28 @@ pub fn copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) {
8383
));
8484
}
8585

86+
#[track_caller]
87+
/// An extension of [`std::fs::copy`] which can copy a directory recursively.
88+
pub fn copy_dir_all<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) {
89+
create_dir_all(&to);
90+
for entry in read_dir(from) {
91+
let entry = entry.unwrap();
92+
let ty = entry.file_type().unwrap();
93+
if ty.is_dir() {
94+
copy_dir_all(entry.path(), to.as_ref().join(entry.file_name()));
95+
} else if ty.is_symlink() {
96+
copy_symlink(entry.path(), to.as_ref().join(entry.file_name()));
97+
} else {
98+
copy(entry.path(), to.as_ref().join(entry.file_name()));
99+
}
100+
}
101+
}
102+
103+
fn copy_symlink<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) {
104+
let target_path = fs::read_link(from).unwrap();
105+
std::os::unix::fs::symlink(target_path, to).unwrap();
106+
}
107+
86108
/// A wrapper around [`std::fs::File::create`] which includes the file path in the panic message.
87109
#[track_caller]
88110
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
@@ -41,7 +41,6 @@ run-make/raw-dylib-alt-calling-convention/Makefile
4141
run-make/raw-dylib-c/Makefile
4242
run-make/redundant-libs/Makefile
4343
run-make/remap-path-prefix-dwarf/Makefile
44-
run-make/reproducible-build-2/Makefile
4544
run-make/reproducible-build/Makefile
4645
run-make/rlib-format-packed-bundled-libs/Makefile
4746
run-make/simd-ffi/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)