Skip to content

Commit 8f359a0

Browse files
committed
Fix miri
1 parent e8327f1 commit 8f359a0

File tree

11 files changed

+87
-60
lines changed

11 files changed

+87
-60
lines changed

src/tools/miri/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ extern crate rustc_index;
6767
extern crate rustc_middle;
6868
extern crate rustc_session;
6969
extern crate rustc_span;
70+
extern crate rustc_symbol_mangling;
7071
extern crate rustc_target;
7172
// Linking `rustc_driver` pulls in the required object code as the rest of the rustc crates are
7273
// shipped only as rmeta files.

src/tools/miri/src/shims/extern_static.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Provides the `extern static` that this platform expects.
22
3+
use rustc_symbol_mangling::mangle_internal_symbol;
4+
35
use crate::*;
46

57
impl<'tcx> MiriMachine<'tcx> {
@@ -50,7 +52,11 @@ impl<'tcx> MiriMachine<'tcx> {
5052
// "__rust_alloc_error_handler_should_panic"
5153
let val = ecx.tcx.sess.opts.unstable_opts.oom.should_panic();
5254
let val = ImmTy::from_int(val, ecx.machine.layouts.u8);
53-
Self::alloc_extern_static(ecx, "__rust_alloc_error_handler_should_panic", val)?;
55+
Self::alloc_extern_static(
56+
ecx,
57+
&mangle_internal_symbol(*ecx.tcx, "__rust_alloc_error_handler_should_panic"),
58+
val,
59+
)?;
5460

5561
if ecx.target_os_is_unix() {
5662
// "environ" is mandated by POSIX.

src/tools/miri/src/shims/foreign_items.rs

Lines changed: 55 additions & 59 deletions
Large diffs are not rendered by default.

src/tools/miri/tests/fail/alloc/too_large.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
#![feature(rustc_attrs)]
2+
13
extern "Rust" {
4+
#[rustc_std_internal_symbol]
25
fn __rust_alloc(size: usize, align: usize) -> *mut u8;
36
}
47

src/tools/miri/tests/fail/alloc/unsupported_big_alignment.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
// because rustc does not support alignments that large.
33
// https://github.com/rust-lang/miri/issues/3687
44

5+
#![feature(rustc_attrs)]
6+
57
extern "Rust" {
8+
#[rustc_std_internal_symbol]
69
fn __rust_alloc(size: usize, align: usize) -> *mut u8;
710
}
811

src/tools/miri/tests/fail/alloc/unsupported_non_power_two_alignment.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// Test non-power-of-two alignment.
2+
3+
#![feature(rustc_attrs)]
4+
25
extern "Rust" {
6+
#[rustc_std_internal_symbol]
37
fn __rust_alloc(size: usize, align: usize) -> *mut u8;
48
}
59

src/tools/miri/tests/fail/data_race/dealloc_read_race1.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// Avoid accidental synchronization via address reuse inside `thread::spawn`.
44
//@compile-flags: -Zmiri-address-reuse-cross-thread-rate=0
55

6+
#![feature(rustc_attrs)]
7+
68
use std::thread::spawn;
79

810
#[derive(Copy, Clone)]
@@ -12,6 +14,7 @@ unsafe impl<T> Send for EvilSend<T> {}
1214
unsafe impl<T> Sync for EvilSend<T> {}
1315

1416
extern "Rust" {
17+
#[rustc_std_internal_symbol]
1518
fn __rust_dealloc(ptr: *mut u8, size: usize, align: usize);
1619
}
1720

src/tools/miri/tests/fail/data_race/dealloc_read_race2.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// Avoid accidental synchronization via address reuse inside `thread::spawn`.
44
//@compile-flags: -Zmiri-address-reuse-cross-thread-rate=0
55

6+
#![feature(rustc_attrs)]
7+
68
use std::thread::spawn;
79

810
#[derive(Copy, Clone)]
@@ -12,6 +14,7 @@ unsafe impl<T> Send for EvilSend<T> {}
1214
unsafe impl<T> Sync for EvilSend<T> {}
1315

1416
extern "Rust" {
17+
#[rustc_std_internal_symbol]
1518
fn __rust_dealloc(ptr: *mut u8, size: usize, align: usize);
1619
}
1720

src/tools/miri/tests/fail/data_race/dealloc_write_race1.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// Avoid accidental synchronization via address reuse inside `thread::spawn`.
44
//@compile-flags: -Zmiri-address-reuse-cross-thread-rate=0
55

6+
#![feature(rustc_attrs)]
7+
68
use std::thread::spawn;
79

810
#[derive(Copy, Clone)]
@@ -12,6 +14,7 @@ unsafe impl<T> Send for EvilSend<T> {}
1214
unsafe impl<T> Sync for EvilSend<T> {}
1315

1416
extern "Rust" {
17+
#[rustc_std_internal_symbol]
1518
fn __rust_dealloc(ptr: *mut u8, size: usize, align: usize);
1619
}
1720
pub fn main() {

src/tools/miri/tests/fail/data_race/dealloc_write_race2.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// Avoid accidental synchronization via address reuse inside `thread::spawn`.
44
//@compile-flags: -Zmiri-address-reuse-cross-thread-rate=0
55

6+
#![feature(rustc_attrs)]
7+
68
use std::thread::spawn;
79

810
#[derive(Copy, Clone)]
@@ -12,6 +14,7 @@ unsafe impl<T> Send for EvilSend<T> {}
1214
unsafe impl<T> Sync for EvilSend<T> {}
1315

1416
extern "Rust" {
17+
#[rustc_std_internal_symbol]
1518
fn __rust_dealloc(ptr: *mut u8, size: usize, align: usize);
1619
}
1720
pub fn main() {

0 commit comments

Comments
 (0)