[FIPS 4.0 CHERRY PICK] Generate Rust Bindings (#2999)#3048
Merged
justsmth merged 1 commit intoaws:fips-2025-09-12from Feb 26, 2026
Merged
[FIPS 4.0 CHERRY PICK] Generate Rust Bindings (#2999)#3048justsmth merged 1 commit intoaws:fips-2025-09-12from
justsmth merged 1 commit intoaws:fips-2025-09-12from
Conversation
* Addresses: V2090958423 This adds CMake support for generating Rust FFI bindings from the AWS-LC public C headers using `bindgen-cli`. This is intended for use by downstream Rust consumers so that bindings can be generated directly from the CMake build system. **New CMake option:** `-DGENERATE_RUST_BINDINGS=ON` (off by default) When enabled, the build: 1. Validates that `bindgen-cli` (≥0.69.5) and `rustfmt` are available 2. Auto-discovers all public OpenSSL headers and generates a `rust_wrapper.h` aggregation header 3. Invokes `bindgen` to produce `aws_lc_bindings.rs` in the build directory 4. Supports the existing `BORINGSSL_PREFIX` mechanism — uses `--prefix-link-name` so Rust-side function names stay unprefixed while `#[link_name]` attributes carry the prefix for the linker 5. During install, the bindings are placed at `$INSTALL_DIR/share/rust/aws_lc_bindings.rs` **Files added:** - `cmake/rust_bindings.cmake` — Module containing the header discovery, prefix formatting, and bindgen invocation logic - `cmake/rust_wrapper.h.in` — Template header that aggregates all public headers for bindgen input - The prefix symbols header (`boringssl_prefix_symbols.h`) is intentionally excluded from bindgen's input. The rationale is documented in the module-level comment in `cmake/rust_bindings.cmake`. - The `rust_bindings` target is not part of `ALL`. It is built on-demand when explicitly requested (`--target rust_bindings`) or automatically during `cmake --install`. - Platform-specific symbol prefix formatting (Apple/Win32 leading underscore) is handled by `get_symbol_prefix_format()`. CI workflow added in `.github/workflows/aws-lc-rs.yml` (`cmake-rust-bindings` job) covering: - Linux (no prefix) - Linux with `BORINGSSL_PREFIX=AWSLC` - macOS (no prefix) - macOS with `BORINGSSL_PREFIX=AWSLC` - Windows (no prefix) Each matrix entry verifies that bindings are generated, contain expected symbols, have correct prefix behavior, and compile as valid Rust. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## fips-2025-09-12 #3048 +/- ##
================================================
Coverage 78.73% 78.73%
================================================
Files 667 667
Lines 113072 113072
Branches 16056 16057 +1
================================================
+ Hits 89028 89031 +3
+ Misses 23271 23266 -5
- Partials 773 775 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
WillChilds-Klein
approved these changes
Feb 26, 2026
samuel40791765
approved these changes
Feb 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Originally: #2999
Issues:
Description of changes:
This adds CMake support for generating Rust FFI bindings from the AWS-LC public C headers using
bindgen-cli. This is intended for use by downstream Rust consumers so that bindings can be generated directly from the CMake build system.New CMake option:
-DGENERATE_RUST_BINDINGS=ON(off by default)When enabled, the build:
bindgen-cli(≥0.69.5) andrustfmtare availablerust_wrapper.haggregation headerbindgento produceaws_lc_bindings.rsin the build directoryBORINGSSL_PREFIXmechanism — uses--prefix-link-nameso Rust-side function names stay unprefixed while#[link_name]attributes carry the prefix for the linker$INSTALL_DIR/share/rust/aws_lc_bindings.rsFiles added:
cmake/rust_bindings.cmake— Module containing the header discovery, prefix formatting, and bindgen invocation logiccmake/rust_wrapper.h.in— Template header that aggregates all public headers for bindgen inputCall-outs:
boringssl_prefix_symbols.h) is intentionally excluded from bindgen's input. The rationale is documented in the module-level comment incmake/rust_bindings.cmake.rust_bindingstarget is not part ofALL. It is built on-demand when explicitly requested (--target rust_bindings) or automatically duringcmake --install.get_symbol_prefix_format().Testing:
CI workflow added in
.github/workflows/aws-lc-rs.yml(cmake-rust-bindingsjob) covering:BORINGSSL_PREFIX=AWSLCBORINGSSL_PREFIX=AWSLCEach matrix entry verifies that bindings are generated, contain expected symbols, have correct prefix behavior, and compile as valid Rust.
Call-outs:
Point out areas that need special attention or support during the review process. Discuss architecture or design changes.
Testing:
How is this change tested (unit tests, fuzz tests, etc.)? Are there any testing steps to be verified by the reviewer?
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.