From c7c83a35fa74b419145f2e5013873bf98bf46df5 Mon Sep 17 00:00:00 2001 From: Philipp David Date: Sat, 19 Mar 2022 18:08:28 +0100 Subject: [PATCH 1/4] Enable LTO/IPO on release builds --- .gitmodules | 4 ++-- CMakeLists.txt | 14 +++++++++++++- libraries/LocalPeer/CMakeLists.txt | 2 +- libraries/iconfix/CMakeLists.txt | 2 +- libraries/javacheck/CMakeLists.txt | 2 +- libraries/katabasis/CMakeLists.txt | 2 +- libraries/launcher/CMakeLists.txt | 2 +- libraries/libnbtplusplus | 2 +- libraries/optional-bare/CMakeLists.txt | 2 +- libraries/rainbow/CMakeLists.txt | 2 +- libraries/xz-embedded/CMakeLists.txt | 2 +- 11 files changed, 24 insertions(+), 12 deletions(-) diff --git a/.gitmodules b/.gitmodules index 10575207..08b94c96 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,7 @@ [submodule "depends/libnbtplusplus"] path = libraries/libnbtplusplus - url = https://github.com/MultiMC/libnbtplusplus.git - pushurl = git@github.com:MultiMC/libnbtplusplus.git + url = https://github.com/PolyMC/libnbtplusplus.git + pushurl = git@github.com:PolyMC/libnbtplusplus.git [submodule "libraries/quazip"] path = libraries/quazip diff --git a/CMakeLists.txt b/CMakeLists.txt index 7537703c..889d6fc4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.9.4) if(WIN32) # In Qt 5.1+ we have our own main() function, don't autolink to qtmain on Windows @@ -43,6 +43,18 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Werror=return-type") # Fix build with Qt 5.13 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DQT_NO_DEPRECATED_WARNINGS=Y") +include(CheckIPOSupported) +check_ipo_supported(RESULT ipo_supported OUTPUT ipo_error) + +if(ipo_supported AND (CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")) + message(STATUS "IPO / LTO enabled") + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) +elseif(ipo_supported) + message(STATUS "Not enabling IPO / LTO on debug builds") +else() + message(STATUS "IPO / LTO not supported: <${ipo_error}>") +endif() + ##################################### Set Application options ##################################### ######## Set URLs ######## diff --git a/libraries/LocalPeer/CMakeLists.txt b/libraries/LocalPeer/CMakeLists.txt index 1e7557ec..0b434803 100644 --- a/libraries/LocalPeer/CMakeLists.txt +++ b/libraries/LocalPeer/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.9.4) project(LocalPeer) find_package(Qt5 COMPONENTS Core Network REQUIRED) diff --git a/libraries/iconfix/CMakeLists.txt b/libraries/iconfix/CMakeLists.txt index 049879c4..08441203 100644 --- a/libraries/iconfix/CMakeLists.txt +++ b/libraries/iconfix/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.9.4) project(iconfix) find_package(Qt5Core REQUIRED QUIET) diff --git a/libraries/javacheck/CMakeLists.txt b/libraries/javacheck/CMakeLists.txt index f599bf15..735de443 100644 --- a/libraries/javacheck/CMakeLists.txt +++ b/libraries/javacheck/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.9.4) project(launcher Java) find_package(Java 1.7 REQUIRED COMPONENTS Development) diff --git a/libraries/katabasis/CMakeLists.txt b/libraries/katabasis/CMakeLists.txt index d579dc29..77db286a 100644 --- a/libraries/katabasis/CMakeLists.txt +++ b/libraries/katabasis/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.6) +cmake_minimum_required(VERSION 3.9.4) string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BUILD_DIR}" IS_IN_SOURCE_BUILD) if(IS_IN_SOURCE_BUILD) diff --git a/libraries/launcher/CMakeLists.txt b/libraries/launcher/CMakeLists.txt index 54913fd4..0eccae8b 100644 --- a/libraries/launcher/CMakeLists.txt +++ b/libraries/launcher/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.9.4) project(launcher Java) find_package(Java 1.7 REQUIRED COMPONENTS Development) diff --git a/libraries/libnbtplusplus b/libraries/libnbtplusplus index dc72a20b..b156bcaa 160000 --- a/libraries/libnbtplusplus +++ b/libraries/libnbtplusplus @@ -1 +1 @@ -Subproject commit dc72a20b7efd304d12af2025223fad07b4b78464 +Subproject commit b156bcaa4acf0a5b392bbed60bd274c39e2398d4 diff --git a/libraries/optional-bare/CMakeLists.txt b/libraries/optional-bare/CMakeLists.txt index b8b498c5..952df6e2 100644 --- a/libraries/optional-bare/CMakeLists.txt +++ b/libraries/optional-bare/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.9.4) project(optional-bare) add_library(optional-bare INTERFACE) diff --git a/libraries/rainbow/CMakeLists.txt b/libraries/rainbow/CMakeLists.txt index e57dbbc2..94cc1b49 100644 --- a/libraries/rainbow/CMakeLists.txt +++ b/libraries/rainbow/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.9.4) project(rainbow) find_package(Qt5Core REQUIRED QUIET) diff --git a/libraries/xz-embedded/CMakeLists.txt b/libraries/xz-embedded/CMakeLists.txt index 86ac60c8..4ce46102 100644 --- a/libraries/xz-embedded/CMakeLists.txt +++ b/libraries/xz-embedded/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.9.4) project(xz-embedded LANGUAGES C) option(XZ_BUILD_BCJ "Build xz-embedded with BCJ support (native binary optimization)" OFF) From dfa5f614aaf8c8e1843c5224e20d5349efb04fa0 Mon Sep 17 00:00:00 2001 From: Philipp David Date: Wed, 23 Mar 2022 10:05:31 +0100 Subject: [PATCH 2/4] Put LTO behind an optional flag --- CMakeLists.txt | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 889d6fc4..9ff47353 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,16 +43,20 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Werror=return-type") # Fix build with Qt 5.13 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DQT_NO_DEPRECATED_WARNINGS=Y") -include(CheckIPOSupported) -check_ipo_supported(RESULT ipo_supported OUTPUT ipo_error) +option(ENABLE_LTO "Enable Link Time Optimization" off) -if(ipo_supported AND (CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")) - message(STATUS "IPO / LTO enabled") - set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) -elseif(ipo_supported) - message(STATUS "Not enabling IPO / LTO on debug builds") -else() - message(STATUS "IPO / LTO not supported: <${ipo_error}>") +if(ENABLE_LTO) + include(CheckIPOSupported) + check_ipo_supported(RESULT ipo_supported OUTPUT ipo_error) + + if(ipo_supported AND (CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")) + message(STATUS "IPO / LTO enabled") + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) + elseif(ipo_supported) + message(STATUS "Not enabling IPO / LTO on debug builds") + else() + message(STATUS "IPO / LTO not supported: <${ipo_error}>") + endif() endif() ##################################### Set Application options ##################################### From d2529177927d8ede31d2e7217c9b30ca769d87f4 Mon Sep 17 00:00:00 2001 From: Philipp David Date: Wed, 23 Mar 2022 11:40:19 +0100 Subject: [PATCH 3/4] Enable LTO for Actions --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4aa316f4..1a4e0a25 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -132,25 +132,25 @@ jobs: - name: Configure CMake if: runner.os != 'Linux' && runner.os != 'Windows' run: | - cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -G Ninja + cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -G Ninja - name: Configure CMake on Windows if: runner.os == 'Windows' && matrix.portable != true shell: msys2 {0} run: | - cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DLauncher_PORTABLE=OFF -G Ninja + cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -DLauncher_PORTABLE=OFF -G Ninja - name: Configure CMake on Windows portable if: runner.os == 'Windows' && matrix.portable == true shell: msys2 {0} run: | - cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -G Ninja + cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -G Ninja - name: Configure CMake on Linux if: runner.os == 'Linux' run: | - cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DLauncher_PORTABLE=OFF -G Ninja + cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DLauncher_PORTABLE=OFF -DENABLE_LTO=ON -G Ninja - name: Build if: runner.os != 'Windows' From 1b47132ebb5b825065833cdd08252466efe58faa Mon Sep 17 00:00:00 2001 From: Philipp David Date: Thu, 24 Mar 2022 08:32:26 +0100 Subject: [PATCH 4/4] libnbtplusplus: fix compilation as shared library --- libraries/libnbtplusplus | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/libnbtplusplus b/libraries/libnbtplusplus index b156bcaa..129be45a 160000 --- a/libraries/libnbtplusplus +++ b/libraries/libnbtplusplus @@ -1 +1 @@ -Subproject commit b156bcaa4acf0a5b392bbed60bd274c39e2398d4 +Subproject commit 129be45a7f91920e76673af104534d215c497d85