Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows support #977

Closed
FireFlyForLife opened this issue Apr 22, 2020 · 20 comments
Closed

Windows support #977

FireFlyForLife opened this issue Apr 22, 2020 · 20 comments
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. O-windows Operating system: Windows

Comments

@FireFlyForLife
Copy link

I believe cranelift is cross-platform. At least on windows.

However I only found Bash scripts for building with cargo for example. Is this a limitation, or am I missing something?

If a port from Bash to Batch (or something else like python) is needed I am of course happy to help!

@bjorn3 bjorn3 added C-enhancement Category: An issue proposing an enhancement or a PR with one. O-windows Operating system: Windows labels Apr 22, 2020
@bjorn3
Copy link
Member

bjorn3 commented Apr 22, 2020

I have been focusing on Linux and macOS. There are several places where Windows support is missing:

  • Abi::System: This is equivalent to Abi::C on x86_64 I think, but I am not sure.
  • .rlib: The rust-ar crate only supports BSD and Gnu style ar archives. I believe Windows uses a slightly different format.
  • The bash scripts, as you already noticed. (only config.sh, prepare.sh, test.sh and cargo.sh need to be ported. rustup.sh is just for me to switch to a new rustc version more easily. I haven't used flamegraph.sh in ages.)
  • Probably other things.

I did some experimentation on the windows_support branch, but it currently fails as I used bash to run the scripts and bash turns C:\ into /c/, which rustc doesn't recognize. As I don't use Windows, I have to wait for CI every time I try to fix something.

I don't think I will add Windows support soon, but PR's are of course welcome.

@bjorn3
Copy link
Member

bjorn3 commented May 26, 2020

I got working support for cross compilation from Linux to MinGW on the wip_windows_support branch. For reference: see the comment thread starting at bytecodealliance/wasmtime#1510 (comment).

@bjorn3
Copy link
Member

bjorn3 commented May 26, 2020

The branch depends on bytecodealliance/wasmtime#1670 and an update to object 0.19.0.

@FireFlyForLife
Copy link
Author

Wow amazing work, I will check this out soon!

@bjorn3
Copy link
Member

bjorn3 commented May 27, 2020

The branch now also depends on bytecodealliance/wasmtime#1767 for the object 0.19.0 update. (You need to merge both PR's into one branch)

@bjorn3
Copy link
Member

bjorn3 commented Jun 16, 2020

Updated the wip_windows_support branch for the latest Cranelift, which includes both bytecodealliance/wasmtime#1670 as well as bytecodealliance/wasmtime#1767.

bjorn3 added a commit that referenced this issue Jun 16, 2020
@bjorn3
Copy link
Member

bjorn3 commented Jun 16, 2020

Patches in wip_windows_support:

@bjorn3
Copy link
Member

bjorn3 commented Jan 31, 2021

9384af4 makes the examples link on windows. 9c943bf and 9164653 together add support for building the sysroot for windows. The examples and sysroot will still fail to build for windows though until the above todo list is fixed. a77ee9e is a workaround for these things when using the old x86 cranelift backend, but I won't merge that commit as it negatively affects other platforms too.

@bjorn3
Copy link
Member

bjorn3 commented Feb 21, 2021

9c98027 reduced the amount of used 128bit int intrinsics.

@bjorn3

This comment has been minimized.

@bjorn3
Copy link
Member

bjorn3 commented May 1, 2021

Dwarf debuginfo generation will need to be disabled for MSVC:

error: linking with `link.exe` failed: exit code: 1165
  |
  = note: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.28.29333\\bin\\HostX64\\x64\\link.exe" [...]
  = note: build_script_build-de97622aa2c42411.build_script_build.42ir3bpd-cgu.9.rcgu.o : error LNK2017: 'ADDR32' relocation to '.debug_abbrev' invalid without /LARGEADDRESSAWARE:NO
          build_script_build-de97622aa2c42411.build_script_build.42ir3bpd-cgu.9.rcgu.o : error LNK2017: 'ADDR32' relocation to '.debug_str' invalid without /LARGEADDRESSAWARE:NO
          build_script_build-de97622aa2c42411.build_script_build.42ir3bpd-cgu.9.rcgu.o : error LNK2017: 'ADDR32' relocation to '.debug_str' invalid without /LARGEADDRESSAWARE:NO
          build_script_build-de97622aa2c42411.build_script_build.42ir3bpd-cgu.9.rcgu.o : error LNK2017: 'ADDR32' relocation to '.debug_str' invalid without /LARGEADDRESSAWARE:NO
          build_script_build-de97622aa2c42411.build_script_build.42ir3bpd-cgu.9.rcgu.o : error LNK2017: 'ADDR32' relocation to '.debug_ranges' invalid without /LARGEADDRESSAWARE:NO
[...]

@Blues-star
Copy link

Blues-star commented Jun 4, 2021

Now, Could it be used on windows? either GNU or MSVC toolchain is fine if it can work, I try to build it on Win10 but failed.

$ rustup default nightly-x86_64-pc-windows-gnu
info: using existing install for 'nightly-x86_64-pc-windows-gnu'
info: default toolchain set to 'nightly-x86_64-pc-windows-gnu'

  nightly-x86_64-pc-windows-gnu unchanged - rustc 1.54.0-nightly (fe72845f7 2021-05-16)

info: note that the toolchain 'nightly-2021-05-26-x86_64-pc-windows-gnu' is currently in use (overridden by 'G:\Git-repo\rustc_codegen_cranelift\rust-toolchain')

$ cargo build --release
   Compiling rustc_codegen_cranelift v0.1.0 (G:\Git-repo\rustc_codegen_cranelift)
warning: associated function is never used: `relocate_for_jit`
  --> src\debuginfo\emit.rs:71:19
   |
71 |     pub(super) fn relocate_for_jit(mut self, jit_module: &cranelift_jit::JITModule) -> Vec<u8> {
   |                   ^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default

error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1

  = note: G:\Git-repo\rustc_codegen_cranelift\target\release\deps\rustc_codegen_cranelift.10pdpqne00tf2gqr.rcgu.o:10pdpqne00tf2gqr:(.text+0x982): undefined reference to `_Unwind_Resume'
          G:\Git-repo\rustc_codegen_cranelift\target\release\deps\rustc_codegen_cranelift.11gqdvl8vhcuv9se.rcgu.o:11gqdvl8vhcuv9se:(.text+0x467): undefined reference to `_Unwind_Resume'
          G:\Git-repo\rustc_codegen_cranelift\target\release\deps\rustc_codegen_cranelift.11gqdvl8vhcuv9se.rcgu.o:11gqdvl8vhcuv9se:(.text+0x8eb): undefined reference to `_Unwind_Resume'
          G:\Git-repo\rustc_codegen_cranelift\target\release\deps\rustc_codegen_cranelift.136c1t4zvxe9wtqm.rcgu.o:136c1t4zvxe9wtqm:(.text+0x46d): undefined reference to `_Unwind_Resume'
          G:\Git-repo\rustc_codegen_cranelift\target\release\deps\rustc_codegen_cranelift.13e4gfb0bi3c1hb3.rcgu.o:13e4gfb0bi3c1hb3:(.text+0xb9e): undefined reference to `_Unwind_Resume'
          G:\Git-repo\rustc_codegen_cranelift\target\release\deps\rustc_codegen_cranelift.13irbfn73kf9gsap.rcgu.o:13irbfn73kf9gsap:(.text+0x163): more undefined references to `_Unwind_Resume' follow
          collect2.exe: error: ld returned 1 exit status


error: aborting due to previous error; 1 warning emitted

error: could not compile `rustc_codegen_cranelift`

To learn more, run the command again with --verbose.

@bjorn3
Copy link
Member

bjorn3 commented Jun 4, 2021

Building using both the MSVC and GNU toolchain should work fine. When compiling your own code for MSVC with cg_clif it will likely crash due to something not yet being implemented. With the GNU toolchain everything should work. Compiling code for the GNU toolchain using cg_clif is tested on CI. Compiling cg_clif itself for the MSVC toolchain worked fine in rust-lang/rust#81746. I am not sure why it gives undefined reference to `_Unwind_Resume' for you. That symbol is part of the exception unwinding mechanism that is used by gcc and rustc, so it should be defined.

@Blues-star
Copy link

I solved the trouble above, but when I want to translate the build.sh to buld.ps1, I found build.sh disallow building on windows

if [[ "$unamestr" == 'Linux' || "$unamestr" == "FreeBSD" ]]; then
   export RUSTFLAGS='-Clink-arg=-Wl,-rpath=$ORIGIN/../lib '$RUSTFLAGS
elif [[ "$unamestr" == 'Darwin' ]]; then
   export RUSTFLAGS='-Csplit-debuginfo=unpacked -Clink-arg=-Wl,-rpath,@loader_path/../lib -Zosx-rpath-install-name '$RUSTFLAGS
   dylib_ext='dylib'
else
   echo "Unsupported os $unamestr"
   exit 1

Does it mean I can not build it on windows ? and how to use cg_clif on windows?

@bjorn3
Copy link
Member

bjorn3 commented Jun 5, 2021

The build system doesn't have support for Windows yet. The main changes required to work on windows are likely to change ln target/$CHANNEL/*rustc_codegen_cranelift* "$target_dir"/lib to have "$target_dir"/bin as target instead of "$target_dir"/lib and have an empty case for windows in the if statement you mentioned. Windows doesn't support rpaths, so the dll needs to be next to the binaries.

@afonso360
Copy link
Contributor

An update on the x86_64-windows-pc-msvc target:

We've introduced TLS support for the COFF file format in cranelift (bytecodealliance/wasmtime#4546).

The test.sh file was also moved into y.rs so that we can run windows tests.

Here's an update on the current status of the testsuite on MSVC (only showing failed tests):

no_sysroot


build.mini_core

Fails with: "unresolved external symbol printf"
H:C:\\Users\\Afonso\\CLionProjects\\rustc_codegen_cranelift\\build\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "msvcrt.lib" "/NXCOMPAT" "/LIBPATH:C:\\Users\\Afonso\\CLionProjects\\rustc_codegen_cranel
ift\\build\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "/OUT:C:\\Users\\Afonso\\CLionProjects\\rustc_codegen_cranelift\\target\\out\\mini_core.dll" "/OPT:REF,NOICF" "/DLL" "/IMPLIB:C:\\Users\\Afonso\\
CLionProjects\\rustc_codegen_cranelift\\target\\out\\mini_core.dll.lib" "/DEBUG"
  = note:    Creating library C:\Users\Afonso\CLionProjects\rustc_codegen_cranelift\target\out\mini_core.dll.lib and object C:\Users\Afonso\CLionProjects\rustc_codegen_cranelift\target\out\mini_core.d
ll.exp
          mini_core.mini_core.c16326b1-cgu.0.rcgu.o : error LNK2001: unresolved external symbol printf
          C:\Users\Afonso\CLionProjects\rustc_codegen_cranelift\target\out\mini_core.dll : fatal error LNK1120: 1 unresolved externals

If I comment out printf usages it passes!

build.example

Passes as long as we build mini_core (i.e. disable printf).

jit.mini_core_hello_world

Need to disable a printf call to run.

Fails with: "can't resolve symbol _ZN9mini_core8A_STATIC17hac12203af6ca6b91E"
thread 'rustc' panicked at 'can't resolve symbol _ZN9mini_core8A_STATIC17hac12203af6ca6b91E', C:\Users\Afonso\CLionProjects\wasmtime\cranelift\jit\src\backend.rs:312:21
stack backtrace:
   0:     0x7fffae9e9c5f - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h22e7b784ac716ba6
   1:     0x7fffaea255ba - core::fmt::write::h710985228ff64dc4
   2:     0x7fffae9dcada - <std::io::IoSliceMut as core::fmt::Debug>::fmt::h7a965e27de439674
   3:     0x7fffae9ed65b - std::panicking::default_hook::h59e772df96aabd4c
   4:     0x7fffae9ed287 - std::panicking::default_hook::h59e772df96aabd4c
   5:     0x7fff82a76b81 - <rustc_session[9ee3cdee11a5ff9c]::options::WasiExecModel as rustc_session[9ee3cdee11a5ff9c]::config::dep_tracking::DepTrackingHash>::hash
   6:     0x7fffae9ee03c - std::panicking::rust_panic_with_hook::h38636381814ab6ea
   7:     0x7fffae9eddbd - <std::panicking::begin_panic_handler::StrPanicPayload as core::panic::BoxMeUp>::get::haeca514280bcf18e
   8:     0x7fffae9ea957 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h22e7b784ac716ba6
   9:     0x7fffae9eda90 - rust_begin_unwind
  10:     0x7fffaea5b485 - core::panicking::panic_fmt::h30a9aaedd2e91939
  11:     0x7fffae43bca3 - cranelift_jit::backend::JITModule::get_address::h79eaafe65aed6ccd
  12:     0x7fffae440b7a - cranelift_jit::compiled_blob::CompiledBlob::perform_relocations::h2d3dd9b12c37a6cc
  13:     0x7fffae43c59d - cranelift_jit::backend::JITModule::finalize_definitions::h1bad446e1d195205
  14:     0x7fffae41d692 - rustc_codegen_cranelift::driver::jit::run_jit::h8585bd81e007a5e3
  15:     0x7fffae363b8f - <rustc_codegen_cranelift::CraneliftCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate::h0da6af42230e73fb
  16:     0x7fff804b18a0 - rustc_interface[6c72882eac342bcd]::passes::analysis
  17:     0x7fff804a3ce3 - <rustc_interface[6c72882eac342bcd]::passes::LintStoreExpandImpl as rustc_expand[6695f8eb6e16e84d]::base::LintStoreExpand>::pre_expansion_lint
  18:     0x7fff80490a5c - <rustc_interface[6c72882eac342bcd]::queries::Queries>::ongoing_codegen
  19:     0x7fff80447030 - <unknown>
  20:     0x7fff8047e937 - rustc_driver[197bfed8d57a407b]::args::arg_expand_all
  21:     0x7fff80467cf9 - <unknown>
  22:     0x7fff804687fd - <rustc_middle[d6f72711bda4db03]::ty::SymbolName as core[9a2c4b0c2bb38f26]::fmt::Display>::fmt
  23:     0x7fffae9ff15c - std::sys::windows::thread::Thread::new::hec2508d69eebdd0a
  24:     0x7ff832ac7034 - BaseThreadInitThunk
  25:     0x7ff833722651 - RtlUserThreadStart

error: internal compiler error: unexpected panic

aot.mini_core_hello_world

LNK1181: cannot open input file 'pthread.lib
error: linking with `link.exe` failed: exit code: 1181
  |
  = note: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "C:\\Users\\Afonso\\AppData\\Local\\Temp\\rustckiFHhD
\\symbols.o" "C:\\Users\\Afonso\\CLionProjects\\rustc_codegen_cranelift\\target\\out\\mini_core_hello_world.mini_core_hello_world.65fa8a3a-cgu.0.rcgu.o" "C:\\Users\\Afonso\\CLionProjects\\rustc_codege
n_cranelift\\target\\out\\mini_core_hello_world.mini_core_hello_world.65fa8a3a-cgu.1.rcgu.o" "C:\\Users\\Afonso\\CLionProjects\\rustc_codegen_cranelift\\target\\out\\mini_core_hello_world.mini_core_he
llo_world.65fa8a3a-cgu.2.rcgu.o" "/LIBPATH:C:\\Users\\Afonso\\CLionProjects\\rustc_codegen_cranelift\\target\\out" "/LIBPATH:C:\\Users\\Afonso\\CLionProjects\\rustc_codegen_cranelift\\build\\lib\\rust
lib\\x86_64-pc-windows-msvc\\lib" "pthread.lib" "C:\\Users\\Afonso\\CLionProjects\\rustc_codegen_cranelift\\target\\out\\libmini_core.rlib" "msvcrt.lib" "/NXCOMPAT" "/LIBPATH:C:\\Users\\Afonso\\CLionP
rojects\\rustc_codegen_cranelift\\build\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "/OUT:C:\\Users\\Afonso\\CLionProjects\\rustc_codegen_cranelift\\target\\out\\mini_core_hello_world.exe" "/OPT:REF,N
OICF" "/DEBUG"
  = note: LINK : fatal error LNK1181: cannot open input file 'pthread.lib'

Commenting out pthread usages makes this test pass!

base_sysroot


jit.std_example

thread 'rustc' panicked at 'can't resolve symbol _ZN42_$LT$$u21$$u20$as$u20$core..fmt..Debug$GT$3fmt17h1451c1c2a910bac2E'
thread 'rustc' panicked at 'can't resolve symbol _ZN42_$LT$$u21$$u20$as$u20$core..fmt..Debug$GT$3fmt17h1451c1c2a910bac2E', C:\Users\Afonso\CLionProjects\wasmtime\cranelift\jit\src\backend.rs:312:21
stack backtrace:
   0:     0x7fffae9e9c5f - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h22e7b784ac716ba6
   1:     0x7fffaea255ba - core::fmt::write::h710985228ff64dc4
   2:     0x7fffae9dcada - <std::io::IoSliceMut as core::fmt::Debug>::fmt::h7a965e27de439674
   3:     0x7fffae9ed65b - std::panicking::default_hook::h59e772df96aabd4c
   4:     0x7fffae9ed287 - std::panicking::default_hook::h59e772df96aabd4c
   5:     0x7fff82a76b81 - <rustc_session[9ee3cdee11a5ff9c]::options::WasiExecModel as rustc_session[9ee3cdee11a5ff9c]::config::dep_tracking::DepTrackingHash>::hash
   6:     0x7fffae9ee03c - std::panicking::rust_panic_with_hook::h38636381814ab6ea
   7:     0x7fffae9eddbd - <std::panicking::begin_panic_handler::StrPanicPayload as core::panic::BoxMeUp>::get::haeca514280bcf18e
   8:     0x7fffae9ea957 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h22e7b784ac716ba6
   9:     0x7fffae9eda90 - rust_begin_unwind
  10:     0x7fffaea5b485 - core::panicking::panic_fmt::h30a9aaedd2e91939
  11:     0x7fffae43bca3 - cranelift_jit::backend::JITModule::get_address::h79eaafe65aed6ccd
  12:     0x7fffae440b7a - cranelift_jit::compiled_blob::CompiledBlob::perform_relocations::h2d3dd9b12c37a6cc
  13:     0x7fffae43c59d - cranelift_jit::backend::JITModule::finalize_definitions::h1bad446e1d195205
  14:     0x7fffae41d692 - rustc_codegen_cranelift::driver::jit::run_jit::h8585bd81e007a5e3
  15:     0x7fffae363b8f - <rustc_codegen_cranelift::CraneliftCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate::h0da6af42230e73fb
  16:     0x7fff804b18a0 - rustc_interface[6c72882eac342bcd]::passes::analysis
  17:     0x7fff804a3ce3 - <rustc_interface[6c72882eac342bcd]::passes::LintStoreExpandImpl as rustc_expand[6695f8eb6e16e84d]::base::LintStoreExpand>::pre_expansion_lint
  18:     0x7fff80490a5c - <rustc_interface[6c72882eac342bcd]::queries::Queries>::ongoing_codegen
  19:     0x7fff80447030 - <unknown>
  20:     0x7fff8047e937 - rustc_driver[197bfed8d57a407b]::args::arg_expand_all
  21:     0x7fff80467cf9 - <unknown>
  22:     0x7fff804687fd - <rustc_middle[d6f72711bda4db03]::ty::SymbolName as core[9a2c4b0c2bb38f26]::fmt::Display>::fmt
  23:     0x7fffae9ff15c - std::sys::windows::thread::Thread::new::hec2508d69eebdd0a
  24:     0x7ff832ac7034 - BaseThreadInitThunk
  25:     0x7ff833722651 - RtlUserThreadStart

error: internal compiler error: unexpected panic

aot.std_example

LNK2001: unresolved external symbol fabsf
  = note: msvcrt.lib(exe_main.obj) : warning LNK4078: multiple '.CRT' sections found with different attributes (40400040)
          std_example.std_example.03190124-cgu.15.rcgu.o : error LNK2001: unresolved external symbol fabsf
          C:\Users\Afonso\CLionProjects\rustc_codegen_cranelift\target\out\std_example.exe : fatal error LNK1120: 1 unresolved externals

extended_sysroot


test.rust-random/rand

Illegal instruction when building `getrandom`, `libm` and `num-traits`
   Compiling num-traits v0.2.15
[build_script_build            : codegen mono items] start
[build_script_build            : codegen mono items] end time: 13.4684ms
error: failed to run custom build command for `getrandom v0.1.16`

Caused by:
  process didn't exit successfully: `C:\Users\Afonso\CLionProjects\rustc_codegen_cranelift\rand\target\debug\build\getrandom-ae9cbaf4035dfeb9\build-script-build` (exit code: 0xc000001d, STATUS_ILLEGAL
_INSTRUCTION)
warning: build failed, waiting for other jobs to finish...
error: failed to run custom build command for `libm v0.2.2`

Caused by:
  process didn't exit successfully: `C:\Users\Afonso\CLionProjects\rustc_codegen_cranelift\rand\target\debug\build\libm-7d775bc88a95dcd8\build-script-build` (exit code: 0xc000001d, STATUS_ILLEGAL_INST
RUCTION)
error: failed to run custom build command for `num-traits v0.2.15`

Caused by:
  process didn't exit successfully: `C:\Users\Afonso\CLionProjects\rustc_codegen_cranelift\rand\target\debug\build\num-traits-77597371f412c10a\build-script-build` (exit code: 0xc000001d, STATUS_ILLEGA
L_INSTRUCTION)
  --- stdout
  [probe0                        : codegen mono items] start
  [probe0                        : codegen mono items] end time: 922.2µs
  [probe1                        : codegen mono items] start
  [probe1                        : codegen mono items] end time: 840.7µs
[serde                         : codegen mono items] start
[serde                         : codegen mono items] end time: 225.6096ms

test.libcore

Illegal instruction when building `getrandom`
error: failed to run custom build command for `getrandom v0.1.16`

Caused by:
  process didn't exit successfully: `C:\Users\Afonso\CLionProjects\rustc_codegen_cranelift\build_sysroot\sysroot_src\library\core\tests\target\debug\build\getrandom-ae9cbaf4035dfeb9\build-script-build
` (exit code: 0xc000001d, STATUS_ILLEGAL_INSTRUCTION)

test.regex-shootout-regex-dna

Builds successfully, but fails when running shootout-regex-dna.exe
    Finished dev [unoptimized + debuginfo] target(s) in 0.10s
     Running `target\x86_64-pc-windows-msvc\debug\examples\shootout-regex-dna.exe`
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: -1073741822, kind: Uncategorized, message: "OS Error -1073741822 (FormatMessageW() returned error 317)" }', examples\
shootout-regex-dna.rs:18:42
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: process didn't exit successfully: `target\x86_64-pc-windows-msvc\debug\examples\shootout-regex-dna.exe` (exit code: 0xc000001d, STATUS_ILLEGAL_INSTRUCTION)
thread '<unnamed>

test.regex

Fails to build with illegal instruction
error: failed to run custom build command for `winapi v0.3.9`

Caused by:
  process didn't exit successfully: `C:\Users\Afonso\CLionProjects\rustc_codegen_cranelift\regex\target\debug\build\winapi-4fa2ba29c6d2280e\build-script-build` (exit code: 0xc000001d, STATUS_ILLEGAL_I
NSTRUCTION)
warning: build failed, waiting for other jobs to finish...
error: failed to run custom build command for `rand_pcg v0.1.2`

Caused by:
  process didn't exit successfully: `C:\Users\Afonso\CLionProjects\rustc_codegen_cranelift\regex\target\debug\build\rand_pcg-bb69e9857a3d383b\build-script-build` (exit code: 0xc000001d, STATUS_ILLEGAL
_INSTRUCTION)
error: failed to run custom build command for `rand_chacha v0.1.1`

Caused by:
  process didn't exit successfully: `C:\Users\Afonso\CLionProjects\rustc_codegen_cranelift\regex\target\debug\build\rand_chacha-743ffc42347a8cb3\build-script-build` (exit code: 0xc000001d, STATUS_ILLE
GAL_INSTRUCTION)
error: failed to run custom build command for `rand v0.6.5`

Caused by:
  process didn't exit successfully: `C:\Users\Afonso\CLionProjects\rustc_codegen_cranelift\regex\target\debug\build\rand-be94e9473ad495f2\build-script-build` (exit code: 0xc000001d, STATUS_ILLEGAL_INS
TRUCTION)

test.portable-simd

LNK2001: unresolved external symbol fabsf
  = note: msvcrt.lib(exe_main.obj) : warning LNK4078: multiple '.CRT' sections found with different attributes (40400040)
          f32_ops-12918a2a6d68f6ed.4bstrdpwoxpm0wzh.rcgu.o : error LNK2001: unresolved external symbol fabsf
          C:\Users\Afonso\CLionProjects\rustc_codegen_cranelift\portable-simd\target\x86_64-pc-windows-msvc\debug\deps\f32_ops-12918a2a6d68f6ed.exe : fatal error LNK1120: 1 unresolved externals       


error: could not compile `core_simd` due to previous error

@bjorn3
Copy link
Member

bjorn3 commented Aug 4, 2022

cc #1254

@afonso360
Copy link
Contributor

afonso360 commented Aug 21, 2022

Once bytecodealliance/wasmtime#4747 lands, we are in pretty good shape for windows support. If anyone wants to test it out in the mean time, this branch enables pretty much everything that we need.


As mentioned in #1249 (comment) we are still missing JIT support, and its currently disabled in the testsuite.

I had a go at enabling the JIT tests, but it fails in jit.mini_core_hello_world.

It panics with: thread 'rustc' panicked at 'can't resolve symbol _ZN9mini_core8A_STATIC17hc53ef79cc689fdd5E', and it looks like its because the object crate does not enumerate dll exports so no symbols are ever registered. (this also looks like what is reported in #1197)

I checked with dumpbin.exe and the symbol is exported in the dll, so we should be good in that regard.

Edit: Tried to run the objdump example from the object crate in the current master branch, and it detects the symbols! But it looks like it uses file.symbols() instead of file.dynamic_symbols() like we use in the JIT.

Edit2: Opened gimli-rs/object#457

@afonso360
Copy link
Contributor

afonso360 commented Sep 1, 2022

bytecodealliance/wasmtime#4747 Is merged! 🎉 . With that I think we should remove the MSVC check on y.rs and enable inline stackprobing for Windows once cranelift 0.88 lands (CC #1276 I guess?).

Additionally on my TODO list is adding MSVC to CI.

From here, follow up work is the following:

Although I'm quite busy now so I might not get to these anytime soon.

This was referenced Sep 27, 2022
@bjorn3
Copy link
Member

bjorn3 commented Dec 15, 2022

This should be done now thanks to @afonso360.

@bjorn3 bjorn3 closed this as completed Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. O-windows Operating system: Windows
Projects
None yet
Development

No branches or pull requests

4 participants