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

Bindgen - Errors with bazelmod for missing targets #3137

Closed
YuhanunCitgez opened this issue Dec 24, 2024 · 1 comment · Fixed by #3149
Closed

Bindgen - Errors with bazelmod for missing targets #3137

YuhanunCitgez opened this issue Dec 24, 2024 · 1 comment · Fixed by #3149
Labels
bindgen Relates to Rust Bindgen: https://rust-lang.github.io/rust-bindgen/

Comments

@YuhanunCitgez
Copy link

Hey!

I'm working with bzlmod and these are my files

MODULE.bazel

module(
    name = "aeron",
    version = "0.0.0",
)
bazel_dep(name = "rules_rust_bindgen", version = "0.56.0")
bazel_dep(name = "rules_cc", version = "0.1.0")
bazel_dep(name = "rules_foreign_cc", version = "0.13.0")


### AERON ###
git_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

git_repository(
    name = "reallogic_aeron",
    build_file = "//misc:BUILD.aeron.bazel",
    commit = "eb83c224e5dd8e22fce1d4631c4e5b952697f30d",
    remote = "https://github.com/real-logic/aeron.git",
)

misc/BUILD.aeron.bazel

load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")

filegroup(
    name = "all_srcs",
    srcs = glob(["**/**"]),
)

cmake(
    name = "aeron-lib",
    defines = [
        "BUILD_AERON_ARCHIVE_API=OFF",
        "CMAKE_BUILD_TYPE=Release",
        "AERON_BUILD_SAMPLES=OFF",
        "AERON_INSTALL_TARGETS=OFF",
        "AERON_TEST=OFF",
        "AERON_SYSTEM_TEST=OFF",
    ],
    lib_source = ":all_srcs",
    targets = [
        "aeron_static",
    ],
    visibility = ["//visibility:public"],
)

exports_files(
    [
        "aeron-client/src/main/c/aeronc.h",
    ],
)

shared/aeron-sys/BUILD.bazel

load("@rules_rust_bindgen//:defs.bzl", "rust_bindgen_library")


rust_bindgen_library(
    name = "aeron-sys",
    bindgen_flags = [],
    cc_lib = "@reallogic_aeron//:aeron-lib",
    header = "@reallogic_aeron//:aeron-client/src/main/c/aeronc.h",
)

For some reason I get the following error:

ERROR: Traceback (most recent call last):
        File "/private/var/tmp/_bazel_yuhanun.citgez/de3a364b6442aaec3a05b5dfddcde7ea/external/llvm-project+/clang/BUILD.bazel", line 530, column 13, in <toplevel>
                ] + glob([
Error in glob: glob pattern 'lib/Basic/*.c' didn't match anything, but allow_empty is set to False (the default value of allow_empty can be set with --incompatible_disallow_empty_glob).
ERROR: /private/var/tmp/_bazel_yuhanun.citgez/de3a364b6442aaec3a05b5dfddcde7ea/external/llvm-project+/clang/BUILD.bazel: no such target '@@llvm-project+//clang:libclang': target 'libclang' not declared in package 'clang' defined by /private/var/tmp/_bazel_yuhanun.citgez/de3a364b6442aaec3a05b5dfddcde7ea/external/llvm-project+/clang/BUILD.bazel
ERROR: /private/var/tmp/_bazel_yuhanun.citgez/de3a364b6442aaec3a05b5dfddcde7ea/external/rules_rust_bindgen+/BUILD.bazel:34:32: no such target '@@llvm-project+//clang:libclang': target 'libclang' not declared in package 'clang' defined by /private/var/tmp/_bazel_yuhanun.citgez/de3a364b6442aaec3a05b5dfddcde7ea/external/llvm-project+/clang/BUILD.bazel and referenced by '@@rules_rust_bindgen+//:libclang'
ERROR: Analysis of target '//shared/aeron-sys:aeron-sys__bindgen' failed; build aborted: Analysis failed
INFO: Elapsed time: 0.296s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
FAILED: 
    Fetching repository @@rules_cc++cc_configure_extension+local_config_cc; starting

when it's simply setting up the bindgen... not sure what I'm doing wrong.

Let me know if this is an issue internally and whether I can contribute

@UebelAndre
Copy link
Collaborator

This is because of the missing patches described here https://github.com/bazelbuild/rules_rust/tree/89aec557796a3a404f3458b8643a85d49a789b83/extensions/bindgen/3rdparty/patches

I've not yet looked into whether or not this can be upstreamed somewhere but seemingly since the patches are applied via an override they're ignored by external consumers (oops!).

single_version_override(
module_name = "llvm-project",
patch_strip = 1,
patches = [
"@//3rdparty/patches:llvm-project.incompatible_disallow_empty_glob.patch",
],
)

Feel free to copy the patches for now or maybe open a pull-request to https://github.com/bazelbuild/bazel-central-registry up-streaming the llvm patches?

@UebelAndre UebelAndre added the bindgen Relates to Rust Bindgen: https://rust-lang.github.io/rust-bindgen/ label Dec 24, 2024
fmeum added a commit to bazelbuild/bazel-central-registry that referenced this issue Dec 31, 2024
…_glob (#3507)

An issue was reported in `rules_rust`
(bazelbuild/rules_rust#3137) where some local
patches to satisfy bazelbuild/bazel#8195 were
added to llvm via a `single_version_override` which does not affect
consumers. This change is an attempt to upstream an otherwise noop
change to llvm that supports this flag being flipped in Bazel.

---------

Co-authored-by: Fabian Meumertzheim <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bindgen Relates to Rust Bindgen: https://rust-lang.github.io/rust-bindgen/
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants