Skip to content

fix: support building with MinGW on Windows 7#1120

Merged
justsmth merged 1 commit into
aws:mainfrom
justsmth:fix-win7-gnu
May 12, 2026
Merged

fix: support building with MinGW on Windows 7#1120
justsmth merged 1 commit into
aws:mainfrom
justsmth:fix-win7-gnu

Conversation

@justsmth
Copy link
Copy Markdown
Contributor

Issues:

Addresses:

Description of changes:

Enable x86_64-win7-windows-gnu (and similar win7 MinGW triples) to build and run on Windows 7 by routing CRYPTO_sysrand through BCryptGenRandom instead of ProcessPrng.

The upstream C source (crypto/rand_extra/windows.c) guards the Win7-compatible code path with !defined(__MINGW32__), so MinGW builds always take the ProcessPrng path — which aborts on Windows 7 because that API only exists on Windows 8+. This change works around the guard by defining AWSLC_WINDOWS_7_COMPAT directly from the build script for win7-gnu targets, and explicitly links bcrypt (since MinGW ignores the MSVC #pragma comment(lib, ...) in the source).

Call-outs:

This is a temporary workaround. The proper fix is aws/aws-lc#3239, which drops the !defined(__MINGW32__) guard upstream. Once that merges and we bump the submodule, the AWSLC_WINDOWS_7_COMPAT define can be removed. The _WIN32_WINNT and bcrypt link will still be needed for the CC builder path.

The existing win7-msvc handling was refactored into the same if target().contains("-win7-windows-") block so both toolchains share the _WIN32_WINNT=0x0601 define in one place.

Testing:

Build-tested with cargo check -p aws-lc-sys. Full validation requires a MinGW cross-compile targeting x86_64-win7-windows-gnu, which will be exercised once the upstream fix and a CI job are in place.

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.

@justsmth justsmth requested a review from a team as a code owner May 11, 2026 21:00
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.71%. Comparing base (c358484) to head (eef2aad).
⚠️ Report is 378 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1120      +/-   ##
==========================================
- Coverage   95.80%   92.71%   -3.09%     
==========================================
  Files          61       71      +10     
  Lines        8143    10248    +2105     
  Branches        0    10248   +10248     
==========================================
+ Hits         7801     9501    +1700     
- Misses        342      451     +109     
- Partials        0      296     +296     

☔ 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.

@dougch dougch self-requested a review May 11, 2026 21:40
@justsmth justsmth merged commit 4fdf672 into aws:main May 12, 2026
404 checks passed
@justsmth justsmth deleted the fix-win7-gnu branch May 12, 2026 00:22
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