bytecodealliance / wasmtime

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

wasmtime 2.0 doesn't build on Windows #5133

Closed CryZe closed 2 years ago

CryZe commented 2 years ago

Expected Results

I expected it to build.

Actual Results

error[E0432]: unresolved import `windows_sys::Win32::Foundation`
  --> C:\Users\Christopher Serr\.cargo\registry\src\github.com-1ecc6299db9ec823\wasmtime-runtime-2.0.0\src\mmap.rs:90:37
   |
90 |             use windows_sys::Win32::Foundation::*;
   |                                     ^^^^^^^^^^ could not find `Foundation` in `Win32`

error[E0432]: unresolved import `windows_sys::Win32::Foundation`
 --> C:\Users\Christopher Serr\.cargo\registry\src\github.com-1ecc6299db9ec823\wasmtime-runtime-2.0.0\src\traphandlers\windows.rs:3:25
  |
3 | use windows_sys::Win32::Foundation::*;
  |                         ^^^^^^^^^^ could not find `Foundation` in `Win32`

error[E0425]: cannot find function, tuple struct or tuple variant `CreateFileMappingW` in this scope
   --> C:\Users\Christopher Serr\.cargo\registry\src\github.com-1ecc6299db9ec823\wasmtime-runtime-2.0.0\src\mmap.rs:114:31
    |
