bazelbuild / bazelbuild/rules_rust
Can't use rules_rust on windows with zig hermetic_cc_toolchain
- Dominant language
- Starlark
- Stars
- 843
- Forks
- 651
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 15
Description
I'm attempting to use rules_rust together with the hermetic_cc_toolchain and running into an issue with build of process_wrapper:
MODULE.bazel:
```
bazel_dep(name = "hermetic_cc_toolchain", version = "3.1.0")
toolchains = use_extension("@hermetic_cc_toolchain//toolchain:ext.bzl", "toolchains")
use_repo(toolchains, "zig_sdk")
register_toolchains(
"@zig_sdk//toolchain:x86_64-windows-gnu",
)
bazel_dep(name = "rules_rust", version = "0.64.0")
# Rust toolchain extension
rust_toolchain_ext = use_extension("@rules_rust//rust:extensions.bzl", "rust")
rust_toolchain_ext.toolchain(edition = "2024")
use_repo(rust_toolchain_ext, "rust_toolchains")
```
```
error: linking with `external/hermetic_cc_toolchain++toolchains+zig_sdk/tools/x86_64-windows-gnu/c++.exe` failed: exit code: 1
|
= note: "external/hermetic_cc_toolchain++toolchains+zig_sdk/tools/x86_64-windows-gnu/c++.exe" "/NOLOGO" "C:\\Users\\browchri\\AppData\\Local\\Temp\\rustcXqFB9Z\\symbols.o" "<17 object files omitted>" "D:\\udu\\b\\jsuyf6jg\\execroot\\_main\\bazel-out\\x64_windows-opt-exec-ST-d57f47055a04\\bin\\external\\rules_rust++i+rules_rust_tinyjson/{libtinyjson-1317710085.rlib}.rlib" "D:\\udu\\b\\jsuyf6jg\\external\\rules_rust++rust+rw-1704990954_tools\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib/{libstd-02295aa7264c5c18.rlib,libpanic_unwind-5619d5a3441fc816.rlib,libwindows_targets-f3142254eeaa955d.rlib,librustc_demangle-877f79c609d649c2.rlib,libstd_detect-77bdbc8d7f5b490f.rlib,libhashbrown-a06caeda3bfa8c34.rlib,librustc_std_workspace_alloc-3f7cd706091b134c.rlib,libunwind-8a55a095caad445b.rlib,libcfg_if-96f5b4614f98deaa.rlib,liballoc-ba8c60d18e59dfba.rlib,librustc_std_workspace_core-05d5d2668e7fcf5f.rlib,libcore-d3f6b6fdad4e9c8b.rlib,libcompiler_builtins-c4d2db4aec166f72.rlib}.rlib" "kernel32.lib" "kernel32.lib" "advapi32.lib" "ntdll.lib" "userenv.lib" "ws2_32.lib" "dbghelp.lib" "/defaultlib:msvcrt" "/NXCOMPAT" "/LIBPATH:/lib/rustlib/x86_64-pc-windows-msvc/lib" "/OUT:bazel-out/x64_windows-opt-exec-ST-d57f47055a04/bin/external/rules_rust+/util/process_wrapper/process_wrapper.exe" "/OPT:REF,ICF" "/DEBUG" "/PDBALTPATH:%_PDB%" "-O2" "-DNDEBUG"
= note: some arguments are omitted. use `--verbose` to show all linker arguments
= note: lld-link: error: duplicate symbol: __guard_check_icall_fptr␍
>>> defined at mingw32.lib(mingw_cfguard_support.obj)␍
>>> defined at msvcrt.lib(guard_support.obj)␍
␍
lld-link: error: duplicate symbol: __guard_dispatch_icall_fptr␍
>>> defined at mingw32.lib(mingw_cfguard_support.obj)␍
>>> defined at msvcrt.lib(guard_support.obj)␍
```
It appears that rules_rust is attempting to use the msvc libraries; so I need to convince rules_rust to use the windows-gnu variants. I've attempted to configure the rust toolchain thus but it doesn't help:
MODULE.bazel:
```
rust_toolchain_ext = use_extension("@rules_rust//rust:extensions.bzl", "rust")
rust_toolchain_ext.toolchain(edition = "2024")
rust_toolchain_ext.repository_set(
exec_triple = "x86_64-pc-windows-gnu",
name="x86_64-pc-windows-gnu",
target_triple = "x86_64-pc-windows-gnu")
use_repo(rust_toolchain_ext, "rust_toolchains")
```
Am I missing something simple? Thanks!
Contributor guide
Assessment
This issue has not been assessed yet.