-
Notifications
You must be signed in to change notification settings - Fork 534
Open
Labels
Description
I'm trying to generate a wasm binary that uses wgpu. However, it fails to build under bazel while I'm able to build it using cargo.
ERROR: /home/doug/.cache/bazel/_bazel_doug/b0db08dbefda9318e6dcb1f83205b236/external/crate_index_cargo_workspace__ash-0.37.2-1.3.238/BUILD.bazel:22:13: Compiling Rust rlib ash v0.37.2+1.3.238 (95 files) failed: (Exit 1): process_wrapper failed: error executing command (from target @crate_index_cargo_workspace__ash-0.37.2-1.3.238//:ash) bazel-out/k8-opt-exec-2B5CBBC6-ST-e846b08c7501/bin/external/rules_rust/util/process_wrapper/process_wrapper --env-file ... (remaining 38 arguments skipped)
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
error[E0432]: unresolved import `libloading::Library`
--> external/crate_index_cargo_workspace__ash-0.37.2-1.3.238/src/entry.rs:16:5
|
16 | use libloading::Library;
| ^^^^^^^^^^^^^^^^^^^ no `Library` in the root
error[E0425]: cannot find value `LIB_PATH` in this scope
--> external/crate_index_cargo_workspace__ash-0.37.2-1.3.238/src/entry.rs:76:25
|
76 | Self::load_from(LIB_PATH)
| ^^^^^^^^ not found in this scope
error[E0282]: type annotations needed
--> external/crate_index_cargo_workspace__ash-0.37.2-1.3.238/src/entry.rs:164:25
|
164 | _lib_guard: None,
| ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option`
|
help: consider specifying the generic argument
|
164 | _lib_guard: None::<T>,
| +++++
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0282, E0425, E0432.
For more information about an error, try `rustc --explain E0282`.
Target //cargo_workspace/rng:rng_bindgen failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 180.079s, Critical Path: 32.13s
INFO: 489 processes: 223 internal, 266 linux-sandbox.
FAILED: Build did NOT complete successfully
I believe this error is caused by features being incorrectly enabled/disabled in the build. However, I'm not sure what's going wrong.
The library ash that is trying to use libloading is referenced by wgpu-hal:
bazel cquery --platforms=@rules_rust//rust/platform:wasm 'somepath(//cargo_workspace/rng:rng_bindgen, @crate_index_cargo_workspace__ash-0.37.2-1.3.238//:all)' 1 ↵
INFO: Build option --platforms has changed, discarding analysis cache.
INFO: Analyzed 5 targets (322 packages loaded, 13371 targets configured).
INFO: Found 5 targets...
//cargo_workspace/rng:rng_bindgen (07cfa71)
//cargo_workspace/rng:rng_shared (07cfa71)
@crate_index_cargo_workspace__wgpu-0.15.0//:wgpu (07cfa71)
@crate_index_cargo_workspace__wgpu-core-0.15.0//:wgpu_core (07cfa71)
@crate_index_cargo_workspace__wgpu-hal-0.15.1//:wgpu_hal (07cfa71)
@crate_index_cargo_workspace__ash-0.37.2-1.3.238//:ash (07cfa71)
INFO: Elapsed time: 1.040s, Critical Path: 0.00s
INFO: 0 processes.
INFO: Build completed successfully, 0 total actions
However, if you look at the wgpu-hal Cargo.toml, it's listed as an optional dependency that's only enabled for the vulkan feature.
Steps to reproduce
I've made a small reproduction of the problem using one of the rules_rust examples. The main changes I made are:
- Add a wasm build in the BUILD
- Add
wgpuas a dependency in the Cargo.toml
cd /tmp
git clone https://github.com/Dig-Doug/rules_rust.git
cd rules_rust
git checkout wgpu-test
cd examples/crate_universe/
bazel build //cargo_workspace/rng:rng_bindgen
s-panferov