bazelbuild / rules_rust

Rust rules for Bazel
https://bazelbuild.github.io/rules_rust/
Apache License 2.0
654 stars 413 forks source link

rustfmt/clippy output_groups suppress DefaultInfo output #1924

Closed qzmfranklin closed 1 year ago

qzmfranklin commented 1 year ago

rules_rust version: 0.20.0 bazel version: 7.0.0-pre.20230405.2 relevant bazelrc config:

build --aspects=@rules_rust//rust:defs.bzl%rustfmt_aspect
build --output_groups=+rustfmt_checks

build --aspects=@rules_rust//rust:defs.bzl%rust_clippy_aspect
build --output_groups=+clippy_checks

What happens:

With the above bazelrc configs turned on, my bazel build commands no longer prints the DefaultInfo. For example:

 % bb build tools/build_defs/gpu/cuda/examples/simple:kernel
INFO: Invocation ID: 78b2bc59-94a2-49aa-a8cb-9b6526fabf1e
INFO: Streaming build results to: https://app.buildbuddy.io/invocation/78b2bc59-94a2-49aa-a8cb-9b6526fabf1e
INFO: Analyzed target //tools/build_defs/gpu/cuda/examples/simple:kernel (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Aspect @rules_rust//rust/private:rustfmt.bzl%rustfmt_aspect of //tools/build_defs/gpu/cuda/examples/simple:kernel up-to-date (nothing to build)
Aspect @rules_rust//rust/private:clippy.bzl%rust_clippy_aspect of //tools/build_defs/gpu/cuda/examples/simple:kernel up-to-date (nothing to build)
INFO: Elapsed time: 1.207s ⏳, Critical Path: 0.00s ⏰
INFO: 1 process: 1 internal.
INFO: Build completed successfully ✅ 1 total action
INFO: Streaming build results to: https://app.buildbuddy.io/invocation/78b2bc59-94a2-49aa-a8cb-9b6526fabf1e

Deleting all --output_groups flags recovered the DefaultInfo files, such as this one:

 % bb build tools/build_defs/gpu/cuda/examples/simple:kernel
INFO: Invocation ID: dab63f5c-4349-48d3-a969-84eeb4cbdc9d
INFO: Streaming build results to: https://app.buildbuddy.io/invocation/dab63f5c-4349-48d3-a969-84eeb4cbdc9d
DEBUG: /home/zhongmingqu/.cache/bazel/_bazel_zhongmingqu/33d097c4393d1ec801bb3e6d74ed212d/external/bazel_toolchains/rules/rbe_repo/version_check.bzl:68:14: 
Current running Bazel is ahead of bazel-toolchains repo. Please update your pin to bazel-toolchains repo in your WORKSPACE file.
DEBUG: /home/zhongmingqu/.cache/bazel/_bazel_zhongmingqu/33d097c4393d1ec801bb3e6d74ed212d/external/bazel_toolchains/rules/rbe_repo/checked_in.bzl:113:18: rte_default not using checked in configs; registry was set to 'index.docker.io' and toolchain_config_suite_spec is configured for 'marketplace.gcr.io'
INFO: Analyzed target //tools/build_defs/gpu/cuda/examples/simple:kernel (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //tools/build_defs/gpu/cuda/examples/simple:kernel up-to-date:
  __build__/bin/tools/build_defs/gpu/cuda/examples/simple/libkernel.a
  __build__/bin/tools/build_defs/gpu/cuda/examples/simple/libkernel.so
INFO: Elapsed time: 14.052s ⏳, Critical Path: 0.00s ⏰
INFO: 1 process: 1 internal.
INFO: Build completed successfully ✅ 1 total action
INFO: Streaming build results to: https://app.buildbuddy.io/invocation/dab63f5c-4349-48d3-a969-84eeb4cbdc9d

I Googled and GPT'ed around DefaultInfo and output groups. Did not find a solution. I understand this should probably be a bazel question in general instead of a rules_rust-specific question. But since these flags originated here, I suppose maybe people have encountered it and solved it?

Thanks in advance.

illicitonion commented 1 year ago

As far as I can tell, Bazel is still (correctly) building the default info provider, it just isn't including it in the output. Accordingly, I think this probably is a display bug in Bazel - looks like https://github.com/bazelbuild/bazel/issues/10530 may track the same issue?

qzmfranklin commented 1 year ago

Thanks for the prompt response and informative redirect.