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

rust_bindgen should not require a static library #2704

Open
neilisaac opened this issue Jun 18, 2024 · 1 comment · May be fixed by #2742
Open

rust_bindgen should not require a static library #2704

neilisaac opened this issue Jun 18, 2024 · 1 comment · May be fixed by #2742

Comments

@neilisaac
Copy link
Contributor

neilisaac commented Jun 18, 2024

rust_bindgen currently asserts that the cc_lib has an associated static library to link: https://github.com/bazelbuild/rules_rust/blob/main/bindgen/private/bindgen.bzl#L140. This is problematic for use cases where this cannot be satisfied.

Example use cases:

  • 3rd party vendor provides a pre-compiled shared object and header only (used via cc_library + cc_import)
  • generating rust constants from a header file without any code to link to

Ideally rust_bindgen should just be a code generator that does not impose any additional requirements not needed by bindgen itself, or a separate un-opinionated interoperable code generation rule should be provided.

@neilisaac neilisaac changed the title rust_bindgen should not require compile_data rust_bindgen should not require a static library Jun 18, 2024
@neilisaac
Copy link
Contributor Author

I worked around this by generating an empty .cc file and creating a dummy cc_library target that depends on it + the headers, which is passed to cc_lib, then I wrap rust_bindgen with a rust_library that adds the real shared object to deps.

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 a pull request may close this issue.

1 participant