From 2233fae2358ba3b7472a626a9d057895585f3e5a Mon Sep 17 00:00:00 2001 From: MechaCat02 Date: Sun, 12 Jul 2026 15:43:22 +0200 Subject: [PATCH] [Build] Guard ThinLTO behind XENIA_ENABLE_LTO for memory-constrained hosts Release enables -flto=thin unconditionally; the ThinLTO link spikes memory past what a 15GB box can handle. Gate it behind an option (default ON, so normal/CI builds are unchanged); pass -DXENIA_ENABLE_LTO=OFF to build Release without the LTO memory spike. Co-Authored-By: Claude Opus 4.8 (1M context) --- CMakeLists.txt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 74da6dc93..05c002230 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -314,9 +314,14 @@ else() ) add_compile_options($<$:-O3>) # Link-time optimization (use lld and llvm-ar/ranlib to avoid system - # linker/archiver LTO plugin version mismatch with clang's bitcode) - add_compile_options($<$:-flto=thin>) - add_link_options($<$:-flto=thin>) + # linker/archiver LTO plugin version mismatch with clang's bitcode). + # Guarded so memory-constrained hosts can build Release without the + # ThinLTO link-time memory spike: pass -DXENIA_ENABLE_LTO=OFF. + option(XENIA_ENABLE_LTO "Enable ThinLTO for Release builds" ON) + if(XENIA_ENABLE_LTO) + add_compile_options($<$:-flto=thin>) + add_link_options($<$:-flto=thin>) + endif() add_link_options($<$:-fuse-ld=lld>) find_program(LLVM_AR NAMES llvm-ar) find_program(LLVM_RANLIB NAMES llvm-ranlib)