diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-06-24 15:39:40 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-24 15:39:40 +0200 |
| commit | d9ee943db2bcc24d8d7dd8586caee73e6cbab10e (patch) | |
| tree | 7c297b15272e459a017a0c560b1986762844f49c /tests | |
| parent | 4b52c9d8ead516211eefba8341913e1a3a2cf7d1 (diff) | |
| parent | 81a7cb67182d76f1ac77e1454d6a796fba17a4ce (diff) | |
Rollup merge of #142843 - dpaoliello:reproducible-build-2, r=jieyouxu
Enable reproducible-build-2 for Windows MSVC Works with MSVC if instructing the linker to avoid timestamps and deleting the PDB between compilations. Addresses item in rust-lang/rust#128602 --- try-job: x86_64-mingw-* try-job: x86_64-msvc-* try-job: i686-msvc-*
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/run-make/reproducible-build-2/rmake.rs | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/tests/run-make/reproducible-build-2/rmake.rs b/tests/run-make/reproducible-build-2/rmake.rs index 5971fa01f92..1de5ca1e6f7 100644 --- a/tests/run-make/reproducible-build-2/rmake.rs +++ b/tests/run-make/reproducible-build-2/rmake.rs @@ -7,22 +7,36 @@ // See https://github.com/rust-lang/rust/issues/34902 //@ ignore-cross-compile -//@ ignore-windows -// Reasons: -// 1. The object files are reproducible, but their paths are not, which causes -// the first assertion in the test to fail. -// 2. When the sysroot gets copied, some symlinks must be re-created, -// which is a privileged action on Windows. -use run_make_support::{rfs, rust_lib_name, rustc}; +//@ ignore-windows-gnu +// GNU Linker for Windows is non-deterministic. + +use run_make_support::{bin_name, is_windows_msvc, rfs, rust_lib_name, rustc}; fn main() { // test 1: fat lto rustc().input("reproducible-build-aux.rs").run(); - rustc().input("reproducible-build.rs").arg("-Clto=fat").output("reproducible-build").run(); - rfs::rename("reproducible-build", "reproducible-build-a"); - rustc().input("reproducible-build.rs").arg("-Clto=fat").output("reproducible-build").run(); - assert_eq!(rfs::read("reproducible-build"), rfs::read("reproducible-build-a")); + let make_reproducible_build = || { + let mut reproducible_build = rustc(); + reproducible_build + .input("reproducible-build.rs") + .arg("-Clto=fat") + .output(bin_name("reproducible-build")); + if is_windows_msvc() { + // Avoids timestamps, etc. when linking. + reproducible_build.arg("-Clink-arg=/Brepro"); + } + reproducible_build.run(); + }; + make_reproducible_build(); + rfs::rename(bin_name("reproducible-build"), "reproducible-build-a"); + if is_windows_msvc() { + // Linker acts differently if there is already a PDB file with the same + // name. + rfs::remove_file("reproducible-build.pdb"); + } + make_reproducible_build(); + assert_eq!(rfs::read(bin_name("reproducible-build")), rfs::read("reproducible-build-a")); // test 2: sysroot let sysroot = rustc().print("sysroot").run().stdout_utf8(); |
