[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) <noreply@anthropic.com>
This commit is contained in:
MechaCat02
2026-07-12 15:43:22 +02:00
parent f81e90f03a
commit 2233fae235

View File

@@ -314,9 +314,14 @@ else()
) )
add_compile_options($<$<CONFIG:Release>:-O3>) add_compile_options($<$<CONFIG:Release>:-O3>)
# Link-time optimization (use lld and llvm-ar/ranlib to avoid system # Link-time optimization (use lld and llvm-ar/ranlib to avoid system
# linker/archiver LTO plugin version mismatch with clang's bitcode) # linker/archiver LTO plugin version mismatch with clang's bitcode).
add_compile_options($<$<CONFIG:Release>:-flto=thin>) # Guarded so memory-constrained hosts can build Release without the
add_link_options($<$<CONFIG:Release>:-flto=thin>) # 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($<$<CONFIG:Release>:-flto=thin>)
add_link_options($<$<CONFIG:Release>:-flto=thin>)
endif()
add_link_options($<$<CONFIG:Release>:-fuse-ld=lld>) add_link_options($<$<CONFIG:Release>:-fuse-ld=lld>)
find_program(LLVM_AR NAMES llvm-ar) find_program(LLVM_AR NAMES llvm-ar)
find_program(LLVM_RANLIB NAMES llvm-ranlib) find_program(LLVM_RANLIB NAMES llvm-ranlib)