bytecodealliance / wasmtime

A fast and secure runtime for WebAssembly
https://wasmtime.dev/
Apache License 2.0
14.82k stars 1.24k forks source link

Cranelift: jit: "region" "2.2.0" dependency doesn't compile on OpenBSD 7.5 #8895

Open FrankReh opened 6 days ago

FrankReh commented 6 days ago

region 2.2.0 is from four years ago. Don't know if it was intended to compile on OpenBSD back then but it doesn't today.

The most recent version is 3.0.2 and it does compile for OpenBSD 7.5. But some things about the API have changed and trying to call cargo test --release on wasmtime fails to compile:

   Compiling cranelift-jit v0.110.0 (/home/frank/forks/wasmtime/cranelift/jit)
error[E0308]: mismatched types
  --> cranelift/jit/src/memory.rs:39:45
   |
39 |         let alloc_size = region::page::ceil(size);
   |                          ------------------ ^^^^ expected `*const _`, found `usize`
   |                          |
   |                          arguments to this function are incorrect
   |
   = note: expected raw pointer `*const _`
                     found type `usize`
note: function defined here
  --> /home/frank/.cargo/registry/src/index.crates.io-6f17d22bba15001f/region-3.0.2/src/page.rs:54:8
   |
54 | pub fn ceil<T>(address: *const T) -> *const T {
   |        ^^^^

error[E0308]: mismatched types
   --> cranelift/jit/src/memory.rs:40:27
    |
40  |         MmapMut::map_anon(alloc_size).map(|mut mmap| {
    |         ----------------- ^^^^^^^^^^ expected `usize`, found `*const _`
    |         |
    |         arguments to this function are incorrect
    |
    = note:     expected type `usize`
            found raw pointer `*const _`
note: associated function defined here
   --> /home/frank/.cargo/registry/src/index.crates.io-6f17d22bba15001f/memmap2-0.2.3/src/lib.rs:658:12
    |
658 |     pub fn map_anon(length: usize) -> Result<MmapMut> {
    |            ^^^^^^^^

error[E0308]: mismatched types
  --> cranelift/jit/src/memory.rs:46:22
   |
46 |                 len: alloc_size,
   |                      ^^^^^^^^^^ expected `usize`, found `*const _`
   |
   = note:     expected type `usize`
           found raw pointer `*const _`
FrankReh commented 6 days ago

The change may be as simple as changing the type. Seems to be what occurred in the 02a1d481 commit to region.

FrankReh commented 5 days ago

This seems to make the compiler happy. Still working out other test issues on OpenBSD so am not sure.

-        let alloc_size = region::page::ceil(size);
+        let alloc_size = region::page::ceil(size as *const ()) as usize;