feat(compat.openssl): add Windows support via VC-WIN64A + nmake sourc… - #211
Open
FarnaHerry wants to merge 3 commits into
Open
feat(compat.openssl): add Windows support via VC-WIN64A + nmake sourc…#211FarnaHerry wants to merge 3 commits into
FarnaHerry wants to merge 3 commits into
Conversation
…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
Collaborator
Author
added 2 commits
August 16, 2026 20:03
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).
Collaborator
Author
|
@Sunrisepeak 这次应该好了 |
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.
Summary
Adds Windows support to
compat.openssl— the last major package in the index stillmarked "windows deferred". OpenSSL is built from the same source tarball the other
platforms use, through Windows' only x64 configuration path:
perl Configure VC-WIN64A+nmake, producing MSVC-ABI staticlibssl.lib/libcrypto.lib.This is the missing link that unblocks
compat.libmysqlclienton Windows — itsmcpp.tomlalready has the Windows build segment written (win_timers.cc,-lws2_32, …); openssl was the one dependency it couldn't resolve. This PRintentionally does not add libmysqlclient's windows xpm line; that's the follow-up.
Changes (
pkgs/c/compat.openssl.lua, +192/−6)xpm: add awindowsentry — same source tarball / sha256 as linux/macosx;only the build path differs.
mcpp: addwindowsldflagsNaming matters: the MSVC static libs are
libssl.lib/libcrypto.lib, andlld-link's
-lXlooks forX.lib, so-lsslwould fail — they must be-llibssl/-llibcrypto. Static libcrypto's own system deps(winsock / crypt / registry / windowing) are listed explicitly, mirroring how the
linux leg lists
-ldl/-lpthread.install()routes Windows to_install_windows()instead of erroring out._install_windows()+ helpers — generates one.batthat runs the whole buildinside a single
vcvars64environment (Configure → nmake → install_sw), verifieslibssl.lib/libcrypto.lib, and writes the anchor TU. Helpers:find_vcvars()(vswhere, then well-known VS paths),resolve_perl_windows()/perl_usable_windows()(Strawberry-first, with theextra module probe),
win_dirname()(xpkg has nopath.dirname).Build config:
no-shared no-dso no-tests no-apps no-engine no-asm.Pitfalls for maintainers (all found on real hardware)
These are why the Windows path looks the way it does:
os.rmandpath.dirname. Callingos.rmthrowsattempt to call a nil valueand would take the wholeinstall()down, so it's invoked through
pcall.path.joinexists butpath.dirnamedoesn't —
win_dirname()hand-rolls it.Locale::Maketext::Simple(via Params::Check →IPC::Cmd). Git-for-Windows' MSYS perl doesn't ship it and dies deep inside
Configure. The existing
perl_usable()module check (Config/FindBin/File::Path/…)does not include this module and would wrongly accept MSYS perl, so the Windows
probe explicitly requires
Locale::Maketext::Simple. Strawberry Perl(scoop
perlorC:\Strawberry) is required.os.exec("bash -c …")silently does nothing in the Windows hook env. Itreturns
truebut the command never runs (probed directly: target file notproduced, vswhere output empty). So the Windows branch cannot reuse the shared
run()helper — it drives the build viaos.exec("cmd /c <bat> > <log> 2>&1")instead.
comment claimed "running vcvars in ANY form takes the whole process chain down".
Tested on Windows 11 + VS 2022/18:
cmd /c "vcvars64.bat & set"runs fine (alsoinvoked from bash) and dumps INCLUDE/LIB/PATH correctly. That crash was specific
to the old xlings hook env (almost certainly the same
bash -cno-op as feat: add mcpplibs.tinyhttps 0.2.1 + mcpplibs.llmapi 0.2.4 #3), nota property of Windows.
→ Could a maintainer update the now-outdated note in
.agents/docs/2026-08-05-openssl-windows-todo.md(the "vcvars takes down the processchain" claim) accordingly?
Verification (this machine, full chain)
perl Configure VC-WIN64A no-shared no-tests no-asm --prefix=… --libdir=lib+nmake→libcrypto.lib(48MB) +libssl.lib(10MB).clang-cllinkslibssl.lib + libcrypto.lib + ws2_32 + crypt32 + advapi32 + user32→ minimal test exe printsOpenSSL 3.5.1.mcpp buildfrom scratch: downloads the 50MB tarball → builds inside theinstall()hook → compiles the anchor → links → exe printslinked: OpenSSL 3.5.1 1 Jul 2025. ✅Known limitations
no-asm: Windows builds default to pure-C (no NASM dependency). Functionallyidentical, slightly slower. Can be revisited if a
xim:nasm-style build dep everlands.
cmd /csplices paths directly; the standard layout(
C:\Users\<name>\…) is space-free. Usernames with spaces would need quoting thebat path — can be patched later.
bash -cno-op as feat: add mcpplibs.tinyhttps 0.2.1 + mcpplibs.llmapi 0.2.4 #3), sofind_vcvarsprimarily uses the known-path fallback; vswhere is a bonus, not adependency.
Follow-up
compat.libmysqlclient: add the windows xpm line and verify (its Windows buildsegment is already in place). Next PR, gated on this one.