SnowflakePowered / spirv-to-dxil-rs

Rust bindings for spirv-to-dxil
MIT License
1 stars 1 forks source link

build failure on Windows for ARM64 (rust target aarch64-pc-windows-msvc) #7

Closed LukeUsher closed 9 months ago

LukeUsher commented 9 months ago

When building for ARM64 windows (aarch64-pc-windows-msvc) librashader_capi.dll.lib fails to link with the following errors:

Commit built: a8ae407ddbb5d91e80b0581af80535404fe555ca

          libspirv_to_dxil_sys-de688d93c60c8a02.rlib(u_format_bptc.o) : error LNK2001: unresolved external symbol ffs
          libspirv_to_dxil_sys-de688d93c60c8a02.rlib(nir_lower_mediump.o) : error LNK2001: unresolved external symbol ffs
          libspirv_to_dxil_sys-de688d93c60c8a02.rlib(nir_phi_builder.o) : error LNK2001: unresolved external symbol ffs
          libspirv_to_dxil_sys-de688d93c60c8a02.rlib(nir_range_analysis.o) : error LNK2001: unresolved external symbol ffs
          libspirv_to_dxil_sys-de688d93c60c8a02.rlib(nir_opt_load_store_vectorize.o) : error LNK2001: unresolved external symbol ffs
          libspirv_to_dxil_sys-de688d93c60c8a02.rlib(nir_lower_io_to_scalar.o) : error LNK2001: unresolved external symbol ffs
          libspirv_to_dxil_sys-de688d93c60c8a02.rlib(vtn_variables.o) : error LNK2001: unresolved external symbol ffs
          libspirv_to_dxil_sys-de688d93c60c8a02.rlib(vtn_alu.o) : error LNK2001: unresolved external symbol ffs
          libspirv_to_dxil_sys-de688d93c60c8a02.rlib(nir_lower_subgroups.o) : error LNK2001: unresolved external symbol ffs
          libspirv_to_dxil_sys-de688d93c60c8a02.rlib(nir_opt_combine_stores.o) : error LNK2001: unresolved external symbol ffs
          libspirv_to_dxil_sys-de688d93c60c8a02.rlib(dxil_nir.o) : error LNK2001: unresolved external symbol ffs
          libspirv_to_dxil_sys-de688d93c60c8a02.rlib(nir_lower_mem_access_bit_sizes.o) : error LNK2001: unresolved external symbol ffs
          libspirv_to_dxil_sys-de688d93c60c8a02.rlib(nir_lower_io.o) : error LNK2001: unresolved external symbol ffs
          libspirv_to_dxil_sys-de688d93c60c8a02.rlib(nir_serialize.o) : error LNK2001: unresolved external symbol ffs
          libspirv_to_dxil_sys-de688d93c60c8a02.rlib(nir_gather_info.o) : error LNK2001: unresolved external symbol ffs
          libspirv_to_dxil_sys-de688d93c60c8a02.rlib(nir_deref.o) : error LNK2001: unresolved external symbol ffs
          libspirv_to_dxil_sys-de688d93c60c8a02.rlib(glsl_types.o) : error LNK2001: unresolved external symbol ffs
          libspirv_to_dxil_sys-de688d93c60c8a02.rlib(nir_print.o) : error LNK2001: unresolved external symbol ffs
          libspirv_to_dxil_sys-de688d93c60c8a02.rlib(nir_to_dxil.o) : error LNK2001: unresolved external symbol ffs
          libspirv_to_dxil_sys-de688d93c60c8a02.rlib(nir.o) : error LNK2001: unresolved external symbol ffs
chyyran commented 9 months ago

This is happening downstream in https://github.com/SnowflakePowered/spirv-to-dxil-rs

Seems like the MSVC isn’t providing ffs on ARM or it otherwise isn’t needed on x86_64. Pretty easy fix to just stuff an implementation in a header somewhere, will get to it after work.

Granted there is also a quick fix to disable the runtime-d3d12 feature, I don’t remember if the build script is able to pass arbitrary cargo flags otoh though.

chyyran commented 9 months ago

Fixed by 20381b1777b3664dc99f8d7287a8464a75255a43

If you do cargo update it should be able to build librashader now on aarch64-pc-windows-msvc without code changes needed.

chyyran commented 9 months ago

Seems like there's a bug right now with the nightly aarch64-pc-windows-msvc compiler, I've filed an issue upstream at https://github.com/rust-lang/rust/issues/121367.

If you pin the rustup toolchain to nightly-2024-01-15, librashader will build just fine; alternatively you can use a stable toolchain like 1.72 with the RUSTC_BOOTSTRAP hack but I don't encourage that unless absolutely necessary.