bazelbuild / rules_rust

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

rust_benchmark: expected value of type 'File or NoneType' for parameter 'sibling', for call to method #231

Open prestonvanloon opened 5 years ago

prestonvanloon commented 5 years ago
        File "/home/preston/.cache/bazel/_bazel_preston/3c9e35e32d4309221d1ab3ca894b94ae/external/io_bazel_rules_rust/rust/private/rust.bzl", line 201, in _rust_benchmark_impl
                ctx.actions.declare_file("{}_bin".format(bench_script.bas...), ...)
expected value of type 'File or NoneType' for parameter 'sibling', for call to method declare_file(filename, sibling = None) of 'actions'

https://github.com/bazelbuild/rules_rust/blob/adccbbad58411657102ab8168aee7c5f4ff3af4c/rust/private/rust.bzl#L200-L204

prestonvanloon commented 5 years ago

ctx.bin_dir is not a file, but is a root: https://docs.bazel.build/versions/master/skylark/lib/ctx.html#bin_dir

Is there an example of rust_benchmark? I don't think this rule works at all.

prestonvanloon commented 5 years ago

Found the example. To reproduce this, run bazel build //fibonacci:fibonacci_bench from the examples directory.

mfarrugi commented 5 years ago

The benchmark example is skipped for CI because we're running with stable. iirc you are running with nightly, which is a requirement for benchmarks to run at all (ie. the bazel build invocation implies a nightly toolchain).

I would fully believe that either or both:

prestonvanloon commented 5 years ago

I think this is a starlark code bug, not nightly rust issue

Build label: 0.25.3
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Thu May 23 19:25:07 2019 (1558639507)
Build timestamp: 1558639507
Build timestamp as int: 1558639507

Running bazel build on a test benchmark actually runs the benchmark? Wouldn't it be more idiomatic to run the test on bazel test?

mfarrugi commented 5 years ago

I'm saying that benchmarks require nightly, which is why the starlark code is untested and likely broken.

bazel build should build the benchmark + wrapper script, bazel run should run the benchmark. It was a test before, but having a benchmark do a bunch of not-actually-a-test work seemed inappropriate.

a1ph commented 3 years ago

Is there a solution? The rule seems to be completely broken as of Bazel 4.0.0