Build: qualify target support (closes #38)
This commit is contained in:
1 parent
72148da7b2
commit
1335fa86c3
8 files changed
+689
No files matched your search
@@ -45,6 +45,7 @@ set(EXPORT_SET_NAME ${PROJECT_NAME}Targets)
|
||||
include(cmake/Capabilities.cmake)
|
||||
void_probe_capabilities()
|
||||
include(cmake/Module.cmake)
|
||||
include(cmake/Targets.cmake)
|
||||
|
||||
# Modules to configure, with the modules they need (INTERNAL_DEPS, followed
|
||||
# transitively); empty configures every module. OPTIONAL_DEPS are used only
|
||||
@@ -83,6 +84,12 @@ if(VOID_ENABLED_MODULES)
|
||||
endif()
|
||||
|
||||
file(GLOB children RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/src/*)
|
||||
if(_void_selected)
|
||||
# Fail on unsupported target/module combinations before resolving any
|
||||
# dependency, so a browser engine requesting native networking gets the
|
||||
# target message instead of a Boost/OpenSSL one.
|
||||
void_validate_target_modules(${_void_selected})
|
||||
endif()
|
||||
foreach(module_path ${children})
|
||||
if(_void_selected AND NOT module_path IN_LIST _void_selected)
|
||||
continue()
|
||||
@@ -96,6 +103,9 @@ foreach(module_path ${children})
|
||||
endif()
|
||||
endforeach()
|
||||
void_finalize_modules()
|
||||
void_validate_target_modules()
|
||||
void_write_target_manifest(
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/void-target-manifest.cmake")
|
||||
void_report_capabilities()
|
||||
if(VOID_ENABLE_TESTING)
|
||||
|
||||
@@ -144,6 +154,7 @@ install(EXPORT ${EXPORT_SET_NAME}
|
||||
install(FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/void-target-manifest.cmake"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/VoidTesting.cmake"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/VoidTestScanner.cmake"
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
|
||||
|
||||
@@ -48,6 +48,15 @@ ctest --test-dir build-asan
|
||||
|
||||
Format code with `clang-format -i <file>`.
|
||||
|
||||
## Supported targets
|
||||
|
||||
Void is qualified per target profile: Linux (reference), Linux/musl, the
|
||||
Windows client subset, and a browser/Wasm subset of the pure computation
|
||||
modules. The profile is detected from the toolchain, validated against the
|
||||
selected modules, and recorded in `void-target-manifest.cmake`. See
|
||||
[docs/targets.md](docs/targets.md) for the exact compiler/standard-library
|
||||
tuples, module allowlists and qualification status.
|
||||
|
||||
## Modules
|
||||
|
||||
Functionality is grouped into umbrella modules (one CMake target each).
|
||||
|
||||
@@ -0,0 +1,237 @@
|
||||
# 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.
|
||||
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 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.
|
||||
set(VOID_WINDOWS_MODULES
|
||||
Algorithms
|
||||
Async
|
||||
Binary
|
||||
Containers
|
||||
Core
|
||||
Data
|
||||
Discovery
|
||||
Fsm
|
||||
Functional
|
||||
IO
|
||||
Log
|
||||
LogState
|
||||
Math
|
||||
Memory
|
||||
Messaging
|
||||
Scheduler
|
||||
Service
|
||||
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()
|
||||
+170
@@ -0,0 +1,170 @@
|
||||
# Target support
|
||||
|
||||
VoidLibrary is qualified per **target profile**: a platform, a compiler and
|
||||
standard library, the external dependencies that are expected to exist, and
|
||||
the set of modules that are expected to build there. The profile is detected
|
||||
from the toolchain at configure time, validated against the selected modules,
|
||||
and recorded in `void-target-manifest.cmake` (installed next to
|
||||
`VoidConfig.cmake`).
|
||||
|
||||
```bash
|
||||
# Native Linux (default)
|
||||
cmake -S . -B build -G Ninja -DVOID_ENABLE_TESTING=ON
|
||||
|
||||
# Force a profile for a qualification run (normally auto-detected)
|
||||
cmake -S . -B build-wasm -G Ninja -DVOID_TARGET=wasm \
|
||||
-DVOID_ENABLED_MODULES="Core;Functional;Text;Data"
|
||||
|
||||
# Cross build (Windows client example)
|
||||
cmake -S . -B build-mingw -G Ninja \
|
||||
-DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/mingw-w64.cmake \
|
||||
-DVOID_ENABLED_MODULES="Core;Functional;Text;Data"
|
||||
```
|
||||
|
||||
`VOID_TARGET` is `auto` by default. The recognized values are `linux`,
|
||||
`linux-musl`, `windows` and `wasm`; anything else fails at configure time with
|
||||
the list of known targets. `cmake/Targets.cmake` holds the allowlists and the
|
||||
validation rules.
|
||||
|
||||
## Manifest
|
||||
|
||||
Every configure writes `void-target-manifest.cmake`:
|
||||
|
||||
| Field | Meaning |
|
||||
|-------|---------|
|
||||
| `VOID_TARGET_MANIFEST_TARGET` | detected/forced profile (`linux`, `linux-musl`, `windows`, `wasm`) |
|
||||
| `VOID_TARGET_MANIFEST_TARGET_ORIGIN` | `auto` or the forced `VOID_TARGET` value |
|
||||
| `VOID_TARGET_MANIFEST_TRIPLE` | `CMAKE_C_COMPILER -dumpmachine` |
|
||||
| `VOID_TARGET_MANIFEST_SYSTEM_NAME` / `..._SYSTEM_PROCESSOR` | CMake system identification |
|
||||
| `VOID_TARGET_MANIFEST_COMPILER_ID` / `..._COMPILER_VERSION` | compiler tuple |
|
||||
| `VOID_TARGET_MANIFEST_CXX_STANDARD` | language standard |
|
||||
| `VOID_TARGET_MANIFEST_LINKAGE` | `shared` or `static` |
|
||||
| `VOID_TARGET_MANIFEST_REFLECTION` | C++26 reflection available (`yes`/`no`) |
|
||||
| `VOID_TARGET_MANIFEST_STD_EXPECTED` | `<expected>` available |
|
||||
| `VOID_TARGET_MANIFEST_SANITIZERS` | `none`, `ASan`, `UBSan`, `TSan` or a combination |
|
||||
| `VOID_TARGET_MANIFEST_TESTING` | `VOID_ENABLE_TESTING` |
|
||||
| `VOID_TARGET_MANIFEST_MODULES` | configured modules |
|
||||
|
||||
Consumers can read it after `find_package(Void)`:
|
||||
|
||||
```cmake
|
||||
include("${Void_DIR}/void-target-manifest.cmake")
|
||||
message(STATUS "Void target: ${VOID_TARGET_MANIFEST_TARGET}")
|
||||
```
|
||||
|
||||
## Qualified tuples
|
||||
|
||||
### Linux (qualified)
|
||||
|
||||
| Item | Value |
|
||||
|------|-------|
|
||||
| Triple | `x86_64-unknown-linux-gnu` (NixOS, glibc) |
|
||||
| Compiler | GCC 16.2.0 (`dev cpp-gcc`) |
|
||||
| Standard library | libstdc++ 16 |
|
||||
| CMake / generator | CMake 4.5.0, Ninja 1.13.2 |
|
||||
| Language | C++26, reflection `yes` (`-freflection`) |
|
||||
| Dependencies | Boost (headers/url/beast/asio), OpenSSL, SQLite3, Lua 5.4 (optional) |
|
||||
| Modules | all |
|
||||
| Observed | `Testing;Core` configure/build clean; `ctest` 3/3 (VoidTests, installed consumers, target qualification) |
|
||||
|
||||
The Linux profile is the reference target: every module is allowed and the
|
||||
per-module platform code selects the native implementation.
|
||||
|
||||
### Linux / musl (unqualified)
|
||||
|
||||
| Item | Value |
|
||||
|------|-------|
|
||||
| Triple | `x86_64-alpine-linux-musl` |
|
||||
| Compiler | Alpine GCC 14.2+ or Clang 19+ |
|
||||
| Standard library | libstdc++ (or libc++) with musl 1.2.5 |
|
||||
| CMake / generator | CMake 4.0+, Ninja |
|
||||
| Dependencies | `boost-dev`, `openssl-dev`, `sqlite-dev`, `lua5.4-dev` from apk |
|
||||
| Modules | all (no allowlist) |
|
||||
| Status | **not qualified**: no musl toolchain in the qualification environment |
|
||||
|
||||
Detection uses `CMAKE_C_COMPILER -dumpmachine` (or
|
||||
`CMAKE_C_LIBRARY_ARCHITECTURE`/`CMAKE_C_FLAGS`) matching `musl`. The profile is
|
||||
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)
|
||||
|
||||
| Item | Value |
|
||||
|------|-------|
|
||||
| Triple | `x86_64-w64-mingw32` |
|
||||
| Compiler | MinGW-w64 GCC 16.2.0 |
|
||||
| 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) |
|
||||
|
||||
Known blockers for a larger Windows subset:
|
||||
|
||||
- `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.
|
||||
|
||||
The Nix MinGW wrapper needs the mcfgthread include/library paths explicitly:
|
||||
|
||||
```bash
|
||||
MINGW=/nix/store/...-x86_64-w64-mingw32-gcc-wrapper-16.2.0/bin
|
||||
MCFG=/nix/store/...-mcfgthread-x86_64-w64-mingw32-2.5.1/lib
|
||||
MCFGINC=/nix/store/...-mcfgthread-x86_64-w64-mingw32-2.5.1-dev/include
|
||||
cmake -S . -B build-mingw -G Ninja \
|
||||
-DCMAKE_SYSTEM_NAME=Windows \
|
||||
-DCMAKE_C_COMPILER="$MINGW/x86_64-w64-mingw32-gcc" \
|
||||
-DCMAKE_CXX_COMPILER="$MINGW/x86_64-w64-mingw32-g++" \
|
||||
-DCMAKE_C_FLAGS="-I$MCFGINC" -DCMAKE_CXX_FLAGS="-I$MCFGINC" \
|
||||
-DCMAKE_EXE_LINKER_FLAGS="-L$MCFG" \
|
||||
-DCMAKE_SHARED_LINKER_FLAGS="-L$MCFG"
|
||||
```
|
||||
|
||||
A regular MinGW-w64 installation with winpthreads does not need those extra
|
||||
flags.
|
||||
|
||||
### Browser / Wasm subset (unqualified)
|
||||
|
||||
| Item | Value |
|
||||
|------|-------|
|
||||
| Triple | `wasm32-unknown-emscripten` |
|
||||
| Compiler | Emscripten Clang (4.x) |
|
||||
| Standard library | libc++ + Emscripten libc |
|
||||
| CMake / generator | CMake 4.0+ via `emcmake`, Ninja |
|
||||
| Language | C++26 without reflection (`VOID_HAS_CXX26_REFLECTION=no`) |
|
||||
| Modules | `Algorithms Binary Containers Core Data Functional LogState Math Memory Testing TestingMock Text Time Unicode` |
|
||||
| Status | **not qualified**: no Emscripten toolchain in the qualification environment |
|
||||
|
||||
The allowlist is fail-closed: native networking (`Net`, `RPC`), processes and
|
||||
filesystem (`System`, `SystemAsync`), IPC, SQLite, plugins and anything that
|
||||
needs threads or reflection stay out. ThreadSanitizer is rejected for
|
||||
`wasm`. Do not add a module until it has been configured and compiled with
|
||||
`emcmake`.
|
||||
|
||||
## Sanitizers
|
||||
|
||||
Sanitizer builds are native-only qualification configurations, not target
|
||||
profiles: `VOID_ENABLE_ASAN`, `VOID_ENABLE_UBSAN` and `VOID_ENABLE_TSAN`
|
||||
instrument the host build and are recorded in the manifest. Production
|
||||
packages are built with sanitizers off. ASan+TSan is rejected; TSan is
|
||||
rejected on `wasm`.
|
||||
|
||||
## Qualification test
|
||||
|
||||
`tests/package/TargetQualification.cmake` (ctest
|
||||
`VoidTargetQualification`) installs the build tree and:
|
||||
|
||||
1. Consumes the install through `tests/package/TargetProfile`, asserting the
|
||||
manifest target/triple/compiler/linkage/reflection fields and running one
|
||||
Core behaviour.
|
||||
2. Rejects an unknown `VOID_TARGET`.
|
||||
3. Rejects a native module (`IPC`) and native networking (`Net`) on the
|
||||
`wasm` profile.
|
||||
4. Rejects a missing external dependency (`Sqlite` without SQLite3).
|
||||
5. Configures the pure wasm subset and asserts the manifest records
|
||||
`wasm`.
|
||||
@@ -158,6 +158,23 @@ if(_all_generated)
|
||||
)
|
||||
set_tests_properties(VoidInstalledComponentConsumers PROPERTIES
|
||||
DEPENDS VoidTests)
|
||||
|
||||
add_test(NAME VoidTargetQualification
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DVOID_BUILD_DIR=${CMAKE_BINARY_DIR}
|
||||
-DVOID_SOURCE_DIR=${CMAKE_SOURCE_DIR}
|
||||
-DVOID_TEST_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/package
|
||||
-DVOID_TEST_ROOT=${CMAKE_CURRENT_BINARY_DIR}/target-qualification
|
||||
-DVOID_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
||||
-DVOID_CTEST_COMMAND=${CMAKE_CTEST_COMMAND}
|
||||
-DVOID_GENERATOR=${CMAKE_GENERATOR}
|
||||
-DVOID_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
|
||||
-DVOID_TARGET=${VOID_TARGET_DETECTED}
|
||||
-DVOID_CROSSCOMPILING=${CMAKE_CROSSCOMPILING}
|
||||
-DVOID_BUILD_CONFIG=$<CONFIG>
|
||||
-P ${CMAKE_CURRENT_SOURCE_DIR}/package/TargetQualification.cmake)
|
||||
set_tests_properties(VoidTargetQualification PROPERTIES
|
||||
DEPENDS VoidTests)
|
||||
endif()
|
||||
|
||||
# ── Test-support executables & libraries ──────────────────────────────────────
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
cmake_minimum_required(VERSION 4.0)
|
||||
project(VoidTargetProfileConsumer LANGUAGES CXX)
|
||||
|
||||
# Records and asserts the target tuple of an installed Void package. The
|
||||
# qualification driver (tests/package/TargetQualification.cmake) passes the
|
||||
# expected target and then checks the emitted profile file. Core is the
|
||||
# always-present leaf module; per-module consumption is covered by the other
|
||||
# tests/package fixtures.
|
||||
if(NOT DEFINED VOID_EXPECTED_TARGET OR VOID_EXPECTED_TARGET STREQUAL "")
|
||||
message(FATAL_ERROR "VOID_EXPECTED_TARGET is required")
|
||||
endif()
|
||||
|
||||
find_package(Void CONFIG REQUIRED COMPONENTS Core)
|
||||
|
||||
include("${Void_DIR}/void-target-manifest.cmake")
|
||||
|
||||
if(NOT VOID_TARGET_MANIFEST_TARGET STREQUAL VOID_EXPECTED_TARGET)
|
||||
message(FATAL_ERROR
|
||||
"[TargetProfile] installed manifest target "
|
||||
"'${VOID_TARGET_MANIFEST_TARGET}' does not match expected "
|
||||
"'${VOID_EXPECTED_TARGET}'")
|
||||
endif()
|
||||
if(NOT Core IN_LIST VOID_TARGET_MANIFEST_MODULES)
|
||||
message(FATAL_ERROR
|
||||
"[TargetProfile] installed manifest does not record module 'Core' "
|
||||
"(modules: ${VOID_TARGET_MANIFEST_MODULES})")
|
||||
endif()
|
||||
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/target-profile.txt"
|
||||
"target=${VOID_TARGET_MANIFEST_TARGET}\n"
|
||||
"triple=${VOID_TARGET_MANIFEST_TRIPLE}\n"
|
||||
"compiler=${VOID_TARGET_MANIFEST_COMPILER_ID}-${VOID_TARGET_MANIFEST_COMPILER_VERSION}\n"
|
||||
"cxx_standard=${VOID_TARGET_MANIFEST_CXX_STANDARD}\n"
|
||||
"linkage=${VOID_TARGET_MANIFEST_LINKAGE}\n"
|
||||
"reflection=${VOID_TARGET_MANIFEST_REFLECTION}\n"
|
||||
"sanitizers=${VOID_TARGET_MANIFEST_SANITIZERS}\n"
|
||||
"modules=${VOID_TARGET_MANIFEST_MODULES}\n"
|
||||
)
|
||||
message(STATUS
|
||||
"[TargetProfile] target=${VOID_TARGET_MANIFEST_TARGET} "
|
||||
"triple=${VOID_TARGET_MANIFEST_TRIPLE} "
|
||||
"compiler=${VOID_TARGET_MANIFEST_COMPILER_ID}-${VOID_TARGET_MANIFEST_COMPILER_VERSION} "
|
||||
"linkage=${VOID_TARGET_MANIFEST_LINKAGE} "
|
||||
"reflection=${VOID_TARGET_MANIFEST_REFLECTION}")
|
||||
|
||||
add_executable(void_target_profile_consumer main.cpp)
|
||||
target_link_libraries(void_target_profile_consumer PRIVATE Void::Core)
|
||||
|
||||
enable_testing()
|
||||
add_test(NAME VoidTargetProfileConsumer COMMAND void_target_profile_consumer)
|
||||
@@ -0,0 +1,28 @@
|
||||
// Isolated consumer fixture for target qualification. Exercises a small
|
||||
// runtime behaviour from the always-present Core module so an install/consume
|
||||
// check covers headers, linkage and the module dependency closure.
|
||||
#include <Void/Core/CheckedBits.hpp>
|
||||
#include <Void/Core/Hash.hpp>
|
||||
#include <Void/Core/Uuid.hpp>
|
||||
|
||||
#include <random>
|
||||
#include <string_view>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::mt19937_64 rng{11};
|
||||
const auto uuid = Void::Uuid::v4(rng);
|
||||
const auto chars = Void::Uuid::format_chars(uuid);
|
||||
const auto reparsed =
|
||||
Void::Uuid::parse(std::string_view{chars.data(), chars.size()});
|
||||
if (!reparsed || *reparsed != uuid) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
const auto aligned = Void::Bits::checked_align_up(13u, 8u);
|
||||
if (!aligned || *aligned != 16u) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return Void::Hash::fnv1a64("target-profile") != 0 ? 0 : 1;
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
# Target qualification driver.
|
||||
#
|
||||
# 1. Installs the build tree and consumes it through an isolated fixture that
|
||||
# records the target tuple (target, triple, compiler, linkage, reflection,
|
||||
# modules) and runs one behaviour per module.
|
||||
# 2. Re-configures the source tree for negative cases: unknown target,
|
||||
# unsupported module on a target, and a missing external dependency. Each
|
||||
# must fail at configure time with a useful message.
|
||||
# 3. Re-configures the wasm subset positively to prove the allowlist accepts
|
||||
# a pure computation selection without native networking/SQLite/reflection.
|
||||
|
||||
foreach(required IN ITEMS VOID_BUILD_DIR VOID_SOURCE_DIR VOID_TEST_SOURCE_DIR
|
||||
VOID_TEST_ROOT VOID_CXX_COMPILER VOID_CTEST_COMMAND)
|
||||
if(NOT DEFINED ${required} OR "${${required}}" STREQUAL "")
|
||||
message(FATAL_ERROR "${required} is required")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
file(REMOVE_RECURSE "${VOID_TEST_ROOT}")
|
||||
file(MAKE_DIRECTORY "${VOID_TEST_ROOT}")
|
||||
|
||||
set(_gen_args "")
|
||||
if(DEFINED VOID_GENERATOR AND NOT VOID_GENERATOR STREQUAL "")
|
||||
list(APPEND _gen_args -G "${VOID_GENERATOR}")
|
||||
endif()
|
||||
if(DEFINED VOID_MAKE_PROGRAM AND NOT VOID_MAKE_PROGRAM STREQUAL "")
|
||||
list(APPEND _gen_args "-DCMAKE_MAKE_PROGRAM=${VOID_MAKE_PROGRAM}")
|
||||
endif()
|
||||
|
||||
# ── 1. Install and consume the current target ─────────────────────────────────
|
||||
set(_install_prefix "${VOID_TEST_ROOT}/install")
|
||||
set(_install_command "${CMAKE_COMMAND}" --install "${VOID_BUILD_DIR}"
|
||||
--prefix "${_install_prefix}")
|
||||
if(DEFINED VOID_BUILD_CONFIG AND NOT VOID_BUILD_CONFIG STREQUAL "")
|
||||
list(APPEND _install_command --config "${VOID_BUILD_CONFIG}")
|
||||
endif()
|
||||
execute_process(COMMAND ${_install_command} COMMAND_ERROR_IS_FATAL ANY)
|
||||
|
||||
set(_consumer_build "${VOID_TEST_ROOT}/TargetProfile")
|
||||
set(_consumer_source "${VOID_TEST_SOURCE_DIR}/TargetProfile")
|
||||
set(_no_external_deps
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_LibArchive=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_OpenSSL=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_Threads=TRUE)
|
||||
execute_process(
|
||||
COMMAND "${CMAKE_COMMAND}" -S "${_consumer_source}" -B "${_consumer_build}"
|
||||
${_gen_args}
|
||||
"-DCMAKE_PREFIX_PATH=${_install_prefix}"
|
||||
"-DCMAKE_CXX_COMPILER=${VOID_CXX_COMPILER}"
|
||||
"-DVOID_EXPECTED_TARGET=${VOID_TARGET}"
|
||||
${_no_external_deps}
|
||||
COMMAND_ERROR_IS_FATAL ANY)
|
||||
|
||||
set(_consumer_build_command "${CMAKE_COMMAND}" --build "${_consumer_build}")
|
||||
if(DEFINED VOID_BUILD_CONFIG AND NOT VOID_BUILD_CONFIG STREQUAL "")
|
||||
list(APPEND _consumer_build_command --config "${VOID_BUILD_CONFIG}")
|
||||
endif()
|
||||
execute_process(COMMAND ${_consumer_build_command} COMMAND_ERROR_IS_FATAL ANY)
|
||||
|
||||
set(_profile_file "${_consumer_build}/target-profile.txt")
|
||||
if(NOT EXISTS "${_profile_file}")
|
||||
message(FATAL_ERROR "[TargetQualification] consumer did not record a profile")
|
||||
endif()
|
||||
file(READ "${_profile_file}" _profile)
|
||||
foreach(_field IN ITEMS target triple compiler linkage reflection modules)
|
||||
if(NOT _profile MATCHES "(^|\n)${_field}=")
|
||||
message(FATAL_ERROR
|
||||
"[TargetQualification] profile misses '${_field}':\n${_profile}")
|
||||
endif()
|
||||
endforeach()
|
||||
if(NOT _profile MATCHES "(^|\n)target=${VOID_TARGET}(\n|$)")
|
||||
message(FATAL_ERROR
|
||||
"[TargetQualification] profile target mismatch (expected ${VOID_TARGET}):\n${_profile}")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED VOID_CROSSCOMPILING OR NOT VOID_CROSSCOMPILING)
|
||||
execute_process(
|
||||
COMMAND "${VOID_CTEST_COMMAND}" --test-dir "${_consumer_build}"
|
||||
--output-on-failure
|
||||
COMMAND_ERROR_IS_FATAL ANY)
|
||||
endif()
|
||||
|
||||
# ── 2. Negative and positive configure cases ─────────────────────────────────
|
||||
set(_configure_result 0)
|
||||
set(_configure_output "")
|
||||
|
||||
function(run_void_configure name)
|
||||
set(_build_dir "${VOID_TEST_ROOT}/configure-${name}")
|
||||
file(REMOVE_RECURSE "${_build_dir}")
|
||||
execute_process(
|
||||
COMMAND "${CMAKE_COMMAND}" -S "${VOID_SOURCE_DIR}" -B "${_build_dir}"
|
||||
${_gen_args}
|
||||
"-DCMAKE_CXX_COMPILER=${VOID_CXX_COMPILER}"
|
||||
-DCMAKE_BUILD_TYPE=Debug
|
||||
${ARGN}
|
||||
RESULT_VARIABLE _result
|
||||
OUTPUT_VARIABLE _stdout
|
||||
ERROR_VARIABLE _stderr)
|
||||
set(_configure_result "${_result}" PARENT_SCOPE)
|
||||
set(_configure_output "${_stdout}${_stderr}" PARENT_SCOPE)
|
||||
set(_configure_build_dir "${_build_dir}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(expect_configure_failure name pattern)
|
||||
run_void_configure("${name}" ${ARGN})
|
||||
if(_configure_result EQUAL 0)
|
||||
message(FATAL_ERROR
|
||||
"[TargetQualification] '${name}' configured successfully but "
|
||||
"was expected to fail")
|
||||
endif()
|
||||
if(NOT _configure_output MATCHES "${pattern}")
|
||||
message(FATAL_ERROR
|
||||
"[TargetQualification] '${name}' failed without matching "
|
||||
"'${pattern}'. Output:\n${_configure_output}")
|
||||
endif()
|
||||
message(STATUS "[TargetQualification] ${name}: rejected as expected")
|
||||
endfunction()
|
||||
|
||||
# Unknown target profile.
|
||||
expect_configure_failure(unknown-target "Unknown VOID_TARGET"
|
||||
-DVOID_TARGET=plan9
|
||||
-DVOID_ENABLED_MODULES=Core
|
||||
-DVOID_ENABLE_TESTING=OFF)
|
||||
|
||||
# Native module on the browser/Wasm target. IPC pulls IO/Async/Resilience,
|
||||
# which are also outside the wasm allowlist.
|
||||
expect_configure_failure(wasm-rejects-native
|
||||
"Modules not supported on target 'wasm'"
|
||||
-DVOID_TARGET=wasm
|
||||
-DVOID_ENABLED_MODULES=IPC
|
||||
-DVOID_ENABLE_TESTING=OFF)
|
||||
|
||||
# Native networking is rejected before Boost/OpenSSL are even resolved.
|
||||
expect_configure_failure(wasm-rejects-net
|
||||
"Modules not supported on target 'wasm'"
|
||||
-DVOID_TARGET=wasm
|
||||
-DVOID_ENABLED_MODULES=Net
|
||||
-DVOID_ENABLE_TESTING=OFF)
|
||||
|
||||
# Missing external dependency fails with the dependency name.
|
||||
expect_configure_failure(missing-sqlite "SQLite3"
|
||||
-DVOID_ENABLED_MODULES=Sqlite
|
||||
-DVOID_ENABLE_TESTING=OFF
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE)
|
||||
|
||||
# The pure subset must configure for wasm and record the target.
|
||||
run_void_configure(wasm-subset
|
||||
-DVOID_TARGET=wasm
|
||||
-DVOID_ENABLED_MODULES=Data
|
||||
-DVOID_ENABLE_TESTING=OFF)
|
||||
if(NOT _configure_result EQUAL 0)
|
||||
message(FATAL_ERROR
|
||||
"[TargetQualification] wasm subset failed to configure:\n${_configure_output}")
|
||||
endif()
|
||||
set(_manifest "${_configure_build_dir}/void-target-manifest.cmake")
|
||||
if(NOT EXISTS "${_manifest}")
|
||||
message(FATAL_ERROR "[TargetQualification] wasm subset wrote no manifest")
|
||||
endif()
|
||||
file(READ "${_manifest}" _manifest_text)
|
||||
if(NOT _manifest_text MATCHES "VOID_TARGET_MANIFEST_TARGET \"wasm\"")
|
||||
message(FATAL_ERROR
|
||||
"[TargetQualification] wasm manifest does not record target wasm:\n${_manifest_text}")
|
||||
endif()
|
||||
message(STATUS "[TargetQualification] wasm subset: configured and recorded")
|
||||
Reference in new issue
Block a user