From 0dab31ab2a06d8f6c94d4b94c9c11d92afd3249d Mon Sep 17 00:00:00 2001 From: Connor Fitzgerald Date: Mon, 6 Jan 2025 21:28:05 -0500 Subject: [PATCH] Fix aarch64-pc-windows-msvc (#6868) --- .github/workflows/ci.yml | 6 ++++++ Cargo.lock | 1 + naga/fuzz/Cargo.toml | 4 ++++ naga/fuzz/build.rs | 5 +++++ naga/fuzz/fuzz_targets/glsl_parser.rs | 8 ++++++-- naga/fuzz/fuzz_targets/ir.rs | 8 ++++++-- naga/fuzz/fuzz_targets/spv_parser.rs | 8 ++++++-- naga/fuzz/fuzz_targets/wgsl_parser.rs | 8 ++++++-- wgpu-hal/Cargo.toml | 7 ++++++- wgpu-hal/build.rs | 4 +++- wgpu-hal/src/dx12/shader_compilation.rs | 4 ++-- wgpu-types/src/lib.rs | 4 +++- wgpu/build.rs | 2 ++ wgpu/src/util/init.rs | 2 +- 14 files changed, 57 insertions(+), 14 deletions(-) create mode 100644 naga/fuzz/build.rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bf4fada34f..3baefb469b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -88,6 +88,12 @@ jobs: target: x86_64-pc-windows-msvc kind: native + # Windows + - name: Windows aarch64 + os: windows-2022 + target: aarch64-pc-windows-msvc + kind: native + # MacOS - name: MacOS x86_64 os: macos-14 diff --git a/Cargo.lock b/Cargo.lock index b34d82b2e3..49e0517467 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2205,6 +2205,7 @@ name = "naga-fuzz" version = "0.0.0" dependencies = [ "arbitrary", + "cfg_aliases 0.2.1", "libfuzzer-sys", "naga", ] diff --git a/naga/fuzz/Cargo.toml b/naga/fuzz/Cargo.toml index fe4f7e5d06..b37f373ddc 100644 --- a/naga/fuzz/Cargo.toml +++ b/naga/fuzz/Cargo.toml @@ -5,6 +5,7 @@ authors = ["Automatically generated"] publish = false edition = "2018" license = "MIT OR Apache-2.0" +build = "build.rs" [package.metadata] cargo-fuzz = true @@ -19,6 +20,9 @@ path = ".." version = "23.0.0" features = ["arbitrary", "spv-in", "wgsl-in", "glsl-in"] +[build-dependencies] +cfg_aliases.workspace = true + [[bin]] name = "spv_parser" path = "fuzz_targets/spv_parser.rs" diff --git a/naga/fuzz/build.rs b/naga/fuzz/build.rs new file mode 100644 index 0000000000..fa71d088aa --- /dev/null +++ b/naga/fuzz/build.rs @@ -0,0 +1,5 @@ +fn main() { + cfg_aliases::cfg_aliases! { + enable_fuzzing: { not(any(target_arch = "wasm32", target_os = "ios", all(windows, target_arch = "aarch64"))) }, + } +} diff --git a/naga/fuzz/fuzz_targets/glsl_parser.rs b/naga/fuzz/fuzz_targets/glsl_parser.rs index aed7ba981b..97a6ae3fbf 100644 --- a/naga/fuzz/fuzz_targets/glsl_parser.rs +++ b/naga/fuzz/fuzz_targets/glsl_parser.rs @@ -1,5 +1,6 @@ -#![no_main] -#[cfg(not(any(target_arch = "wasm32", target_os = "ios")))] +#![cfg_attr(enable_fuzzing, no_main)] + +#[cfg(enable_fuzzing)] mod fuzz { use arbitrary::Arbitrary; use libfuzzer_sys::fuzz_target; @@ -47,3 +48,6 @@ mod fuzz { let _result = parser.parse(&options.into(), &source); }); } + +#[cfg(not(enable_fuzzing))] +fn main() {} diff --git a/naga/fuzz/fuzz_targets/ir.rs b/naga/fuzz/fuzz_targets/ir.rs index 6768917c3b..53815c0649 100644 --- a/naga/fuzz/fuzz_targets/ir.rs +++ b/naga/fuzz/fuzz_targets/ir.rs @@ -1,5 +1,6 @@ -#![no_main] -#[cfg(not(any(target_arch = "wasm32", target_os = "ios")))] +#![cfg_attr(enable_fuzzing, no_main)] + +#[cfg(enable_fuzzing)] mod fuzz { use libfuzzer_sys::fuzz_target; @@ -12,3 +13,6 @@ mod fuzz { let _result = validator.validate(&module); }); } + +#[cfg(not(enable_fuzzing))] +fn main() {} diff --git a/naga/fuzz/fuzz_targets/spv_parser.rs b/naga/fuzz/fuzz_targets/spv_parser.rs index 2b0fae2960..cf72644cfc 100644 --- a/naga/fuzz/fuzz_targets/spv_parser.rs +++ b/naga/fuzz/fuzz_targets/spv_parser.rs @@ -1,5 +1,6 @@ -#![no_main] -#[cfg(not(any(target_arch = "wasm32", target_os = "ios")))] +#![cfg_attr(enable_fuzzing, no_main)] + +#[cfg(enable_fuzzing)] mod fuzz { use libfuzzer_sys::fuzz_target; use naga::front::spv::{Frontend, Options}; @@ -10,3 +11,6 @@ mod fuzz { let _result = Frontend::new(data.into_iter(), &options).parse(); }); } + +#[cfg(not(enable_fuzzing))] +fn main() {} diff --git a/naga/fuzz/fuzz_targets/wgsl_parser.rs b/naga/fuzz/fuzz_targets/wgsl_parser.rs index 7513d63d1d..1507ef0506 100644 --- a/naga/fuzz/fuzz_targets/wgsl_parser.rs +++ b/naga/fuzz/fuzz_targets/wgsl_parser.rs @@ -1,5 +1,6 @@ -#![no_main] -#[cfg(not(any(target_arch = "wasm32", target_os = "ios")))] +#![cfg_attr(enable_fuzzing, no_main)] + +#[cfg(enable_fuzzing)] mod fuzz { use libfuzzer_sys::fuzz_target; use naga::front::wgsl::Frontend; @@ -9,3 +10,6 @@ mod fuzz { let _result = Frontend::new().parse(&data); }); } + +#[cfg(not(enable_fuzzing))] +fn main() {} diff --git a/wgpu-hal/Cargo.toml b/wgpu-hal/Cargo.toml index d9b4a3a187..4817a22e22 100644 --- a/wgpu-hal/Cargo.toml +++ b/wgpu-hal/Cargo.toml @@ -165,13 +165,18 @@ windows = { workspace = true, optional = true } bit-set = { workspace = true, optional = true } range-alloc = { workspace = true, optional = true } gpu-allocator = { workspace = true, optional = true } -mach-dxcompiler-rs = { workspace = true, optional = true } # For core macros. This crate is also reexported as windows::core. windows-core = { workspace = true, optional = true } # backend: Gles glutin_wgl_sys = { workspace = true, optional = true } +# This doesn't support aarch64. See https://github.com/gfx-rs/wgpu/issues/6860. +# +# ⚠️ Keep in sync with static_dxc cfg in build.rs and cfg_alias in `wgpu` crate ⚠️ +[target.'cfg(all(windows, not(target_arch = "aarch64")))'.dependencies] +mach-dxcompiler-rs = { workspace = true, optional = true } + [target.'cfg(any(target_os="macos", target_os="ios"))'.dependencies] # backend: Metal block = { workspace = true, optional = true } diff --git a/wgpu-hal/build.rs b/wgpu-hal/build.rs index 7d17591605..510f2a35f6 100644 --- a/wgpu-hal/build.rs +++ b/wgpu-hal/build.rs @@ -10,6 +10,8 @@ fn main() { dx12: { all(target_os = "windows", feature = "dx12") }, gles: { all(feature = "gles") }, metal: { all(any(target_os = "ios", target_os = "macos"), feature = "metal") }, - vulkan: { all(not(target_arch = "wasm32"), feature = "vulkan") } + vulkan: { all(not(target_arch = "wasm32"), feature = "vulkan") }, + // ⚠️ Keep in sync with target.cfg() definition in Cargo.toml and cfg_alias in `wgpu` crate ⚠️ + static_dxc: { all(target_os = "windows", feature = "static-dxc", not(target_arch = "aarch64")) } } } diff --git a/wgpu-hal/src/dx12/shader_compilation.rs b/wgpu-hal/src/dx12/shader_compilation.rs index 9739627017..81e51b83d1 100644 --- a/wgpu-hal/src/dx12/shader_compilation.rs +++ b/wgpu-hal/src/dx12/shader_compilation.rs @@ -179,7 +179,7 @@ pub(super) fn get_dynamic_dxc_container( /// Creates a [`DxcContainer`] that delegates to the statically-linked version of DXC. pub(super) fn get_static_dxc_container() -> Result { - #[cfg(feature = "static-dxc")] + #[cfg(static_dxc)] { unsafe { let compiler = dxc_create_instance::(|clsid, iid, ppv| { @@ -206,7 +206,7 @@ pub(super) fn get_static_dxc_container() -> Result Option { dxc_path: std::path::PathBuf::from("dxcompiler.dll"), dxil_path: std::path::PathBuf::from("dxil.dll"), }, - #[cfg(feature = "static-dxc")] + #[cfg(static_dxc)] Ok("static-dxc") => wgt::Dx12Compiler::StaticDxc, Ok("fxc") => wgt::Dx12Compiler::Fxc, _ => return None,