Skip to content

Commit

Permalink
Use O3 + flto with all but msvc (#2696)
Browse files Browse the repository at this point in the history
* use O3 with flto

* fix msvc builds

* back to minsizerel in msvc, baremetal and 3ds

* default to static in builds with flto

* use ubuntu 22.04 for linux amd64

* use gcc12 in ubuntu 22.04

* include ubuntu24.04 + gcc14 for linux amd64

* Update build.yml

* Update build.yml

* add required dep for ubuntu24.04

* Update build.yml

* try to force strict aliasing

* revert and try to get latest gcc14

* build with Os + flto to compare

* compile with O2 with flto to compare

* go back to O3+flto as is the faster option

* forgot to use release in android

* use macos13 as 12 is being deprecated

* more platforms

---------

Co-authored-by: Vadim Grigoruk <grigoruk@gmail.com>
  • Loading branch information
Miguel-hrvs and nesbox authored Nov 11, 2024
1 parent ce24e76 commit 0365ecc
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 47 deletions.
136 changes: 90 additions & 46 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ jobs:
shell: bash
run: |
cd build
cmake -G "MSYS Makefiles" -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_ALL=ON -DBUILD_WITH_JANET=OFF ..
cmake --build . --config MinSizeRel --parallel
cmake -G "MSYS Makefiles" -DBUILD_SDLGPU=On -DBUILD_STATIC=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_WITH_ALL=ON -DBUILD_WITH_JANET=OFF ..
cmake --build . --parallel
# === Ubuntu ===
linux:
runs-on: ubuntu-20.04
linux-gcc12-glibc235:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4
Expand All @@ -132,18 +132,62 @@ jobs:
- name: Install
run: |
sudo apt-get update
sudo apt-get install libglu1-mesa-dev libasound2-dev libpulse-dev libaudio-dev libsamplerate0-dev libcurl4-openssl-dev -y
sudo apt-get install gcc-12 g++-12 libglu1-mesa-dev libasound2-dev libpulse-dev libaudio-dev libsamplerate0-dev libcurl4-openssl-dev -y
sudo ln -s -f /usr/bin/gcc-12 /usr/bin/gcc
sudo ln -s -f /usr/bin/g++-12 /usr/bin/g++
- name: Build
run: |
cd build
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_SDLGPU=On -DBUILD_WITH_ALL=ON ..
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SDLGPU=On -DBUILD_STATIC=ON -DBUILD_WITH_ALL=ON ..
cmake --build . --parallel
- name: Deploy
uses: actions/upload-artifact@v4
with:
name: "tic80-linux-gcc12"
path: |
build/bin/tic80
build/bin/*.so
- name: Build Pro
run: |
cd build
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_SDLGPU=On -DBUILD_PRO=On -DBUILD_WITH_ALL=ON ..
cmake --build . --config MinSizeRel --parallel
# === Ubuntu gcc14 ===
linux-gcc14-glibc239:
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6

- name: Install
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa
sudo apt update
sudo apt-get install gcc-14 g++-14 libxext-dev libglu1-mesa-dev libasound2-dev libpulse-dev libaudio-dev libsamplerate0-dev libcurl4-openssl-dev -y
sudo ln -s -f /usr/bin/gcc-14 /usr/bin/gcc
sudo ln -s -f /usr/bin/g++-14 /usr/bin/g++
- name: Build
run: |
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SDLGPU=On -DBUILD_STATIC=ON -DBUILD_WITH_ALL=ON ..
cmake --build . --parallel
- name: Deploy
uses: actions/upload-artifact@v4
with:
name: "tic80-linux"
name: "tic80-linux-gcc14"
path: |
build/bin/tic80
build/bin/*.so
Expand Down Expand Up @@ -173,8 +217,8 @@ jobs:
- name: Build
run: |
cd build
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_TOOLCHAIN_FILE=rpi/toolchain.cmake -DBUILD_WITH_ALL=ON ..
cmake --build . --config MinSizeRel --parallel
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_STATIC=ON -DCMAKE_TOOLCHAIN_FILE=rpi/toolchain.cmake -DBUILD_WITH_ALL=ON ..
cmake --build . --parallel
- name: Deploy
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -226,7 +270,7 @@ jobs:
run: |
git apply build/baremetalpi/circle.patch
cd build
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_TOOLCHAIN_FILE=baremetalpi/toolchain.cmake -DBUILD_WITH_ALL=ON ..
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=baremetalpi/toolchain.cmake -DBUILD_WITH_ALL=ON ..
make tic80studio -j$(nproc)
cd baremetalpi
make -j$(nproc)
Expand Down Expand Up @@ -287,7 +331,7 @@ jobs:
run: |
git apply build/baremetalpi/circle.patch
cd build
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_TOOLCHAIN_FILE=baremetalpi/toolchain.cmake -DBUILD_WITH_ALL=ON ..
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=baremetalpi/toolchain.cmake -DBUILD_WITH_ALL=ON ..
make tic80studio -j$(nproc)
cd baremetalpi
make -j$(nproc)
Expand Down Expand Up @@ -343,9 +387,9 @@ jobs:
name: "tic80-nintendo-3ds"
path: build/bin/tic80.3dsx

# === MacOS 12 ===
# === MacOS 13 ===
macos:
runs-on: macos-12
runs-on: macos-13

steps:
- uses: actions/checkout@v4
Expand All @@ -359,8 +403,8 @@ jobs:
- name: Build
run: |
cd build
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_SDLGPU=On -DBUILD_WITH_ALL=ON ..
cmake --build . --config MinSizeRel --parallel
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_STATIC=ON -DBUILD_SDLGPU=On -DBUILD_WITH_ALL=ON ..
cmake --build . --parallel
- name: Deploy
uses: actions/upload-artifact@v4
Expand All @@ -373,8 +417,8 @@ jobs:
- name: Build Pro
run: |
cd build
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_SDLGPU=On -DBUILD_PRO=On -DBUILD_WITH_ALL=ON ..
cmake --build . --config MinSizeRel --parallel
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SDLGPU=On -DBUILD_PRO=On -DBUILD_WITH_ALL=ON ..
cmake --build . --parallel
# === MacOS 14 / arm64 ===
macos-arm64:
Expand All @@ -392,8 +436,8 @@ jobs:
- name: Build
run: |
cd build
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_SDLGPU=On -DBUILD_WITH_ALL=ON ..
cmake --build . --config MinSizeRel --parallel
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_STATIC=ON -DBUILD_SDLGPU=On -DBUILD_WITH_ALL=ON ..
cmake --build . --parallel
- name: Deploy
uses: actions/upload-artifact@v4
Expand All @@ -406,8 +450,8 @@ jobs:
- name: Build Pro
run: |
cd build
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_SDLGPU=On -DBUILD_PRO=On -DBUILD_WITH_ALL=ON ..
cmake --build . --config MinSizeRel --parallel
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SDLGPU=On -DBUILD_PRO=On -DBUILD_WITH_ALL=ON ..
cmake --build . --parallel
# === Android ===
android:
Expand Down Expand Up @@ -468,74 +512,74 @@ jobs:
- name: Build lua
run: |
cd build
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=ON -DTIC80_TARGET=tic80lua .. --fresh
cmake --build . --config MinSizeRel --parallel
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=Release -DBUILD_WITH_LUA=ON -DTIC80_TARGET=tic80lua .. --fresh
cmake --build . --parallel
- name: Build ruby
run: |
cd build
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=OFF -DBUILD_WITH_RUBY=ON -DTIC80_TARGET=tic80ruby .. --fresh
cmake --build . --config MinSizeRel --parallel
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=Release -DBUILD_WITH_LUA=OFF -DBUILD_WITH_RUBY=ON -DTIC80_TARGET=tic80ruby .. --fresh
cmake --build . --parallel
- name: Build js
run: |
cd build
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=OFF -DBUILD_WITH_JS=ON -DTIC80_TARGET=tic80js .. --fresh
cmake --build . --config MinSizeRel --parallel
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=Release -DBUILD_WITH_LUA=OFF -DBUILD_WITH_JS=ON -DTIC80_TARGET=tic80js .. --fresh
cmake --build . --parallel
- name: Build moon
run: |
cd build
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=OFF -DBUILD_WITH_MOON=ON -DTIC80_TARGET=tic80moon .. --fresh
cmake --build . --config MinSizeRel --parallel
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=Release -DBUILD_WITH_LUA=OFF -DBUILD_WITH_MOON=ON -DTIC80_TARGET=tic80moon .. --fresh
cmake --build . --parallel
- name: Build fennel
run: |
cd build
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=OFF -DBUILD_WITH_FENNEL=ON -DTIC80_TARGET=tic80fennel .. --fresh
cmake --build . --config MinSizeRel --parallel
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=Release -DBUILD_WITH_LUA=OFF -DBUILD_WITH_FENNEL=ON -DTIC80_TARGET=tic80fennel .. --fresh
cmake --build . --parallel
- name: Build scheme
run: |
cd build
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=OFF -DBUILD_WITH_SCHEME=ON -DTIC80_TARGET=tic80scheme .. --fresh
cmake --build . --config MinSizeRel --parallel
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=Release -DBUILD_WITH_LUA=OFF -DBUILD_WITH_SCHEME=ON -DTIC80_TARGET=tic80scheme .. --fresh
cmake --build . --parallel
- name: Build squirrel
run: |
cd build
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=OFF -DBUILD_WITH_SQUIRREL=ON -DTIC80_TARGET=tic80squirrel .. --fresh
cmake --build . --config MinSizeRel --parallel
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=Release -DBUILD_WITH_LUA=OFF -DBUILD_WITH_SQUIRREL=ON -DTIC80_TARGET=tic80squirrel .. --fresh
cmake --build . --parallel
- name: Build wren
run: |
cd build
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=OFF -DBUILD_WITH_WREN=ON -DTIC80_TARGET=tic80wren .. --fresh
cmake --build . --config MinSizeRel --parallel
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=Release -DBUILD_WITH_LUA=OFF -DBUILD_WITH_WREN=ON -DTIC80_TARGET=tic80wren .. --fresh
cmake --build . --parallel
- name: Build wasm
run: |
cd build
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=OFF -DBUILD_WITH_WASM=ON -DTIC80_TARGET=tic80wasm .. --fresh
cmake --build . --config MinSizeRel --parallel
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=Release -DBUILD_WITH_LUA=OFF -DBUILD_WITH_WASM=ON -DTIC80_TARGET=tic80wasm .. --fresh
cmake --build . --parallel
- name: Build janet
run: |
cd build
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=OFF -DBUILD_WITH_JANET=ON -DTIC80_TARGET=tic80janet .. --fresh
cmake --build . --config MinSizeRel --parallel
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=Release -DBUILD_WITH_LUA=OFF -DBUILD_WITH_JANET=ON -DTIC80_TARGET=tic80janet .. --fresh
cmake --build . --parallel
- name: Build python
run: |
cd build
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=OFF -DBUILD_WITH_PYTHON=ON -DTIC80_TARGET=tic80python .. --fresh
cmake --build . --config MinSizeRel --parallel
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=Release -DBUILD_WITH_LUA=OFF -DBUILD_WITH_PYTHON=ON -DTIC80_TARGET=tic80python .. --fresh
cmake --build . --parallel
- name: Build all
run: |
cd build
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_ALL=ON .. --fresh
cmake --build . --config MinSizeRel --parallel
emcmake cmake -DBUILD_SDLGPU=On -DBUILD_STATIC=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_WITH_ALL=ON .. --fresh
cmake --build . --parallel
cp html/index.html bin/index.html
- name: Deploy
Expand Down
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ include(cmake/version.cmake)

project(TIC-80 VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION} LANGUAGES C CXX)

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -flto -ffat-lto-objects")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -flto -ffat-lto-objects")
endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -flto")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -flto")
endif()

if(APPLE)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version")
endif()
Expand Down
2 changes: 1 addition & 1 deletion build/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ android {
arguments "APP_PLATFORM=android-31"
}
cmake {
arguments "-DBUILD_WITH_RUBY=OFF", "-DBUILD_PRO=Off", "-DCMAKE_BUILD_TYPE=MinSizeRel", "-DBUILD_WITH_ALL=ON"
arguments "-DBUILD_WITH_RUBY=OFF", "-DBUILD_PRO=Off", "-DCMAKE_BUILD_TYPE=Release", "-DBUILD_WITH_ALL=ON"
}
}
}
Expand Down

0 comments on commit 0365ecc

Please sign in to comment.