Add a POSIX compatibility layer for the Windows build of StagedArchive: directory descriptors are synthetic path handles, file IO uses the CRT with UTF-8 to wide path conversion, fstatat/fstat/mkdirat/unlinkat/fsync are emulated, and publication uses MoveFileExW without replace. The isolated worker keeps its POSIX rlimit path (guarded) and RSS reporting returns no value on Windows. Allowlist Archive for the Windows target. Cross-built with x86_64-w64-mingw32 GCC 16.2: Void_Archive and VoidTests.exe link with no errors. Linux Archive suite: 10/10 pass. Refs #65
246 lines
8.1 KiB
CMake
246 lines
8.1 KiB
CMake
# Target qualification for VoidLibrary.
|
|
#
|
|
# A "target" is a platform profile with a known compiler/standard-library
|
|
# tuple and an explicit set of modules that are expected to work there. The
|
|
# profile is detected from the toolchain, can be overridden for
|
|
# qualification runs with -DVOID_TARGET=..., and is validated against the
|
|
# selected modules so unsupported combinations fail at configure time with a
|
|
# useful message instead of deep inside a cross build.
|
|
#
|
|
# See docs/targets.md for the recorded tuples and their qualification status.
|
|
|
|
set(VOID_KNOWN_TARGETS linux linux-musl windows wasm)
|
|
|
|
set(VOID_TARGET "auto" CACHE STRING
|
|
"Target profile: auto (detect from the toolchain), ${VOID_KNOWN_TARGETS}")
|
|
set_property(CACHE VOID_TARGET PROPERTY STRINGS auto ${VOID_KNOWN_TARGETS})
|
|
|
|
# Browser/Wasm subset: pure computation modules only. Nothing here performs
|
|
# native I/O, spawns processes, loads shared libraries, uses SQLite, or needs
|
|
# C++26 reflection. Keep this list fail-closed: a module is added only after
|
|
# it has been configured and compiled for wasm32-unknown-emscripten.
|
|
# Qualified with Emscripten 6.0.9 (Clang 22, libc++) for configure, build,
|
|
# install, consume and run under Node, including the test suite with
|
|
# -pthread (see docs/targets.md).
|
|
set(VOID_WASM_MODULES
|
|
Algorithms
|
|
Binary
|
|
Containers
|
|
Core
|
|
Data
|
|
Functional
|
|
LogState
|
|
Math
|
|
Memory
|
|
Testing
|
|
TestingMock
|
|
Text
|
|
Time
|
|
Unicode
|
|
)
|
|
|
|
# Windows client subset: modules qualified with x86_64-w64-mingw32 (MinGW-w64).
|
|
# 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
|
|
Archive
|
|
Async
|
|
Binary
|
|
Configuration
|
|
Containers
|
|
Core
|
|
Crypto
|
|
Data
|
|
Discovery
|
|
Fsm
|
|
Functional
|
|
IO
|
|
Log
|
|
LogState
|
|
Math
|
|
Memory
|
|
Messaging
|
|
Observability
|
|
ObservabilityHooks
|
|
Scheduler
|
|
Service
|
|
System
|
|
Testing
|
|
TestingMock
|
|
Text
|
|
Time
|
|
Unicode
|
|
)
|
|
|
|
function(void_detect_target out_var)
|
|
if(NOT VOID_TARGET STREQUAL "auto")
|
|
set(${out_var} "${VOID_TARGET}" PARENT_SCOPE)
|
|
return()
|
|
endif()
|
|
|
|
if(EMSCRIPTEN OR CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
|
|
set(_target wasm)
|
|
elseif(WIN32)
|
|
set(_target windows)
|
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
execute_process(
|
|
COMMAND "${CMAKE_C_COMPILER}" -dumpmachine
|
|
OUTPUT_VARIABLE _triple
|
|
ERROR_QUIET
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
if(_triple MATCHES "musl" OR
|
|
CMAKE_C_LIBRARY_ARCHITECTURE MATCHES "musl" OR
|
|
CMAKE_C_FLAGS MATCHES "musl")
|
|
set(_target linux-musl)
|
|
else()
|
|
set(_target linux)
|
|
endif()
|
|
else()
|
|
set(_target unsupported)
|
|
endif()
|
|
set(${out_var} "${_target}" PARENT_SCOPE)
|
|
endfunction()
|
|
|
|
function(_void_target_allowlist target out_var)
|
|
if(target STREQUAL "wasm")
|
|
set(${out_var} "${VOID_WASM_MODULES}" PARENT_SCOPE)
|
|
elseif(target STREQUAL "windows")
|
|
set(${out_var} "${VOID_WINDOWS_MODULES}" PARENT_SCOPE)
|
|
else()
|
|
# Linux and Linux/musl qualify every module: platform-specific code is
|
|
# selected inside the module sources.
|
|
set(${out_var} "" PARENT_SCOPE)
|
|
endif()
|
|
endfunction()
|
|
|
|
# Validate the detected/forced target against a module selection. Called
|
|
# from the top-level CMakeLists as soon as the selection is expanded (before
|
|
# any module dependency is resolved, so an unsupported browser-engine
|
|
# combination fails with the target message, not a missing-package error),
|
|
# and again after void_finalize_modules() for the all-modules default.
|
|
# With no arguments the configured module list is validated.
|
|
function(void_validate_target_modules)
|
|
void_detect_target(_target)
|
|
|
|
if(_target STREQUAL "unsupported")
|
|
message(FATAL_ERROR
|
|
"[Void] Unsupported target '${CMAKE_SYSTEM_NAME} "
|
|
"${CMAKE_SYSTEM_PROCESSOR}'. Known targets: ${VOID_KNOWN_TARGETS}. "
|
|
"Pass -DVOID_TARGET=<target> only for a qualification run; "
|
|
"see docs/targets.md.")
|
|
endif()
|
|
if(NOT _target IN_LIST VOID_KNOWN_TARGETS)
|
|
message(FATAL_ERROR
|
|
"[Void] Unknown VOID_TARGET='${_target}'. Known targets: "
|
|
"${VOID_KNOWN_TARGETS}.")
|
|
endif()
|
|
|
|
if(_target STREQUAL "wasm" AND VOID_ENABLE_TSAN)
|
|
message(FATAL_ERROR
|
|
"[Void] ThreadSanitizer is not supported on the wasm target; "
|
|
"run native sanitizer builds separately (docs/targets.md).")
|
|
endif()
|
|
|
|
if(ARGN)
|
|
set(_modules ${ARGN})
|
|
else()
|
|
get_property(_modules GLOBAL PROPERTY VOID_MODULES)
|
|
endif()
|
|
_void_target_allowlist(${_target} _allowed)
|
|
if(_allowed)
|
|
set(_rejected "")
|
|
foreach(_module IN LISTS _modules)
|
|
if(NOT _module IN_LIST _allowed)
|
|
list(APPEND _rejected ${_module})
|
|
endif()
|
|
endforeach()
|
|
if(_rejected)
|
|
message(FATAL_ERROR
|
|
"[Void] Modules not supported on target '${_target}': "
|
|
"${_rejected}. Supported modules: ${_allowed}. "
|
|
"Select a supported subset with -DVOID_ENABLED_MODULES=... "
|
|
"or use a native target (docs/targets.md).")
|
|
endif()
|
|
endif()
|
|
|
|
if(NOT DEFINED VOID_TARGET_DETECTED OR
|
|
NOT VOID_TARGET_DETECTED STREQUAL _target)
|
|
set(VOID_TARGET_DETECTED "${_target}" CACHE INTERNAL
|
|
"Detected or forced Void target profile" FORCE)
|
|
if(NOT VOID_TARGET STREQUAL "auto")
|
|
message(STATUS "[Void] Target forced to '${_target}' by VOID_TARGET")
|
|
else()
|
|
message(STATUS "[Void] Target: ${_target}")
|
|
endif()
|
|
endif()
|
|
endfunction()
|
|
|
|
# Record the exact tuple this build was configured with. The manifest is
|
|
# installed next to VoidConfig.cmake so consumers can inspect what they got,
|
|
# and the qualification fixtures assert on it.
|
|
function(void_write_target_manifest path)
|
|
get_property(_modules GLOBAL PROPERTY VOID_MODULES)
|
|
list(JOIN _modules ";" _modules_value)
|
|
|
|
if(VOID_HAS_CXX26_REFLECTION)
|
|
set(_reflection yes)
|
|
else()
|
|
set(_reflection no)
|
|
endif()
|
|
if(VOID_HAS_STD_EXPECTED)
|
|
set(_expected yes)
|
|
else()
|
|
set(_expected no)
|
|
endif()
|
|
if(BUILD_SHARED_LIBS)
|
|
set(_linkage shared)
|
|
else()
|
|
set(_linkage static)
|
|
endif()
|
|
|
|
set(_sanitizers "")
|
|
if(VOID_ENABLE_ASAN)
|
|
list(APPEND _sanitizers ASan)
|
|
endif()
|
|
if(VOID_ENABLE_UBSAN)
|
|
list(APPEND _sanitizers UBSan)
|
|
endif()
|
|
if(VOID_ENABLE_TSAN)
|
|
list(APPEND _sanitizers TSan)
|
|
endif()
|
|
if(NOT _sanitizers)
|
|
set(_sanitizers none)
|
|
else()
|
|
string(REPLACE ";" "+" _sanitizers "${_sanitizers}")
|
|
endif()
|
|
|
|
execute_process(
|
|
COMMAND "${CMAKE_C_COMPILER}" -dumpmachine
|
|
OUTPUT_VARIABLE _triple
|
|
ERROR_QUIET
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
set(_content
|
|
"# Generated by VoidLibrary's build system (cmake/Targets.cmake).
|
|
# Describes the exact target tuple this build was configured with.
|
|
set(VOID_TARGET_MANIFEST_TARGET \"${VOID_TARGET_DETECTED}\")
|
|
set(VOID_TARGET_MANIFEST_TARGET_ORIGIN \"${VOID_TARGET}\")
|
|
set(VOID_TARGET_MANIFEST_TRIPLE \"${_triple}\")
|
|
set(VOID_TARGET_MANIFEST_SYSTEM_NAME \"${CMAKE_SYSTEM_NAME}\")
|
|
set(VOID_TARGET_MANIFEST_SYSTEM_PROCESSOR \"${CMAKE_SYSTEM_PROCESSOR}\")
|
|
set(VOID_TARGET_MANIFEST_COMPILER_ID \"${CMAKE_CXX_COMPILER_ID}\")
|
|
set(VOID_TARGET_MANIFEST_COMPILER_VERSION \"${CMAKE_CXX_COMPILER_VERSION}\")
|
|
set(VOID_TARGET_MANIFEST_CXX_STANDARD \"${CMAKE_CXX_STANDARD}\")
|
|
set(VOID_TARGET_MANIFEST_LINKAGE \"${_linkage}\")
|
|
set(VOID_TARGET_MANIFEST_REFLECTION \"${_reflection}\")
|
|
set(VOID_TARGET_MANIFEST_STD_EXPECTED \"${_expected}\")
|
|
set(VOID_TARGET_MANIFEST_SANITIZERS \"${_sanitizers}\")
|
|
set(VOID_TARGET_MANIFEST_TESTING \"${VOID_ENABLE_TESTING}\")
|
|
set(VOID_TARGET_MANIFEST_WARNINGS_AS_ERRORS \"${VOID_WARNINGS_AS_ERRORS}\")
|
|
set(VOID_TARGET_MANIFEST_MODULES \"${_modules_value}\")
|
|
")
|
|
file(WRITE "${path}" "${_content}")
|
|
endfunction()
|