Browse Source

Add a script for building a PGO'd binary

pull/5656/head
Gleb Mazovetskiy 3 years ago
parent
commit
ff27203d65
  1. 4
      CMakeLists.txt
  2. 1
      Packaging/OpenDingux/build.sh
  3. 36
      tools/build_pgo.sh

4
CMakeLists.txt

@ -233,8 +233,8 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
add_link_options("$<$<BOOL:${DEVILUTIONX_PROFILE_GENERATE}>:-fprofile-generate>")
add_compile_options("$<$<BOOL:${DEVILUTIONX_PROFILE_USE}>:-fprofile-use>")
add_link_options("$<$<BOOL:${DEVILUTIONX_PROFILE_USE}>:-fprofile-use>")
add_compile_options("$<$<BOOL:${DEVILUTIONX_PROFILE_DIR}>:-fprofile-dir=${DEVILUTIONX_PROFILE_DIR}>")
add_link_options("$<$<BOOL:${DEVILUTIONX_PROFILE_DIR}>:-fprofile-dir=${DEVILUTIONX_PROFILE_DIR}>")
add_compile_options("$<$<BOOL:${DEVILUTIONX_PROFILE_DIR}>:-fprofile-dir=${DEVILUTIONX_PROFILE_DIR};-fprofile-prefix-path=${CMAKE_CURRENT_BINARY_DIR}>")
add_link_options("$<$<BOOL:${DEVILUTIONX_PROFILE_DIR}>:-fprofile-dir=${DEVILUTIONX_PROFILE_DIR};-fprofile-prefix-path=${CMAKE_CURRENT_BINARY_DIR}>")
endif()
# Not a genexp because CMake doesn't support it

1
Packaging/OpenDingux/build.sh

@ -110,7 +110,6 @@ parse_args() {
"-DDEVILUTIONX_PROFILE_GENERATE=ON"
"-DDEVILUTIONX_PROFILE_DIR=${PROFILE_DIR}"
)
BUILD_TYPE=relwithdebinfo
OPK_DESKTOP_NAME="DevilutionX PG"
OPK_DESKTOP_EXEC="profile-generate.sh"
OPK_EXTRA_FILES=(

36
tools/build_pgo.sh

@ -0,0 +1,36 @@
#!/usr/bin/env bash
# Builds a PGO-optimized binary with the profile data gathered by running the test demo.
set -euo pipefail
PARALLELISM="$(getconf _NPROCESSORS_ONLN)"
set -x
rm -rf build-profile-data/config build-profile-data/profile
mkdir -p build-profile-data/config
cd build-profile-data/config
ln -s ../../test/fixtures/timedemo/WarriorLevel1to2/demo_* .
cp ../../test/fixtures/timedemo/WarriorLevel1to2/spawn_* .
cd -
# We build both versions with the same FetchContent base directory because otherwise
# gcc will complain about the source locations for FetchContent dependencies,
# which are stored in the build directory by default.
# Ideally, we would only specify the location for the FetchContent src directories
# but CMake does not support that.
cmake -S. -Bbuild-profile-generate -G Ninja -DCMAKE_BUILD_TYPE=Release \
-DDEVILUTIONX_PROFILE_GENERATE=ON \
-DDEVILUTIONX_PROFILE_DIR="${PWD}/build-profile-data/profile" \
-DFETCHCONTENT_BASE_DIR="${PWD}/build-profile-data/fetchcontent-base" \
-DBUILD_TESTING=OFF "$@"
cmake --build build-profile-generate -j "$PARALLELISM"
build-profile-generate/devilutionx --diablo --spawn --lang en --demo 0 --timedemo \
--save-dir build-profile-data/config
cmake -S. -Bbuild-profile-use -G Ninja -DCMAKE_BUILD_TYPE=Release \
-DDEVILUTIONX_PROFILE_USE=ON \
-DDEVILUTIONX_PROFILE_DIR="${PWD}/build-profile-data/profile" \
-DFETCHCONTENT_BASE_DIR="${PWD}/build-profile-data/fetchcontent-base" \
-DBUILD_TESTING=OFF "$@"
cmake --build build-profile-use -j "$PARALLELISM"
Loading…
Cancel
Save