|
7 | 7 | // See https://github.com/rust-lang/rust/issues/34902
|
8 | 8 |
|
9 | 9 | //@ ignore-cross-compile
|
10 |
| -//@ ignore-windows |
11 |
| -// Reasons: |
12 |
| -// 1. The object files are reproducible, but their paths are not, which causes |
13 |
| -// the first assertion in the test to fail. |
14 |
| -// 2. When the sysroot gets copied, some symlinks must be re-created, |
15 |
| -// which is a privileged action on Windows. |
16 | 10 |
|
17 |
| -use run_make_support::{rfs, rust_lib_name, rustc}; |
| 11 | +//@ ignore-windows-gnu |
| 12 | +// GNU Linker for Windows is non-deterministic. |
| 13 | + |
| 14 | +use run_make_support::{bin_name, is_windows_msvc, rfs, rust_lib_name, rustc}; |
18 | 15 |
|
19 | 16 | fn main() {
|
20 | 17 | // test 1: fat lto
|
21 | 18 | rustc().input("reproducible-build-aux.rs").run();
|
22 |
| - rustc().input("reproducible-build.rs").arg("-Clto=fat").output("reproducible-build").run(); |
23 |
| - rfs::rename("reproducible-build", "reproducible-build-a"); |
24 |
| - rustc().input("reproducible-build.rs").arg("-Clto=fat").output("reproducible-build").run(); |
25 |
| - assert_eq!(rfs::read("reproducible-build"), rfs::read("reproducible-build-a")); |
| 19 | + let make_reproducible_build = || { |
| 20 | + let mut reproducible_build = rustc(); |
| 21 | + reproducible_build |
| 22 | + .input("reproducible-build.rs") |
| 23 | + .arg("-Clto=fat") |
| 24 | + .output(bin_name("reproducible-build")); |
| 25 | + if is_windows_msvc() { |
| 26 | + // Avoids timestamps, etc. when linking. |
| 27 | + reproducible_build.arg("-Clink-arg=/Brepro"); |
| 28 | + } |
| 29 | + reproducible_build.run(); |
| 30 | + }; |
| 31 | + make_reproducible_build(); |
| 32 | + rfs::rename(bin_name("reproducible-build"), "reproducible-build-a"); |
| 33 | + if is_windows_msvc() { |
| 34 | + // Linker acts differently if there is already a PDB file with the same |
| 35 | + // name. |
| 36 | + rfs::remove_file("reproducible-build.pdb"); |
| 37 | + } |
| 38 | + make_reproducible_build(); |
| 39 | + assert_eq!(rfs::read(bin_name("reproducible-build")), rfs::read("reproducible-build-a")); |
26 | 40 |
|
27 | 41 | // test 2: sysroot
|
28 | 42 | let sysroot = rustc().print("sysroot").run().stdout_utf8();
|
|
0 commit comments