Is it possible to keep the intermediate `.rs` file used during `rust_prost_library`?

Open
#3,909 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
rust
Domain
build-system

Research direction

Start with extensions/prost/private/prost.bzl, especially the rust_prost_library implementation and the lines around 316-323, then reproduce the shown bazel build command with --subcommands. Determine how the generated *.lib.rs artifact is handled and make it remain accessible after the build; done when users can inspect that file for a generated proto target.

Written by the indexing model from the issue text.

Description

awaiting-response proto

rust_prost_library's ProstGenProto action will - it seems - create an ephemeral *.lib.rs file before building the resulting *.rlib file.

Note the --out_librs=bazel-out/k8-fastbuild/bin/rust/proto/connect_proto.lib.rs arg in the protoc_wrapper command:

$ bazel build --subcommands //rust/proto:connect_rust_proto
...
SUBCOMMAND: # //rust/proto:connect_proto [action 'ProstGenProto //rust/proto:connect_proto', configuration: ce57de3d3d3898ef19a604dc9e90220b91db82beb22d97846032d915a639010f, execution platform: //tools/bazel/rbe/config/config:platform, mnemonic: ProstGenProto]                                                                                                                                                                                                                        
(cd /usr/local/google/home/dthor/.cache/bazel/_bazel_dthor/0f8c52850e7230283fc2f8033149fba2/execroot/_main && \                                                                                                                               
  exec env - \                                                                                                                                                                                                                                
    BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 \                                                                                                                                                                                                     
    PATH=/bin:/usr/bin:/usr/local/bin \                                                                                                                                                                                                       
  bazel-out/k8-opt-exec-ST-7ac76b60419a/bin/external/rules_rust_prost+/private/protoc_wrapper '--prost_out=bazel-out/k8-fastbuild/bin' '--plugin=protoc-gen-prost=bazel-out/k8-opt-exec-ST-7ac76b60419a/bin/external/rules_rust++crate+crates__protoc-gen-prost-0.4.0/protoc-gen-prost__bin' -I. rust/proto/connect.proto '--protoc=bazel-out/k8-opt-exec-ST-7ac76b60419a/bin/external/protobuf+/protoc' '--label=//rust/proto:connect_proto' '--out_librs=bazel-out/k8-fastbuild/bin/rust/proto/connect_proto.lib.rs' '--package_info_output=connect_proto=bazel-out/k8-fastbuild/bin/rust/proto/connect_proto.prost_package_info' '--deps_info=bazel-out/k8-fastbuild/bin/rust/proto/connect_proto.prost_deps_info' '--descriptor_set=bazel-out/k8-fastbuild/bin/rust/proto/connect_proto-descriptor-set.proto.bin' '--prost_opt=enable_type_names' '--plugin=protoc-gen-tonic=bazel-out/k8-opt-exec-ST-7ac76b60419a/bin/external/rules_rust++crate+crates__protoc-gen-tonic-0.4.1/protoc-gen-tonic__bin' '--tonic_opt=no_include' --is_tonic '--rustfmt=external/rules_rust++rust+rustfmt_nightly-2025-04-03__x86_64-unknown-linux-gnu_tools/bin/rustfmt')                                                                         
# Configuration: ce57de3d3d3898ef19a604dc9e90220b91db82beb22d97846032d915a639010f                                                                                                                                                             
# Execution platform: //tools/bazel/rbe/config/config:platform                                                                                                                                                                                
# Runner: remote

https://github.com/bazelbuild/rules_rust/blob/76abd40167aa8a1a9ef399783c4c610b9c6331a6/extensions/prost/private/prost.bzl#L66

https://github.com/bazelbuild/rules_rust/blob/76abd40167aa8a1a9ef399783c4c610b9c6331a6/extensions/prost/private/prost.bzl#L316-L323

Is it possible to keep that *.lib.rs file around? Even just in the sandbox or outdir or cache or something. Having it accessible can help debug issues with protos.

Dominant language
Starlark
Stars
857
Forks
701
Avg merge
4d 7h
Merged PRs (30d)
46

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bazelbuild/rules_rust

All issues in bazelbuild/rules_rust

Similar issues

More Build System issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.