bazelbuild / bazelbuild/rules_rust

Data dependencies not passed to `rust_doc`

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

Description

You can use `include_bytes!` in a source file and add an appropriate
`data` dependency to the `rust_library`, and the library will build
fine. But any dependent `rust_doc` target will fail to build:

```
$ bazel build :rustboard_core
INFO: Build completed successfully, 2 total actions
$ bazel build :rustboard_core_doc
INFO: Analyzed target //tensorboard/data/server:rustboard_core_doc (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: /HOMEDIR/git/tensorboard/tensorboard/data/server/BUILD:121:9: Generating rustdoc for rustboard_core (24 files) failed (Exit 1): rustdoc failed: error executing command external/rust_linux_x86_64/bin/rustdoc tensorboard/data/server/lib.rs --crate-name rustboard_core --crate-type rlib --output bazel-out/k8-opt/bin/tensorboard/data/server/rustboard_core_doc ... (remaining 180 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox rustdoc failed: error executing command external/rust_linux_x86_64/bin/rustdoc tensorboard/data/server/lib.rs --crate-name rustboard_core --crate-type rlib --output bazel-out/k8-opt/bin/tensorboard/data/server/rustboard_core_doc ... (remaining 180 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
error: couldn't read tensorboard/data/server/descriptor.bin: No such file or directory (os error 2)
--> tensorboard/data/server/lib.rs:57:52
|
57 | pub const FILE_DESCRIPTOR_SET: &'static [u8] = include_bytes!("descriptor.bin");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: Compilation failed, aborting rustdoc

error: aborting due to 2 previous errors

Target //tensorboard/data/server:rustboard_core_doc failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.529s, Critical Path: 0.40s
INFO: 2 processes: 2 internal.
FAILED: Build did NOT complete successfully
```

Inspecting `bazel aquery` shows that the data dependency is not passed
for the Rustdoc action.

As far as I can tell, the only workaround is to delete the `rust_doc`
target. :-(

I’m on `rules_rust` version acd759b6fe99a3ae518ea6380e8e95653d27bb9e4a6a2a443abf48cb51fecaa7.

See also: #573.

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.