Skip to content

Commit

Permalink
Fix aarch64-pc-windows-msvc (#6868)
Browse files Browse the repository at this point in the history
  • Loading branch information
cwfitzgerald authored Jan 7, 2025
1 parent 991ee61 commit 0dab31a
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 14 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions naga/fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down
5 changes: 5 additions & 0 deletions naga/fuzz/build.rs
Original file line number Diff line number Diff line change
@@ -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"))) },
}
}
8 changes: 6 additions & 2 deletions naga/fuzz/fuzz_targets/glsl_parser.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -47,3 +48,6 @@ mod fuzz {
let _result = parser.parse(&options.into(), &source);
});
}

#[cfg(not(enable_fuzzing))]
fn main() {}
8 changes: 6 additions & 2 deletions naga/fuzz/fuzz_targets/ir.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -12,3 +13,6 @@ mod fuzz {
let _result = validator.validate(&module);
});
}

#[cfg(not(enable_fuzzing))]
fn main() {}
8 changes: 6 additions & 2 deletions naga/fuzz/fuzz_targets/spv_parser.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand All @@ -10,3 +11,6 @@ mod fuzz {
let _result = Frontend::new(data.into_iter(), &options).parse();
});
}

#[cfg(not(enable_fuzzing))]
fn main() {}
8 changes: 6 additions & 2 deletions naga/fuzz/fuzz_targets/wgsl_parser.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -9,3 +10,6 @@ mod fuzz {
let _result = Frontend::new().parse(&data);
});
}

#[cfg(not(enable_fuzzing))]
fn main() {}
7 changes: 6 additions & 1 deletion wgpu-hal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
4 changes: 3 additions & 1 deletion wgpu-hal/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")) }
}
}
4 changes: 2 additions & 2 deletions wgpu-hal/src/dx12/shader_compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<DxcContainer, crate::DeviceError> {
#[cfg(feature = "static-dxc")]
#[cfg(static_dxc)]
{
unsafe {
let compiler = dxc_create_instance::<Dxc::IDxcCompiler3>(|clsid, iid, ppv| {
Expand All @@ -206,7 +206,7 @@ pub(super) fn get_static_dxc_container() -> Result<DxcContainer, crate::DeviceEr
})
}
}
#[cfg(not(feature = "static-dxc"))]
#[cfg(not(static_dxc))]
{
panic!("Attempted to create a static DXC shader compiler, but the static-dxc feature was not enabled")
}
Expand Down
4 changes: 3 additions & 1 deletion wgpu-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7692,7 +7692,9 @@ pub enum Dx12Compiler {
dxil_path: PathBuf,
},
/// The statically-linked variant of Dxc.
/// The `static-dxc` feature is required to use this.
///
/// The `static-dxc` feature is required for this setting to be used successfully on DX12.
/// Not available on `windows-aarch64-pc-*` targets.
StaticDxc,
}

Expand Down
2 changes: 2 additions & 0 deletions wgpu/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ fn main() {
// This alias is _only_ if _we_ need naga in the wrapper. wgpu-core provides
// its own re-export of naga, which can be used in other situations
naga: { any(feature = "naga-ir", feature = "spirv", feature = "glsl") },
// ⚠️ Keep in sync with target.cfg() definition in wgpu-hal/Cargo.toml and cfg_alias in `wgpu-hal` crate ⚠️
static_dxc: { all(target_os = "windows", feature = "static-dxc", not(target_arch = "aarch64")) },
}
}
2 changes: 1 addition & 1 deletion wgpu/src/util/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pub fn dx12_shader_compiler_from_env() -> Option<wgt::Dx12Compiler> {
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,
Expand Down

0 comments on commit 0dab31a

Please sign in to comment.