11//! Implements calling functions from a native library. 
22
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; 
65
76use  std:: ops:: Deref ; 
87
@@ -13,13 +12,13 @@ use rustc_middle::mir::interpret::Pointer;
1312use  rustc_middle:: ty:: { self  as  ty,  IntTy ,  UintTy } ; 
1413use  rustc_span:: Symbol ; 
1514
16- // #[cfg(target_os  = "linux ")]
17- // use self::trace::Supervisor;
15+ #[ cfg( feature  = "trace " ) ]  
16+ use  self :: trace:: Supervisor ; 
1817use  crate :: * ; 
1918
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 " ) ) ]  
2322type  CallResult < ' tcx >  = InterpResult < ' tcx ,  ( ImmTy < ' tcx > ,  Option < !> ) > ; 
2423
2524impl < ' tcx >  EvalContextExtPriv < ' tcx >  for  crate :: MiriInterpCx < ' tcx >  { } 
@@ -33,12 +32,12 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
3332        libffi_args :  Vec < libffi:: high:: Arg < ' a > > , 
3433    )  -> CallResult < ' tcx >  { 
3534        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 ( ) ; 
3837
3938        // 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)  } ; 
4241
4342        // Call the function (`ptr`) with arguments `libffi_args`, and obtain the return value 
4443        // as the specified primitive integer type 
@@ -112,9 +111,9 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
112111
113112        // SAFETY: We got the guard and stack pointer from start_ffi, and 
114113        // 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 " ) ) ]  
118117        let  events = None ; 
119118
120119        interp_ok ( ( res?,  events) ) 
@@ -214,9 +213,9 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
214213                if  !this. machine . native_call_mem_warned . replace ( true )  { 
215214                    // Newly set, so first time we get here. 
216215                    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 " ) ) ]  
220219                        tracing :  false , 
221220                    } ) ; 
222221                } 
0 commit comments