bazelbuild / bazelbuild/rules_rust

Prost: Alias Proto Libraries cause crash

Open
#2,808 0 comments 1 reaction 0 assignees View on GitHub
bug needs-triage proto
Dominant language
Starlark
Stars
843
Forks
651
Avg merge
2d 18h
Merged PRs (30d)
15

Description

I am trying to setup prost for a mono-repo. However, it seems that `rust_prost_library` has a problem with alias proto libraries (i.e. `proto_library` that only has dependencies.

## Toy Example

I am using the following rules:

```bazel
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_rust//proto/prost:defs.bzl", "rust_prost_library")

package(default_visibility = ["//visibility:public"])

proto_library(
name="message",
srcs = ["simple.proto"],
deps = [
"@com_google_protobuf//:duration_proto",
"@com_google_protobuf//:timestamp_proto",
],
)

rust_prost_library(
name = "message_rs",
proto = ":message",
)

proto_library(
name = "simple",
deps = [
":message",
],
)

rust_prost_library(
name = "simple_rs",
proto = ":simple",
)
```

I can compile `message_rs` just fine (command: `bazel build //simple:message_rs`. However, it causes problems when compiling `simple_rs` (command: `bazel build //simple:simple_rs`):

```bash
ERROR: /Users/.../BUILD.bazel:26:14: ProstGenProto //simple:simple failed: (Exit 101): protoc_wrapper failed: error executing ProstGenProto command (from target //simple:simple) bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/rules_rust~/proto/prost/private/protoc_wrapper '--protoc=bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/protobuf~/protoc' ... (remaining 16 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
Missing input file.
thread 'main' panicked at external/rules_rust~/proto/prost/private/protoc_wrapper.rs:751:9:
protoc failed with status: 1
stack backtrace:
0: _rust_begin_unwind
1: core::panicking::panic_fmt
2: protoc_wrapper::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Target /simple:simple_rs failed to build
Use --verbose_failures to see the command lines of failed build steps.
```

To me this looks like a gap in the prost rules to cover alias libraries that are allowed by [official docs](https://bazel.build/reference/be/protocol-buffer#proto_library):

> One usecase where srcs can be empty is an alias-library. This is a proto_library rule having one or more other proto_library in deps. This pattern can be used to e.g. export a public api under a persistent name.

Or am I missing a compile flag for prost here?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.