Skip to content

fix: make delivery_module cross-compile for Windows - #85

Draft
dlipicar wants to merge 1 commit into
masterfrom
fix/windows-cross-portability
Draft

fix: make delivery_module cross-compile for Windows#85
dlipicar wants to merge 1 commit into
masterfrom
fix/windows-cross-portability

Conversation

@dlipicar

Copy link
Copy Markdown
Contributor

Two portability defects that stop delivery_module cross-compiling for
x86_64-w64-mingw32. Both are invisible on Linux/macOS, and neither is
Windows-specific in nature — one is arguably a correctness improvement on
every platform.

1. nix.packages.runtime declared postgresql, not libpq

postgresql is the server, which has no mingw build in nixpkgs, so a
Windows evaluation hard-failed on meta.platforms before anything compiled:

error: Refusing to evaluate package 'postgresql-17.10' ... because it is not
       available on the requested hostPlatform:
         hostPlatform.system = "x86_64-windows"

The module never links or loads the server — it dlopens libpq, which is
what postInstall already goes looking for via pkg-config --variable=libdir libpq. Declaring libpq directly is narrower and more correct everywhere, and
drops the entire server from the closure.

2. currentTimestampNs() used POSIX clock_gettime

mingw declares neither clock_gettime nor CLOCK_REALTIME:

src/delivery_module_plugin.cpp:38:19: error: 'CLOCK_REALTIME' was not declared in this scope
src/delivery_module_plugin.cpp:38:5:  error: 'clock_gettime' was not declared in this scope

std::chrono::system_clock is the portable spelling of the same wall-clock
reading, needs no platform branch, and the translation unit is already built at
-std=c++20. I swept the rest of src/ for other POSIX-isms (gettimeofday,
<unistd.h>, <sys/*>, /tmp, $HOME) — clean.

Verification

Cross-built for x86_64-w64-mingw32 and run on real Windows (10.0.26200,
x86_64). delivery_module_plugin.dll is a PE32+ DLL exporting
qt_plugin_instance / qt_plugin_query_metadata_v2, loads into the
logoscore daemon, and dispatches:

$ logoscore.exe list-modules
[{"name":"delivery_module","status":"not_loaded","version":"0.1.3"}]

$ logoscore.exe load-module delivery_module
{"module":"delivery_module","status":"ok","version":"0.1.3"}

$ logoscore.exe call delivery_module version
{"method":"version","module":"delivery_module",
 "result":"1.1.0 (liblogosdelivery version unknown, context not initialized)",
 "status":"ok"}

Daemon log confirms the module's own C++ ran:

[info] [logos] Module loaded: delivery_module
[info] [logos] [delivery_module] DeliveryModuleImpl: Initializing...
[info] [logos] [delivery_module] DeliveryModuleImpl: Initialized successfully

Linux and macOS are unaffected: the libpq swap resolves to the same
pkg-config lookup the module already performed, and std::chrono compiles
identically.

Dependencies

Getting here also needed fixes outside this repo, which are not required for
this PR to be correct but are required to reproduce the Windows build:

🤖 Generated with Claude Code

Two portability defects, both found by cross-building the module for
x86_64-w64-mingw32 and both invisible on Linux/macOS.

nix.packages.runtime declared `postgresql` -- the server -- which has no
mingw build in nixpkgs, so evaluation hard-failed on meta.platforms
before anything compiled. The module never links or loads the server; it
dlopens libpq. Declaring `libpq` is narrower and more correct on every
platform, and drops the server from the closure entirely.

currentTimestampNs() used clock_gettime(CLOCK_REALTIME), of which mingw
declares neither the function nor the constant. std::chrono::system_clock
is the portable spelling of the same wall-clock reading and needs no
platform branch; the translation unit is already built at -std=c++20.

Verified on real Windows (10.0.26200, x86_64): the plugin loads into the
logoscore daemon and `call delivery_module version` returns a result.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 14, 2026 11:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

2 participants