Skip to content

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

@dougthor42

Description

@dougthor42

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

lib_rs = ctx.actions.declare_file("{}.lib.rs".format(ctx.label.name))

dep_variant_info = _compile_rust(
ctx = ctx,
attr = ctx.rule.attr,
crate_name = crate_name,
src = lib_rs,
deps = rust_deps,
edition = RUST_EDITION,
)

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting-responseMaintainers have responded to the pull-request or thread and now await contributor responses.proto

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions