dtolnay / cxx

Safe interop between Rust and C++
https://cxx.rs
Apache License 2.0
5.68k stars 320 forks source link

Error in configuring crates_universe when included as a Bazel module #1348

Open tel opened 1 month ago

tel commented 1 month ago

I'm attempting to include CXX as a Bzlmod module. Since it is not published on the Bazel Central Registry I'm doing so via a git_override

git_override(
    module_name = "cxx.rs",
    commit = "462896c80629a51ddcdc72fa55af0bb4befbb675",
    patches = [
        "//repo_patches:add_rules_cc_to_cxx.patch",
    ],
    remote = "https://github.com/dtolnay/cxx.git",
)

where the add_rules_cc_to_cxx.patch modifies cxx's MODULE.bazel file to include an explicit dependency on rules_cc, something that I found was necessary to allow Bazel to even attempt to build any targets in @cxx.rs//.

Unfortunately, this still fails due to a repo lookup failure that gets memorialized into the MODULE.bazel.lock file. The details are available in this minimal reproduction

https://github.com/tel/cxx_bzlmod_repro

I think this may be an error in rules_rust or how crate_universe is being configured, but I wanted to start here and escalate if necessary.