Skip to content
New issue

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

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

Already on GitHub? # to your account

WSL2 to Windows compilation fails in Bevy 0.12 #10425

Open
sanrafa opened this issue Nov 7, 2023 · 10 comments
Open

WSL2 to Windows compilation fails in Bevy 0.12 #10425

sanrafa opened this issue Nov 7, 2023 · 10 comments
Labels
A-Assets Load files from disk to use for things like images, models, and sounds C-Bug An unexpected or incorrect behavior S-Blocked This cannot move forward until something else changes

Comments

@sanrafa
Copy link

sanrafa commented Nov 7, 2023

Bevy version

0.12

Relevant system information

Rust version: cargo 1.73.0 (9c4383fb5 2023-08-26)

Operating system:

5.15.90.1-microsoft-standard-WSL2 GNU/Linux
Description:    Manjaro Linux
Release:        23.1.0
Codename:       Vulcan

What you did

Attempted to cross-compile for Windows MSVC target from Linux (WSL2).

Code in main.rs:

use bevy::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .run();
}

What went wrong

Compilation fails, the following error occurs:

$  cargo build --target x86_64-pc-windows-msvc
   ...
   Compiling blake3 v1.5.0
The following warnings were emitted during compilation:

warning: GNU compiler is not supported for this target
warning: GNU compiler is not supported for this target
warning: The C compiler "cc" does not support /arch:AVX512.
warning: GNU compiler is not supported for this target

error: failed to run custom build command for `blake3 v1.5.0`

Caused by:
  process didn't exit successfully: `/home/sanrafa/dev/bevy-test/target/debug/build/blake3-7487fe5fac26a6d9/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=CARGO_FEATURE_PURE
  cargo:rerun-if-env-changed=CARGO_FEATURE_NO_NEON
  TARGET = Some("x86_64-pc-windows-msvc")
  HOST = Some("x86_64-unknown-linux-gnu")
  cargo:rerun-if-env-changed=CC_x86_64-pc-windows-msvc
  CC_x86_64-pc-windows-msvc = None
  cargo:rerun-if-env-changed=CC_x86_64_pc_windows_msvc
  CC_x86_64_pc_windows_msvc = None
  cargo:rerun-if-env-changed=TARGET_CC
  TARGET_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  RUSTC_LINKER = Some("lld")
  cargo:rerun-if-env-changed=CROSS_COMPILE
  CROSS_COMPILE = None
  cargo:warning=GNU compiler is not supported for this target
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  cargo:rerun-if-env-changed=CFLAGS_x86_64-pc-windows-msvc
  CFLAGS_x86_64-pc-windows-msvc = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_pc_windows_msvc
  CFLAGS_x86_64_pc_windows_msvc = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  OPT_LEVEL = Some("0")
  cargo:rerun-if-env-changed=CC_x86_64-pc-windows-msvc
  CC_x86_64-pc-windows-msvc = None
  cargo:rerun-if-env-changed=CC_x86_64_pc_windows_msvc
  CC_x86_64_pc_windows_msvc = None
  cargo:rerun-if-env-changed=TARGET_CC
  TARGET_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  RUSTC_LINKER = Some("lld")
  cargo:rerun-if-env-changed=CROSS_COMPILE
  CROSS_COMPILE = None
  cargo:warning=GNU compiler is not supported for this target
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  cargo:rerun-if-env-changed=CFLAGS_x86_64-pc-windows-msvc
  CFLAGS_x86_64-pc-windows-msvc = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_pc_windows_msvc
  CFLAGS_x86_64_pc_windows_msvc = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:warning=The C compiler "cc" does not support /arch:AVX512.
  cargo:rerun-if-env-changed=BLAKE3_CI
  cargo:rerun-if-env-changed=CARGO_FEATURE_PREFER_INTRINSICS
  cargo:rerun-if-env-changed=CARGO_FEATURE_PURE
  cargo:rustc-cfg=blake3_sse2_ffi
  cargo:rustc-cfg=blake3_sse41_ffi
  cargo:rustc-cfg=blake3_avx2_ffi
  TARGET = Some("x86_64-pc-windows-msvc")
  OPT_LEVEL = Some("0")
  HOST = Some("x86_64-unknown-linux-gnu")
  cargo:rerun-if-env-changed=CC_x86_64-pc-windows-msvc
  CC_x86_64-pc-windows-msvc = None
  cargo:rerun-if-env-changed=CC_x86_64_pc_windows_msvc
  CC_x86_64_pc_windows_msvc = None
  cargo:rerun-if-env-changed=TARGET_CC
  TARGET_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  RUSTC_LINKER = Some("lld")
  cargo:rerun-if-env-changed=CROSS_COMPILE
  CROSS_COMPILE = None
  cargo:warning=GNU compiler is not supported for this target
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  cargo:rerun-if-env-changed=CFLAGS_x86_64-pc-windows-msvc
  CFLAGS_x86_64-pc-windows-msvc = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_pc_windows_msvc
  CFLAGS_x86_64_pc_windows_msvc = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  running: "ml64.exe" "-nologo" "-Zi" "-o" "/home/sanrafa/dev/bevy-test/target/x86_64-pc-windows-msvc/debug/build/blake3-474c1f516b0299bd/out/c/blake3_sse2_x86-64_windows_msvc.o" "-c" "c/blake3_sse2_x86-64_windows_msvc.asm"

  --- stderr


  error occurred: Failed to find tool. Is `ml64.exe` installed?


