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