Skip to content

Commit

Permalink
chore: enable LTO by default and add w/o LTO CI for debug (#177)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* fix: github action failed

---------

Signed-off-by: Coelacanthus <[email protected]>
Co-authored-by: septs <[email protected]>
  • Loading branch information
CoelacanthusHex and septs authored Dec 15, 2024
1 parent 79034c6 commit 0fa28bb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
7 changes: 7 additions & 0 deletions scripts/build-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0fa28bb

Please sign in to comment.