From 6ec7e06773b0a3ea3b03297d45e0cc898796af03 Mon Sep 17 00:00:00 2001 From: AlenHay <82121826+AlenHay@users.noreply.github.com> Date: Wed, 7 Oct 2026 07:40:52 +0200 Subject: [PATCH 1/4] Allow generated projects to use host codegen and target emulators --- resources/templates/init/rexglue_cmake.inja | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/resources/templates/init/rexglue_cmake.inja b/resources/templates/init/rexglue_cmake.inja index 39ea11e..7f92ef4 100644 --- a/resources/templates/init/rexglue_cmake.inja +++ b/resources/templates/init/rexglue_cmake.inja @@ -108,6 +108,20 @@ macro(rexglue_setup_target target_name) rexglue_configure_target({{ cmake_var("target_name") }} {{ cmake_var("ARGN") }}) endmacro() +# A cross-build can reuse a host-native CLI, keeping host paths in the manifest +# usable and avoiding a target-platform codegen executable build. +set(REXGLUE_HOST_CODEGEN_EXECUTABLE "" CACHE FILEPATH + "Host-native rexglue CLI used for code generation") +if(REXGLUE_HOST_CODEGEN_EXECUTABLE) + if(NOT EXISTS "{{ cmake_var("REXGLUE_HOST_CODEGEN_EXECUTABLE") }}") + message(FATAL_ERROR "Host rexglue CLI not found: {{ cmake_var("REXGLUE_HOST_CODEGEN_EXECUTABLE") }}") + endif() + set(REXGLUE_CODEGEN_COMMAND "{{ cmake_var("REXGLUE_HOST_CODEGEN_EXECUTABLE") }}") +else() + # A target name lets CMake honor CROSSCOMPILING_EMULATOR when necessary. + set(REXGLUE_CODEGEN_COMMAND rex::rexglue) +endif() + # Codegen runs as part of the build, re-running only when an input in codegen.d # changes. Build it alone with 'cmake --build . --target {{ names.snake_case }}_codegen'. # Listing the sources as outputs orders any target that compiles them after @@ -126,7 +140,8 @@ add_custom_command( # declares some of them inside existing functions, and emit_conditional_branch # cannot yet resolve a branch across such a split without emitting a goto to # an unlabelled address (see the comment there). - COMMAND $ codegen --pointer_table_scan {{ cmake_var("CMAKE_CURRENT_SOURCE_DIR") }}/{{ names.snake_case }}_manifest.toml + COMMAND "{{ cmake_var("REXGLUE_CODEGEN_COMMAND") }}" codegen --pointer_table_scan "{{ cmake_var("CMAKE_CURRENT_SOURCE_DIR") }}/{{ names.snake_case }}_manifest.toml" + DEPENDS "{{ cmake_var("REXGLUE_CODEGEN_COMMAND") }}" DEPFILE "{{ cmake_var("CMAKE_CURRENT_SOURCE_DIR") }}/{{ entrypoint_out_dir }}/codegen.d" WORKING_DIRECTORY {{ cmake_var("CMAKE_CURRENT_SOURCE_DIR") }} COMMENT "Generating recompiled code for {{ names.snake_case }}" From 85a0be517c22f30feec3c7c18465243522e5a0eb Mon Sep 17 00:00:00 2001 From: AlenHay <82121826+AlenHay@users.noreply.github.com> Date: Wed, 7 Oct 2026 08:47:59 +0200 Subject: [PATCH 2/4] Prepare and verify the pinned SIMDe streaming-store compatibility patch Keep the public dependency revision, record the native __m64 fix as an overlay, and verify exact repository identity and actual patched hunks independently of Git status. Document clean-checkout preparation and register offline preparation plus streaming-store regressions. --- README.md | 4 + patches/README.md | 29 +++++ patches/simde-native-m64-stream.patch | 21 +++ scripts/prepare_simde.py | 100 +++++++++++++++ tests/CMakeLists.txt | 45 +++++++ tests/regression/test_prepare_simde.py | 157 +++++++++++++++++++++++ tests/regression/test_simde_stream_pi.py | 84 ++++++++++++ 7 files changed, 440 insertions(+) create mode 100644 patches/README.md create mode 100644 patches/simde-native-m64-stream.patch create mode 100644 scripts/prepare_simde.py create mode 100644 tests/regression/test_prepare_simde.py create mode 100644 tests/regression/test_simde_stream_pi.py diff --git a/README.md b/README.md index bfc31ce..57e0b47 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,10 @@ > > **Building:** use the presets. `cmake --preset win-amd64` then > `cmake --build out/build/win-amd64 --config Release --target install`. +> After initializing submodules, run `python3 scripts/prepare_simde.py` and +> `python3 scripts/prepare_simde.py --check` before configuring this fork. +> See [compatibility patch instructions](patches/README.md) for preparation and +> offline validation of the pinned SIMDe source. > The x86 baseline is `REXGLUE_X86_BASELINE` (default `x86-64-v2`); the SDK's > byte-swap helpers need SSSE3, so plain `x86-64` will not compile. For a CPU > without AVX2, pass the same baseline to the game as well - see diff --git a/patches/README.md b/patches/README.md new file mode 100644 index 0000000..42b69db --- /dev/null +++ b/patches/README.md @@ -0,0 +1,29 @@ +SIMDe remains pinned to `71fd833d9666141edcd1d3c109a80e228303d8d7`. +The native `__m64` streaming-store compatibility fix is recorded in +`simde-native-m64-stream.patch`; no private vendor commit is required. + +After initializing the SDK submodules, run from the SDK root: + +```sh +python3 scripts/prepare_simde.py +python3 scripts/prepare_simde.py --check +``` + +The preparer accepts the exact repository root and revision, preserves unrelated +local edits, and verifies the actual patched source independently of Git's exit +status. A partial/conflicting patch fails rather than overwriting local edits. +This step is required before building with Windows Clang toolchains that +represent native `__m64` as a union rejected by `__builtin_nontemporal_store`. +The public SIMD type and its eight stored bytes remain unchanged. + +Offline preparation regression, using disposable clones of locally available +Git objects (no network or original-checkout writes): + +```sh +python3 tests/regression/test_prepare_simde.py /tmp/rex-simde-preparation +``` + +The separate `test_simde_stream_pi.py` fixture compiles the actual header and +checks bit patterns and adjacent canaries. Its optional `--windows-sysroot` +mode also checks the real Windows Clang non-temporal `i64` store. Preparation +checks do not substitute for compiler or runtime validation. diff --git a/patches/simde-native-m64-stream.patch b/patches/simde-native-m64-stream.patch new file mode 100644 index 0000000..ae4192c --- /dev/null +++ b/patches/simde-native-m64-stream.patch @@ -0,0 +1,21 @@ +diff --git a/simde/x86/sse.h b/simde/x86/sse.h +index a8855f5..fac2f98 100644 +--- a/simde/x86/sse.h ++++ b/simde/x86/sse.h +@@ -4757,7 +4757,15 @@ simde_mm_stream_pi (simde__m64* mem_addr, simde__m64 a) { + #elif HEDLEY_HAS_BUILTIN(__builtin_nontemporal_store) && ( \ + defined(SIMDE_ARM_NEON_A32V7_NATIVE) || defined(SIMDE_MIPS_LOONGSON_MMI_NATIVE) || \ + defined(SIMDE_VECTOR_SUBSCRIPT)) +- __builtin_nontemporal_store(a, mem_addr); ++ #if defined(SIMDE_X86_MMX_USE_NATIVE_TYPE) ++ /* Windows Clang represents the native __m64 type as a union, which ++ * __builtin_nontemporal_store cannot accept. Preserve its eight bytes ++ * through the private integer lane without changing the public type. */ ++ simde__m64_private a_ = simde__m64_to_private(a); ++ __builtin_nontemporal_store(a_.i64[0], HEDLEY_REINTERPRET_CAST(int64_t*, mem_addr)); ++ #else ++ __builtin_nontemporal_store(a, mem_addr); ++ #endif + #elif defined(SIMDE_ARM_NEON_A32V7_NATIVE) + simde__m64_private a_ = simde__m64_to_private(a); + vst1_s64(HEDLEY_REINTERPRET_CAST(int64_t *, mem_addr), a_.neon_i64); diff --git a/scripts/prepare_simde.py b/scripts/prepare_simde.py new file mode 100644 index 0000000..e0e58cb --- /dev/null +++ b/scripts/prepare_simde.py @@ -0,0 +1,100 @@ +"""Apply or verify the pinned SIMDe native __m64 streaming-store fix.""" + +import argparse +from pathlib import Path +import re +import subprocess + + +PIN = "71fd833d9666141edcd1d3c109a80e228303d8d7" + + +def verify_patched_source(checkout, patch): + """Require every actual new-side hunk, independently of git's exit status.""" + target = None + expected = None + lines = [] + hunks = 0 + + def finish(): + nonlocal hunks + if expected is None: + return + if target is None or not lines or len(lines) != expected: + raise ValueError("Invalid SIMDe patch hunk") + path = checkout / target + if path.resolve() != path or not path.is_file(): + raise ValueError(f"SIMDe source verification failed: invalid source path {target}") + if "\n".join(lines) + "\n" not in path.read_text(): + raise ValueError(f"SIMDe source verification failed: missing patched hunk in {target}") + hunks += 1 + + for line in patch.read_text().splitlines(): + if line.startswith("diff --git "): + finish() + target, expected, lines = None, None, [] + elif line.startswith("+++ b/"): + target = Path(line[6:]) + if target.is_absolute() or ".." in target.parts: + raise ValueError("Invalid SIMDe patch target") + elif line.startswith("@@ "): + finish() + header = re.fullmatch(r"@@ -\d+(?:,\d+)? \+\d+(?:,(\d+))? @@.*", line) + if header is None: + raise ValueError("Invalid SIMDe patch header") + expected, lines = int(header.group(1) or "1"), [] + elif expected is not None: + if line.startswith((" ", "+")): + lines.append(line[1:]) + elif not line.startswith(("-", "\\ No newline")): + raise ValueError("Invalid SIMDe patch content") + finish() + if not hunks: + raise ValueError("SIMDe patch has no verifiable hunks") + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + sdk = Path(__file__).resolve().parents[1] + parser.add_argument("checkout", type=Path, nargs="?", default=sdk / "thirdparty/simde") + parser.add_argument("--check", action="store_true", help="Verify only; do not modify the checkout") + args = parser.parse_args() + checkout = args.checkout.resolve() + patch = sdk / "patches/simde-native-m64-stream.patch" + + def git(*arguments, check=False): + return subprocess.run(["git", "-C", str(checkout), *arguments], check=check, + cwd=checkout, capture_output=True, text=True, timeout=30) + + if not checkout.is_dir(): + parser.error(f"SIMDe checkout does not exist: {checkout}") + repository = git("rev-parse", "--show-toplevel") + if repository.returncode or Path(repository.stdout.strip()).resolve() != checkout: + parser.error("SIMDe checkout must be the repository root, not a subdirectory") + revision = git("rev-parse", "HEAD", check=True).stdout.strip() + if revision != PIN: + parser.error(f"Expected SIMDe {PIN}, got {revision}; use the SDK's pinned submodule revision") + if git("apply", "--reverse", "--check", str(patch)).returncode == 0: + try: + verify_patched_source(checkout, patch) + except ValueError as error: + parser.error(str(error)) + print(f"PASS: SIMDe {PIN} with native __m64 streaming-store fix") + return + if args.check: + parser.error("Native __m64 streaming-store fix is missing or incomplete; run without --check") + applicability = git("apply", "--check", str(patch)) + if applicability.returncode: + parser.error("Cannot apply the SIMDe fix without conflicting with existing edits:\n" + + applicability.stderr.strip()) + git("apply", str(patch), check=True) + git("apply", "--reverse", "--check", str(patch), check=True) + try: + verify_patched_source(checkout, patch) + except ValueError as error: + parser.error(str(error)) + print(f"Applied native __m64 streaming-store fix to SIMDe {PIN}") + + +if __name__ == "__main__": + main() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3e67044..619ab04 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -6,3 +6,48 @@ add_subdirectory(unit) # PPC instruction tests (requires PPC toolchain) add_subdirectory(ppc) + +# Compile small production-body fixtures with fake guest threads and graphics +# objects. These tests do not require game assets or a graphics device. The +# cache-storage fixtures use POSIX stdio/file APIs, so register them on Linux +# with GNU-style compiler drivers only. +if(CMAKE_SYSTEM_NAME STREQUAL "Linux" + AND NOT CMAKE_CROSSCOMPILING + AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU") + find_package(Python3 COMPONENTS Interpreter QUIET) + if(Python3_Interpreter_FOUND) + set(REXGLUE_REGRESSION_CHECKS) + if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(AMD64|amd64|x86_64)$") + list(APPEND REXGLUE_REGRESSION_CHECKS simde_stream_pi) + endif() + foreach(check IN LISTS REXGLUE_REGRESSION_CHECKS) + add_test(NAME regression_${check} + COMMAND ${Python3_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/regression/test_${check}.py + ${CMAKE_CURRENT_BINARY_DIR}/regression/${check} + --compiler ${CMAKE_CXX_COMPILER}) + set_tests_properties(regression_${check} PROPERTIES + TIMEOUT 60 LABELS "regression;asset_free") + if(check STREQUAL "timer_wait") + set_tests_properties(regression_${check} PROPERTIES TIMEOUT 100) + endif() + endforeach() + else() + message(STATUS "Python3 unavailable: production-body regression fixtures are disabled") + endif() +endif() + +# Patch preparation uses local Git objects and does not execute target binaries. +if(UNIX) + find_package(Python3 COMPONENTS Interpreter QUIET) + find_package(Git QUIET) + if(Python3_Interpreter_FOUND AND Git_FOUND + AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../thirdparty/simde/.git") + add_test(NAME regression_prepare_simde + COMMAND ${Python3_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/regression/test_prepare_simde.py + ${CMAKE_CURRENT_BINARY_DIR}/regression/prepare_simde) + set_tests_properties(regression_prepare_simde PROPERTIES + TIMEOUT 60 LABELS "regression;asset_free") + endif() +endif() diff --git a/tests/regression/test_prepare_simde.py b/tests/regression/test_prepare_simde.py new file mode 100644 index 0000000..76fb6fc --- /dev/null +++ b/tests/regression/test_prepare_simde.py @@ -0,0 +1,157 @@ +"""Verify preparation of the exact public SIMDe pin in disposable offline clones.""" +import argparse +import hashlib +import json +from pathlib import Path +import shutil +import subprocess +import sys +import tempfile + +PIN = '71fd833d9666141edcd1d3c109a80e228303d8d7' + + +def digest(path): + return hashlib.sha256(path.read_bytes()).hexdigest() + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + sdk = Path(__file__).resolve().parents[2] + parser.add_argument('output', type=Path) + parser.add_argument('--checkout', type=Path, default=sdk/'thirdparty/simde') + parser.add_argument('--preparer', type=Path, default=sdk/'scripts/prepare_simde.py') + args = parser.parse_args() + output = args.output.resolve() + output.mkdir(parents=True, exist_ok=True) + source, preparer = args.checkout.resolve(), args.preparer.resolve() + patch = sdk/'patches/simde-native-m64-stream.patch' + git_executable = shutil.which('git') + if git_executable is None: + parser.error('Git is required for the offline public-source fixture') + checks = [] + + def command(argv, cwd, *, expect=0, oracle=None): + result = subprocess.run(argv, cwd=cwd, capture_output=True, text=True, timeout=15) + if result.returncode != expect or (oracle and oracle not in result.stdout+result.stderr): + raise AssertionError(f'Expected exit{expect}, oracle{oracle!r}; got{result.returncode}\n' + + result.stdout + result.stderr) + return result + + def git(checkout, *arguments): + return command([git_executable, '-C', str(checkout), *arguments], output) + + def identity(): + return dict(head=git(source, 'rev-parse', 'HEAD').stdout, + status=git(source, 'status', '--porcelain=v1', '--untracked-files=all').stdout, + header_sha256=digest(source/'simde/x86/sse.h')) + + original = identity() + git(source, 'cat-file', '-e', PIN+'^{commit}') + public = subprocess.run([git_executable, '-C', str(source), 'show', PIN+':simde/x86/sse.h'], + capture_output=True, check=True, timeout=15).stdout + with tempfile.TemporaryDirectory(prefix='simde-preparation-', dir=output) as temporary: + sandbox = Path(temporary) + unrelated = sandbox/'unrelated-cwd' + unrelated.mkdir() + + def clone(name): + checkout = sandbox/name + command([git_executable, 'clone', '--config', 'core.autocrlf=false', + '--shared', '--no-checkout', str(source), str(checkout)], unrelated) + git(checkout, 'checkout', '--detach', PIN) + assert (checkout/'simde/x86/sse.h').read_bytes() == public + return checkout + + def prepare(checkout, *options, expect=0, oracle=None): + return command([sys.executable, str(preparer), str(checkout), *options], unrelated, + expect=expect, oracle=oracle) + + expected = clone('independent-patch') + git(expected, 'apply', '--check', str(patch)) + git(expected, 'apply', str(patch)) + expected_sha = digest(expected/'simde/x86/sse.h') + checks.append('actual public pin independently patched with real Git') + + checkout = clone('prepare-under-test') + before = digest(checkout/'simde/x86/sse.h') + prepare(checkout, '--check', expect=2, oracle='Native __m64 streaming-store fix is missing or incomplete') + assert digest(checkout/'simde/x86/sse.h') == before + checks.append('missing patch check rejects without source writes') + for options in ((), ('--check',)): + prepare(checkout/'simde/x86', *options, expect=2, + oracle='must be the repository root, not a subdirectory') + assert digest(checkout/'simde/x86/sse.h') == before + checks.append('apply/check reject actual repository subdirectory') + prepare(checkout, oracle='Applied native __m64 streaming-store fix') + assert digest(checkout/'simde/x86/sse.h') == expected_sha + for options in (('--check',), ()): + prepare(checkout, *options, oracle='PASS: SIMDe') + assert digest(checkout/'simde/x86/sse.h') == expected_sha + checks.append('apply/check/repeat from unrelated cwd match independent patch exactly') + # Represents an existing checkout prepared before root/content hardening. + for options in (('--check',), ()): + prepare(expected, *options, oracle='PASS: SIMDe') + assert digest(expected/'simde/x86/sse.h') == expected_sha + checks.append('old independently prepared checkout accepted unchanged') + with (checkout/'simde/x86/sse.h').open('a') as stream: + stream.write('\n/* Fixture unrelated edit outside patched hunks. */\n') + edited = digest(checkout/'simde/x86/sse.h') + prepare(checkout, '--check', oracle='PASS: SIMDe') + prepare(checkout, oracle='PASS: SIMDe') + assert digest(checkout/'simde/x86/sse.h') == edited + checks.append('unrelated local edit preserved') + header = (checkout/'simde/x86/sse.h').read_text() + old = '__builtin_nontemporal_store(a_.i64[0], HEDLEY_REINTERPRET_CAST(int64_t*, mem_addr));' + assert header.count(old) == 1 + (checkout/'simde/x86/sse.h').write_text(header.replace(old, old.replace('i64[0]', 'i64[1]'))) + partial_sha = digest(checkout/'simde/x86/sse.h') + prepare(checkout, '--check', expect=2, oracle='Native __m64 streaming-store fix is missing or incomplete') + prepare(checkout, expect=2, oracle='Cannot apply the SIMDe fix without conflicting with existing edits') + assert digest(checkout/'simde/x86/sse.h') == partial_sha + checks.append('partial patch check/apply reject without overwriting edits') + + wrong = clone('wrong-revision') + tree = git(wrong, 'rev-parse', PIN+'^{tree}').stdout.strip() + commit = command([git_executable, '-C', str(wrong), '-c', 'user.name=Fixture', + '-c', 'user.email=fixture@example.invalid', 'commit-tree', tree, + '-p', PIN, '-m', 'Fixture wrong revision with identical public tree'], unrelated).stdout.strip() + git(wrong, 'checkout', '--detach', commit) + prepare(wrong, expect=2, oracle=f'Expected SIMDe {PIN}, got {commit}') + checks.append('wrong revision rejected even with identical tree') + + noop = clone('false-success-git') + wrapper = '''import runpy, subprocess, sys +real_run = subprocess.run +reverse_calls = 0 +mode, preparer, checkout = sys.argv[1:4] +def fake_run(argv, *args, **kwargs): + global reverse_calls + if isinstance(argv, list) and argv[0] == 'git' and 'apply' in argv: + if '--reverse' in argv: + reverse_calls += 1 + if mode == 'apply' and reverse_calls == 1: + return subprocess.CompletedProcess(argv, 1, '', 'fixture patch missing') + return subprocess.CompletedProcess(argv, 0, '', '') + return real_run(argv, *args, **kwargs) +subprocess.run = fake_run +sys.argv = [preparer, checkout] +runpy.run_path(preparer, run_name='__main__') +''' + for mode in ('already', 'apply'): + command([sys.executable, '-c', wrapper, mode, str(preparer), str(noop)], unrelated, + expect=2, oracle='SIMDe source verification failed: missing patched hunk') + assert digest(noop/'simde/x86/sse.h') == before + checks.append('false already-applied and no-op apply Git success rejected by actual source') + assert identity() == original, 'Original SIMDe checkout changed' + checks.append('original checkout HEAD/status/source preserved') + report = dict(passed=True, pin=PIN, actual_public_source=True, offline=True, + preparer_sha256=digest(preparer), patch_sha256=digest(patch), + public_header_sha256=hashlib.sha256(public).hexdigest(), + prepared_header_sha256=expected_sha, checks=checks) + (output/'verification.json').write_text(json.dumps(report, indent=2)+'\n') + print(f'PASS: {len(checks)} offline exact-public-pin preparation checks; original checkout unchanged') + + +if __name__ == '__main__': + main() diff --git a/tests/regression/test_simde_stream_pi.py b/tests/regression/test_simde_stream_pi.py new file mode 100644 index 0000000..2545e9f --- /dev/null +++ b/tests/regression/test_simde_stream_pi.py @@ -0,0 +1,84 @@ +"""Check actual SIMDe streaming stores, optionally including Windows Clang IR.""" + +import argparse +from pathlib import Path +import re +import subprocess + + +parser = argparse.ArgumentParser(description=__doc__) +parser.add_argument("output", type=Path) +parser.add_argument("--compiler", default="clang++") +parser.add_argument("--windows-sysroot", type=Path, + help="Also compile the real header for Windows and verify its non-temporal i64 store") +args = parser.parse_args() +sdk = Path(__file__).resolve().parents[2] +output = args.output.resolve() +output.mkdir(parents=True, exist_ok=True) +source = output / "simde-stream.cpp" +binary = output / "simde-stream.exe" +source.write_text(r''' +#define SIMDE_X86_MMX_NO_NATIVE +#include +#include +#include +#include +#if !defined(SIMDE_X86_MMX_USE_NATIVE_TYPE) || defined(SIMDE_X86_MMX_NATIVE) +#error The regression must exercise the native m64 type with the fallback streaming store. +#endif +extern "C" void stream(simde__m64* destination, simde__m64 value) { + simde_mm_stream_pi(destination, value); +} +int main() { + struct alignas(64) Destination { uint64_t before; simde__m64 value; uint64_t after; }; + static_assert(sizeof(simde__m64) == sizeof(uint64_t)); + constexpr uint64_t patterns[] = {0, UINT64_MAX, 1, UINT64_C(0x8000000000000000), + UINT64_C(0x0123456789ABCDEF), UINT64_C(0xFEDCBA9876543210), + UINT64_C(0x7FF80000FFFFFFFF), UINT64_C(0xFFFFFFFF7FC00000)}; + auto check = [](uint64_t bits) { + Destination destination{}; + destination.before = UINT64_C(0xDEADBEEF12345678); + destination.after = UINT64_C(0x8877665544332211); + simde__m64 value; + std::memcpy(&value, &bits, sizeof(value)); + stream(&destination.value, value); + simde_mm_sfence(); + uint64_t result; + std::memcpy(&result, &destination.value, sizeof(result)); + assert(result == bits); + assert(destination.before == UINT64_C(0xDEADBEEF12345678)); + assert(destination.after == UINT64_C(0x8877665544332211)); + }; + for (uint64_t bits : patterns) check(bits); + uint64_t random = UINT64_C(0xE12CD327901A9EAB); + for (unsigned i = 0; i != 2048; ++i) { + random ^= random << 13; random ^= random >> 7; random ^= random << 17; + check(random); + } +} +''') +include = sdk / "thirdparty/simde" +subprocess.run([args.compiler, "-std=c++20", "-O2", "-UNDEBUG", "-I", str(include), + str(source), "-o", str(binary)], check=True, timeout=30) +subprocess.run([str(binary)], check=True, timeout=10) +print("PASS: actual SIMDe fallback stream_pi preserves 2056 bit patterns and adjacent canaries") + +if args.windows_sysroot: + sysroot = args.windows_sysroot.resolve() + windows_source = output / "simde-stream-windows.cpp" + windows_source.write_text( + '#include \n' + 'extern "C" void stream(simde__m64* destination, simde__m64 value) {\n' + ' simde_mm_stream_pi(destination, value);\n}\n') + llvm = output / "simde-stream-windows.ll" + command = [args.compiler, "--target=x86_64-pc-windows-msvc", "-std=c++20", "-O2", + "-march=x86-64-v3", "-fms-compatibility-version=19.40", "-I", str(include)] + for directory in ("crt/include", "sdk/include/ucrt", "sdk/include/shared", "sdk/include/um"): + command += ["-isystem", str(sysroot / directory)] + command += ["-S", "-emit-llvm", str(windows_source), "-o", str(llvm)] + subprocess.run(command, check=True, timeout=30) + ir = llvm.read_text() + function = re.search(r"define [^\n]*@stream\([^\n]*\).*?\n\}", ir, re.S) + if not function or not re.search(r"store i64 [^\n]*align 8, !nontemporal", function[0]): + raise AssertionError("Windows native union store must preserve all 64 bits and the non-temporal hint") + print("PASS: actual Windows SIMDe header emits one non-temporal aligned i64 store") From fc5d9f2a35d90bda52c6e7c0d22d1f8a7703d809 Mon Sep 17 00:00:00 2001 From: AlenHay <82121826+AlenHay@users.noreply.github.com> Date: Wed, 7 Oct 2026 08:48:18 +0200 Subject: [PATCH 3/4] Fix Linux and case-sensitive cross-build dependency integration Use lowercase Windows SDK header paths, guard the Windows physical portal implementation, propagate ImGui headers to public runtime consumers, expose the integration xxHash alias, and link unit hash tests directly. --- include/rex/ui/d3d12/d3d12_api.h | 2 +- src/core/platform_win.h | 4 ++-- src/input/input_system.cpp | 7 +++++++ src/system/CMakeLists.txt | 3 +++ tests/unit/CMakeLists.txt | 1 + thirdparty/CMakeLists.txt | 1 + 6 files changed, 15 insertions(+), 3 deletions(-) diff --git a/include/rex/ui/d3d12/d3d12_api.h b/include/rex/ui/d3d12/d3d12_api.h index 788a407..1cc2275 100644 --- a/include/rex/ui/d3d12/d3d12_api.h +++ b/include/rex/ui/d3d12/d3d12_api.h @@ -19,7 +19,7 @@ #define NOMINMAX #endif #include -#include +#include #include #include diff --git a/src/core/platform_win.h b/src/core/platform_win.h index 22d6566..e39ff02 100644 --- a/src/core/platform_win.h +++ b/src/core/platform_win.h @@ -24,8 +24,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/src/input/input_system.cpp b/src/input/input_system.cpp index 2e4a11d..eaa1f89 100644 --- a/src/input/input_system.cpp +++ b/src/input/input_system.cpp @@ -22,7 +22,9 @@ #include #include #include +#if REX_PLATFORM_WIN32 #include +#endif #include #include #include @@ -401,8 +403,13 @@ std::unique_ptr CreateDefaultInputSystem(bool tool_mode) { REXLOG_INFO("Portal: using the emulated ToyPad."); input->SetPortal(std::make_unique()); } else { +#if REX_PLATFORM_WIN32 REXLOG_INFO("Portal: using a physical portal over USB."); input->SetPortal(std::make_unique()); +#else + REXLOG_WARN("Portal: physical USB passthrough is unavailable on this platform; " + "enable toypad_emulation to use the emulated ToyPad."); +#endif } } diff --git a/src/system/CMakeLists.txt b/src/system/CMakeLists.txt index 30a2fa2..44022ed 100644 --- a/src/system/CMakeLists.txt +++ b/src/system/CMakeLists.txt @@ -71,6 +71,9 @@ rex_target_pch(rexruntime target_include_directories(rexruntime PUBLIC $ $ + # Public UI headers expose ImGui types. Propagate its headers while keeping + # the ImGui OBJECT library linked privately into this single runtime DLL. + $ $ ) target_include_directories(rexruntime PRIVATE diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index 7bd264b..77c4f5c 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -35,6 +35,7 @@ target_include_directories(unit_tests PRIVATE target_link_libraries(unit_tests PRIVATE rexcodegen rexruntime + xxHash::xxhash Catch2::Catch2WithMain ) diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 68048c8..3eb8959 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -157,6 +157,7 @@ target_compile_options(o1heap PRIVATE -w) # xxHash - extremely fast non-cryptographic hash (git submodule) set(XXHASH_BUILD_XXHSUM OFF CACHE BOOL "" FORCE) add_subdirectory(xxHash/cmake_unofficial) +add_library(rex::xxhash ALIAS xxhash) target_compile_options(xxhash PRIVATE -w) # disasm - PowerPC disassembler (existing local library) From f856cf24f0c287b3e92afdd9cdad0169f57c241e Mon Sep 17 00:00:00 2001 From: AlenHay <82121826+AlenHay@users.noreply.github.com> Date: Wed, 7 Oct 2026 09:17:44 +0200 Subject: [PATCH 4/4] Validate serialized TOML values and literal depfile escapes --- tests/unit/codegen/output_stamp_test.cpp | 4 ++-- tests/unit/core/cvar_test.cpp | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/unit/codegen/output_stamp_test.cpp b/tests/unit/codegen/output_stamp_test.cpp index d97edb5..f030f58 100644 --- a/tests/unit/codegen/output_stamp_test.cpp +++ b/tests/unit/codegen/output_stamp_test.cpp @@ -224,6 +224,6 @@ TEST_CASE("Depfile escapes characters make treats as syntax", "[output_stamp]") std::ifstream in(depfile, std::ios::binary); std::string content((std::istreambuf_iterator(in)), std::istreambuf_iterator()); - CHECK(content.find("has\ space.toml") != std::string::npos); - CHECK(content.find("hash\#.toml") != std::string::npos); + CHECK(content.find("has\\ space.toml") != std::string::npos); + CHECK(content.find("hash\\#.toml") != std::string::npos); } diff --git a/tests/unit/core/cvar_test.cpp b/tests/unit/core/cvar_test.cpp index 03a12cb..dc4deba 100644 --- a/tests/unit/core/cvar_test.cpp +++ b/tests/unit/core/cvar_test.cpp @@ -12,6 +12,7 @@ #include #include +#include #include @@ -513,7 +514,8 @@ TEST_CASE("cvar TOML serialization", "[cvar]") { // Should contain modified flags CHECK(toml.find("test_int32_flag = 999") != std::string::npos); - CHECK(toml.find("test_string_flag = \"custom\"") != std::string::npos); + const auto parsed = ::toml::parse(toml); + CHECK(parsed["test_string_flag"].value() == "custom"); // Should not contain flags at default CHECK(toml.find("test_bool_flag") == std::string::npos); @@ -695,7 +697,8 @@ TEST_CASE("cvar SaveConfig", "[cvar]") { } CHECK(content.find("test_int32_flag = 777") != std::string::npos); - CHECK(content.find("test_string_flag = \"saved_value\"") != std::string::npos); + const auto parsed = ::toml::parse(content); + CHECK(parsed["test_string_flag"].value() == "saved_value"); std::filesystem::remove(save_path); }