Support pregenerated Rust bindings from AWS-LC installations#2578
Support pregenerated Rust bindings from AWS-LC installations#2578alex merged 3 commits intorust-openssl:masterfrom
Conversation
alex
left a comment
There was a problem hiding this comment.
What's the backwards compatibility/versioning/linking strategy for these?
We definitely want to maintain backward compatibility with all existing AWS-LC installations. Even with the latest versions, the pregeneration of Rust bindings during AWS-LC's build is optional, and will likely always be. The linking strategy is unchanged — In fact, testing against an installation without pregenerated bindings caught a bug in my original patch (sorry! 😬): the pure-Rust |
alex
left a comment
There was a problem hiding this comment.
(I'm looking at the failing CI job separately)
5a68907 to
5ae69dd
Compare
|
Thanks for getting this done @justsmth! And thanks @alex for the review! Would it be possible to cut a patch release sometime soon? We've accumulated quite a few nice features and fixes since openssl-sys@0.9.111 :) |
|
If someone sends a PR with the changelogs + version bumps, I'm happy to cut a release. If not, I can try to get to it this weekend. |
Description:
AWS-LC can now optionally generate and install Rust bindings at
$PREFIX/share/rust/aws_lc_bindings.rs. This PR teachesopenssl-systo discover and use those bindings, removing the need for bindgen (or bindgen-cli) at build time when they're present.The detection logic lives in
try_pregenerated_awslc_bindings, which looks for the file relative to the include directory. When found, it copies the bindings intoOUT_DIR/bindgen.rsand short-circuits both bindgen and the static wrapper C compilation step. If the file isn't present, the existing bindgen / bindgen-cli path runs exactly as before. Both thebindgenfeature and non-bindgencode paths are covered.Because the pregenerated bindings don't include static inline functions or C preprocessor macros, pure-Rust implementations of
ERR_GET_LIB,ERR_GET_REASON,ERR_GET_FUNC, andBIO_get_mem_dataare provided in theaws_lcmodule. The existingBIO_get_mem_datashim was already there; the error helpers are new and match the logic inaws-lc-sys. These shims are gated with#[cfg(any(feature = "aws-lc", feature = "aws-lc-fips", awslc_pregenerated))]to avoid conflicting with theextern "C"declarations that bindgen'swrap_static_fnsproduces on the normal (non-pregenerated) path.A few things worth noting for review:
::std::os::raw::*types rather than::libc::*(since they weren't generated withctypes_prefix). These are the same underlying types, so there's no compatibility issue.#[allow(unpredictable_function_pointer_comparisons)]is added to theaws_lcmodule because the pregenerated bindings derivePartialEqon structs containing function pointer fields. When usingaws-lc-sysas a crate dependency this lint is scoped to that crate; withinclude!-d bindings it surfaces here instead.OPENSSL_DIR, normal bindgen viaOPENSSL_DIR(without pregenerated bindings), and theaws-lccrate feature.