114 |                 let mapping = CreateFileMappingW(
    |                               ^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `MapViewOfFile` in this scope
   --> C:\Users\Christopher Serr\.cargo\registry\src\github.com-1ecc6299db9ec823\wasmtime-runtime-2.0.0\src\mmap.rs:129:27
    |
129 |                 let ptr = MapViewOfFile(mapping, FILE_MAP_READ | FILE_MAP_EXECUTE, 0, 0, len);
    |                           ^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `CloseHandle` in this scope
   --> C:\Users\Christopher Serr\.cargo\registry\src\github.com-1ecc6299db9ec823\wasmtime-runtime-2.0.0\src\mmap.rs:131:17
    |
131 |                 CloseHandle(mapping);
    |                 ^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `VirtualProtect` in this scope
   --> C:\Users\Christopher Serr\.cargo\registry\src\github.com-1ecc6299db9ec823\wasmtime-runtime-2.0.0\src\mmap.rs:146:20
    |
146 |                 if VirtualProtect(ret.ptr as *mut _, ret.len, PAGE_READONLY, &mut old) == 0 {
    |                    ^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `VirtualProtect` in this scope
   --> C:\Users\Christopher Serr\.cargo\registry\src\github.com-1ecc6299db9ec823\wasmtime-runtime-2.0.0\src\mmap.rs:396:17
    |
396 |                 VirtualProtect(base, len, PAGE_WRITECOPY, &mut old)
    |                 ^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `VirtualProtect` in this scope
   --> C:\Users\Christopher Serr\.cargo\registry\src\github.com-1ecc6299db9ec823\wasmtime-runtime-2.0.0\src\mmap.rs:398:17
    |
398 |                 VirtualProtect(base, len, PAGE_READWRITE, &mut old)
    |                 ^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `VirtualProtect` in this scope
   --> C:\Users\Christopher Serr\.cargo\registry\src\github.com-1ecc6299db9ec823\wasmtime-runtime-2.0.0\src\mmap.rs:443:26
    |
443 |             let result = VirtualProtect(base, len, flags, &mut old);
    |                          ^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `VirtualFree` in this scope
   --> C:\Users\Christopher Serr\.cargo\registry\src\github.com-1ecc6299db9ec823\wasmtime-runtime-2.0.0\src\mmap.rs:496:34
    |
496 |                 let r = unsafe { VirtualFree(self.ptr as *mut c_void, 0, MEM_RELEASE) };
    |                                  ^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `UnmapViewOfFile` in this scope
   --> C:\Users\Christopher Serr\.cargo\registry\src\github.com-1ecc6299db9ec823\wasmtime-runtime-2.0.0\src\mmap.rs:499:34
    |
499 |                 let r = unsafe { UnmapViewOfFile(self.ptr as *mut c_void) };
    |                                  ^^^^^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type `EXCEPTION_POINTERS` in this scope
 --> C:\Users\Christopher Serr\.cargo\registry\src\github.com-1ecc6299db9ec823\wasmtime-runtime-2.0.0\src\traphandlers\windows.rs:8:42
  |
8 | pub type SignalHandler<'a> = dyn Fn(*mut EXCEPTION_POINTERS) -> bool + Send + Sync + 'a;
  |                                          ^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `AddVectoredExceptionHandler` in this scope
   --> C:\Users\Christopher Serr\.cargo\registry\src\github.com-1ecc6299db9ec823\wasmtime-runtime-2.0.0\src\traphandlers\windows.rs:14:8    |
14  |     if AddVectoredExceptionHandler(1, Some(exception_handler)).is_null() {
    |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `RemoveVectoredExceptionHandler`
    |
   ::: C:\Users\Christopher Serr\.cargo\registry\src\github.com-1ecc6299db9ec823\windows-sys-0.36.1\src\Windows\Win32\System\Diagnostics\Debug\mod.rs:305:5
    |
305 |     pub fn RemoveVectoredExceptionHandler(handle: *const ::core::ffi::c_void) -> u32;
    |     -------------------------------------------------------------------------------- similarly named function `RemoveVectoredExceptionHandler` defined here

error[E0412]: cannot find type `EXCEPTION_POINTERS` in this scope
  --> C:\Users\Christopher Serr\.cargo\registry\src\github.com-1ecc6299db9ec823\wasmtime-runtime-2.0.0\src\traphandlers\windows.rs:22:66   |
22 | unsafe extern "system" fn exception_handler(exception_info: *mut EXCEPTION_POINTERS) -> i32 {
   |                                                                  ^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value `EXCEPTION_ACCESS_VIOLATION` in this scope
  --> C:\Users\Christopher Serr\.cargo\registry\src\github.com-1ecc6299db9ec823\wasmtime-runtime-2.0.0\src\traphandlers\windows.rs:27:32   |
27 |     if record.ExceptionCode != EXCEPTION_ACCESS_VIOLATION
   |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value `EXCEPTION_ILLEGAL_INSTRUCTION` in this scope
  --> C:\Users\Christopher Serr\.cargo\registry\src\github.com-1ecc6299db9ec823\wasmtime-runtime-2.0.0\src\traphandlers\windows.rs:28:36   |
28 |         && record.ExceptionCode != EXCEPTION_ILLEGAL_INSTRUCTION
   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value `EXCEPTION_INT_DIVIDE_BY_ZERO` in this scope
  --> C:\Users\Christopher Serr\.cargo\registry\src\github.com-1ecc6299db9ec823\wasmtime-runtime-2.0.0\src\traphandlers\windows.rs:29:36   |
29 |         && record.ExceptionCode != EXCEPTION_INT_DIVIDE_BY_ZERO
   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value `EXCEPTION_INT_OVERFLOW` in this scope
  --> C:\Users\Christopher Serr\.cargo\registry\src\github.com-1ecc6299db9ec823\wasmtime-runtime-2.0.0\src\traphandlers\windows.rs:30:36   |
30 |         && record.ExceptionCode != EXCEPTION_INT_OVERFLOW
   |                                    ^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

Versions and Environment

Wasmtime version or commit: wasmtime-runtime-2.0.0

Operating system: Windows 10

Architecture: x86_64

Extra Info

Anything else you'd like to add?

Pretty sure this is related to the upgrade of the windows-sys crate. A necessary feature might not be active.

No idea how to interpret cargo tree but it gave me this:

$ cargo tree -i windows-sys -e features
windows-sys v0.36.1
├── windows-sys feature "Win32"
│   ├── windows-sys feature "Win32_Security"
│   │   └── wasmtime-runtime v2.0.0
│   │       └── wasmtime-runtime feature "default"
│   │           ├── wasmtime v2.0.0
│   │           │   ├── wasmtime feature "cranelift"
│   │           │   │   └── livesplit-auto-splitting v0.1.0 (https://github.com/LiveSplit/livesplit-core#2298fc2a)
│   │           │   │       └── livesplit-auto-splitting feature "default"
│   │           │   │           └── asr-capi v0.1.0 (C:\Projekte\LiveSplit.AutoSplittingRuntime\asr-capi)
│   │           │   │               └── asr-capi feature "default" (command-line)
│   │           │   └── wasmtime feature "parallel-compilation"
│   │           │       └── livesplit-auto-splitting v0.1.0 (https://github.com/LiveSplit/livesplit-core#2298fc2a) (*)
│   │           └── wasmtime-jit v2.0.0
│   │               └── wasmtime-jit feature "default"
│   │                   └── wasmtime v2.0.0 (*)
│   ├── windows-sys feature "Win32_Storage"
│   │   └── windows-sys feature "Win32_Storage_FileSystem"
│   │       └── wasmtime-runtime v2.0.0 (*)
│   └── windows-sys feature "Win32_System"
│       ├── windows-sys feature "Win32_System_Diagnostics"
│       │   └── windows-sys feature "Win32_System_Diagnostics_Debug"
│       │       ├── wasmtime v2.0.0 (*)
│       │       ├── wasmtime-jit v2.0.0 (*)
│       │       └── wasmtime-runtime v2.0.0 (*)
│       ├── windows-sys feature "Win32_System_Kernel"
│       │   └── wasmtime-runtime v2.0.0 (*)
│       ├── windows-sys feature "Win32_System_Memory"
│       │   └── wasmtime-runtime v2.0.0 (*)
│       └── windows-sys feature "Win32_System_SystemInformation"
│           └── wasmtime-runtime v2.0.0 (*)
├── windows-sys feature "Win32_Security" (*)
├── windows-sys feature "Win32_Storage" (*)
├── windows-sys feature "Win32_Storage_FileSystem" (*)
├── windows-sys feature "Win32_System" (*)
├── windows-sys feature "Win32_System_Diagnostics" (*)
├── windows-sys feature "Win32_System_Diagnostics_Debug" (*)
├── windows-sys feature "Win32_System_Kernel" (*)
├── windows-sys feature "Win32_System_Memory" (*)
├── windows-sys feature "Win32_System_SystemInformation" (*)
└── windows-sys feature "default"
    ├── wasmtime v2.0.0 (*)
    ├── wasmtime-jit v2.0.0 (*)
    └── wasmtime-runtime v2.0.0 (*)
alexcrichton commented 2 years ago

Thanks for the report! As your PR indicates looks like this never worked and isn't related to the upgrade itself, we instead don't have tests on CI for more minimal builds on Windows than whole-repo tests, and other crates in this workspace enable the necessary feature.

I'll look into backporting this to 2.0.0 and get 2.0.1 out with a fix.

CryZe commented 2 years ago

Thank you so much! :)