-
Notifications
You must be signed in to change notification settings - Fork 517
Open
Labels
Description
What
Hey! I have a project using the rust bindings for envoys dynamic modules sdk that I am trying to bring into a monorepo. When I try to include it in my project it fails to compile.
Currently cargo successfully builds this crate. Bazel raises this error.
thread 'main' panicked at external/rules_rust++crate+crates__envoy-proxy-dynamic-modules-rust-sdk-0.1.0/build.rs:29:6:
Unable to generate bindings: NotExist("../../abi_version.h")This crate generates bindings from cc sources outside of the crate root.
Full Error
ERROR: /home/user/.cache/bazel/_bazel_user/34c6fa7f467484e23b6742c76862b361/external/rules_rust++crate+crates__envoy-proxy-dynamic-modules-rust-sdk-0.1.0/BUILD.bazel:77:19: Running Cargo build script envoy-proxy-dynamic-modules-rust-sdk failed: (Exit 1): runner failed: error executing CargoBuildScriptRun command (from target @@rules_rust++crate+crates__envoy-proxy-dynamic-modules-rust-sdk-0.1.0//:_bs) bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/rules_rust+/cargo/cargo_build_script_runner/runner ... (remaining 10 arguments skipped)
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
Build script process failed with exit code 101
--stdout:
cargo:rerun-if-changed=abi.h
cargo:rerun-if-env-changed=TARGET
cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS
cargo:rerun-if-changed=../../abi.h
cargo:rerun-if-changed=../../abi_version.h
--stderr:
thread 'main' panicked at external/rules_rust++crate+crates__envoy-proxy-dynamic-modules-rust-sdk-0.1.0/build.rs:29:6:
Unable to generate bindings: NotExist("../../abi_version.h")
stack backtrace:
0: 0x55d4cb823472 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hdcfcb6d4c8489523
1: 0x55d4cb84a063 - core::fmt::write::h8a494366950f23bb
2: 0x55d4cb8203f3 - std::io::Write::write_fmt::h6556609fca33d0b1
3: 0x55d4cb8232c2 - std::sys::backtrace::BacktraceLock::print::hb2a626a81e06b2dc
4: 0x55d4cb8247a3 - std::panicking::default_hook::{{closure}}::h4f78485264f12d10
5: 0x55d4cb824585 - std::panicking::default_hook::h2c66fc99e962531d
6: 0x55d4cb8251b5 - std::panicking::rust_panic_with_hook::h33ac55f64bbd807d
7: 0x55d4cb824f4a - std::panicking::begin_panic_handler::{{closure}}::h30e7cb89678a57fe
8: 0x55d4cb823979 - std::sys::backtrace::__rust_end_short_backtrace::hed60f27456c16ced
9: 0x55d4cb824bdd - __rustc[de2ca18b4c54d5b8]::rust_begin_unwind
10: 0x55d4cb848530 - core::panicking::panic_fmt::h62f63d096dd276af
11: 0x55d4cb8488f6 - core::result::unwrap_failed::h95bc3f5a607b2c95
12: 0x55d4cb40ddc2 - build_script_build::main::h64096fa5741dcf99
13: 0x55d4cb40aaf3 - std::sys::backtrace::__rust_begin_short_backtrace::h9c32449f57da8917
14: 0x55d4cb40a9c9 - std::rt::lang_start::{{closure}}::h5aeb0c5d39d6e5e1
15: 0x55d4cb81b2c0 - std::rt::lang_start_internal::h34f9328d113fd60a
16: 0x55d4cb40e0c5 - main
17: 0x7f36fa23f575 - __libc_start_call_main
18: 0x7f36fa23f628 - __libc_start_main_alias_2
19: 0x55d4cb4080c5 - _start
20: 0x0 - <unknown>Generated BULID File
###############################################################################
# @generated
# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To
# regenerate this file, run the following:
#
# bazel mod show_repo 'module'
###############################################################################
load(
"@rules_rust//cargo:defs.bzl",
"cargo_build_script",
"cargo_toml_env_vars",
)
load("@rules_rust//rust:defs.bzl", "rust_library")
# buildifier: disable=bzl-visibility
load("@rules_rust//crate_universe/private:selects.bzl", "selects")
package(default_visibility = ["//visibility:public"])
cargo_toml_env_vars(
name = "cargo_toml_env_vars",
src = "Cargo.toml",
)
rust_library(
name = "envoy_proxy_dynamic_modules_rust_sdk",
deps = [
"@crates__envoy-proxy-dynamic-modules-rust-sdk-0.1.0//:build_script_build",
"@crates__mockall-0.13.1//:mockall",
],
compile_data = glob(
allow_empty = True,
include = ["**"],
exclude = [
"**/* *",
".tmp_git_root/**/*",
"BUILD",
"BUILD.bazel",
"WORKSPACE",
"WORKSPACE.bazel",
],
),
crate_root = "src/lib.rs",
edition = "2021",
rustc_env_files = [
":cargo_toml_env_vars",
],
rustc_flags = [
"--cap-lints=allow",
],
srcs = glob(
allow_empty = True,
include = ["**/*.rs"],
),
tags = [
"cargo-bazel",
"crate-name=envoy-proxy-dynamic-modules-rust-sdk",
"manual",
"noclippy",
"norustfmt",
],
target_compatible_with = select({
"@rules_rust//rust/platform:aarch64-apple-darwin": [],
"@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [],
"@rules_rust//rust/platform:wasm32-unknown-unknown": [],
"@rules_rust//rust/platform:wasm32-wasip1": [],
"@rules_rust//rust/platform:x86_64-pc-windows-msvc": [],
"@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [],
"@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
version = "0.1.0",
)
cargo_build_script(
name = "_bs",
compile_data = glob(
allow_empty = True,
include = ["**"],
exclude = [
"**/* *",
"**/*.rs",
".tmp_git_root/**/*",
"BUILD",
"BUILD.bazel",
"WORKSPACE",
"WORKSPACE.bazel",
],
),
crate_name = "build_script_build",
crate_root = "build.rs",
data = glob(
allow_empty = True,
include = ["**"],
exclude = [
"**/* *",
".tmp_git_root/**/*",
"BUILD",
"BUILD.bazel",
"WORKSPACE",
"WORKSPACE.bazel",
],
),
deps = [
"@crates__bindgen-0.70.1//:bindgen",
],
edition = "2021",
pkg_name = "envoy-proxy-dynamic-modules-rust-sdk",
rustc_env_files = [
":cargo_toml_env_vars",
],
rustc_flags = [
"--cap-lints=allow",
],
srcs = glob(
allow_empty = True,
include = ["**/*.rs"],
),
tags = [
"cargo-bazel",
"crate-name=envoy-proxy-dynamic-modules-rust-sdk",
"manual",
"noclippy",
"norustfmt",
],
version = "0.1.0",
visibility = ["//visibility:private"],
)
alias(
name = "build_script_build",
actual = ":_bs",
tags = ["manual"],
)Reproduction Steps
Add dynamic modules to your Cargo.toml. I have also tried this with the starlark rules in my MODULE.bazel to the same effect.
envoy-proxy-dynamic-modules-rust-sdk = { git = "https://github.com/envoyproxy/envoy",rev = "dc2d3098ae5641555f15c71d5bb5ce0060a8015c"}Add the crate to a rust_binary. The code doesn't need to import anything from the crate, it just needs to be in the deps.
rust_binary(
name = "hello_world",
srcs = ["main.rs"],
deps = ["@crates//:envoy-proxy-dynamic-modules-rust-sdk"],
)Build the above target to trigger the error.
bazel build //:hello_world
# see 'full error' above for output