mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-06 07:15:30 -04:00
meson-pgo: initial version of a meson wrapper script for PGO builds
Usage: meson-pgo.sh auto|partial|full <source-dir> <build-dir> <meson-options> Note: build-dir must *not* exist before the script is run (but if it does, the script will tell you so, and exit). Supported compilers: gcc and clang The script does *not* add _any_ custom meson options, except configure -Db_pgo. Thus, you probably want to call it like this: meson-pgo.sh auto . /tmp/foot-pgo-build --buildtype=release -Db_lto=true
This commit is contained in:
parent
729cbc3ffd
commit
996356983b
1 changed files with 109 additions and 0 deletions
109
meson-pgo.sh
Executable file
109
meson-pgo.sh
Executable file
|
|
@ -0,0 +1,109 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
mode=${1}; shift
|
||||||
|
source_dir=$(realpath "${1}"); shift
|
||||||
|
build_dir=${1}; shift
|
||||||
|
|
||||||
|
if [ -d ${build_dir} ]; then
|
||||||
|
echo "${build_dir}: build directory already exists"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
case ${mode} in
|
||||||
|
auto|partial|full)
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo "${mode}: invalid PGO mode (must be one of 'auto', 'partial' or 'full')"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
compiler=other
|
||||||
|
do_pgo=no
|
||||||
|
|
||||||
|
CFLAGS="${CFLAGS} -O3"
|
||||||
|
|
||||||
|
case $(${CC-cc} --version) in
|
||||||
|
*GCC*)
|
||||||
|
compiler=gcc
|
||||||
|
do_pgo=yes
|
||||||
|
;;
|
||||||
|
|
||||||
|
*clang*)
|
||||||
|
compiler=clang
|
||||||
|
|
||||||
|
if command -v llvm-profdata > /dev/null; then
|
||||||
|
do_pgo=yes
|
||||||
|
CFLAGS="${CFLAGS} -Wno-ignored-optimization-argument"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ ${mode} = auto ]; then
|
||||||
|
if [ -n "${WAYLAND_DISPLAY+x}" ]; then
|
||||||
|
mode=full
|
||||||
|
else
|
||||||
|
mode=partial
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# echo "source: ${source_dir}"
|
||||||
|
# echo "build: ${build_dir}"
|
||||||
|
# echo "compiler: ${compiler}"
|
||||||
|
# echo "mode: ${mode}"
|
||||||
|
|
||||||
|
export CFLAGS
|
||||||
|
meson "${@}" "${build_dir}"
|
||||||
|
|
||||||
|
if [ ${do_pgo} = yes ]; then
|
||||||
|
find . -name "*.gcda" -delete
|
||||||
|
meson configure "${build_dir}" -Db_pgo=generate
|
||||||
|
ninja -C "${build_dir}"
|
||||||
|
|
||||||
|
# If fcft/tllist are subprojects, we need to ensure their tests
|
||||||
|
# have been executed, or we’ll get “profile count data file not
|
||||||
|
# found” errors.
|
||||||
|
ninja -C "${build_dir}" test
|
||||||
|
|
||||||
|
script_options="--scroll --scroll-region --colors-regular --colors-bright --colors-256 --colors-rgb --attr-bold --attr-italic --attr-underline --sixel"
|
||||||
|
|
||||||
|
tmp_file=$(mktemp)
|
||||||
|
pwd=$(pwd)
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
rm -f "${tmp_file}"
|
||||||
|
cd "${pwd}"
|
||||||
|
}
|
||||||
|
trap cleanup EXIT INT HUP TERM
|
||||||
|
|
||||||
|
cd "${build_dir}"
|
||||||
|
if [ ${mode} = full ]; then
|
||||||
|
./footclient --version
|
||||||
|
./foot \
|
||||||
|
--config=/dev/null \
|
||||||
|
--term=xterm \
|
||||||
|
sh -c "${source_dir}/scripts/generate-alt-random-writes.py ${script_options} ${tmp_file} && cat ${tmp_file}"
|
||||||
|
else
|
||||||
|
./footclient --version
|
||||||
|
./foot --version
|
||||||
|
"${source_dir}/scripts/generate-alt-random-writes.py" \
|
||||||
|
--rows=67 \
|
||||||
|
--cols=135 \
|
||||||
|
${script_options} \
|
||||||
|
"${tmp_file}"
|
||||||
|
./pgo "${tmp_file}"
|
||||||
|
fi
|
||||||
|
cd "${pwd}"
|
||||||
|
rm "${tmp_file}"
|
||||||
|
|
||||||
|
if [ ${compiler} = clang ]; then
|
||||||
|
llvm-profdata merge "${build_dir}"/default_*.profraw --output="${build_dir}/default.profdata"
|
||||||
|
fi
|
||||||
|
|
||||||
|
meson configure "${build_dir}" -Db_pgo=use
|
||||||
|
else
|
||||||
|
echo "Not doing PGO"
|
||||||
|
fi
|
||||||
Loading…
Add table
Add a link
Reference in a new issue