Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for rustc flags to rust_proto_library #1932

Merged
merged 4 commits into from
Apr 24, 2023

Conversation

UebelAndre
Copy link
Collaborator

When updating the version of Rust in #1930 I came across an error in the proto rules

(13:12:48) ERROR: /workdir/test/proto/BUILD.bazel:17:19: Clippy test/proto/b_rust.proto.rust/b_rust.clippy.ok failed: (Exit 1): process_wrapper failed: error executing command (from target //test/proto:b_rust)
  (cd /var/lib/buildkite-agent/.cache/bazel/_bazel_buildkite-agent/ec321eb2cc2d0f8f91b676b6d4c66c29/sandbox/linux-sandbox/1824/execroot/rules_rust && \
  exec env - \
    CARGO_CFG_TARGET_ARCH=x86_64 \
    CARGO_CFG_TARGET_OS=linux \
    CARGO_CRATE_NAME=b_rust \
    CARGO_MANIFEST_DIR='${pwd}/test/proto' \
    CARGO_PKG_AUTHORS='' \
    CARGO_PKG_DESCRIPTION='' \
    CARGO_PKG_HOMEPAGE='' \
    CARGO_PKG_NAME=b_rust \
    CARGO_PKG_VERSION=0.0.0 \
    CARGO_PKG_VERSION_MAJOR=0 \
    CARGO_PKG_VERSION_MINOR=0 \
    CARGO_PKG_VERSION_PATCH=0 \
    CARGO_PKG_VERSION_PRE='' \
    CLIPPY_CONF_DIR='${pwd}/tools/clippy' \
    SYSROOT=bazel-out/k8-fastbuild/bin/external/rust_linux_x86_64__x86_64-unknown-linux-gnu__nightly_tools/rust_toolchain \
  bazel-out/k8-opt-exec-2B5CBBC6/bin/util/process_wrapper/process_wrapper --arg-file bazel-out/k8-fastbuild/bin/external/rules_rust_proto__libc-0.2.139/libc_build_script.linksearchpaths --arg-file bazel-out/k8-fastbuild/bin/external/rules_rust_proto__protobuf-2.8.2/protobuf_build_script.linksearchpaths --subst 'pwd=${pwd}' --touch-file bazel-out/k8-fastbuild/bin/test/proto/b_rust.proto.rust/b_rust.clippy.ok -- bazel-out/k8-fastbuild/bin/external/rust_linux_x86_64__x86_64-unknown-linux-gnu__nightly_tools/rust_toolchain/bin/clippy-driver bazel-out/k8-fastbuild/bin/test/proto/b_rust.proto.rust/lib.rs '--crate-name=b_rust' '--crate-type=rlib' '--error-format=human' '--codegen=metadata=-224398518' '--codegen=extra-filename=-224398518' '--out-dir=bazel-out/k8-fastbuild/bin/test/proto/b_rust.proto.rust' '--codegen=opt-level=0' '--codegen=debuginfo=0' '--remap-path-prefix=${pwd}=' '--emit=dep-info,metadata' '--color=always' '--target=x86_64-unknown-linux-gnu' -L bazel-out/k8-fastbuild/bin/external/rust_linux_x86_64__x86_64-unknown-linux-gnu__nightly_tools/rust_toolchain/lib/rustlib/x86_64-unknown-linux-gnu/lib '--edition=2018' '--extern=protobuf=bazel-out/k8-fastbuild/bin/external/rules_rust_proto__protobuf-2.8.2/libprotobuf-551824660.rlib' '-Ldependency=bazel-out/k8-fastbuild/bin/external/rules_rust_proto__byteorder-1.4.3' '-Ldependency=bazel-out/k8-fastbuild/bin/external/rules_rust_proto__libc-0.2.139' '-Ldependency=bazel-out/k8-fastbuild/bin/external/rules_rust_proto__iovec-0.1.4' '-Ldependency=bazel-out/k8-fastbuild/bin/external/rules_rust_proto__bytes-0.4.12' '-Ldependency=bazel-out/k8-fastbuild/bin/external/rules_rust_proto__protobuf-2.8.2' -Dwarnings)
# Configuration: f536cc10af391e0e7d5cac77a213b18582941d039d39ba1a143b8cea1b58f3ce
# Execution platform: @local_config_platform//:host
 
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
error: ambiguous glob re-exports
 --> bazel-out/k8-fastbuild/bin/test/proto/b_rust.proto.rust/lib.rs:3:9
  |
3 | pub use a::*;
  |         ^^^^ the name `file_descriptor_proto` in the value namespace is first re-exported here
4 | pub mod b;
5 | pub use b::*;
  |         ---- but the name `file_descriptor_proto` in the value namespace is also re-exported here
  |
  = note: `-D ambiguous-glob-reexports` implied by `-D warnings`
 
error: aborting due to previous error

I've opted for a means to silence this warning vs fixing it because I'm generally unfamiliar with the proto rules and I suspect they will be replaced by @com_google_protobuf//rust in the future.

Thus, I've added rustc_flags which allow users to pass flags directly to the Rust compiler when building proto targets.

@UebelAndre UebelAndre enabled auto-merge (squash) April 24, 2023 13:42
@UebelAndre UebelAndre merged commit 7677c61 into bazelbuild:main Apr 24, 2023
@UebelAndre UebelAndre deleted the proto branch April 24, 2023 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants