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
compile: Add minimal bindgen
allowlist_function()
support
#20
Conversation
By default `bindgen` emits bindings for every item in the provided header, which are typically platform- and architecture-specific defines from `stdint.h` and `stdbool.h`. This is noisy and unnecessary as the function signatures typically don't use any of these. By allowing the user to set a custom list of function names, bindgen only emits bindings for said functions and any type(s) they (recursively) reference. Unfortunately `bindgen::Builder` cannot be cloned and is moved by every call, which doesn't allow us to call `.generate()` on it multiple times (and neatly add the `header()` without updating the underlying struct). In contrast, `Config::compile()` here borrows `self` and requires the builder struct to be reusable across possibly multiple calls on the same `Config`. For this reason a minimal struct has been added that currently only supports `allowlist_function()`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @MarijnS95 , this looks great!
It'd be a bit nicer if the whole bindgen options could be cloned since then we wouldn't need to do any work to add support for specifying other ones, but this will work well to get around that limitation. We can add other bindgen options as needed for folks through this same route
I think CI should pass after I merge this to master since then it'll pick up your commit removing aligned_alloc
`ispc_compile` can now be configured to omit irrelevant bindings from the bindings file and leave only the function(s) in place that are relevant to interface with the ISPC kernel (Twinklebear/ispc-rs#20). This makes the file less busy/noisy, and it won't change when regenerating across OS-es anymore.
`ispc_compile` can now be configured to omit irrelevant bindings from the bindings file and leave only the function(s) in place that are relevant to interface with the ISPC kernel (Twinklebear/ispc-rs#20). This makes the file less busy/noisy, and it won't change when regenerating across OS-es anymore.
`ispc_compile` can now be configured to omit irrelevant bindings from the bindings file and leave only the function(s) in place that are relevant to interface with the ISPC kernel (Twinklebear/ispc-rs#20). This makes the file less busy/noisy, and it won't change when regenerating across OS-es anymore.
`ispc_compile` can now be configured to omit irrelevant bindings from the bindings file and leave only the function(s) in place that are relevant to interface with the ISPC kernel (Twinklebear/ispc-rs#20). This makes the file less busy/noisy, and it won't change when regenerating across OS-es anymore.
`ispc_compile` can now be configured to omit irrelevant bindings from the bindings file and leave only the function(s) in place that are relevant to interface with the ISPC kernel (Twinklebear/ispc-rs#20). This makes the file less busy/noisy, and it won't change when regenerating across OS-es anymore.
`ispc_compile` can now be configured to omit irrelevant bindings from the bindings file and leave only the function(s) in place that are relevant to interface with the ISPC kernel (Twinklebear/ispc-rs#20). This makes the file less busy/noisy, and it won't change when regenerating across OS-es anymore.
* Upgrade to `ispc 1.1.0` with cleaned up bindings file `ispc_compile` can now be configured to omit irrelevant bindings from the bindings file and leave only the function(s) in place that are relevant to interface with the ISPC kernel (Twinklebear/ispc-rs#20). This makes the file less busy/noisy, and it won't change when regenerating across OS-es anymore. * Edition 2018 cleanup
rust-lang/rust-bindgen#2302 looks like this just got implemented, so we might improve the situation soon when a newer |
As announced earlier in Twinklebear#20 when introducing `BindgenOptions`, upstream `bindgen` didn't yet allow cloning nor copying their `Builder` struct, limiting it to generate a single binding per `Builder` object. This doesn't fit with ispc-rs's `Config` struct which explicitly allows multiple libraries to be compiled using (partially) the same base configuration (barring any side-effects from `fn compile(&mut self, lib)` updating various fields depending on `lib`). This issue has since been addressed upstream, and now allows us to move and clone the `bindgen::Builder` around instead of implementing a very limited subset of config fields and manually reconstructing the builder every time.
By default
bindgen
emits bindings for every item in the provided header, which are typically platform- and architecture-specific defines fromstdint.h
andstdbool.h
. This is noisy and unnecessary as the function signatures typically don't use any of these.By allowing the user to set a custom list of function names, bindgen only emits bindings for said functions and any type(s) they (recursively) reference.
Unfortunately
bindgen::Builder
cannot be cloned and is moved by every call, which doesn't allow us to call.generate()
on it multiple times (and neatly add theheader()
without updating the underlying struct). In contrast,Config::compile()
here borrowsself
and requires the builder struct to be reusable across possibly multiple calls on the sameConfig
. For this reason a minimal struct has been added that currently only supportsallowlist_function()
.