-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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-cli: alternate use of bindgen - v1 #12139
base: master
Are you sure you want to change the base?
Commits on Nov 21, 2024
-
rust: integrate bindgen to generate rust bindings to C
Add a minimal integration of bindgen to the build. Bindgen is integrated at compile time with a "build.rs" file that for now only generates AppLayerEventType Rust bindings. This required some refactoring of the C so app-layer-events.h did not also include "rust.h", which causes issues for bindgen, probably related to circular references. AppLayerEventType was chosen as the first step as its an argument type some app-layer functions that we may want to use bindgen to export Rust, and one of the requirements of bindgen might be that C functions should only use datatypes defined in C, and not Rust. Following such a rule also prevents circular dependencies between Rust and C code. Bindgen generates the bindings in a file named "bindings.rs" in the target/ direction, which "sys.rs" will statically "include" at compiling name, making these bindings available under package "crate::sys". "build.rs" had to be placed in the non-standard location of "src/build.rs" (its usually alongside Cargo.toml) to satisfy the out-of-tree build requirements of distcheck. Note that bindgen is also available as a command line tool which could be used instead of integrating this at compile time, however the tool requires a newer version of Rust than our MSRV, and may present additional issues with respect to autoconf and distcheck.
Configuration menu - View commit details
-
Copy full SHA for 51b972a - Browse repository at this point
Copy the full SHA 51b972aView commit details -
app-layer: rename AppLayerEventType to SCAppLayerEventType
Follow the naming scheme for public exports.
Configuration menu - View commit details
-
Copy full SHA for 4adaef3 - Browse repository at this point
Copy the full SHA 4adaef3View commit details -
app-layer: remove prototypes from decode.h
This lets us remove decode.h from app-layer-events.h as pulling in app-layer-events.h shouldn't result in pulling in dpdk, and other includes not related to app-layer-events. decode.h also doesn't need those forward declarations anymore due to previous changes.
Configuration menu - View commit details
-
Copy full SHA for d810bed - Browse repository at this point
Copy the full SHA d810bedView commit details -
bindgen: export SCAppLayerStateGetEventInfoByIdFn from C to Rust
Instead of defining this function pointer in type in Rust, and having it in C signatures, create a type and export it to Rust. To facilitate this, and new header has been creates, "app-layer-types.h", this is to avoid the circular reference of C headers pulling in "rust.h" which are required to generate Rust bindings.
Configuration menu - View commit details
-
Copy full SHA for 2c05b35 - Browse repository at this point
Copy the full SHA 2c05b35View commit details -
bindgen: export AppProto and AppProtoEnum to Rust
This exposes the C define ALPROTO values to Rust without having to perform some runtime initialization with init_ffi. As app-layer-protos.h was clean of a circular reference to rust.h we could use it directly, it just needed the addition of suricata-common.h.
Configuration menu - View commit details
-
Copy full SHA for 3ff6063 - Browse repository at this point
Copy the full SHA 3ff6063View commit details -
Configuration menu - View commit details
-
Copy full SHA for ec9ab02 - Browse repository at this point
Copy the full SHA ec9ab02View commit details -
bindgen: use bindgen-cli instead of library
Replace bindgen usage from build.rs with the bindgen-cli program much like we use cbindgen. As bindgen can only accept one header file, we construct a pseudo-header file of all the headers that need to be consumed. Makefile dependency checking is done to make sure the pseudo-header is only generated as needed to avoid rebuilding every time. Special handling is required for Windows to use the Windows path.
Configuration menu - View commit details
-
Copy full SHA for 748fb24 - Browse repository at this point
Copy the full SHA 748fb24View commit details -
bindgen: use --allowlist-type instead of --allowlist-item
The bindgen found in Ubuntu 24.04 and older is not new enough for --allowlist-item.
Configuration menu - View commit details
-
Copy full SHA for 199db46 - Browse repository at this point
Copy the full SHA 199db46View commit details -
Configuration menu - View commit details
-
Copy full SHA for 154e6b3 - Browse repository at this point
Copy the full SHA 154e6b3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 4e75afe - Browse repository at this point
Copy the full SHA 4e75afeView commit details