Skip to content

s2n-bignum: Add prefix header to _s2n_bignum_internal.h #2510

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

Merged
merged 1 commit into from
Jul 3, 2025

Conversation

hanno-becker
Copy link
Contributor

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.


AWS-LC's prefix build works by providing a 'prefix header' which prefixes global symbols through a series of #define ... directives. This header needs to be included ahead of the source files it applies to.

  1. For C files, the prefix header is pulled in through openssl/base.h.
  2. For perl-generated ASM files, it comes from openssl/asm_base.h which is #included through xxx-xlate.pl.
  3. In contrast to 1. and 2., for s2n-bignum assembly, the prefix header is indirectly included through an --include directive in the CMakeLists.txt. Similarly, the cc_builder in aws-lc-rs is patched to use such --include clause when building s2n-bignum files.

This commit simplifies and improves the transparency of prefix handling for s2n-bignum files (case 3): Instead of using an --include directive in the build files, it explicitly adds the prefix header in the header _s2n_bignum_internal.h. This header is included by all s2n-bignum assembly. This is functionally equivalent to the previous --include directive, but avoids having to patch CMakeLists.txt or cc_builder.

The cc_builder patch can be removed from aws-lc-rs when convenient -- this commit renders the --include directive redundant, but not harmful.

AWS-LC's prefix build works by providing a 'prefix header' which
prefixes global symbols through a series of `#define ...` directives.
This header needs to be included ahead of the source files it applies to.

1. For C files, the prefix header is pulled in through openssl/base.h.
2. For perl-generated ASM files, it comes from openssl/asm_base.h which
   is `#include`d through `xxx-xlate.pl`.
3. In contrast to 1. and 2., for s2n-bignum assembly, the prefix header
   is indirectly included through an `--include` directive in the
   CMakeLists.txt. Similarly, the cc_builder in aws-lc-rs is patched
   to use such `--include` clause when building s2n-bignum files.

This commit simplifies and improves the transparency of prefix handling
for s2n-bignum files (case 3): Instead of using an `--include` directive
in the build files, it explicitly adds the prefix header in the header
_s2n_bignum_internal.h. This header is included by all s2n-bignum assembly.
This is functionally equivalent to the previous --include directive,
but avoids having to patch CMakeLists.txt or cc_builder.

The cc_builder patch can be removed from aws-lc-rs when convenient --
this commit renders the `--include` directive redundant, but not harmful.

Signed-off-by: Hanno Becker <[email protected]>
@hanno-becker hanno-becker marked this pull request as ready for review June 26, 2025 13:34
@hanno-becker hanno-becker requested a review from a team as a code owner June 26, 2025 13:34
@hanno-becker hanno-becker requested a review from dkostic June 26, 2025 13:34
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.85%. Comparing base (9db959e) to head (cb0c2c4).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2510      +/-   ##
==========================================
- Coverage   78.86%   78.85%   -0.01%     
==========================================
  Files         640      640              
  Lines      109560   109560              
  Branches    15521    15520       -1     
==========================================
- Hits        86401    86392       -9     
- Misses      22460    22469       +9     
  Partials      699      699              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hanno-becker hanno-becker marked this pull request as draft June 27, 2025 03:25
@hanno-becker hanno-becker marked this pull request as ready for review July 1, 2025 08:25
@torben-hansen torben-hansen merged commit b95767e into aws:main Jul 3, 2025
123 of 126 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants