From 0a958c8e1668959491f2e8d5759e963a12b719f2 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Sun, 6 Apr 2025 20:37:03 +0200 Subject: [PATCH] Meta: Add an option to disable LTO for Release builds --- Meta/CMake/lagom_compile_options.cmake | 14 ++++++++------ Meta/CMake/lagom_options.cmake | 1 + 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Meta/CMake/lagom_compile_options.cmake b/Meta/CMake/lagom_compile_options.cmake index 238f3e97098..6659e9aea25 100644 --- a/Meta/CMake/lagom_compile_options.cmake +++ b/Meta/CMake/lagom_compile_options.cmake @@ -38,12 +38,14 @@ elseif (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") else() add_cxx_compile_options(-O3) - include(CheckIPOSupported) - check_ipo_supported(RESULT IPO_AVAILABLE OUTPUT output) - if(IPO_AVAILABLE) - set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) - else() - message(WARNING "Not enabling IPO as it is not supported: ${output}") + if (ENABLE_LTO_FOR_RELEASE) + include(CheckIPOSupported) + check_ipo_supported(RESULT IPO_AVAILABLE OUTPUT output) + if(IPO_AVAILABLE) + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) + else() + message(WARNING "Not enabling IPO as it is not supported: ${output}") + endif() endif() endif() diff --git a/Meta/CMake/lagom_options.cmake b/Meta/CMake/lagom_options.cmake index aaeded5d60c..97e27170004 100644 --- a/Meta/CMake/lagom_options.cmake +++ b/Meta/CMake/lagom_options.cmake @@ -14,6 +14,7 @@ serenity_option(LAGOM_TOOLS_ONLY OFF CACHE BOOL "Don't build libraries, utilitie serenity_option(ENABLE_LAGOM_CCACHE ON CACHE BOOL "Enable ccache for Lagom builds") serenity_option(LAGOM_USE_LINKER "" CACHE STRING "The linker to use (e.g. lld, mold) instead of the system default") serenity_option(LAGOM_LINK_POOL_SIZE "" CACHE STRING "The maximum number of parallel jobs to use for linking") +serenity_option(ENABLE_LTO_FOR_RELEASE ON CACHE BOOL "Enable link-time optimization for release builds") serenity_option(ENABLE_LAGOM_COVERAGE_COLLECTION OFF CACHE STRING "Enable code coverage instrumentation for lagom binaries in clang") if (ANDROID OR APPLE)