1
1
//! Implements calling functions from a native library.
2
2
3
- // FIXME: disabled since it fails to build on many targets.
4
- //#[cfg(target_os = "linux")]
5
- //pub mod trace;
3
+ #[ cfg( feature = "trace" ) ]
4
+ pub mod trace;
6
5
7
6
use std:: ops:: Deref ;
8
7
@@ -13,13 +12,13 @@ use rustc_middle::mir::interpret::Pointer;
13
12
use rustc_middle:: ty:: { self as ty, IntTy , UintTy } ;
14
13
use rustc_span:: Symbol ;
15
14
16
- // #[cfg(target_os = "linux ")]
17
- // use self::trace::Supervisor;
15
+ #[ cfg( feature = "trace " ) ]
16
+ use self :: trace:: Supervisor ;
18
17
use crate :: * ;
19
18
20
- // #[cfg(target_os = "linux ")]
21
- // type CallResult<'tcx> = InterpResult<'tcx, (ImmTy<'tcx>, Option<self::trace::messages::MemEvents>)>;
22
- // #[cfg(not(target_os = "linux "))]
19
+ #[ cfg( feature = "trace " ) ]
20
+ type CallResult < ' tcx > = InterpResult < ' tcx , ( ImmTy < ' tcx > , Option < self :: trace:: messages:: MemEvents > ) > ;
21
+ #[ cfg( not( feature = "trace " ) ) ]
23
22
type CallResult < ' tcx > = InterpResult < ' tcx , ( ImmTy < ' tcx > , Option < !> ) > ;
24
23
25
24
impl < ' tcx > EvalContextExtPriv < ' tcx > for crate :: MiriInterpCx < ' tcx > { }
@@ -33,12 +32,12 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
33
32
libffi_args : Vec < libffi:: high:: Arg < ' a > > ,
34
33
) -> CallResult < ' tcx > {
35
34
let this = self . eval_context_mut ( ) ;
36
- // #[cfg(target_os = "linux ")]
37
- // let alloc = this.machine.allocator.as_ref().unwrap();
35
+ #[ cfg( feature = "trace " ) ]
36
+ let alloc = this. machine . allocator . as_ref ( ) . unwrap ( ) ;
38
37
39
38
// SAFETY: We don't touch the machine memory past this point.
40
- // #[cfg(target_os = "linux ")]
41
- // let (guard, stack_ptr) = unsafe { Supervisor::start_ffi(alloc) };
39
+ #[ cfg( feature = "trace " ) ]
40
+ let ( guard, stack_ptr) = unsafe { Supervisor :: start_ffi ( alloc) } ;
42
41
43
42
// Call the function (`ptr`) with arguments `libffi_args`, and obtain the return value
44
43
// as the specified primitive integer type
@@ -112,9 +111,9 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
112
111
113
112
// SAFETY: We got the guard and stack pointer from start_ffi, and
114
113
// the allocator is the same
115
- // #[cfg(target_os = "linux ")]
116
- // let events = unsafe { Supervisor::end_ffi(alloc, guard, stack_ptr) };
117
- // #[cfg(not(target_os = "linux "))]
114
+ #[ cfg( feature = "trace " ) ]
115
+ let events = unsafe { Supervisor :: end_ffi ( alloc, guard, stack_ptr) } ;
116
+ #[ cfg( not( feature = "trace " ) ) ]
118
117
let events = None ;
119
118
120
119
interp_ok ( ( res?, events) )
@@ -214,9 +213,9 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
214
213
if !this. machine . native_call_mem_warned . replace ( true ) {
215
214
// Newly set, so first time we get here.
216
215
this. emit_diagnostic ( NonHaltingDiagnostic :: NativeCallSharedMem {
217
- // #[cfg(target_os = "linux ")]
218
- // tracing: self::trace::Supervisor::is_enabled(),
219
- // #[cfg(not(target_os = "linux "))]
216
+ #[ cfg( feature = "trace " ) ]
217
+ tracing : self :: trace:: Supervisor :: is_enabled ( ) ,
218
+ #[ cfg( not( feature = "trace " ) ) ]
220
219
tracing : false ,
221
220
} ) ;
222
221
}
0 commit comments