Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions tests/run-make/parallel-reproducible-build/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//@ ignore-windows-gnu
// GNU Linker for Windows is non-deterministic. (from `reproducible-build-2` test in this suite)

use std::rc::Rc;

use run_make_support::{bin_name, is_windows_msvc, rfs, run_in_tmpdir, rustc};

/// Test that parallel compiler produces identical binaries.
fn main() {
const FILE_NAME: &str = "static-muts-issue-140413";
let bin_name = bin_name(FILE_NAME);

let mut reference = None;

for _ in 0..100 {
// Tmp dir as previous runs affect output binary on windows.
run_in_tmpdir(|| {
let mut rustc = rustc();
rustc.input(format!("{FILE_NAME}.rs")).arg("-Zthreads=50").output(&bin_name);

if is_windows_msvc() {
rustc.arg("-Clink-arg=/Brepro");
}

rustc.run();

let current = Rc::new(rfs::read(&bin_name));
reference.get_or_insert(Rc::clone(&current));

assert_eq!(Some(current), reference);
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Checks that mutable static items can have mutable slices and other references

pub static mut TEST: &'static mut [isize] = &mut [1];
pub static mut EMPTY: &'static mut [isize] = &mut [];
pub static mut INT: &'static mut isize = &mut 1;

// And the same for raw pointers.

pub static mut TEST_RAW: *mut [isize] = &mut [1isize] as *mut _;
pub static mut EMPTY_RAW: *mut [isize] = &mut [] as *mut _;
pub static mut INT_RAW: *mut isize = &mut 1isize as *mut _;

pub fn main() {
unsafe {
TEST[0] += 1;
assert_eq!(TEST[0], 2);
*INT_RAW += 1;
assert_eq!(*INT_RAW, 2);
}
}
Loading