Skip to content

Add Windows 64-bit cross-compilation support via MinGW-w64#76

Open
covertmatthew wants to merge 1 commit into
masterfrom
win64-build
Open

Add Windows 64-bit cross-compilation support via MinGW-w64#76
covertmatthew wants to merge 1 commit into
masterfrom
win64-build

Conversation

@covertmatthew
Copy link
Copy Markdown
Contributor

@covertmatthew covertmatthew commented May 13, 2026

  • Add buildx/Dockerfile.mingw64 for cross-compiling with Fedora MinGW toolchain
  • Update docs/INSTALL.md with Windows 64-bit build instructions
  • Add win64 build entry to CHANGELOG.md
  • Add output-win64/ to .gitignore

A note on Windows 64-bit data model compatibility (LLP64 vs LP64)...

Windows 64-bit uses the LLP64 data model where long is 32-bit, unlike Linux 64-bit (LP64) where long is 64-bit. MinGW-w64 correctly follows the Windows convention, which means CK_ULONG (unsigned long) is 32-bit on Windows. This is expected and matches all Windows PKCS#11 provider DLLs. MinGW's lsearch/lfind functions accept unsigned int * for the element count parameter, while the codebase uses size_t * (POSIX convention). A compatibility wrapper (mingw_compat.h, generated at build time in the Dockerfile) bridges this mismatch by converting between size_t and unsigned int for the element count argument.

While this represents a theoretical precision loss (64-bit to 32-bit), it is safe in practice because the values represent the number of PKCS#11 attributes in a template array, typically 10–50 elements, never exceeding a few hundred. Exceeding UINT_MAX (~4.3 billion) elements would require hundreds of gigabytes of RAM for the array alone, which is not a realistic scenario.

- Add buildx/Dockerfile.mingw64 for cross-compiling with Fedora MinGW toolchain
- Update docs/INSTALL.md with Windows 64-bit build instructions
- Add win64 build entry to CHANGELOG.md
- Add output-win64/ to .gitignore
@covertmatthew covertmatthew requested a review from keldonin May 13, 2026 16:24
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.

1 participant