diff options
| author | Ralf Jung <post@ralfj.de> | 2024-06-21 09:40:30 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-06-21 09:40:30 +0200 |
| commit | 8a657f9ec4f565129fa543ffb0bd85ca58b98188 (patch) | |
| tree | f4cce11ac9d719d7ca223ef27772b596b3bb3887 /src | |
| parent | ac4f1c41292c5b5e72e42ebdff38cb04cf9f304d (diff) | |
| download | rust-8a657f9ec4f565129fa543ffb0bd85ca58b98188.tar.gz rust-8a657f9ec4f565129fa543ffb0bd85ca58b98188.zip | |
don't rely on libc existing on Windows
Diffstat (limited to 'src')
| -rw-r--r-- | src/tools/miri/src/helpers.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/tools/miri/src/helpers.rs b/src/tools/miri/src/helpers.rs index 843aff02495..6fa1c16fec5 100644 --- a/src/tools/miri/src/helpers.rs +++ b/src/tools/miri/src/helpers.rs @@ -273,6 +273,11 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { /// Helper function to get a `libc` constant as a `Scalar`. fn eval_libc(&self, name: &str) -> Scalar { + if self.eval_context_ref().tcx.sess.target.os == "windows" { + panic!( + "`libc` crate is not reliably available on Windows targets; Miri should not use it there" + ); + } self.eval_path_scalar(&["libc", name]) } @@ -316,6 +321,11 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { /// Helper function to get the `TyAndLayout` of a `libc` type fn libc_ty_layout(&self, name: &str) -> TyAndLayout<'tcx> { let this = self.eval_context_ref(); + if this.tcx.sess.target.os == "windows" { + panic!( + "`libc` crate is not reliably available on Windows targets; Miri should not use it there" + ); + } let ty = this .resolve_path(&["libc", name], Namespace::TypeNS) .ty(*this.tcx, ty::ParamEnv::reveal_all()); @@ -1048,7 +1058,12 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { /// Always returns a `Vec<u32>` no matter the size of `wchar_t`. fn read_wchar_t_str(&self, ptr: Pointer) -> InterpResult<'tcx, Vec<u32>> { let this = self.eval_context_ref(); - let wchar_t = this.libc_ty_layout("wchar_t"); + let wchar_t = if this.tcx.sess.target.os == "windows" { + // We don't have libc on Windows so we have to hard-code the type ourselves. + this.machine.layouts.u16 + } else { + this.libc_ty_layout("wchar_t") + }; self.read_c_str_with_char_size(ptr, wchar_t.size, wchar_t.align.abi) } |
