Enable Windows 7 compat path on MinGW builds#3239
Open
justsmth wants to merge 1 commit into
Open
Conversation
The `AWSLC_WINDOWS_7_COMPAT` branch in crypto/rand_extra/windows.c was guarded by `!defined(__MINGW32__)`, which prevented it from being taken on MinGW even though the top-level CMakeLists.txt already sets `-D_WIN32_WINNT=_WIN32_WINNT_WIN7` for MINGW-and-not-Clang builds. As a result, MinGW builds took the ProcessPrng path and aborted at runtime on Windows 7 (GetProcAddress for ProcessPrng returns NULL on Win7). Drop the MinGW guard so the Win7 path is selected when _WIN32_WINNT targets Win7, and add an explicit `bcrypt` link for MinGW since it ignores the `#pragma comment(lib, "bcrypt.lib")` used by MSVC. Addresses aws/aws-lc-rs#1111
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3239 +/- ##
==========================================
+ Coverage 78.12% 78.14% +0.02%
==========================================
Files 689 689
Lines 123214 123214
Branches 17137 17136 -1
==========================================
+ Hits 96257 96286 +29
+ Misses 26047 26018 -29
Partials 910 910 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This was referenced May 11, 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.
Issues:
Addresses aws/aws-lc-rs#1111
Description of changes:
crypto/rand_extra/windows.cgates the Windows 7 compatibility branch (AWSLC_WINDOWS_7_COMPAT, which usesBCryptGenRandominstead ofProcessPrng) on:The
!defined(__MINGW32__)guard was suppressing that branch on MinGW even though the top-levelCMakeLists.txtalready forces-D_WIN32_WINNT=_WIN32_WINNT_WIN7forMINGW AND NOT CLANG. So MinGW builds were effectively configured to target Windows 7 but then took theProcessPrng/bcryptprimitives.dllpath, which aborts at runtime on Windows 7 becauseGetProcAddressforProcessPrngreturns NULL there.This change drops the MinGW guard so the Win7 path is taken when
_WIN32_WINNTtargets Win7, regardless of toolchain, and adds an explicittarget_link_libraries(... bcrypt)for MinGW incrypto/CMakeLists.txt. The link is required because MinGW ignores the#pragma comment(lib, "bcrypt.lib")that MSVC uses inside the same file.Call-outs:
bcryptlink is added unconditionally on MinGW rather than mirroring the preprocessor condition, since detecting the effective_WIN32_WINNTat configure time is fragile.bcrypt.dllexists on all supported Windows versions, and the extra PE import is negligible when the Win7 branch isn't active.cross-mingwCI job (which sets_WIN32_WINNT=_WIN32_WINNT_WIN7via the top-levelCMakeLists.txt) will now naturally exerciseAWSLC_WINDOWS_7_COMPAT; no new CI job is needed.x86_64-win7-windows-gnuRust target in its builder once this change is pulled in via submodule bump.Testing:
Local cross-compile from macOS with
x86_64-w64-mingw32-gcc14.0.0:libcrypto.abuilds;nmonrand_extra/windows.c.objshows onlyU BCryptGenRandom.libcrypto.dlllinks cleanly;objdump -xshowsbcrypt.dll/BCryptGenRandomin the import table and nobcryptprimitives.dll/ProcessPrngreferences.The existing
cross-mingwCI job will now exercise this code path end-to-end under Wine (Wine implementsBCryptGenRandom).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.