From f2e0748a22be7ee1dd6e46a0579f7fa23cf82f8e Mon Sep 17 00:00:00 2001 From: Steveice10 <1269164+Steveice10@users.noreply.github.com> Date: Sat, 26 Aug 2023 11:15:13 -0700 Subject: [PATCH] build: Enable link time optimization in release builds. (#6887) --- .github/workflows/ci.yml | 5 +++++ CMakeLists.txt | 4 +++- src/CMakeLists.txt | 4 ++++ src/audio_core/CMakeLists.txt | 1 - src/common/CMakeLists.txt | 1 - src/core/CMakeLists.txt | 1 - src/input_common/CMakeLists.txt | 1 - src/network/CMakeLists.txt | 1 - src/video_core/CMakeLists.txt | 1 - src/web_service/CMakeLists.txt | 1 - 10 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e418689d..b554c6058 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -158,6 +158,11 @@ jobs: key: ${{ runner.os }}-${{ matrix.target }}-${{ github.sha }} restore-keys: | ${{ runner.os }}-${{ matrix.target }}- + - name: Increase Pagefile size + uses: al-cheb/configure-pagefile-action@v1.2 + with: + minimum-size: 2GB + maximum-size: 6GB - name: Set up MSVC uses: ilammy/msvc-dev-cmd@v1 if: ${{ matrix.target == 'msvc' }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 64b42a09e..7bd7edf13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,8 +40,10 @@ endif() if (CMAKE_BUILD_TYPE STREQUAL Debug) set(IS_DEBUG_BUILD ON) + set(IS_RELEASE_BUILD OFF) else() set(IS_DEBUG_BUILD OFF) + set(IS_RELEASE_BUILD ON) endif() option(ENABLE_SDL2 "Enable using SDL2" ON) @@ -73,7 +75,7 @@ CMAKE_DEPENDENT_OPTION(CITRA_ENABLE_BUNDLE_TARGET "Enable the distribution bundl # Compile options CMAKE_DEPENDENT_OPTION(COMPILE_WITH_DWARF "Add DWARF debugging information" ${IS_DEBUG_BUILD} "MINGW" OFF) -option(ENABLE_LTO "Enable link time optimization" OFF) +option(ENABLE_LTO "Enable link time optimization" ${IS_RELEASE_BUILD}) option(CITRA_USE_PRECOMPILED_HEADERS "Use precompiled headers" ON) option(CITRA_WARNINGS_AS_ERRORS "Enable warnings as errors" ON) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e22cb211e..ffbc5558e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,6 +5,10 @@ include_directories(.) set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$:_DEBUG> $<$>:NDEBUG>) +if (ENABLE_LTO) + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) +endif() + # Set compilation flags if (MSVC) set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE STRING "" FORCE) diff --git a/src/audio_core/CMakeLists.txt b/src/audio_core/CMakeLists.txt index fddcc866d..003ebf181 100644 --- a/src/audio_core/CMakeLists.txt +++ b/src/audio_core/CMakeLists.txt @@ -49,7 +49,6 @@ create_target_directory_groups(audio_core) target_link_libraries(audio_core PUBLIC citra_common citra_core) target_link_libraries(audio_core PRIVATE SoundTouch teakra) -set_target_properties(audio_core PROPERTIES INTERPROCEDURAL_OPTIMIZATION ${ENABLE_LTO}) add_definitions(-DSOUNDTOUCH_INTEGER_SAMPLES) if(ENABLE_MF) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index d5500a432..8bb515488 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -167,7 +167,6 @@ create_target_directory_groups(citra_common) target_link_libraries(citra_common PUBLIC fmt::fmt library-headers microprofile Boost::boost Boost::serialization Boost::iostreams) target_link_libraries(citra_common PRIVATE libzstd_static) -set_target_properties(citra_common PROPERTIES INTERPROCEDURAL_OPTIMIZATION ${ENABLE_LTO}) if ("x86_64" IN_LIST ARCHITECTURE) target_link_libraries(citra_common PRIVATE xbyak) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index b25a8c388..8c7acd8cb 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -480,7 +480,6 @@ create_target_directory_groups(citra_core) target_link_libraries(citra_core PUBLIC citra_common PRIVATE audio_core network video_core) target_link_libraries(citra_core PRIVATE Boost::boost Boost::serialization Boost::iostreams httplib) target_link_libraries(citra_core PUBLIC dds-ktx PRIVATE cryptopp fmt::fmt lodepng open_source_archives) -set_target_properties(citra_core PROPERTIES INTERPROCEDURAL_OPTIMIZATION ${ENABLE_LTO}) if (ENABLE_WEB_SERVICE) target_link_libraries(citra_core PRIVATE web_service) diff --git a/src/input_common/CMakeLists.txt b/src/input_common/CMakeLists.txt index e1221530f..70d36cbfd 100644 --- a/src/input_common/CMakeLists.txt +++ b/src/input_common/CMakeLists.txt @@ -43,7 +43,6 @@ endif() create_target_directory_groups(input_common) target_link_libraries(input_common PUBLIC citra_core PRIVATE citra_common ${Boost_LIBRARIES}) -set_target_properties(input_common PROPERTIES INTERPROCEDURAL_OPTIMIZATION ${ENABLE_LTO}) if (CITRA_USE_PRECOMPILED_HEADERS) target_precompile_headers(input_common PRIVATE precompiled_headers.h) diff --git a/src/network/CMakeLists.txt b/src/network/CMakeLists.txt index f429627fa..d8058dfd2 100644 --- a/src/network/CMakeLists.txt +++ b/src/network/CMakeLists.txt @@ -23,7 +23,6 @@ if (ENABLE_WEB_SERVICE) endif() target_link_libraries(network PRIVATE citra_common enet Boost::serialization httplib) -set_target_properties(network PROPERTIES INTERPROCEDURAL_OPTIMIZATION ${ENABLE_LTO}) if (CITRA_USE_PRECOMPILED_HEADERS) target_precompile_headers(network PRIVATE precompiled_headers.h) diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt index 824a6b310..900d9b3d0 100644 --- a/src/video_core/CMakeLists.txt +++ b/src/video_core/CMakeLists.txt @@ -143,7 +143,6 @@ create_target_directory_groups(video_core) target_link_libraries(video_core PUBLIC citra_common citra_core) target_link_libraries(video_core PRIVATE Boost::serialization dds-ktx json-headers nihstro-headers tsl::robin_map) target_link_libraries(video_core PRIVATE vulkan-headers vma glad sirit SPIRV glslang) -set_target_properties(video_core PROPERTIES INTERPROCEDURAL_OPTIMIZATION ${ENABLE_LTO}) if ("x86_64" IN_LIST ARCHITECTURE) target_link_libraries(video_core PUBLIC xbyak) diff --git a/src/web_service/CMakeLists.txt b/src/web_service/CMakeLists.txt index feb158b68..566ddd432 100644 --- a/src/web_service/CMakeLists.txt +++ b/src/web_service/CMakeLists.txt @@ -17,7 +17,6 @@ create_target_directory_groups(web_service) target_compile_definitions(web_service PUBLIC -DENABLE_WEB_SERVICE) target_link_libraries(web_service PRIVATE citra_common network json-headers httplib cpp-jwt) target_link_libraries(web_service PUBLIC ${OPENSSL_LIBS}) -set_target_properties(web_service PROPERTIES INTERPROCEDURAL_OPTIMIZATION ${ENABLE_LTO}) if (ANDROID) target_link_libraries(web_service PRIVATE ifaddrs) elseif(WIN32)