-
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?
Conversation
b64eeb7
to
4869aff
Compare
AC_PATH_PROG([BINDGEN], [bindgen], [no]) | ||
if test "x$BINDGEN" = "xno"; then | ||
AC_MSG_ERROR([bindgen required]) | ||
fi |
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.
The idea is that when building from a distribution archive this wouldn't be required. Just like cbindgen.
eac1b70
to
e4ccf11
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #12139 +/- ##
===========================================
+ Coverage 49.77% 75.05% +25.27%
===========================================
Files 909 848 -61
Lines 257884 155587 -102297
===========================================
- Hits 128367 116775 -11592
+ Misses 129517 38812 -90705
Flags with carried forward coverage won't be shown. Click here to find out more.
|
ERROR: ERROR: QA failed on build_asan. Pipeline 23468 |
e4ccf11
to
1d5f58c
Compare
ERROR: ERROR: QA failed on build_asan. Pipeline 23469 |
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.
Follow the naming scheme for public exports.
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.
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.
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.
587acd0
to
3f1f490
Compare
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.
The bindgen found in Ubuntu 24.04 and older is not new enough for --allowlist-item.
3f1f490
to
4e75afe
Compare
Like #12062, but uses the bindgen-cli tool.
Currently requires it to exist, but the idea is that a distribution archive would provide the bindings, meaning users of the release would not require bindgen to be install (and the clang tooling it requires).
Draft as I'm figuring out some Windows issue, also an issue on the other PR.