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

Add new c-bindings feature flag #6

Closed
wants to merge 2 commits into from

Conversation

landonxjames
Copy link

The c bindings generated in build.rs were causing issues for some sandboxed builds. This PR introduces a new feature flag c-bindings that allows building those bindings to be opted in to. It is off by default. This would technically be a breaking change for anyone using the c bindings, so we could instead make it a default feature that can be disabled if that is a worry.

Feature optionally enables building the c bindings. It is off by default.
@lierdakil
Copy link

This would technically be a breaking change for anyone using the c bindings

Not really, because AFAICS the bindings are already checked into the repo and bundled with the crate.

Also, the name of the generated file was changed in 8bf7a42 since the last release, so the next release will be breaking for anyone using C bindings anyway 🤷

Unless I'm missing something, there's no reason not to disable binding generation by default.

@landonxjames
Copy link
Author

landonxjames commented Jan 21, 2025

Note after some digging it looks like our internal build issues were caused by some unexpected behavior in the cbindgen crate around cargo metadata. See this issue for more context: mozilla/cbindgen#666. We are still trying to figure out a way around that, but I think having the bindings be optional here would still be helpful to everyone.

fn main() {
let crate_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
#[cfg(feature = "c-bindings")]
Copy link

@dpc dpc Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also thought that, but this SO question clarified (and this worked locally for me). It doesn't seem to be documented anywhere that I could find.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh. Good to know. Thanks!

@jrandolf
Copy link

jrandolf commented Jan 23, 2025

How about:

  1. Removing the build script.
  2. Creating a test that creates the binding and diffs it against the working directory's crc64fast_nvme.h.
  3. If it fails, then you can pass an env-var to recreate the binding (or just recreate it automatically since it's likely the only action to take.)

@ntrinquier
Copy link

How about:

1. Removing the build script.

2. Creating a test that creates the binding and diffs it against the working directory's `crc64fast_nvme.h`.

3. If it fails, then you can pass an env-var to recreate the binding (or just recreate it automatically since it's likely the only action to take.)

@jrandolf I gave it a try in #9, I will leave it to the maintainers to decide what option they prefer.

@onethumb
Copy link

The implementation in #9 is better, imho, and has been merged in https://github.com/awesomized/crc64fast-nvme/releases/tag/1.2.0. Thanks all!

@onethumb onethumb closed this Feb 18, 2025
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 this pull request may close these issues.

6 participants