Windows target: qualify Configuration/Crypto/System and port Archive for embedding projects (VBS) #65

Open
opened 2026-12-05 12:16:54 +00:00 by faumaray · 3 comments
Owner

Context

VoidBuildSystem (pinned to 0002e74a7da94a756f55a4a5574d20b77736c185) is adding native Windows CI (MSYS2/MinGW-w64, GCC 16.2). Configuring it for x86_64-w64-mingw32 currently fails in cmake/Targets.cmake:

[Void] Modules not supported on target 'windows':
Configuration;Crypto;Archive;System.

VBS enables Configuration;Text;Unicode;Async;Algorithms;Crypto;Archive;Log;Testing on top of the core modules.

What was observed

Cross-configured with MinGW-w64 GCC 16.2 and a scratch copy of this checkout whose VOID_WINDOWS_MODULES allowlist was extended with the four modules:

  • Void_Configuration - compiles and links on Windows.
  • Void_Crypto - compiles and links on Windows.
  • Void_System - compiles and links on Windows.
  • Void_Archive - fails to compile; e.g. src/Archive/StagedArchive.cpp uses ::openat, ::write, STDERR_FILENO and OwnedFd assumptions that do not exist in the Windows runtime.

Requests

  1. Qualify Configuration, Crypto and System for the Windows target (they already build), so they can be enabled there.
  2. Port the Archive staging code to Windows (or provide a supported Windows subset/fallback) so embedding projects can keep linking Void::Archive.
  3. Follow-up: Void::System::DirectoryWatcher is inotify-only; a Windows backend (ReadDirectoryChangesW) is needed for VBS watch/daemon support.

Reproduction

cmake -S . -B build-win -G Ninja \
  -DCMAKE_TOOLCHAIN_FILE=<mingw-w64-toolchain.cmake> \
  -DCMAKE_BUILD_TYPE=Debug

This blocks native Windows builds of VoidBuildSystem (VBS Track C3).

## Context VoidBuildSystem (pinned to `0002e74a7da94a756f55a4a5574d20b77736c185`) is adding native Windows CI (MSYS2/MinGW-w64, GCC 16.2). Configuring it for `x86_64-w64-mingw32` currently fails in `cmake/Targets.cmake`: ``` [Void] Modules not supported on target 'windows': Configuration;Crypto;Archive;System. ``` VBS enables `Configuration;Text;Unicode;Async;Algorithms;Crypto;Archive;Log;Testing` on top of the core modules. ## What was observed Cross-configured with MinGW-w64 GCC 16.2 and a scratch copy of this checkout whose `VOID_WINDOWS_MODULES` allowlist was extended with the four modules: - `Void_Configuration` - compiles and links on Windows. - `Void_Crypto` - compiles and links on Windows. - `Void_System` - compiles and links on Windows. - `Void_Archive` - **fails to compile**; e.g. `src/Archive/StagedArchive.cpp` uses `::openat`, `::write`, `STDERR_FILENO` and `OwnedFd` assumptions that do not exist in the Windows runtime. ## Requests 1. Qualify `Configuration`, `Crypto` and `System` for the Windows target (they already build), so they can be enabled there. 2. Port the `Archive` staging code to Windows (or provide a supported Windows subset/fallback) so embedding projects can keep linking `Void::Archive`. 3. Follow-up: `Void::System::DirectoryWatcher` is inotify-only; a Windows backend (`ReadDirectoryChangesW`) is needed for VBS `watch`/daemon support. ## Reproduction ```sh cmake -S . -B build-win -G Ninja \ -DCMAKE_TOOLCHAIN_FILE=<mingw-w64-toolchain.cmake> \ -DCMAKE_BUILD_TYPE=Debug ``` This blocks native Windows builds of VoidBuildSystem (VBS Track C3).
Author
Owner

