@@ -273,6 +273,11 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
273
273
274
274
/// Helper function to get a `libc` constant as a `Scalar`.
275
275
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
+ }
276
281
self . eval_path_scalar ( & [ "libc" , name] )
277
282
}
278
283
@@ -316,6 +321,11 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
316
321
/// Helper function to get the `TyAndLayout` of a `libc` type
317
322
fn libc_ty_layout ( & self , name : & str ) -> TyAndLayout < ' tcx > {
318
323
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
+ }
319
329
let ty = this
320
330
. resolve_path ( & [ "libc" , name] , Namespace :: TypeNS )
321
331
. ty ( * this. tcx , ty:: ParamEnv :: reveal_all ( ) ) ;
@@ -1048,7 +1058,12 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
1048
1058
/// Always returns a `Vec<u32>` no matter the size of `wchar_t`.
1049
1059
fn read_wchar_t_str ( & self , ptr : Pointer ) -> InterpResult < ' tcx , Vec < u32 > > {
1050
1060
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
+ } ;
1052
1067
self . read_c_str_with_char_size ( ptr, wchar_t. size , wchar_t. align . abi )
1053
1068
}
1054
1069
0 commit comments