You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
where it's (I think?) trying to use the downloaded toolchain to execute rather than the nix-provided toolchain.
I tried to ensure that the wasm32-unknown-unknown target was available to the rustc package installed with the following:
diff --git i/toolchains/rust/rust.bzl w/toolchains/rust/rust.bzl
index f555697..31b5fce 100644
--- i/toolchains/rust/rust.bzl+++ w/toolchains/rust/rust.bzl@@ -15,7 +15,26 @@ load("@rules_nixpkgs_core//:util.bzl", "ensure_constraints")
# Nix generation is used to dynamically compute both Linux and Darwin environments
_rust_nix_contents = """\
let
- pkgs = import <nixpkgs> {{ config = {{}}; overrides = []; }};+ pkgs = import <nixpkgs> {{ config = {{}}; overrides = self: super:+ {{+ rustc = super.rustc.override {{+ targets = super.rustc.targets // {{+ wasm32-unknown-unknown = super.rustc.targets.wasm32-unknown-unknown // {{+ stdenv = super.stdenv.override {{+ targetPlatform = {{+ parsed = {{+ cpu = {{ name = "wasm32"; }};+ vendor = {{ name = "unknown"; }};+ kernel = {{ name = "unknown"; }};+ abi = {{ name = "unknown"; }};+ }};+ }};+ }};+ }};+ }};+ }};+ }};+ }};
rust = pkgs.rust;
os = rust.toTargetOs pkgs.stdenv.targetPlatform;
build-triple = rust.toRustTargetSpec pkgs.stdenv.buildPlatform;
fails with the same error (although crate_index__foreign-types-shared-0.1.1 rather than crate_index__bitflags-1.3.2, but I think this is due to parallel building rather than any actual difference.)
Removing the rust_wasm_bindgen_register_toolchains() call from WORKSPACE (in a last ditch kinda attempt) yielded:
ERROR: /home/grawlix/repos/github.com/tweag/rules_nixpkgs/examples/toolchains/rust/BUILD:18:18: While resolving toolchains for target //:wasm: No matching toolchains found for types @rules_rust//wasm_bindgen:toolchain_type.
To debug, rerun with --toolchain_resolution_debug='@rules_rust//wasm_bindgen:toolchain_type'
and doing so results in:
❯ bazel build --config=nix //:wasm --verbose_failures --toolchain_resolution_debug='@rules_rust//wasm_bindgen:toolchain_type'
INFO: Build option --toolchain_resolution_debug has changed, discarding analysis cache.
INFO: ToolchainResolution: Type @rules_rust//wasm_bindgen:toolchain_type: target platform @rules_nixpkgs_core//platforms:host: No toolchains found.
ERROR: /home/grawlix/repos/github.com/tweag/rules_nixpkgs/examples/toolchains/rust/BUILD:18:18: While resolving toolchains for target //:wasm: No matching toolchains found for types @rules_rust//wasm_bindgen:toolchain_type.
To debug, rerun with --toolchain_resolution_debug='@rules_rust//wasm_bindgen:toolchain_type'
If platforms or toolchains are a new concept for you, we'd encourage reading https://bazel.build/concepts/platforms-intro.
Expected behavior
Expect to be able to build wasm libraries using the tooling provided by rules_rust.
Environment
OS name + version: NixOS 23.11.5541.56528ee42526 (Tapir) x86_64
Created #496 to track updates/attempts at addressing this issue. I can only work part time on this, and making a best effort to help resolve my own issue 🙂
Describe the bug
Can't build rust wasm targets.
To Reproduce
I used the following changes to the
examples/toolchains/rust
:trying to build
bazel build --config=nix //:wasm
fails with:where it's (I think?) trying to use the downloaded toolchain to execute rather than the nix-provided toolchain.
I tried to ensure that the
wasm32-unknown-unknown
target was available to therustc
package installed with the following:fails with the same error (although
crate_index__foreign-types-shared-0.1.1
rather thancrate_index__bitflags-1.3.2
, but I think this is due to parallel building rather than any actual difference.)Removing the
rust_wasm_bindgen_register_toolchains()
call fromWORKSPACE
(in a last ditch kinda attempt) yielded:and doing so results in:
Expected behavior
Expect to be able to build wasm libraries using the tooling provided by
rules_rust
.Environment
Additional context
The text was updated successfully, but these errors were encountered: