Expose bindgen toolchain through bzlmod
With this change I was able to use the default bindgen toolchain with bzlmod by adding this to my MODULE.bazel:
bindgen = use_extension("@rules_rust//bindgen:extension.bzl", "bindgen")
use_repo(bindgen, "bindgen_toolchains")
register_toolchains("@bindgen_toolchains//:default_bindgen_toolchain")
Had to backport a change from recent versions of LLVM which use this WORKSPACE_ROOT environment variable to fix paths to generated files. Updating the LLVM archive would also fix that problem.
Happy to add tests and documentation if this matches what you had in mind for getting this working.
@jwnrt any chance you could pick this up again? Seems like this would fix https://github.com/bazelbuild/rules_rust/issues/2787
@jwnrt any chance you could pick this up again? Seems like this would fix https://github.com/bazelbuild/rules_rust/issues/2787
Sorry, I took my eye off this when I realised I wouldn't need it for OpenTitan.
I'm happy to finish it off but I won't have time for at least a week. Happy for anyone else to take it over if they get there before me.
Aside, it turns out the local_repository thing I switched to using isn't available in Bazel 6, so that might be blocked on https://github.com/bazelbuild/rules_rust/pull/2812. I'll switch it back to the manual re-implementation for now.
I still have no resolution for the repo_mapping thing. It's not supported in Bzlmod, but may break non-bzlmod users who depend on a different version of zlib if removed. The best solution would be for Bzlmod to stop erroring on that parameter and just ignore it. That would be an upstream change.
@jwnrt Hello James, is there any plan to fix this issue? Has a bug been filed with bazelbuild for the repo_mapping issue? Thanks!
Thanks for the reminder, I've updated the PR to resolve those issues.
Based on https://github.com/bazelbuild/bazel/issues/21846 it seems to me that Bazel are moving away from supporting repo_mapping entirely. Even if upstream Bazel stops erroring on repo_mapping for Bzlmod, rules_rust would have to greatly increase its minimum supported Bazel version to benefit.
I've worked around it by making repo_mapping optional (but used by default). I've documented it as being unstable / subject to change.
@jwnrt Thanks for your effort, sounds like a good solution to me. @UebelAndre Could you take another look, so we can merge this PR? The issue blocks the transition of rules_ros2 to bzlmod.
@jwnrt Thank you!! Sorry it took me a while to get back but I appreciate your help!
(just a drive by that this is an exciting change and it would be great to have it merged - thanks @jwnrt and @UebelAndre)
I also keep rebasing this because I need it. Anything I can do to help get this merged?
Hello, is there anything I can do to help get this merged? I've received inquiries from other teams that would like to use bindgen + bzlmod. Thanks!