warning: build failed, waiting for other jobs to finish...

Additional information

Current workaround is to use 0.11.3 - it works just fine on that version.

Based on this discussion, the issue seems to be stemming from the new Blake3 dependency.

@sanrafa sanrafa added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Nov 7, 2023
@tbillington
Copy link
Contributor

tbillington commented Nov 7, 2023

Can confirm this is also happening on Mac.

cargo xwin build --target=x86_64-pc-windows-msvc --release --no-default-features
warning: Patch `blake3 v1.3.1 (https://github.com/Sporif/BLAKE3?branch=fix-clang-cl-cross#124a7d89)` was not used in the crate graph.
Check that the patched package version and available features are compatible
with the dependency requirements. If the patch has a different version from
what is locked in the Cargo.lock file, run `cargo update` to use the new
version. This may also occur with an optional dependency that is not enabled.
   Compiling bevy_log v0.12.0
   Compiling bevy_core v0.12.0
   Compiling blake3 v1.5.0
   Compiling bevy_input v0.12.0
   Compiling wgpu-hal v0.17.2
   Compiling bevy_a11y v0.12.0
   Compiling bevy_time v0.12.0
   Compiling thiserror-core v1.0.38
   Compiling constgebra v0.1.3
   Compiling twox-hash v1.6.3
   Compiling const_panic v0.2.8
   Compiling bevy_hierarchy v0.12.0
   Compiling data-encoding v2.4.0
   Compiling color_quant v1.1.0
   Compiling unicode-ident v1.0.11
   Compiling ruzstd v0.4.0
   Compiling image v0.24.7
The following warnings were emitted during compilation:

warning: The C compiler "clang-cl" does not support /arch:AVX512.

error: failed to run custom build command for `blake3 v1.5.0`

Caused by:
  process didn't exit successfully: `/Users/choc/code/driving/target/release/build/blake3-cb09758bdbfea287/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=CARGO_FEATURE_PURE
  cargo:rerun-if-env-changed=CARGO_FEATURE_NO_NEON
  TARGET = Some("x86_64-pc-windows-msvc")
  HOST = Some("aarch64-apple-darwin")
  cargo:rerun-if-env-changed=CC_x86_64-pc-windows-msvc
  CC_x86_64-pc-windows-msvc = None
  cargo:rerun-if-env-changed=CC_x86_64_pc_windows_msvc
  CC_x86_64_pc_windows_msvc = Some("clang-cl")
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  cargo:rerun-if-env-changed=CFLAGS_x86_64-pc-windows-msvc
  CFLAGS_x86_64-pc-windows-msvc = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_pc_windows_msvc
  CFLAGS_x86_64_pc_windows_msvc = Some("--target=x86_64-pc-windows-msvc -Wno-unused-command-line-argument -fuse-ld=lld-link /imsvc/Users/choc/Library/Caches/cargo-xwin/xwin/crt/include /imsvc/Users/choc/Library/Caches/cargo-xwin/xwin/sdk/include/ucrt /imsvc/Users/choc/Library/Caches/cargo-xwin/xwin/sdk/include/um /imsvc/Users/choc/Library/Caches/cargo-xwin/xwin/sdk/include/shared  ")
  OPT_LEVEL = Some("3")
  cargo:rerun-if-env-changed=CC_x86_64-pc-windows-msvc
  CC_x86_64-pc-windows-msvc = None
  cargo:rerun-if-env-changed=CC_x86_64_pc_windows_msvc
  CC_x86_64_pc_windows_msvc = Some("clang-cl")
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  DEBUG = Some("false")
  cargo:rerun-if-env-changed=CFLAGS_x86_64-pc-windows-msvc
  CFLAGS_x86_64-pc-windows-msvc = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_pc_windows_msvc
  CFLAGS_x86_64_pc_windows_msvc = Some("--target=x86_64-pc-windows-msvc -Wno-unused-command-line-argument -fuse-ld=lld-link /imsvc/Users/choc/Library/Caches/cargo-xwin/xwin/crt/include /imsvc/Users/choc/Library/Caches/cargo-xwin/xwin/sdk/include/ucrt /imsvc/Users/choc/Library/Caches/cargo-xwin/xwin/sdk/include/um /imsvc/Users/choc/Library/Caches/cargo-xwin/xwin/sdk/include/shared  ")
  cargo:warning=The C compiler "clang-cl" does not support /arch:AVX512.
  cargo:rerun-if-env-changed=BLAKE3_CI
  cargo:rerun-if-env-changed=CARGO_FEATURE_PREFER_INTRINSICS
  cargo:rerun-if-env-changed=CARGO_FEATURE_PURE
  cargo:rustc-cfg=blake3_sse2_ffi
  cargo:rustc-cfg=blake3_sse41_ffi
  cargo:rustc-cfg=blake3_avx2_ffi
  TARGET = Some("x86_64-pc-windows-msvc")
  OPT_LEVEL = Some("3")
  HOST = Some("aarch64-apple-darwin")
  cargo:rerun-if-env-changed=CC_x86_64-pc-windows-msvc
  CC_x86_64-pc-windows-msvc = None
  cargo:rerun-if-env-changed=CC_x86_64_pc_windows_msvc
  CC_x86_64_pc_windows_msvc = Some("clang-cl")
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  DEBUG = Some("false")
  cargo:rerun-if-env-changed=CFLAGS_x86_64-pc-windows-msvc
  CFLAGS_x86_64-pc-windows-msvc = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_pc_windows_msvc
  CFLAGS_x86_64_pc_windows_msvc = Some("--target=x86_64-pc-windows-msvc -Wno-unused-command-line-argument -fuse-ld=lld-link /imsvc/Users/choc/Library/Caches/cargo-xwin/xwin/crt/include /imsvc/Users/choc/Library/Caches/cargo-xwin/xwin/sdk/include/ucrt /imsvc/Users/choc/Library/Caches/cargo-xwin/xwin/sdk/include/um /imsvc/Users/choc/Library/Caches/cargo-xwin/xwin/sdk/include/shared  ")
  running: "ml64.exe" "-nologo" "-Fo/Users/choc/code/driving/target/x86_64-pc-windows-msvc/release/build/blake3-3939cd5691820b01/out/c/blake3_sse2_x86-64_windows_msvc.o" "-c" "c/blake3_sse2_x86-64_windows_msvc.asm"

  --- stderr


  error occurred: Failed to find tool. Is `ml64.exe` installed?


