Skip to content

Latest commit

 

History

History
40 lines (31 loc) · 1.79 KB

File metadata and controls

40 lines (31 loc) · 1.79 KB

rules_rust_clippy_go_cross_reproducer

Reproducer for an issue with rust_clippy_aspect in combination with go_cross_binary().

To reproduce (on Linux/Mac):

  • This builds fine:
bazel build //...
bazel build //rust/... --aspects=@rules_rust//rust:defs.bzl%rust_clippy_aspect --output_groups=+clippy_checks
  • But this yields an error:
bazel build //... --aspects=@rules_rust//rust:defs.bzl%rust_clippy_aspect --output_groups=+clippy_checks
Use --verbose_failures to see the command lines of failed build steps.
ERROR: Analysis of aspects '[@@rules_rust~//rust:defs.bzl%rust_clippy_aspect] with parameters {} on //go:windows_x64' failed; build aborted: No matching toolchains found for types @@rules_rust~//rust:toolchain_type, @@bazel_tools//tools/cpp:toolchain_type.
To debug, rerun with --toolchain_resolution_debug='@@rules_rust~//rust:toolchain_type|@@bazel_tools//tools/cpp:toolchain_type'
If platforms or toolchains are a new concept for you, we'd encourage reading https://bazel.build/concepts/platforms-intro.
INFO: Elapsed time: 0.480s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully

Analysis

This is due to the rust_clippy_aspect aspect requiring a C++/Rust toolchain for the aspect execution. rules_go's go_cross_binary() transitions the target platform which results in a requirement for a C++/Rust toolchain that is compatible.

With bazel's optional toolchains we can solve this issue. See: