diff --git a/cmake/Targets.cmake b/cmake/Targets.cmake index 13f1b79..1129159 100644 --- a/cmake/Targets.cmake +++ b/cmake/Targets.cmake @@ -37,10 +37,9 @@ set(VOID_WASM_MODULES ) # Windows client subset: modules qualified with x86_64-w64-mingw32 (MinGW-w64). -# Filled from the cross-build observations in docs/targets.md; modules that -# need POSIX APIs stay out until a Windows implementation is qualified. -# Observability is excluded: MinGW emits duplicate TLS init functions for its -# inline thread_local hook controls and the link fails. +# Filled from the cross-build and Wine runtime observations in +# docs/targets.md. IO is deliberately absent: it builds on Windows but its +# native backend is Linux-only (EpollBackend), so only the mock backend works. set(VOID_WINDOWS_MODULES Algorithms Async @@ -51,12 +50,13 @@ set(VOID_WINDOWS_MODULES Discovery Fsm Functional - IO Log LogState Math Memory Messaging + Observability + ObservabilityHooks Scheduler Service Testing diff --git a/docs/targets.md b/docs/targets.md index fd246a3..7a7d9b8 100644 --- a/docs/targets.md +++ b/docs/targets.md @@ -88,7 +88,7 @@ recognized and configured like Linux, but no Alpine build has been observed, so musl-specific behaviour (subprocess `/proc`, `dl`, locale) must not be assumed. Record the exact tuple before claiming support. -### Windows client (compile/install/consume qualified) +### Windows client (compile/install/consume + Wine runtime qualified) | Item | Value | |------|-------| @@ -97,18 +97,27 @@ assumed. Record the exact tuple before claiming support. | Standard library | libstdc++ + mingw-w64 CRT (mcfgthread threading in the Nix wrapper) | | CMake / generator | CMake 4.5.0, Ninja 1.13.2 | | Language | C++26, reflection `yes` | -| Modules | `Algorithms Binary Containers Core Data Functional LogState Math Memory Testing TestingMock Text Time Unicode` plus the compiled subset: `Async Discovery Fsm IO Log Messaging Scheduler Service` | -| Observed | configure, compile, `cmake --install`, and consume (`TargetProfile.exe` linked, not executed on the Linux host) | +| Runtime | Wine 11.0 (`wine64`), no native Windows runner available | +| Modules | `Algorithms Async Binary Containers Core Data Discovery Fsm Functional Log LogState Math Memory Messaging Observability ObservabilityHooks Scheduler Service Testing TestingMock Text Time Unicode` | +| Observed | configure, compile, `cmake --install`, consume (`TargetProfile.exe` linked); `VoidTests.exe` under Wine: **1364 tests, 1360 passed, 4 skipped, 0 failed** | -Known blockers for a larger Windows subset: +Notes from the runtime run: -- `Observability` fails to link with MinGW because the inline `thread_local` - hook control emits duplicate TLS init functions (GCC/mingw behaviour, not - a Void bug). Modules depending on it stay out of the allowlist. -- The test suite (`VOID_ENABLE_TESTING=ON`) cross-compiles most suites but - `tests/standalone/IO/IoFile.cpp` uses POSIX-only `O_CLOEXEC`/`fcntl`, so a - Windows test build currently stops there. Windows runtime tests need a - Windows runner. +- `IO` is **not** in the Windows allowlist. It builds, but its native backend + is Linux-only (`EpollBackend`); on Windows `Driver::create` returns + `IoErrorCode::unsupported` unless the mock backend is selected. A Windows + IO backend (IOCP) is a separate task. +- `Observability` links after replacing the namespace-scope + `inline thread_local` hook stack with a function-local `thread_local` + accessor (MinGW emitted duplicate TLS init functions). +- Test code is portable: POSIX-only descriptor assertions are guarded, the + Log hardening test closes its `ifstream` before removing the file, and the + subprocess-isolation test skips when `current_executable_path()` is not + implemented (Windows has no subprocess isolation yet). +- MinGW test builds need `-Wa,-mbig-obj`: the Fsm hardening test TU exceeds + the COFF section limit with the default object format. +- Runtime observations come from Wine, not a native Windows runner; a + Windows CI runner should confirm them. The Nix MinGW wrapper needs the mcfgthread include/library paths explicitly: diff --git a/include/Void/Observability/Hooks.hpp b/include/Void/Observability/Hooks.hpp index 1ccecaf..cab40e9 100644 --- a/include/Void/Observability/Hooks.hpp +++ b/include/Void/Observability/Hooks.hpp @@ -97,7 +97,16 @@ struct HookControl { std::condition_variable drain_cv; }; -inline thread_local std::vector t_active_hook_controls; +// Per-thread stack of hook controls currently executing. A function-local +// thread_local keeps a single definition across TUs; a namespace-scope +// `inline thread_local` makes MinGW emit one TLS init function per TU and +// fails to link with duplicate symbols. +[[nodiscard]] inline std::vector& +active_hook_controls() noexcept +{ + static thread_local std::vector controls; + return controls; +} struct HookCallScope { const HookControl* control{nullptr}; @@ -105,14 +114,15 @@ struct HookCallScope { explicit HookCallScope(const HookControl* ctrl) : control(ctrl) { if (control != nullptr) { - t_active_hook_controls.push_back(control); + active_hook_controls().push_back(control); } } ~HookCallScope() noexcept { - if (control != nullptr && !t_active_hook_controls.empty()) { - t_active_hook_controls.pop_back(); + auto& controls = active_hook_controls(); + if (control != nullptr && !controls.empty()) { + controls.pop_back(); } } @@ -121,7 +131,7 @@ struct HookCallScope { [[nodiscard]] static bool is_active_on_thread(const HookControl* ctrl) noexcept { - for (const auto* entry : t_active_hook_controls) { + for (const auto* entry : active_hook_controls()) { if (entry == ctrl) { return true; } diff --git a/tests/standalone/IO/IoDriver.cpp b/tests/standalone/IO/IoDriver.cpp index 10c35c6..f09a704 100644 --- a/tests/standalone/IO/IoDriver.cpp +++ b/tests/standalone/IO/IoDriver.cpp @@ -315,9 +315,11 @@ Void::Testing::Test io_mock_stop_completion_races_and_clock_timeout() } } -#ifdef __linux__ Void::Testing::Test io_epoll_socketpair_fragmented_half_close_and_fd_reuse() { +#ifndef __linux__ + Void::Testing::skip("epoll backend is Linux-only"); +#else ManualExecutor exec; auto drv_res = Driver::create( exec, @@ -453,10 +455,14 @@ Void::Testing::Test io_epoll_socketpair_fragmented_half_close_and_fd_reuse() (reused->first.id().generation > a_orig_id.generation) || (reused->second.id().generation > a_orig_id.generation); Void::Testing::expect(bumped); +#endif } Void::Testing::Test io_epoll_cross_thread_wake_poll_and_stop_tsan() { +#ifndef __linux__ + Void::Testing::skip("epoll backend is Linux-only"); +#else ManualExecutor exec; auto drv_res = Driver::create(exec, BackendOptions{.preference = BackendPreference::epoll}); Void::Testing::require(drv_res.has_value()); @@ -505,5 +511,5 @@ Void::Testing::Test io_epoll_cross_thread_wake_poll_and_stop_tsan() driver.wake(); poller.join(); (void)b.valid(); -} -#endif // __linux__ \ No newline at end of file +#endif +} \ No newline at end of file diff --git a/tests/standalone/IO/IoFile.cpp b/tests/standalone/IO/IoFile.cpp index 6e0210a..20b3ca6 100644 --- a/tests/standalone/IO/IoFile.cpp +++ b/tests/standalone/IO/IoFile.cpp @@ -44,6 +44,20 @@ namespace using namespace std::chrono_literals; +#if defined(_WIN32) +// The MinGW CRT has no O_CLOEXEC and no fcntl(F_GETFD); the POSIX-only +// descriptor assertions below are guarded separately. +int open_readonly(const std::filesystem::path& path) +{ + return ::_wopen(path.c_str(), _O_RDONLY); +} +#else +int open_readonly(const std::filesystem::path& path) +{ + return ::open(path.c_str(), O_RDONLY | O_CLOEXEC); +} +#endif + using Void::Async::ManualExecutor; using Void::Async::OperationOptions; using Void::Async::TaskScope; @@ -535,7 +549,7 @@ Void::Testing::Test io_file_native_roundtrip_isolated_tmpdir() expect_eq(drv->telemetry().active_descriptors, std::size_t{0}); // adopt_file_fd and a default (read-only) open of the same path. - auto ro = drv->adopt_file_fd(::open(path.c_str(), O_RDONLY | O_CLOEXEC)); + auto ro = drv->adopt_file_fd(open_readonly(path)); require(ro.has_value()); File ro_file = std::move(*ro); auto ro2 = drv->open_file(path); @@ -1814,10 +1828,12 @@ Void::Testing::Test io_file_counts_against_max_descriptors() expect(!std::filesystem::exists(third)); // adopt_file_fd takes ownership only on success. - const int fd = ::open(dir.file("first.bin").c_str(), O_RDONLY | O_CLOEXEC); + const int fd = open_readonly(dir.file("first.bin")); require(fd >= 0); expect(failed_with(drv->adopt_file_fd(fd), IoErrorCode::overloaded)); +#if !defined(_WIN32) expect(::fcntl(fd, F_GETFD) != -1); +#endif spawn(scope, do_close(&file, {}, &c)); (void)exec.drain(); diff --git a/tests/standalone/Log/LogHardening.cpp b/tests/standalone/Log/LogHardening.cpp index 04477bf..fa391fd 100644 --- a/tests/standalone/Log/LogHardening.cpp +++ b/tests/standalone/Log/LogHardening.cpp @@ -368,5 +368,6 @@ Void::Testing::Test log_formatters_multilogger_and_file_sync_reopen() std::string content{(std::istreambuf_iterator(ifs)), {}}; expect(content.find("before-reopen") != std::string::npos); expect(content.find("after-reopen") != std::string::npos); + ifs.close(); std::filesystem::remove_all(base); } diff --git a/tests/standalone/Math/VecMat.cpp b/tests/standalone/Math/VecMat.cpp index 86f825e..367d877 100644 --- a/tests/standalone/Math/VecMat.cpp +++ b/tests/standalone/Math/VecMat.cpp @@ -4,6 +4,7 @@ #include #include +#include static constexpr float EPS = 1e-5f; @@ -129,7 +130,7 @@ Void::Testing::Test mat4_scale() Void::Testing::Test mat4_rotation_z_90_degrees() { const auto R = Void::Math::Mat4f::rotation_z( - static_cast(M_PI) / 2.f); + std::numbers::pi_v / 2.f); const Void::Math::Vec4f v{1, 0, 0, 0}; const auto r = R * v; Void::Testing::expect(std::abs(r.x - 0.f) < EPS); diff --git a/tests/standalone/Testing/FrameworkHardening.cpp b/tests/standalone/Testing/FrameworkHardening.cpp index 2ba9904..0719caf 100644 --- a/tests/standalone/Testing/FrameworkHardening.cpp +++ b/tests/standalone/Testing/FrameworkHardening.cpp @@ -200,6 +200,9 @@ Void::Testing::Test testing_subprocess_isolation_exit_crash_timeout_and_flood() using namespace Void::Testing; const std::string exe = current_executable_path(); + if (exe.empty()) { + skip("subprocess isolation is not implemented on this platform"); + } require(!exe.empty()); // 1. Passing self-invocation on skipped/tiny test