Skip to content

Commit e562940

Browse files
committed
disable ptrace codepath since it doesn't build on many targets
1 parent a317123 commit e562940

File tree

5 files changed

+29
-59
lines changed

5 files changed

+29
-59
lines changed

src/tools/miri/src/bin/miri.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ impl rustc_driver::Callbacks for MiriCompilerCalls {
227227
} else {
228228
let return_code = miri::eval_entry(tcx, entry_def_id, entry_type, &config, None)
229229
.unwrap_or_else(|| {
230-
#[cfg(target_os = "linux")]
231-
miri::native_lib::register_retcode_sv(rustc_driver::EXIT_FAILURE);
230+
//#[cfg(target_os = "linux")]
231+
//miri::native_lib::register_retcode_sv(rustc_driver::EXIT_FAILURE);
232232
tcx.dcx().abort_if_errors();
233233
rustc_driver::EXIT_FAILURE
234234
});
@@ -804,7 +804,7 @@ fn main() {
804804
// thread in an async-signal-unsafe way such as by accessing shared
805805
// semaphores, etc.; the handler only calls `sleep()` and `exit()`, which
806806
// are async-signal-safe, as is accessing atomics
807-
let _ = unsafe { miri::native_lib::init_sv() };
807+
//let _ = unsafe { miri::native_lib::init_sv() };
808808
}
809809
run_compiler_and_exit(
810810
&rustc_args,

src/tools/miri/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ pub use rustc_const_eval::interpret::{self, AllocMap, Provenance as _};
100100
use rustc_middle::{bug, span_bug};
101101
use tracing::{info, trace};
102102

103-
#[cfg(target_os = "linux")]
104-
pub mod native_lib {
105-
pub use crate::shims::{init_sv, register_retcode_sv};
106-
}
103+
//#[cfg(target_os = "linux")]
104+
//pub mod native_lib {
105+
// pub use crate::shims::{init_sv, register_retcode_sv};
106+
//}
107107

108108
// Type aliases that set the provenance parameter.
109109
pub type Pointer = interpret::Pointer<Option<machine::Provenance>>;

src/tools/miri/src/shims/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ pub mod time;
2121
pub mod tls;
2222

2323
pub use self::files::FdTable;
24-
#[cfg(target_os = "linux")]
25-
pub use self::native_lib::trace::{init_sv, register_retcode_sv};
24+
//#[cfg(target_os = "linux")]
25+
//pub use self::native_lib::trace::{init_sv, register_retcode_sv};
2626
pub use self::unix::{DirTable, EpollInterestTable};
2727

2828
/// What needs to be done after emulating an item (a shim or an intrinsic) is done.

src/tools/miri/src/shims/native_lib/mod.rs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
//! Implements calling functions from a native library.
22
3-
#[cfg(target_os = "linux")]
4-
pub mod trace;
3+
// FIXME: disabled since it fails to build on many targets.
4+
//#[cfg(target_os = "linux")]
5+
//pub mod trace;
56

67
use std::ops::Deref;
78

@@ -12,13 +13,13 @@ use rustc_middle::mir::interpret::Pointer;
1213
use rustc_middle::ty::{self as ty, IntTy, UintTy};
1314
use rustc_span::Symbol;
1415

15-
#[cfg(target_os = "linux")]
16-
use self::trace::Supervisor;
16+
//#[cfg(target_os = "linux")]
17+
//use self::trace::Supervisor;
1718
use crate::*;
1819

19-
#[cfg(target_os = "linux")]
20-
type CallResult<'tcx> = InterpResult<'tcx, (ImmTy<'tcx>, Option<self::trace::messages::MemEvents>)>;
21-
#[cfg(not(target_os = "linux"))]
20+
//#[cfg(target_os = "linux")]
21+
//type CallResult<'tcx> = InterpResult<'tcx, (ImmTy<'tcx>, Option<self::trace::messages::MemEvents>)>;
22+
//#[cfg(not(target_os = "linux"))]
2223
type CallResult<'tcx> = InterpResult<'tcx, (ImmTy<'tcx>, Option<!>)>;
2324

2425
impl<'tcx> EvalContextExtPriv<'tcx> for crate::MiriInterpCx<'tcx> {}
@@ -32,12 +33,12 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
3233
libffi_args: Vec<libffi::high::Arg<'a>>,
3334
) -> CallResult<'tcx> {
3435
let this = self.eval_context_mut();
35-
#[cfg(target_os = "linux")]
36-
let alloc = this.machine.allocator.as_ref().unwrap();
36+
//#[cfg(target_os = "linux")]
37+
//let alloc = this.machine.allocator.as_ref().unwrap();
3738

3839
// SAFETY: We don't touch the machine memory past this point.
39-
#[cfg(target_os = "linux")]
40-
let (guard, stack_ptr) = unsafe { Supervisor::start_ffi(alloc) };
40+
//#[cfg(target_os = "linux")]
41+
//let (guard, stack_ptr) = unsafe { Supervisor::start_ffi(alloc) };
4142

4243
// Call the function (`ptr`) with arguments `libffi_args`, and obtain the return value
4344
// as the specified primitive integer type
@@ -111,9 +112,9 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
111112

112113
// SAFETY: We got the guard and stack pointer from start_ffi, and
113114
// the allocator is the same
114-
#[cfg(target_os = "linux")]
115-
let events = unsafe { Supervisor::end_ffi(alloc, guard, stack_ptr) };
116-
#[cfg(not(target_os = "linux"))]
115+
//#[cfg(target_os = "linux")]
116+
//let events = unsafe { Supervisor::end_ffi(alloc, guard, stack_ptr) };
117+
//#[cfg(not(target_os = "linux"))]
117118
let events = None;
118119

119120
interp_ok((res?, events))
@@ -213,9 +214,9 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
213214
if !this.machine.native_call_mem_warned.replace(true) {
214215
// Newly set, so first time we get here.
215216
this.emit_diagnostic(NonHaltingDiagnostic::NativeCallSharedMem {
216-
#[cfg(target_os = "linux")]
217-
tracing: self::trace::Supervisor::is_enabled(),
218-
#[cfg(not(target_os = "linux"))]
217+
//#[cfg(target_os = "linux")]
218+
//tracing: self::trace::Supervisor::is_enabled(),
219+
//#[cfg(not(target_os = "linux"))]
219220
tracing: false,
220221
});
221222
}

src/tools/miri/src/shims/native_lib/trace/parent.rs

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,11 @@ const ARCH_MAX_ACCESS_SIZE: usize = 64;
2020
/// The largest arm64 simd instruction operates on 16 bytes.
2121
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
2222
const ARCH_MAX_ACCESS_SIZE: usize = 16;
23-
/// The max riscv vector instruction can access 8 consecutive 32-bit values.
24-
#[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))]
25-
const ARCH_MAX_ACCESS_SIZE: usize = 32;
2623

2724
/// The default word size on a given platform, in bytes.
28-
#[cfg(any(target_arch = "x86", target_arch = "arm", target_arch = "riscv32"))]
25+
#[cfg(any(target_arch = "x86", target_arch = "arm"))]
2926
const ARCH_WORD_SIZE: usize = 4;
30-
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64", target_arch = "riscv64"))]
27+
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
3128
const ARCH_WORD_SIZE: usize = 8;
3229

3330
/// The address of the page set to be edited, initialised to a sentinel null
@@ -91,18 +88,6 @@ impl ArchIndependentRegs for libc::user_regs_struct {
9188
fn set_sp(&mut self, sp: usize) { self.sp = sp as _ }
9289
}
9390

94-
#[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))]
95-
#[expect(clippy::as_conversions)]
96-
#[rustfmt::skip]
97-
impl ArchIndependentRegs for libc::user_regs_struct {
98-
#[inline]
99-
fn ip(&self) -> usize { self.pc as _ }
100-
#[inline]
101-
fn set_ip(&mut self, ip: usize) { self.pc = ip as _ }
102-
#[inline]
103-
fn set_sp(&mut self, sp: usize) { self.sp = sp as _ }
104-
}
105-
10691
/// A unified event representing something happening on the child process. Wraps
10792
/// `nix`'s `WaitStatus` and our custom signals so it can all be done with one
10893
/// `match` statement.
@@ -341,10 +326,6 @@ fn get_disasm() -> capstone::Capstone {
341326
{cs_pre.arm64().mode(arch::arm64::ArchMode::Arm)}
342327
#[cfg(target_arch = "arm")]
343328
{cs_pre.arm().mode(arch::arm::ArchMode::Arm)}
344-
#[cfg(target_arch = "riscv64")]
345-
{cs_pre.riscv().mode(arch::riscv::ArchMode::RiscV64)}
346-
#[cfg(target_arch = "riscv32")]
347-
{cs_pre.riscv().mode(arch::riscv::ArchMode::RiscV32)}
348329
}
349330
.detail(true)
350331
.build()
@@ -501,18 +482,6 @@ fn handle_segfault(
501482
}
502483
_ => (),
503484
},
504-
#[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))]
505-
arch::ArchOperand::RiscVOperand(risc_voperand) => {
506-
match risc_voperand {
507-
arch::riscv::RiscVOperand::Mem(_) => {
508-
// We get basically no info here.
509-
let push = addr..addr.strict_add(size);
510-
acc_events.push(AccessEvent::Read(push.clone()));
511-
acc_events.push(AccessEvent::Write(push));
512-
}
513-
_ => (),
514-
}
515-
}
516485
_ => unimplemented!(),
517486
}
518487
}

0 commit comments

Comments
 (0)