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)