From 6981af9b95064ac347c130703c184e8128cae9b3 Mon Sep 17 00:00:00 2001 From: Marcel Bierling Date: Wed, 2 Sep 2026 20:52:22 +0200 Subject: [PATCH 1/6] Let a native toolchain configure --- CMakeLists.txt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 391723c94..1221adc3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,7 @@ set(OPENTS_VERSION_PRERELEASE "") option(OPENTS_OFFICIAL_BUILD "Build as an official release of the declared version" OFF) option(OPENTS_EXPERIMENTAL_CLANG_CL "Build with clang-cl using the MSVC ABI" OFF) +option(OPENTS_EXPERIMENTAL_NATIVE "Configure a native build for the host platform" OFF) if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC") @@ -24,14 +25,20 @@ elseif(MSVC) if(MSVC_VERSION LESS 1930) message(FATAL_ERROR "OpenTS requires MSVC 19.30 or newer.") endif() +elseif(OPENTS_EXPERIMENTAL_NATIVE) + message(STATUS "OpenTS: configuring an unsupported native build for the host platform.") else() message(FATAL_ERROR "OpenTS requires the Visual Studio 2022 MSVC toolchain. " "For the unsupported clang-cl experiment, configure with " - "-DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/clang-cl-msvc.cmake.") + "-DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/clang-cl-msvc.cmake. " + "For the unsupported native build, configure with " + "-DOPENTS_EXPERIMENTAL_NATIVE=ON.") endif() -enable_language(RC) +if(WIN32) + enable_language(RC) +endif() set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) From 600a324ea0abaaf8c45e200a3209d8971d0c3814 Mon Sep 17 00:00:00 2001 From: Marcel Bierling Date: Wed, 2 Sep 2026 20:52:22 +0200 Subject: [PATCH 2/6] Scope the Windows-only build steps to Windows --- code/CMakeLists.txt | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index fa2d5ea20..93a49be1c 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -2,7 +2,7 @@ set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE STRING "" FORCE) # OpenTS currently supports 32-bit (x86) builds only. -if(NOT CMAKE_SIZEOF_VOID_P EQUAL 4) +if(WIN32 AND NOT CMAKE_SIZEOF_VOID_P EQUAL 4) message(FATAL_ERROR "OpenTS must be built as 32-bit x86. Reconfigure with -A Win32.") endif() @@ -156,7 +156,7 @@ set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/bgfxbackend.cpp" PROPER "${BGFX_ROOT}/include;${CMAKE_SOURCE_DIR}/thirdparty/bgfx.cmake/bx/include;${BGFX_ROOT}/examples/common/imgui" COMPILE_DEFINITIONS "BX_CONFIG_DEBUG=$,1,$>" - COMPILE_OPTIONS "/Zc:preprocessor" + COMPILE_OPTIONS "$<$:/Zc:preprocessor>" ) # bx rewrites __stdcall while its headers are being parsed by clang-cl. Force the @@ -318,12 +318,14 @@ add_custom_command(TARGET OpenTS POST_BUILD "${TS_RUN_DIR}" ) -# Copy the linker-generated .pdb alongside the exe -add_custom_command(TARGET OpenTS POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - "$" - "${TS_RUN_DIR}" -) +# Copy the linker-generated .pdb alongside the exe. Only the MSVC linker writes one. +if(MSVC) + add_custom_command(TARGET OpenTS POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "$" + "${TS_RUN_DIR}" + ) +endif() # Copy the linker-generated .map (sits next to the exe, no GenEx for it) add_custom_command(TARGET OpenTS POST_BUILD From 0cffd29c4b7030143612e754c2a06209442c3c00 Mon Sep 17 00:00:00 2001 From: Marcel Bierling Date: Wed, 2 Sep 2026 20:52:22 +0200 Subject: [PATCH 3/6] Enable the Microsoft extensions the tree relies on --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1221adc3e..d7f902f1d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,10 @@ elseif(MSVC) endif() elseif(OPENTS_EXPERIMENTAL_NATIVE) message(STATUS "OpenTS: configuring an unsupported native build for the host platform.") + + # The tree declares imports and exports with __declspec throughout, which clang only + # accepts with the Microsoft extensions enabled. + add_compile_options(-fms-extensions) else() message(FATAL_ERROR "OpenTS requires the Visual Studio 2022 MSVC toolchain. " From edfd6004d347eb826940d46f5b0f5b2fe14b523f Mon Sep 17 00:00:00 2001 From: Marcel Bierling Date: Wed, 2 Sep 2026 20:52:22 +0200 Subject: [PATCH 4/6] Document the native build --- docs/BUILDING.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/BUILDING.md b/docs/BUILDING.md index 25c61988c..d02b202b1 100644 --- a/docs/BUILDING.md +++ b/docs/BUILDING.md @@ -97,6 +97,19 @@ The toolchain requires `clang-cl`, `lld-link`, `llvm-lib`, `llvm-mt`, and `llvm-rc` on `PATH`. It exports `compile_commands.json`; one configuration in `.vscode/c_cpp_properties.clang.example.json` reads that file for IntelliSense. +## Experimental native build + +An unsupported native build for the host platform is available for portability +work. It does not expand the supported build matrix or establish runtime +behavior. + +```bash +cmake -S . -B build/native -G Ninja \ + -DCMAKE_BUILD_TYPE=Release \ + -DOPENTS_EXPERIMENTAL_NATIVE=ON +cmake --build build/native +``` + ## Build from Visual Studio Code With the recommended extensions installed, the repository provides: From 7b3e24522f246a44869287ab4d2b53a15fc3d174 Mon Sep 17 00:00:00 2001 From: Marcel Bierling Date: Tue, 8 Sep 2026 23:53:10 +0200 Subject: [PATCH 5/6] Warn that a wider native pointer changes the save representation --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d7f902f1d..8f85224af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,6 +31,13 @@ elseif(OPENTS_EXPERIMENTAL_NATIVE) # The tree declares imports and exports with __declspec throughout, which clang only # accepts with the Microsoft extensions enabled. add_compile_options(-fms-extensions) + + # Saved games serialize pointer fields at their native width. + if(NOT CMAKE_SIZEOF_VOID_P EQUAL 4) + message(WARNING + "OpenTS: this native build has ${CMAKE_SIZEOF_VOID_P}-byte pointers. Saved games " + "it writes are not interchangeable with a supported 32-bit build's.") + endif() else() message(FATAL_ERROR "OpenTS requires the Visual Studio 2022 MSVC toolchain. " From 22880257a734a4141eac5b2b9d445427ea4c7ea2 Mon Sep 17 00:00:00 2001 From: Marcel Bierling Date: Tue, 8 Sep 2026 23:53:29 +0200 Subject: [PATCH 6/6] State what the native build configures and what it does not --- docs/BUILDING.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/docs/BUILDING.md b/docs/BUILDING.md index d02b202b1..397ef374f 100644 --- a/docs/BUILDING.md +++ b/docs/BUILDING.md @@ -100,16 +100,26 @@ The toolchain requires `clang-cl`, `lld-link`, `llvm-lib`, `llvm-mt`, and ## Experimental native build An unsupported native build for the host platform is available for portability -work. It does not expand the supported build matrix or establish runtime -behavior. +work. It configures; the engine target does not compile yet. It does not expand +the supported build matrix or establish runtime behavior. ```bash cmake -S . -B build/native -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ -DOPENTS_EXPERIMENTAL_NATIVE=ON -cmake --build build/native ``` +Building the generated tree compiles the vendored dependencies and stops on +every engine source, because `code/CMakeLists.txt` passes the MSVC flag set +unconditionally. `/arch:SSE2` and `/fp:precise` carry the float semantics the +simulation depends on, so a native equivalent is a decision to make rather than +a translation. Windows headers and import libraries are named unconditionally +as well. + +A native build takes the host's pointer width, and saved games serialize pointer +fields at that width, so a 64-bit build's saves are not interchangeable with a +supported build's. + ## Build from Visual Studio Code With the recommended extensions installed, the repository provides: