From ba5e097fa6cd6fe89c238084cdff59a11131c6d2 Mon Sep 17 00:00:00 2001 From: Andrew Eiche <1386498+buddingmonkey@users.noreply.github.com> Date: Thu, 6 Aug 2026 08:51:58 -0500 Subject: [PATCH 1/2] Build libultraship into the binary directory and the host asset packer optimised Two independent build fixes to the top-level CMakeLists.txt. The second argument to add_subdirectory() is the *binary* directory, but it was pointed at the source directory. That made libultraship write its entire build output -- CMakeScripts, cmake_install.cmake, generated headers and every target's .a -- into the submodule's source tree, so every build directory shared one output location. Two builds running at once would overwrite each other's artifacts, and `git status` inside the submodule was permanently dirty. Dropping the argument lets CMake place the output under the binary directory as usual. Note that this relocates libultraship's build output: anyone with scripts or tooling that reference build artefacts inside the libultraship/ source tree will need to update those paths. Separately, TorchExternal was being built without optimisation. ExternalProject does not inherit CMAKE_BUILD_TYPE, and an empty build type on a single-config generator -- Ninja or Makefiles, which is the normal Linux and macOS command-line path -- means no optimisation flags at all, so the packer was compiled -O0 even from a Release tree. Torch is a build-time asset packer, so it is now configured Release explicitly regardless of the host project's configuration. Multi-config generators such as Visual Studio and Xcode ignore CMAKE_BUILD_TYPE at configure time and are unaffected either way. The cost was not subtle. Extracting bk.o2r from a 16 MB ROM on the same machine took 2312.96 s (38.5 minutes) unoptimised versus 38.28 s at -O3, roughly 60x, for byte-identical 24 MB output. The work is single-threaded and 99.8% user CPU, so this was never I/O or memory bound. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b4e2ec1ad..ba5c47895 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -370,7 +370,7 @@ if (CMAKE_GENERATOR MATCHES "Visual Studio") ) endif() -add_subdirectory(libultraship ${CMAKE_CURRENT_SOURCE_DIR}/libultraship) +add_subdirectory(libultraship) add_dependencies(${PROJECT_NAME} libultraship) target_link_libraries(${PROJECT_NAME} PRIVATE libultraship) @@ -743,7 +743,7 @@ include(ExternalProject) ExternalProject_Add(TorchExternal PREFIX TorchExternal SOURCE_DIR ${CMAKE_SOURCE_DIR}/Torch - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/Torch -DENABLE_ASAN=${ENABLE_ASAN} + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/Torch -DENABLE_ASAN=${ENABLE_ASAN} -DCMAKE_BUILD_TYPE=Release ) #set_target_properties(TorchExternal PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD TRUE) ExternalProject_Get_Property(TorchExternal install_dir) From dc9642dae2f7643157bc5b37786bc7954ef1680b Mon Sep 17 00:00:00 2001 From: Andrew Eiche <1386498+buddingmonkey@users.noreply.github.com> Date: Fri, 7 Aug 2026 14:07:57 -0500 Subject: [PATCH 2/2] Name libultraship's binary directory explicitly Omitting the second argument to add_subdirectory() already resolves to ${CMAKE_CURRENT_BINARY_DIR}/libultraship, so this is not a behavior change -- it just states the destination rather than relying on the default. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ba5c47895..c6316c1b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -370,7 +370,7 @@ if (CMAKE_GENERATOR MATCHES "Visual Studio") ) endif() -add_subdirectory(libultraship) +add_subdirectory(libultraship ${CMAKE_CURRENT_BINARY_DIR}/libultraship) add_dependencies(${PROJECT_NAME} libultraship) target_link_libraries(${PROJECT_NAME} PRIVATE libultraship)