Progress in bd5488b on main (request 1 done, request 2 still open):

  • Configuration, Crypto and System are now in the Windows allowlist (cmake/Targets.cmake) and documented in docs/targets.md.
  • System links winmm on Windows (Win32 audio) and windows.h now precedes mmsystem.h.
  • Test portability: added a whole-file // @requires-posix gate (honoured by the CMake test scanner and by build.cpp for VBS), marked the POSIX-only System suites, made helper-based cases skip on Windows, and made setenv/unsetenv/getpid portable. The POSIX process helper is not built on Windows.
  • Evidence: cross-built with x86_64-w64-mingw32 GCC 16.2 (-DCMAKE_SYSTEM_NAME=Windows plus mcfgthread paths): all enabled modules and VoidTests.exe link with no errors. Linux System;Testing suite still passes (477 tests, 474 passed, 3 skipped).

Still open:

  • Archive (request 2): src/Archive/StagedArchive.cpp is POSIX-only (openat, dir-fd traversal, renameat2, fsync, fork/wait/rlimits). Enabling the module for Windows produces ~194 compile errors, so it stays out of the allowlist until it gets a dedicated Windows implementation (or an explicitly supported subset).
  • DirectoryWatcher Windows backend (ReadDirectoryChangesW) for vbs watch/daemon (request 3).

No Wine runtime is available in this environment, so the runtime qualification of the newly allowlisted modules was not re-run; the compile/link qualification is complete.

Progress in bd5488b on `main` (request 1 done, request 2 still open): - `Configuration`, `Crypto` and `System` are now in the Windows allowlist (`cmake/Targets.cmake`) and documented in `docs/targets.md`. - `System` links `winmm` on Windows (Win32 audio) and `windows.h` now precedes `mmsystem.h`. - Test portability: added a whole-file `// @requires-posix` gate (honoured by the CMake test scanner and by `build.cpp` for VBS), marked the POSIX-only System suites, made helper-based cases skip on Windows, and made `setenv`/`unsetenv`/`getpid` portable. The POSIX process helper is not built on Windows. - Evidence: cross-built with x86_64-w64-mingw32 GCC 16.2 (`-DCMAKE_SYSTEM_NAME=Windows` plus mcfgthread paths): all enabled modules and `VoidTests.exe` link with no errors. Linux `System;Testing` suite still passes (477 tests, 474 passed, 3 skipped). Still open: - `Archive` (request 2): `src/Archive/StagedArchive.cpp` is POSIX-only (openat, dir-fd traversal, `renameat2`, `fsync`, fork/wait/rlimits). Enabling the module for Windows produces ~194 compile errors, so it stays out of the allowlist until it gets a dedicated Windows implementation (or an explicitly supported subset). - `DirectoryWatcher` Windows backend (`ReadDirectoryChangesW`) for `vbs watch`/daemon (request 3). No Wine runtime is available in this environment, so the runtime qualification of the newly allowlisted modules was not re-run; the compile/link qualification is complete.
Author
Owner

Archive is now allowlisted and cross-builds in a48c745.

Instead of a second implementation, src/Archive/StagedArchive.cpp keeps its validated staging logic and gains a Windows compatibility layer:

  • directory descriptors are synthetic ids mapped to paths (Windows has no CRT directory handles); file descriptors are ordinary CRT handles with UTF-8 -> wide path conversion;
  • open/openat/mkdirat/unlinkat/fstatat/fstat/fdopendir/fsync/getpid/geteuid are emulated (no-follow is checked through reparse-point attributes);
  • publication uses MoveFileExW without replace (same no-overwrite semantics as renameat2(RENAME_NOREPLACE));
  • the isolated worker keeps its POSIX rlimit path (guarded out) and RSS reporting returns no value on Windows.

Evidence: x86_64-w64-mingw32 GCC 16.2 cross-build (-DCMAKE_SYSTEM_NAME=Windows + mcfgthread paths) now compiles all enabled modules and links Void_Archive and VoidTests.exe with zero errors. The Linux Archive suite still passes (10/10), and the full System;Testing Linux suite passes (477 tests).

Remaining for this issue: runtime verification of the new Windows path (no Wine in this environment) and the DirectoryWatcher Windows backend (ReadDirectoryChangesW) for vbs watch/daemon.

Archive is now allowlisted and cross-builds in a48c745. Instead of a second implementation, `src/Archive/StagedArchive.cpp` keeps its validated staging logic and gains a Windows compatibility layer: - directory descriptors are synthetic ids mapped to paths (Windows has no CRT directory handles); file descriptors are ordinary CRT handles with UTF-8 -> wide path conversion; - `open/openat/mkdirat/unlinkat/fstatat/fstat/fdopendir/fsync/getpid/geteuid` are emulated (no-follow is checked through reparse-point attributes); - publication uses `MoveFileExW` without replace (same no-overwrite semantics as `renameat2(RENAME_NOREPLACE)`); - the isolated worker keeps its POSIX rlimit path (guarded out) and RSS reporting returns no value on Windows. Evidence: x86_64-w64-mingw32 GCC 16.2 cross-build (`-DCMAKE_SYSTEM_NAME=Windows` + mcfgthread paths) now compiles all enabled modules and links `Void_Archive` and `VoidTests.exe` with zero errors. The Linux Archive suite still passes (10/10), and the full `System;Testing` Linux suite passes (477 tests). Remaining for this issue: runtime verification of the new Windows path (no Wine in this environment) and the `DirectoryWatcher` Windows backend (`ReadDirectoryChangesW`) for `vbs watch`/daemon.
Author
Owner

More progress on main (3939b05), verified under Wine this time:

  • Archive now runs on Windows. StagedArchive.cpp keeps its staging logic and uses a Windows compatibility layer (synthetic directory descriptors, CRT file handles with UTF-8 to wide conversion, fstatat/mkdirat/unlinkat/fsync emulation, MoveFileExW no-replace publication). Under Wine 11: Archive 6/6 and ArchiveHardening 10/10 pass (isolated-worker success path included; the worker limit-violation path is skipped on Windows).
  • TempDir and TempFile got their Windows implementations (identity by volume serial + file index, no-follow cleanup). Under Wine: 5/5 each.
  • Path: staging cleanup can delete the temp file while open (FILE_SHARE_DELETE) and the parent directory is opened for write before FlushFileBuffers. Path suite under Wine: 9 passed, 2 skipped.
  • Configuration: from_env_prefix now reads the environment (_environ) on Windows. Sources suite: 7/7.
  • DirectoryWatcher tests skip on Windows (inotify-only backend, request 3 still open).

Known remaining Windows failure: Process shell-output capture hangs under Wine (shell_echo_captures_stdout, shell_captures_stderr_separately, run_stdout_and_stderr_independent); a communicate_blocking pipe-wait issue in the Windows backend, not Archive. The rest of the suite passes suite-by-suite.

Also still open: the DirectoryWatcher ReadDirectoryChangesW backend, and IO's native backend (IOCP) if IO is to be enabled on Windows.

More progress on `main` (3939b05), verified under Wine this time: - **Archive now runs on Windows.** `StagedArchive.cpp` keeps its staging logic and uses a Windows compatibility layer (synthetic directory descriptors, CRT file handles with UTF-8 to wide conversion, `fstatat`/`mkdirat`/`unlinkat`/`fsync` emulation, `MoveFileExW` no-replace publication). Under Wine 11: `Archive` 6/6 and `ArchiveHardening` 10/10 pass (isolated-worker success path included; the worker limit-violation path is skipped on Windows). - **TempDir and TempFile** got their Windows implementations (identity by volume serial + file index, no-follow cleanup). Under Wine: 5/5 each. - **Path**: staging cleanup can delete the temp file while open (`FILE_SHARE_DELETE`) and the parent directory is opened for write before `FlushFileBuffers`. Path suite under Wine: 9 passed, 2 skipped. - **Configuration**: `from_env_prefix` now reads the environment (`_environ`) on Windows. Sources suite: 7/7. - DirectoryWatcher tests skip on Windows (inotify-only backend, request 3 still open). Known remaining Windows failure: `Process` shell-output capture hangs under Wine (`shell_echo_captures_stdout`, `shell_captures_stderr_separately`, `run_stdout_and_stderr_independent`); a `communicate_blocking` pipe-wait issue in the Windows backend, not Archive. The rest of the suite passes suite-by-suite. Also still open: the `DirectoryWatcher` `ReadDirectoryChangesW` backend, and IO's native backend (IOCP) if IO is to be enabled on Windows.
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Void/Library#65