Skip to content

feat(compat.openssl): add Windows support via VC-WIN64A + nmake sourc… - #6

Open
FarnaHerry wants to merge 3 commits into
mainfrom
feat/openssl-windows-source-build
Open

feat(compat.openssl): add Windows support via VC-WIN64A + nmake sourc…#6
FarnaHerry wants to merge 3 commits into
mainfrom
feat/openssl-windows-source-build

Conversation

@FarnaHerry

Copy link
Copy Markdown
Owner

…e build

The last major package still marked "windows deferred". Unblocks the Windows leg of compat.libmysqlclient, whose mcpp.toml is already wired for it; openssl was the only missing dependency there.

  • xpm: add a windows entry reusing the shared source tarball (same sha256)
  • mcpp: add windows ldflags. lld-link resolves -lX to X.lib, so the MSVC-built static libs must be spelled -llibssl/-llibcrypto; the static libcrypto system deps (ws2_32, crypt32, advapi32, user32) are listed explicitly, the same way the linux leg lists -ldl/-lpthread.
  • install(): route windows to _install_windows() instead of erroring out.
  • _install_windows(): one generated .bat runs under a single vcvars64 invocation and does Configure VC-WIN64A no-shared no-dso no-tests no-apps no-engine no-asm + nmake + install_sw, then verifies libssl.lib/libcrypto.lib exist and writes the anchor TU. Helpers: find_vcvars (vswhere, then known paths), resolve_perl_windows / perl_usable_windows, win_dirname.

Pitfalls found on real hardware, baked into the implementation:

  • the xpkg hook env on Windows has no os.rm (must be pcall'd) and no path.dirname (hand-rolled win_dirname)
  • OpenSSL Configure needs Locale::Maketext::Simple, which MSYS perl (Git-for-Windows) lacks; the existing module probe would wrongly accept it, so the windows check requires Strawberry Perl
  • os.exec("bash -c ...") silently returns true WITHOUT running the command in the Windows hook env, so the windows build drives cmd /c <bat> > <log> 2>&1 directly instead of reusing the shared run()
  • vcvars (cmd /c "vcvars64.bat & set") works fine on Windows 11 + VS 2022/18; the old "takes the whole process chain down" note was a hook-env artifact, not a property of Windows

FARNA-HERRY-OFF\farna added 3 commits August 16, 2026 14:54
…e build

The last major package still marked "windows deferred". Unblocks the
Windows leg of compat.libmysqlclient, whose mcpp.toml is already wired
for it; openssl was the only missing dependency there.

- xpm: add a windows entry reusing the shared source tarball (same sha256)
- mcpp: add windows ldflags. lld-link resolves `-lX` to `X.lib`, so the
  MSVC-built static libs must be spelled `-llibssl`/`-llibcrypto`; the
  static libcrypto system deps (ws2_32, crypt32, advapi32, user32) are
  listed explicitly, the same way the linux leg lists -ldl/-lpthread.
- install(): route windows to _install_windows() instead of erroring out.
- _install_windows(): one generated .bat runs under a single vcvars64
  invocation and does Configure VC-WIN64A no-shared no-dso no-tests
  no-apps no-engine no-asm + nmake + install_sw, then verifies
  libssl.lib/libcrypto.lib exist and writes the anchor TU. Helpers:
  find_vcvars (vswhere, then known paths), resolve_perl_windows /
  perl_usable_windows, win_dirname.

Pitfalls found on real hardware, baked into the implementation:
- the xpkg hook env on Windows has no os.rm (must be pcall'd) and no
  path.dirname (hand-rolled win_dirname)
- OpenSSL Configure needs Locale::Maketext::Simple, which MSYS perl
  (Git-for-Windows) lacks; the existing module probe would wrongly accept
  it, so the windows check requires Strawberry Perl
- os.exec("bash -c ...") silently returns true WITHOUT running the command
  in the Windows hook env, so the windows build drives
  `cmd /c <bat> > <log> 2>&1` directly instead of reusing the shared run()
- vcvars (cmd /c "vcvars64.bat & set") works fine on Windows 11 + VS
  2022/18; the old "takes the whole process chain down" note was a
  hook-env artifact, not a property of Windows
compat.openssl now builds on Windows (VC-WIN64A + nmake), so the
tests/examples/openssl member no longer has to be a no-op main() there.
Declare the dependency and HAVE_OPENSSL on all three platforms; tls.cpp
compiles its real TLS-context + SHA-256 checks on Windows as well.

Verified on Windows (llvm/clang toolchain, MSVC-built libssl.lib +
libcrypto.lib): `mcpp test -p openssl` → tls ... ok (1 passed, 0 failed).
Windows CI failed `mcpp test -p openssl` at install(): find_vcvars ran
vswhere through `os.exec("bash -c …")`, which this hook's Windows
environment silently swallows (returns true, runs nothing), so vswhere's
output file was never written. The search then fell back to hardcoded
vcvars64.bat paths that only covered Community editions — and GitHub
Actions runners carry VS **Enterprise**, so the toolset was never found.

- find_vcvars: drive vswhere through a generated .bat under `cmd /c`
  (the same pattern _install_windows uses), which actually executes and
  is edition-agnostic; keep the hardcoded fallback but expand it to
  Enterprise/BuildTools across the 2022 (17) / 18 (2026) product lines.
- perl_usable_windows: the old probe ran perl via `bash -c`, which also
  no-ops — it accepted ANY perl, including the MSYS perl that lacks
  Locale::Maketext::Simple and dies inside Configure. Probe perl through
  a generated .bat under `cmd /c` and require it to print a marker only
  when the modules load; MSYS perl on PATH now correctly fails the probe.

Verified on hardware: the generated vswhere .bat returns the install
path (and the matching vcvars64.bat), and the perl probe prints `ok` for
Strawberry (scoop) perl while MSYS perl fails it with the missing-module
error. Descriptor still parses with the pinned CI client (2026.8.10.3).
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