warning: build failed, waiting for other jobs to finish...
error: Recipe `build-release-windows` failed on line 16 with exit code 101

@tbillington
Copy link
Contributor

tbillington commented Nov 7, 2023

Seems like this has been a known issue of blake3 since July 2021.

There is an open PR to fix it but it hasn't been actioned.

@alice-i-cecile alice-i-cecile added A-Assets Load files from disk to use for things like images, models, and sounds and removed S-Needs-Triage This issue needs to be labelled labels Nov 7, 2023
@alice-i-cecile alice-i-cecile added this to the 0.13 milestone Nov 7, 2023
@alice-i-cecile alice-i-cecile added the S-Blocked This cannot move forward until something else changes label Nov 7, 2023
@afonsolage
Copy link
Contributor

The PR #10208 introduced blake3 to replace MD5 in Assets V2, so although I agree MD5 should be avoided, we can look for another crate which has a good and safer hashing implementation and which can cross compile.

@tbillington
Copy link
Contributor

Is there any chance of this being reconsidered for a minor patch?

Currently anyone on Mac or Linux can't build bevy games for Windows (important platform 😅) even with containers/docker.

I encountered this bug while trying to upload a playtest build to itch. So I am currently asking around to borrow someones PC for half an hour haha

@mockersf
Copy link
Member

mockersf commented Nov 7, 2023

could you check if BLAKE3-team/BLAKE3#230 fixes it for you?

@tbillington
Copy link
Contributor

tbillington commented Nov 7, 2023

could you check if BLAKE3-team/BLAKE3#230 fixes it for you?

Just for context as it was mentioned in discord:

The linked PR is too stale to test or patch in as it targets 1.3.1, and bevy uses 1.5.

@bjorn3
Copy link
Contributor

bjorn3 commented Nov 7, 2023

Enabling the prefer_intrinsics or pure features of the blake3 crate should help avoid the C implementation.

@afonsolage
Copy link
Contributor

afonsolage commented Nov 7, 2023

I can confirm that using those features enables cross-compilation.

As a temporary fix, one can add blake3 as dependency with this feature enabled:

blake3 = { version = "1.5", features=["pure"] }

Edit: After checking blake3 build code, I saw that we can also use CARGO_FEATURE_PURE env variable:

CARGO_FEATURE_PURE=1 cargo build --target x86_64-pc-windows-msvc

@oconnor663
Copy link

I would like to land some version of BLAKE3-team/BLAKE3#230 upstream, and I have some questions about how the approach in that PR compares to what cross does when it targets x86_64-pc-windows-msvc. It would be great if someone who understands this stuff better than me could chime in on that thread :)

@fabienjuif
Copy link

Related discussion

And thank you for pointing to a workaround here ❤️

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-Assets Load files from disk to use for things like images, models, and sounds C-Bug An unexpected or incorrect behavior S-Blocked This cannot move forward until something else changes
Projects
None yet
Development

No branches or pull requests

8 participants