chore: enable LTO by default and add w/o LTO CI for debug (#177)

* chore: enable LTO by default and add w/o LTO CI for debug

* Better performance, small size, in theory.
* Cover more test points.

Signed-off-by: Coelacanthus <uwu@coelacanthus.name>

* fix: github action failed

---------

Signed-off-by: Coelacanthus <uwu@coelacanthus.name>
Co-authored-by: septs <github@septs.pw>
This commit is contained in:
Coelacanthus 2024-12-15 10:03:50 +08:00 committed by GitHub
parent 79034c665e
commit 0fa28bb172
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 22 additions and 0 deletions

View file

@ -18,12 +18,15 @@ jobs:
os: [ubuntu-latest]
build:
- {variant: make, name: Linux, artifact: linux-x64}
- {variant: make-without-lto, name: Linux (w/o LTO), artifact: linux-x64-without-lto}
- {variant: debian, name: Debian, artifact: debian-x64}
- {variant: mingw, name: Windows with MinGW, artifact: windows-x64}
- {variant: woa-mingw, name: Windows on ARM with MinGW, artifact: windows-arm64}
include:
- os: macos-latest
build: {variant: make, name: macOS, artifact: macos-universal}
- os: macos-latest
build: {variant: make-without-lto, name: macOS (w/o LTO), artifact: macos-universal-without-lto}
steps:
- name: Checkout
uses: actions/checkout@v4

View file

@ -13,6 +13,18 @@ list(APPEND CMAKE_MODULE_PATH ${LPAC_CMAKE_MODULE_PATH})
# add_compile_options(-Wall -Wextra -Wpedantic)
# Enable LTO when possible.
cmake_policy(SET CMP0069 NEW)
include(CheckIPOSupported)
check_ipo_supported(RESULT result OUTPUT output)
if(result)
if(NOT DEFINED CMAKE_INTERPROCEDURAL_OPTIMIZATION)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
else()
message(INFO "IPO is not supported: ${output}")
endif()
if (APPLE)
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
endif()

View file

@ -21,6 +21,13 @@ make)
copy-usage "$BUILD/output"
create-bundle "$ARTIFACT/lpac-$KERNEL-$MATCHINE.zip" "$BUILD/output"
;;
make-without-lto)
cmake -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF "$WORKSPACE"
make -j
copy-license "$BUILD/output"
copy-usage "$BUILD/output"
create-bundle "$ARTIFACT/lpac-$KERNEL-$MATCHINE-without-lto.zip" "$BUILD/output"
;;
debian)
cmake "$WORKSPACE" -DCPACK_GENERATOR=DEB
make -j package