fix(#2212): PCRE2 comes from vcpkg, like grpc

The Windows build took PCRE2 from a hand-built out-of-tree directory
reached through $(Pcre2Dir).  engine.vcxproj honoured that property for
its headers but hardcoded ..\..\src\pcre2\{Release,Debug} for its
libraries, so -p:Pcre2Dir= applied to one half and not the other and the
link failed with LNK1104 in any tree where PCRE2 was not at the default.

Declare pcre2 in mux/vcpkg.json instead, alongside grpc and
nlohmann-json, and point netmux, libmux and engine at $(VcpkgDir).  All
three now read include and library paths from the same place.  Note
vcpkg's layout is lib/ for release and debug/lib/ for debug, not
Release/ and Debug/.

PCRE2's JIT is required -- funceval2.cpp calls pcre2_jit_compile -- and
comes automatically: the port's platform-default-features pulls in jit
everywhere except emscripten and iOS.

Ship mux/vcpkg.json in both source TOCs.  It was in neither, so the
source distribution carried no statement of its own dependencies; with
PCRE2 moving to vcpkg, the file that declares it has to travel with the
source or an unpacking reader is worse off than before.

Unix is unaffected -- configure finds system PCRE2 via pkg-config.

Verified on hatsuhara: Release and Debug both build clean with no
hand-built PCRE2 present anywhere on the box.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Stephen Dennis 2026-08-10 20:39:31 -06:00
parent ce21a572c3
commit b05539f86a
7 changed files with 58 additions and 19 deletions

View file

@ -60,6 +60,35 @@ without pkg-config metadata has to be pointed at by hand.
MSVC via the `.vcxproj` files; there is no autotools path. See `CLAUDE.md` for
the GANL test harness invocation. Note issue #1499 (`/utf-8`).
**Third-party dependencies come from vcpkg** (#2212). `mux/vcpkg.json` declares
them — currently `grpc`, `nlohmann-json` and `pcre2` — pinned to a
`builtin-baseline` commit:
```
git clone https://github.com/microsoft/vcpkg C:\vcpkg
C:\vcpkg\bootstrap-vcpkg.bat
cd mux && C:\vcpkg\vcpkg.exe install --triplet x64-windows
```
That materialises `mux/vcpkg_installed/x64-windows/` (gitignored), which every
project reads via `$(VcpkgDir)`. Release libraries land in `lib/` and debug in
`debug/lib/` — not `Release/` and `Debug/`, which is what the old hand-built
PCRE2 layout used.
Two things that will waste your afternoon otherwise:
- **Do not `git clone --depth 1`.** The pinned baseline commit is not in a
shallow clone and resolution fails with `failed to git show
versions/baseline.json`. Recover with
`git fetch --depth 1 origin <baseline-sha>`.
- **First run is slow** — grpc dominates, roughly an hour and ~11 GB. It is a
one-time cost: vcpkg's binary cache (`%LOCALAPPDATA%\vcpkg\archives`) makes
any later tree a few seconds.
PCRE2's JIT is required (`funceval2.cpp` calls `pcre2_jit_compile`) and arrives
automatically — the port's `platform-default-features` pulls in `jit` on every
platform except emscripten and iOS, so a plain `"pcre2"` dependency is enough.
## When you still need flags
**`--enable-nls` on macOS.** GNU gettext ships no `.pc` file, so unlike PCRE2

View file

@ -37,19 +37,20 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>12.0.30501.0</_ProjectFileVersion>
<!-- #2185: paths relative to this file (mux\), not C:\tinymux. -->
<!-- #2185: paths relative to this file (mux\), not C:\tinymux.
#2212: PCRE2 headers come from vcpkg (see mux\vcpkg.json). -->
<MuxDir Condition="'$(MuxDir)' == ''">$(MSBuildProjectDirectory)</MuxDir>
<Pcre2Dir Condition="'$(Pcre2Dir)' == ''">$(MuxDir)\src\pcre2</Pcre2Dir>
<VcpkgDir Condition="'$(VcpkgDir)' == ''">$(MuxDir)\vcpkg_installed\x64-windows</VcpkgDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>.\bin_release\</OutDir>
<IntDir>$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
<IncludePath>$(MuxDir)\include;$(Pcre2Dir)\include;$(MuxDir)\sqlite;$(IncludePath)</IncludePath>
<IncludePath>$(MuxDir)\include;$(VcpkgDir)\include;$(MuxDir)\sqlite;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>.\bin_debug\</OutDir>
<IntDir>$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
<IncludePath>$(MuxDir)\include;$(Pcre2Dir)\include;$(MuxDir)\sqlite;$(IncludePath)</IncludePath>
<IncludePath>$(MuxDir)\include;$(VcpkgDir)\include;$(MuxDir)\sqlite;$(IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Midl>

View file

@ -37,19 +37,23 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>12.0.30501.0</_ProjectFileVersion>
<!-- #2185: this file is mux\modules\engine\; MuxDir is mux\. -->
<!-- #2185: this file is mux\modules\engine\; MuxDir is mux\.
#2212: PCRE2 comes from vcpkg (see mux\vcpkg.json). This project
previously took its headers from $(Pcre2Dir) but hardcoded the
library directory, so an override applied to one and not the
other; both now come from the same place. -->
<MuxDir Condition="'$(MuxDir)' == ''">$(MSBuildProjectDirectory)\..\..</MuxDir>
<Pcre2Dir Condition="'$(Pcre2Dir)' == ''">$(MuxDir)\src\pcre2</Pcre2Dir>
<VcpkgDir Condition="'$(VcpkgDir)' == ''">$(MuxDir)\vcpkg_installed\x64-windows</VcpkgDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>..\..\bin_release\</OutDir>
<IntDir>$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
<IncludePath>$(MuxDir)\include;$(MuxDir)\sqlite;$(MuxDir)\lua54;$(Pcre2Dir)\include;$(MuxDir)\ganl\include;$(IncludePath)</IncludePath>
<IncludePath>$(MuxDir)\include;$(MuxDir)\sqlite;$(MuxDir)\lua54;$(VcpkgDir)\include;$(MuxDir)\ganl\include;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>..\..\bin_debug\</OutDir>
<IntDir>$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
<IncludePath>$(MuxDir)\include;$(MuxDir)\sqlite;$(MuxDir)\lua54;$(Pcre2Dir)\include;$(MuxDir)\ganl\include;$(IncludePath)</IncludePath>
<IncludePath>$(MuxDir)\include;$(MuxDir)\sqlite;$(MuxDir)\lua54;$(VcpkgDir)\include;$(MuxDir)\ganl\include;$(IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Midl>
@ -80,7 +84,7 @@
</ResourceCompile>
<Link>
<AdditionalDependencies>libmux.lib;ganl.lib;lua54.lib;pcre2-8.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>..\..\bin_release;..\..\src\pcre2\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>..\..\bin_release;$(VcpkgDir)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<ModuleDefinitionFile />
<SubSystem>Windows</SubSystem>
<RandomizedBaseAddress>true</RandomizedBaseAddress>
@ -110,7 +114,7 @@
</ResourceCompile>
<Link>
<AdditionalDependencies>libmux.lib;ganl.lib;lua54.lib;pcre2-8d.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>..\..\bin_debug;..\..\src\pcre2\Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>..\..\bin_debug;$(VcpkgDir)\debug\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<ModuleDefinitionFile />
<SubSystem>Windows</SubSystem>
<DataExecutionPrevention />

View file

@ -38,23 +38,25 @@
<PropertyGroup>
<_ProjectFileVersion>12.0.30501.0</_ProjectFileVersion>
<!-- #2185: never hardcode C:\tinymux. This file lives in mux\, so
MSBuildProjectDirectory is the mux root for this tree. PCRE2 is
gitignored out-of-tree; override with -p:Pcre2Dir=... to share one
staged copy across checkouts (include\ plus Debug/Release libs). -->
MSBuildProjectDirectory is the mux root for this tree.
#2212: PCRE2 comes from vcpkg now, the same way grpc does — declared
in mux\vcpkg.json, materialised by `vcpkg install` run from mux\.
vcpkg's layout puts release libs in lib\ and debug libs in
debug\lib\, not Release\ and Debug\. -->
<MuxDir Condition="'$(MuxDir)' == ''">$(MSBuildProjectDirectory)</MuxDir>
<Pcre2Dir Condition="'$(Pcre2Dir)' == ''">$(MuxDir)\src\pcre2</Pcre2Dir>
<VcpkgDir Condition="'$(VcpkgDir)' == ''">$(MuxDir)\vcpkg_installed\x64-windows</VcpkgDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>.\bin_debug\</OutDir>
<IntDir>$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
<IncludePath>$(MuxDir)\include;$(MuxDir)\ganl\include;$(Pcre2Dir)\include;$(MuxDir)\sqlite;$(IncludePath)</IncludePath>
<LibraryPath>$(Pcre2Dir)\Debug;$(LibraryPath)</LibraryPath>
<IncludePath>$(MuxDir)\include;$(MuxDir)\ganl\include;$(VcpkgDir)\include;$(MuxDir)\sqlite;$(IncludePath)</IncludePath>
<LibraryPath>$(VcpkgDir)\debug\lib;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>.\bin_release\</OutDir>
<IntDir>$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
<IncludePath>$(MuxDir)\include;$(MuxDir)\ganl\include;$(Pcre2Dir)\include;$(MuxDir)\sqlite;$(IncludePath)</IncludePath>
<LibraryPath>$(Pcre2Dir)\Release;$(LibraryPath)</LibraryPath>
<IncludePath>$(MuxDir)\include;$(MuxDir)\ganl\include;$(VcpkgDir)\include;$(MuxDir)\sqlite;$(IncludePath)</IncludePath>
<LibraryPath>$(VcpkgDir)\lib;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Midl>

View file

@ -4,6 +4,7 @@
"builtin-baseline": "544a4c5c297e60e4ac4a5a1810df66748d908869",
"dependencies": [
"grpc",
"nlohmann-json"
"nlohmann-json",
"pcre2"
]
}

View file

@ -402,3 +402,4 @@ src/websocket.cpp
src/websocket.h
SSL.md
UPGRADING.md
vcpkg.json

View file

@ -393,3 +393,4 @@ src/websocket.cpp
src/websocket.h
SSL.md
UPGRADING.md
vcpkg.json