@@ -273,6 +273,11 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
273273
274274 /// Helper function to get a `libc` constant as a `Scalar`.
275275 fn eval_libc ( & self , name : & str ) -> Scalar {
276+ if self . eval_context_ref ( ) . tcx . sess . target . os == "windows" {
277+ panic ! (
278+ "`libc` crate is not reliably available on Windows targets; Miri should not use it there"
279+ ) ;
280+ }
276281 self . eval_path_scalar ( & [ "libc" , name] )
277282 }
278283
@@ -316,6 +321,11 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
316321 /// Helper function to get the `TyAndLayout` of a `libc` type
317322 fn libc_ty_layout ( & self , name : & str ) -> TyAndLayout < ' tcx > {
318323 let this = self . eval_context_ref ( ) ;
324+ if this. tcx . sess . target . os == "windows" {
325+ panic ! (
326+ "`libc` crate is not reliably available on Windows targets; Miri should not use it there"
327+ ) ;
328+ }
319329 let ty = this
320330 . resolve_path ( & [ "libc" , name] , Namespace :: TypeNS )
321331 . ty ( * this. tcx , ty:: ParamEnv :: reveal_all ( ) ) ;
@@ -1048,7 +1058,12 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
10481058 /// Always returns a `Vec<u32>` no matter the size of `wchar_t`.
10491059 fn read_wchar_t_str ( & self , ptr : Pointer ) -> InterpResult < ' tcx , Vec < u32 > > {
10501060 let this = self . eval_context_ref ( ) ;
1051- let wchar_t = this. libc_ty_layout ( "wchar_t" ) ;
1061+ let wchar_t = if this. tcx . sess . target . os == "windows" {
1062+ // We don't have libc on Windows so we have to hard-code the type ourselves.
1063+ this. machine . layouts . u16
1064+ } else {
1065+ this. libc_ty_layout ( "wchar_t" )
1066+ } ;
10521067 self . read_c_str_with_char_size ( ptr, wchar_t. size , wchar_t. align . abi )
10531068 }
10541069
0 commit comments