From 996356983ba7b3c92f98b434a8ee8677ce2660de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 31 Aug 2021 14:15:21 +0200 Subject: [PATCH 01/29] meson-pgo: initial version of a meson wrapper script for PGO builds Usage: meson-pgo.sh auto|partial|full 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 --- meson-pgo.sh | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100755 meson-pgo.sh diff --git a/meson-pgo.sh b/meson-pgo.sh new file mode 100755 index 00000000..8aa0e97e --- /dev/null +++ b/meson-pgo.sh @@ -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 From ffc6fd7e03e145deec9300a9bff0ac7d8620ac7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 31 Aug 2021 14:22:56 +0200 Subject: [PATCH 02/29] meson-pgo: realpath() on build dir too --- meson-pgo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson-pgo.sh b/meson-pgo.sh index 8aa0e97e..ba3ea954 100755 --- a/meson-pgo.sh +++ b/meson-pgo.sh @@ -4,7 +4,7 @@ set -e mode=${1}; shift source_dir=$(realpath "${1}"); shift -build_dir=${1}; shift +build_dir=$(realpath ${1}); shift if [ -d ${build_dir} ]; then echo "${build_dir}: build directory already exists" From ecf1b30d53f85023bd8a9b9776e9621536f217a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 31 Aug 2021 14:24:36 +0200 Subject: [PATCH 03/29] meson-pgo: remove debug output --- meson-pgo.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/meson-pgo.sh b/meson-pgo.sh index ba3ea954..09dc9c5d 100755 --- a/meson-pgo.sh +++ b/meson-pgo.sh @@ -104,6 +104,4 @@ if [ ${do_pgo} = yes ]; then fi meson configure "${build_dir}" -Db_pgo=use -else - echo "Not doing PGO" fi From 5ab1cd3d644f8d4af2746a767e1ece7ded119170 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 31 Aug 2021 16:25:44 +0200 Subject: [PATCH 04/29] meson-pgo: initial support for full PGO through headless Sway --- meson-pgo.sh | 50 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/meson-pgo.sh b/meson-pgo.sh index 09dc9c5d..dc0157f0 100755 --- a/meson-pgo.sh +++ b/meson-pgo.sh @@ -12,7 +12,7 @@ if [ -d ${build_dir} ]; then fi case ${mode} in - auto|partial|full) + auto|partial|full|full-headless-sway) ;; *) @@ -45,6 +45,8 @@ esac if [ ${mode} = auto ]; then if [ -n "${WAYLAND_DISPLAY+x}" ]; then mode=full + elif command -v sway > /dev/null; then + mode=full-headless-sway else mode=partial fi @@ -80,22 +82,36 @@ if [ ${do_pgo} = yes ]; then 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 + case ${mode} in + full) + ./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}" + ;; + + full-headless-sway) + ./footclient --version + sway_conf=$(mktemp) + echo "exec ${build_dir}/foot -o tweak.render-timer=log --config=/dev/null --term=xterm sh -c \"${source_dir}/scripts/generate-alt-random-writes.py ${script_options} ${tmp_file} && cat ${tmp_file}\" && swaymsg exit" > "${sway_conf}" + export WLR_BACKENDS=headless + sway -c "${sway_conf}" + rm "${sway_conf}" + ;; + + partial) + ./footclient --version + ./foot --version + "${source_dir}/scripts/generate-alt-random-writes.py" \ + --rows=67 \ + --cols=135 \ + ${script_options} \ + "${tmp_file}" + ./pgo "${tmp_file}" + ;; + esac + cd "${pwd}" rm "${tmp_file}" From 8ea6c9351512b833c048db8bfedd4f4075942815 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 31 Aug 2021 16:38:12 +0200 Subject: [PATCH 05/29] =?UTF-8?q?meson-pgo:=20=E2=80=98auto=E2=80=99=20now?= =?UTF-8?q?=20prefers=20full-headless-sway?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- meson-pgo.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/meson-pgo.sh b/meson-pgo.sh index dc0157f0..2057c2a6 100755 --- a/meson-pgo.sh +++ b/meson-pgo.sh @@ -43,10 +43,10 @@ case $(${CC-cc} --version) in esac if [ ${mode} = auto ]; then - if [ -n "${WAYLAND_DISPLAY+x}" ]; then - mode=full - elif command -v sway > /dev/null; then + if command -v sway > /dev/null; then mode=full-headless-sway + elif [ -n "${WAYLAND_DISPLAY+x}" ]; then + mode=full else mode=partial fi From a3b6ecf3b22d3980cde0f74bde677ba114927af1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 31 Aug 2021 16:48:49 +0200 Subject: [PATCH 06/29] meson-pgo: add mode=none --- meson-pgo.sh | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/meson-pgo.sh b/meson-pgo.sh index 2057c2a6..ca542351 100755 --- a/meson-pgo.sh +++ b/meson-pgo.sh @@ -12,7 +12,7 @@ if [ -d ${build_dir} ]; then fi case ${mode} in - auto|partial|full|full-headless-sway) + none|auto|partial|full|full-headless-sway) ;; *) @@ -42,15 +42,21 @@ case $(${CC-cc} --version) in ;; esac -if [ ${mode} = auto ]; then - if command -v sway > /dev/null; then - mode=full-headless-sway - elif [ -n "${WAYLAND_DISPLAY+x}" ]; then - mode=full - else - mode=partial - fi -fi +case ${mode} in + none) + do_pgo=no + ;; + + auto) + if command -v sway > /dev/null; then + mode=full-headless-sway + elif [ -n "${WAYLAND_DISPLAY+x}" ]; then + mode=full + else + mode=partial + fi + ;; +esac # echo "source: ${source_dir}" # echo "build: ${build_dir}" From ac9b3025d87f85b06ebe85aba610dfe1e3424801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 31 Aug 2021 21:07:03 +0200 Subject: [PATCH 07/29] meson-pgo: improved argument validation --- meson-pgo.sh | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/meson-pgo.sh b/meson-pgo.sh index ca542351..6a366f79 100755 --- a/meson-pgo.sh +++ b/meson-pgo.sh @@ -2,25 +2,34 @@ set -e -mode=${1}; shift -source_dir=$(realpath "${1}"); shift -build_dir=$(realpath ${1}); shift - -if [ -d ${build_dir} ]; then - echo "${build_dir}: build directory already exists" +usage_and_die() { + echo "Usage: ${0} none|partial|full|full-headless-sway|[auto] " exit 1 -fi +} + +[ ${#} -ge 3 ] || usage_and_die + +mode=${1} +source_dir=$(realpath "${2}") +build_dir=$(realpath "${3}") +shift 3 case ${mode} in none|auto|partial|full|full-headless-sway) - ;; + ;; *) - echo "${mode}: invalid PGO mode (must be one of 'auto', 'partial' or 'full')" - exit 1 + usage_and_die ;; esac +# meson will complain if source dir is invalid + +if [ -d "${build_dir}" ]; then + echo "${build_dir}: build directory already exists" + exit 1 +fi + compiler=other do_pgo=no From 575f9135ae70d21a113e26f780e9341c1927f36a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 31 Aug 2021 21:10:53 +0200 Subject: [PATCH 08/29] meson-pgo: do mode validation and mode evaluation at the same time --- meson-pgo.sh | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/meson-pgo.sh b/meson-pgo.sh index 6a366f79..ed673316 100755 --- a/meson-pgo.sh +++ b/meson-pgo.sh @@ -14,15 +14,6 @@ source_dir=$(realpath "${2}") build_dir=$(realpath "${3}") shift 3 -case ${mode} in - none|auto|partial|full|full-headless-sway) - ;; - - *) - usage_and_die - ;; -esac - # meson will complain if source dir is invalid if [ -d "${build_dir}" ]; then @@ -52,6 +43,9 @@ case $(${CC-cc} --version) in esac case ${mode} in + partial|full|full-headless-sway) + ;; + none) do_pgo=no ;; @@ -65,6 +59,10 @@ case ${mode} in mode=partial fi ;; + + *) + usage_and_die + ;; esac # echo "source: ${source_dir}" From 098f2c0c88d7ba4c0a57bea572d9d4819eea3b94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 31 Aug 2021 21:14:29 +0200 Subject: [PATCH 09/29] meson-pgo: use as little path quoting as possible --- meson-pgo.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/meson-pgo.sh b/meson-pgo.sh index ed673316..9ad2ad26 100755 --- a/meson-pgo.sh +++ b/meson-pgo.sh @@ -116,7 +116,7 @@ if [ ${do_pgo} = yes ]; then partial) ./footclient --version ./foot --version - "${source_dir}/scripts/generate-alt-random-writes.py" \ + "${source_dir}"/scripts/generate-alt-random-writes.py \ --rows=67 \ --cols=135 \ ${script_options} \ @@ -129,7 +129,10 @@ if [ ${do_pgo} = yes ]; then rm "${tmp_file}" if [ ${compiler} = clang ]; then - llvm-profdata merge "${build_dir}"/default_*.profraw --output="${build_dir}/default.profdata" + llvm-profdata \ + merge \ + "${build_dir}"/default_*.profraw \ + --output="${build_dir}"/default.profdata fi meson configure "${build_dir}" -Db_pgo=use From 87b68f23cba3ef6b733c162eeb991779220fc2f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Wed, 1 Sep 2021 18:57:57 +0200 Subject: [PATCH 10/29] meson-pgo: headless-sway: export XDG_RUNTIME_DIR --- meson-pgo.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/meson-pgo.sh b/meson-pgo.sh index 9ad2ad26..86a1483f 100755 --- a/meson-pgo.sh +++ b/meson-pgo.sh @@ -106,11 +106,18 @@ if [ ${do_pgo} = yes ]; then full-headless-sway) ./footclient --version + + runtime_dir=$(mktemp -d) sway_conf=$(mktemp) + echo "exec ${build_dir}/foot -o tweak.render-timer=log --config=/dev/null --term=xterm sh -c \"${source_dir}/scripts/generate-alt-random-writes.py ${script_options} ${tmp_file} && cat ${tmp_file}\" && swaymsg exit" > "${sway_conf}" + export XDG_RUNTIME_DIR=${runtime_dir} export WLR_BACKENDS=headless + sway -c "${sway_conf}" + rm "${sway_conf}" + rm -rf "${runtime_dir}" ;; partial) From 540310924b08914ff2b00efd1ec70264195b9493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Wed, 1 Sep 2021 19:03:07 +0200 Subject: [PATCH 11/29] meson-pgo: document limitations/requirements --- meson-pgo.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/meson-pgo.sh b/meson-pgo.sh index 86a1483f..cbd355f1 100755 --- a/meson-pgo.sh +++ b/meson-pgo.sh @@ -1,5 +1,13 @@ #!/bin/sh +# Requirements: +# +# * all: build directory must not exist; it is created by the script +# * all: LC_CTYPE must be set to an UTF-8 locale +# * full*: must have at least one font installed +# * full-headless-sway: Sway 1.6.2 must be installed + + set -e usage_and_die() { From a43ae0d098da2b0a5d77b6ecbc578f6d14b22d55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 4 Sep 2021 10:38:41 +0200 Subject: [PATCH 12/29] pgo: replace meson-pgo.sh with several script primitives MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All scripts are in the ‘pgo’ directory: * options: command line options for generate-alt-random-writes.py, sourced by other scripts. * pgo.sh: top-level script, generates a meson build directory, selects a PGO method, generates the profiling data, re-configures the meson build directory and does the final build. This script is intended to be used by end-users, and shows _how_ to integrate the script primitives. Build servers will most likely *not* want to use this script as-is. * partial.sh: generates alt-random-write data and runs “foot{,client} --version”, and then feeds the alt-random data to the PGO helper binary. Does not require a running Wayland session. Touches $blddir/pgo-ok on success. * full-inner.sh: runs “footclient --version”, and then a complex “foot” command that first generates alt-random-write data, and then “cat’s” it. Requires a running Wayland session, *but*, this script is usually not called directly (see below). Touches $blddir/pgo-ok onsucces.. * full-current-session.sh: runs full-inner.sh. That is, it runs foot in the currently running Wayland session. Note that this will pop up a foot window. * full-headless-sway.sh: generates a custom Sway configuration that exec’s foot-headless-sway-inner.sh (see below), and then executes a headless Sway. In other words, this script does a *full* PGO build, but *without* requiring a running Wayland session. Requires Sway >= 1.6.2. * full-headless-sway.sh: runs full-inner.sh + “swaymsg exit”. To do a custom PGO build, without using pgo.sh, you’d need to: CFLAGS=”$CFLAGS -O3” meson --buildtype=release -Db_lto=true meson configure -Db_pgo=generate ninja ninja test (only needed if tllist+fcft are built as subprojects) Run *one* of: - partial.sh - full-current-session.sh - full-headless-sway.sh meson configure -D b_pgo=use ninja --- meson-pgo.sh | 154 -------------------------------- pgo/full-current-session.sh | 8 ++ pgo/full-headless-sway-inner.sh | 9 ++ pgo/full-headless-sway.sh | 24 +++++ pgo/full-inner.sh | 31 +++++++ pgo/options | 1 + pgo/partial.sh | 28 ++++++ pgo/pgo.sh | 101 +++++++++++++++++++++ 8 files changed, 202 insertions(+), 154 deletions(-) delete mode 100755 meson-pgo.sh create mode 100755 pgo/full-current-session.sh create mode 100755 pgo/full-headless-sway-inner.sh create mode 100755 pgo/full-headless-sway.sh create mode 100755 pgo/full-inner.sh create mode 100644 pgo/options create mode 100755 pgo/partial.sh create mode 100755 pgo/pgo.sh diff --git a/meson-pgo.sh b/meson-pgo.sh deleted file mode 100755 index cbd355f1..00000000 --- a/meson-pgo.sh +++ /dev/null @@ -1,154 +0,0 @@ -#!/bin/sh - -# Requirements: -# -# * all: build directory must not exist; it is created by the script -# * all: LC_CTYPE must be set to an UTF-8 locale -# * full*: must have at least one font installed -# * full-headless-sway: Sway 1.6.2 must be installed - - -set -e - -usage_and_die() { - echo "Usage: ${0} none|partial|full|full-headless-sway|[auto] " - exit 1 -} - -[ ${#} -ge 3 ] || usage_and_die - -mode=${1} -source_dir=$(realpath "${2}") -build_dir=$(realpath "${3}") -shift 3 - -# meson will complain if source dir is invalid - -if [ -d "${build_dir}" ]; then - echo "${build_dir}: build directory already exists" - exit 1 -fi - -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 - -case ${mode} in - partial|full|full-headless-sway) - ;; - - none) - do_pgo=no - ;; - - auto) - if command -v sway > /dev/null; then - mode=full-headless-sway - elif [ -n "${WAYLAND_DISPLAY+x}" ]; then - mode=full - else - mode=partial - fi - ;; - - *) - usage_and_die - ;; -esac - -# 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}" - case ${mode} in - full) - ./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}" - ;; - - full-headless-sway) - ./footclient --version - - runtime_dir=$(mktemp -d) - sway_conf=$(mktemp) - - echo "exec ${build_dir}/foot -o tweak.render-timer=log --config=/dev/null --term=xterm sh -c \"${source_dir}/scripts/generate-alt-random-writes.py ${script_options} ${tmp_file} && cat ${tmp_file}\" && swaymsg exit" > "${sway_conf}" - export XDG_RUNTIME_DIR=${runtime_dir} - export WLR_BACKENDS=headless - - sway -c "${sway_conf}" - - rm "${sway_conf}" - rm -rf "${runtime_dir}" - ;; - - partial) - ./footclient --version - ./foot --version - "${source_dir}"/scripts/generate-alt-random-writes.py \ - --rows=67 \ - --cols=135 \ - ${script_options} \ - "${tmp_file}" - ./pgo "${tmp_file}" - ;; - esac - - 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 -fi diff --git a/pgo/full-current-session.sh b/pgo/full-current-session.sh new file mode 100755 index 00000000..3f62a6b5 --- /dev/null +++ b/pgo/full-current-session.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +set -eu + +srcdir=$(realpath "${1}") +blddir=$(realpath "${2}") + +"${srcdir}"/pgo/full-inner.sh "${srcdir}" "${blddir}" diff --git a/pgo/full-headless-sway-inner.sh b/pgo/full-headless-sway-inner.sh new file mode 100755 index 00000000..5bf20390 --- /dev/null +++ b/pgo/full-headless-sway-inner.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +set -u + +srcdir=$(realpath "${1}") +blddir=$(realpath "${2}") + +"${srcdir}"/pgo/full-inner.sh "${srcdir}" "${blddir}" +swaymsg exit diff --git a/pgo/full-headless-sway.sh b/pgo/full-headless-sway.sh new file mode 100755 index 00000000..ef34c560 --- /dev/null +++ b/pgo/full-headless-sway.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +set -eu + +srcdir=$(realpath "${1}") +blddir=$(realpath "${2}") + +runtime_dir=$(mktemp -d) +sway_conf=$(mktemp) + +cleanup() { + rm -f "${sway_conf}" + rm -rf "${runtime_dir}" +} +trap cleanup EXIT INT HUP TERM + +# Generate a custom config that executes our generate-pgo-data script +> "${sway_conf}" echo "exec '${srcdir}'/pgo/full-headless-sway-inner.sh '${srcdir}' '${blddir}'" + +# Run Sway. full-headless-sway-inner.sh ends with a ‘swaymsg exit’ +XDG_RUNTIME_DIR="${runtime_dir}" WLR_BACKENDS=headless sway -c "${sway_conf}" + +# Sway’s exit code doesn’t reflect our script’s exit code +[ -f "${blddir}"/pgo-ok ] || exit 1 diff --git a/pgo/full-inner.sh b/pgo/full-inner.sh new file mode 100755 index 00000000..14a3528c --- /dev/null +++ b/pgo/full-inner.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +set -eu + +srcdir=$(realpath "${1}") +blddir=$(realpath "${2}") + +. "${srcdir}"/pgo/options + +pgo_data=$(mktemp) +trap "rm -f ${pgo_data}" EXIT INT HUP TERM + +rm -f "${blddir}"/pgo-ok + +# To ensure profiling data is generated in the build directory +cd "${blddir}" + +LC_CTYPE=en_US.UTF-8 "${blddir}"/footclient --version +LC_CTYPE=en_US.UTF-8 "${blddir}"/foot \ + -o tweak.render-timer=log \ + --config=/dev/null \ + --term=xterm \ + sh -c " + set -eu + + '${srcdir}/scripts/generate-alt-random-writes.py' \ + ${script_options} \"${pgo_data}\" + + cat \"${pgo_data}\" + " +touch "${blddir}"/pgo-ok diff --git a/pgo/options b/pgo/options new file mode 100644 index 00000000..3fb821e9 --- /dev/null +++ b/pgo/options @@ -0,0 +1 @@ +script_options="--scroll --scroll-region --colors-regular --colors-bright --colors-256 --colors-rgb --attr-bold --attr-italic --attr-underline --sixel" diff --git a/pgo/partial.sh b/pgo/partial.sh new file mode 100755 index 00000000..9cb8bd59 --- /dev/null +++ b/pgo/partial.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -eu + +srcdir=$(realpath "${1}") +blddir=$(realpath "${2}") + +. "${srcdir}"/pgo/options + +pgo_data=$(mktemp) +trap "rm -f ${pgo_data}" EXIT INT HUP TERM + +rm -f "${blddir}"/pgo-ok + +"${srcdir}"/scripts/generate-alt-random-writes.py \ + --rows=67 \ + --cols=135 \ + ${script_options} \ + "${pgo_data}" + +# To ensure profiling data is generated in the build directory +cd "${blddir}" + +"${blddir}"/footclient --version +"${blddir}"/foot --version +"${blddir}"/pgo "${pgo_data}" + +touch "${blddir}"/pgo-ok diff --git a/pgo/pgo.sh b/pgo/pgo.sh new file mode 100755 index 00000000..fbd7fbe2 --- /dev/null +++ b/pgo/pgo.sh @@ -0,0 +1,101 @@ +#!/bin/sh + +set -eu + +usage_and_die() { + echo "Usage: ${0} none|partial|full-current-session|full-headless-sway|[auto] [meson options]" + exit 1 +} + +[ ${#} -ge 3 ] || usage_and_die + +mode=${1} +srcdir=$(realpath "${2}") +blddir=$(realpath "${3}") +shift 3 + +if [ -e "${blddir}" ]; then + echo "error: ${blddir}: build directory already exists" + exit 1 +fi + +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 + +case ${mode} in + partial|full-current-session|full-headless-sway) + ;; + + none) + do_pgo=no + ;; + + auto) + # TODO: once Sway 1.6.2 has been released, prefer + # full-headless-sway + + if [ -n "${WAYLAND_DISPLAY+x}" ]; then + mode=full-current-session + elif command -v sway > /dev/null; then + mode=full-headless-sway + else + mode=partial + fi + ;; + + *) + usage_and_die + ;; +esac + +# echo "source: ${srcdir}" +# echo "build: ${blddir}" +# echo "compiler: ${compiler}" +# echo "mode: ${mode}" +# echo "CFLAGS: ${CFLAGS}" + +export CFLAGS +meson "${@}" "${blddir}" "${srcdir}" --buildtype=release -Db_lto=true + +if [ ${do_pgo} = yes ]; then + find . -name "*.gcda" -delete + meson configure "${blddir}" -Db_pgo=generate + ninja -C "${blddir}" + + # 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 "${blddir}" test + + # Run mode-dependent script to generate profiling data + "${srcdir}"/pgo/${mode}.sh "${srcdir}" "${blddir}" + + if [ ${compiler} = clang ]; then + llvm-profdata \ + merge \ + "${blddir}"/default_*.profraw \ + --output="${blddir}"/default.profdata + fi + + meson configure "${blddir}" -Db_pgo=use +fi + +ninja -C "${blddir}" From aeb510182b32c342a9175045aed37f5e1023384e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 4 Sep 2021 10:55:57 +0200 Subject: [PATCH 13/29] pgo: full-inner: remove -o tweak.render-timer=log --- pgo/full-inner.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/pgo/full-inner.sh b/pgo/full-inner.sh index 14a3528c..4e8265fd 100755 --- a/pgo/full-inner.sh +++ b/pgo/full-inner.sh @@ -17,7 +17,6 @@ cd "${blddir}" LC_CTYPE=en_US.UTF-8 "${blddir}"/footclient --version LC_CTYPE=en_US.UTF-8 "${blddir}"/foot \ - -o tweak.render-timer=log \ --config=/dev/null \ --term=xterm \ sh -c " From 3a34b94f2e8dadf845889bec2fa8cea5f89665d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 4 Sep 2021 11:04:27 +0200 Subject: [PATCH 14/29] =?UTF-8?q?pgo:=20full-inner:=20quote=20path=20in=20?= =?UTF-8?q?trap=E2=80=99s=20=E2=80=9Crm=E2=80=9D=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pgo/full-inner.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pgo/full-inner.sh b/pgo/full-inner.sh index 4e8265fd..2125885d 100755 --- a/pgo/full-inner.sh +++ b/pgo/full-inner.sh @@ -8,7 +8,7 @@ blddir=$(realpath "${2}") . "${srcdir}"/pgo/options pgo_data=$(mktemp) -trap "rm -f ${pgo_data}" EXIT INT HUP TERM +trap "rm -f '${pgo_data}'" EXIT INT HUP TERM rm -f "${blddir}"/pgo-ok From 801bce335be8c3cf6d3793a50c2dfcf2ada29f19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 4 Sep 2021 11:04:54 +0200 Subject: [PATCH 15/29] pgo: full-headless-cage: new headless variant Appears to work, but cage spams a lot of 00:00:08.026 [types/wlr_output.c:720] Basic output test failed for HEADLESS-1 00:00:08.036 [types/wlr_output.c:720] Basic output test failed for HEADLESS-1 --- pgo/full-headless-cage.sh | 15 +++++++++++++++ pgo/pgo.sh | 6 ++++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100755 pgo/full-headless-cage.sh diff --git a/pgo/full-headless-cage.sh b/pgo/full-headless-cage.sh new file mode 100755 index 00000000..c85efd81 --- /dev/null +++ b/pgo/full-headless-cage.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +set -eu + +srcdir=$(realpath "${1}") +blddir=$(realpath "${2}") + +runtime_dir=$(mktemp -d) +trap "rm -rf '${runtime_dir}'" EXIT INT HUP TERM + +# Run Sway. full-headless-sway-inner.sh ends with a ‘swaymsg exit’ +XDG_RUNTIME_DIR="${runtime_dir}" WLR_BACKENDS=headless cage "${srcdir}"/pgo/full-inner.sh "${srcdir}" "${blddir}" + +# Cage’s exit code doesn’t reflect our script’s exit code +[ -f "${blddir}"/pgo-ok ] || exit 1 diff --git a/pgo/pgo.sh b/pgo/pgo.sh index fbd7fbe2..56db6684 100755 --- a/pgo/pgo.sh +++ b/pgo/pgo.sh @@ -3,7 +3,7 @@ set -eu usage_and_die() { - echo "Usage: ${0} none|partial|full-current-session|full-headless-sway|[auto] [meson options]" + echo "Usage: ${0} none|partial|full-current-session|full-headless-sway|full-headless-cage|[auto] [meson options]" exit 1 } @@ -41,7 +41,7 @@ case $(${CC-cc} --version) in esac case ${mode} in - partial|full-current-session|full-headless-sway) + partial|full-current-session|full-headless-sway|full-headless-cage) ;; none) @@ -56,6 +56,8 @@ case ${mode} in mode=full-current-session elif command -v sway > /dev/null; then mode=full-headless-sway + elif command -v cage > /dev/null; then + mode=full-headless-cage else mode=partial fi From f25055f101d031244a88dc37cef20f2c46d060f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 4 Sep 2021 11:06:34 +0200 Subject: [PATCH 16/29] pgo: full-headless-cage: remove references to Sway --- pgo/full-headless-cage.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/pgo/full-headless-cage.sh b/pgo/full-headless-cage.sh index c85efd81..a4fd5699 100755 --- a/pgo/full-headless-cage.sh +++ b/pgo/full-headless-cage.sh @@ -8,7 +8,6 @@ blddir=$(realpath "${2}") runtime_dir=$(mktemp -d) trap "rm -rf '${runtime_dir}'" EXIT INT HUP TERM -# Run Sway. full-headless-sway-inner.sh ends with a ‘swaymsg exit’ XDG_RUNTIME_DIR="${runtime_dir}" WLR_BACKENDS=headless cage "${srcdir}"/pgo/full-inner.sh "${srcdir}" "${blddir}" # Cage’s exit code doesn’t reflect our script’s exit code From 99c4e51e199f87c0b4d97d43a2d34af62c6b7ae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 4 Sep 2021 11:14:09 +0200 Subject: [PATCH 17/29] pgo: add set -x to all PGO scripts Without this, debugging error reports from users is going to be _very_ difficult... --- pgo/full-current-session.sh | 2 +- pgo/full-headless-cage.sh | 2 +- pgo/full-headless-sway-inner.sh | 2 +- pgo/full-headless-sway.sh | 2 +- pgo/full-inner.sh | 4 ++-- pgo/partial.sh | 2 +- pgo/pgo.sh | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pgo/full-current-session.sh b/pgo/full-current-session.sh index 3f62a6b5..363ee793 100755 --- a/pgo/full-current-session.sh +++ b/pgo/full-current-session.sh @@ -1,6 +1,6 @@ #!/bin/sh -set -eu +set -eux srcdir=$(realpath "${1}") blddir=$(realpath "${2}") diff --git a/pgo/full-headless-cage.sh b/pgo/full-headless-cage.sh index a4fd5699..ad5d0264 100755 --- a/pgo/full-headless-cage.sh +++ b/pgo/full-headless-cage.sh @@ -1,6 +1,6 @@ #!/bin/sh -set -eu +set -eux srcdir=$(realpath "${1}") blddir=$(realpath "${2}") diff --git a/pgo/full-headless-sway-inner.sh b/pgo/full-headless-sway-inner.sh index 5bf20390..dd612a2a 100755 --- a/pgo/full-headless-sway-inner.sh +++ b/pgo/full-headless-sway-inner.sh @@ -1,6 +1,6 @@ #!/bin/sh -set -u +set -ux srcdir=$(realpath "${1}") blddir=$(realpath "${2}") diff --git a/pgo/full-headless-sway.sh b/pgo/full-headless-sway.sh index ef34c560..bbf038b9 100755 --- a/pgo/full-headless-sway.sh +++ b/pgo/full-headless-sway.sh @@ -1,6 +1,6 @@ #!/bin/sh -set -eu +set -eux srcdir=$(realpath "${1}") blddir=$(realpath "${2}") diff --git a/pgo/full-inner.sh b/pgo/full-inner.sh index 2125885d..37cb2fb6 100755 --- a/pgo/full-inner.sh +++ b/pgo/full-inner.sh @@ -1,6 +1,6 @@ #!/bin/sh -set -eu +set -eux srcdir=$(realpath "${1}") blddir=$(realpath "${2}") @@ -20,7 +20,7 @@ LC_CTYPE=en_US.UTF-8 "${blddir}"/foot \ --config=/dev/null \ --term=xterm \ sh -c " - set -eu + set -eux '${srcdir}/scripts/generate-alt-random-writes.py' \ ${script_options} \"${pgo_data}\" diff --git a/pgo/partial.sh b/pgo/partial.sh index 9cb8bd59..c16de324 100755 --- a/pgo/partial.sh +++ b/pgo/partial.sh @@ -1,6 +1,6 @@ #!/bin/sh -set -eu +set -eux srcdir=$(realpath "${1}") blddir=$(realpath "${2}") diff --git a/pgo/pgo.sh b/pgo/pgo.sh index 56db6684..7d842036 100755 --- a/pgo/pgo.sh +++ b/pgo/pgo.sh @@ -1,6 +1,6 @@ #!/bin/sh -set -eu +set -eux usage_and_die() { echo "Usage: ${0} none|partial|full-current-session|full-headless-sway|full-headless-cage|[auto] [meson options]" From cf7c5050f64709bea48e3175a3218f7b74d19f36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 4 Sep 2021 18:17:18 +0200 Subject: [PATCH 18/29] =?UTF-8?q?pgo:=20pgo.sh:=20auto:=20don=E2=80=99t=20?= =?UTF-8?q?use=20full-headless-sway?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This requires Sway >= 1.6.2, which hasn’t been released yet. Thus, don’t auto-use it. Users can still request it explicitly. --- pgo/pgo.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pgo/pgo.sh b/pgo/pgo.sh index 7d842036..d608930d 100755 --- a/pgo/pgo.sh +++ b/pgo/pgo.sh @@ -54,8 +54,8 @@ case ${mode} in if [ -n "${WAYLAND_DISPLAY+x}" ]; then mode=full-current-session - elif command -v sway > /dev/null; then - mode=full-headless-sway + # elif command -v sway > /dev/null; then # Requires 1.6.2 + # mode=full-headless-sway elif command -v cage > /dev/null; then mode=full-headless-cage else From 579e1f80b4d4b3955fe783663ce9dead08cff15b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 4 Sep 2021 18:18:58 +0200 Subject: [PATCH 19/29] pkgbuild: build using pgo/pgo.sh --- PKGBUILD | 78 +++----------------------------------------------------- 1 file changed, 4 insertions(+), 74 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index b05d7078..68ecfccf 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,3 +1,5 @@ +PGO=auto # none|partial|full-current-session|full-headless-sway|full-headless-cage + pkgname=('foot-git' 'foot-terminfo-git') pkgver=1.9.0 pkgrel=1 @@ -14,80 +16,8 @@ pkgver() { } build() { - local compiler=other - local do_pgo=no - - # makepkg uses -O2 by default, but we *really* want -O3 - CFLAGS+=" -O3" - - # Figure out which compiler we're using, and whether or not to do PGO - case $(${CC-cc} --version) in - *GCC*) - compiler=gcc - do_pgo=yes - ;; - - *clang*) - compiler=clang - - # We need llvm to be able to manage the profiling data - if command -v llvm-profdata > /dev/null; then - do_pgo=yes - - # Meson adds -fprofile-correction, which Clang doesn't - # understand - CFLAGS+=" -Wno-ignored-optimization-argument" - fi - ;; - esac - - meson \ - --prefix=/usr \ - --buildtype=release \ - --wrap-mode=nofallback \ - -Db_lto=true .. - - if [[ ${do_pgo} == yes ]]; then - find -name "*.gcda" -delete - meson configure -Db_pgo=generate - ninja - - # 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 test - - local script_options="--scroll --scroll-region --colors-regular --colors-bright --colors-256 --colors-rgb --attr-bold --attr-italic --attr-underline --sixel" - - tmp_file=$(mktemp) - - if [[ -v WAYLAND_DISPLAY ]]; then - ./footclient --version - ./foot \ - --config /dev/null \ - --term=xterm \ - sh -c "../scripts/generate-alt-random-writes.py ${script_options} ${tmp_file} && cat ${tmp_file}" - else - ./footclient --version - ./foot --version - ../scripts/generate-alt-random-writes.py \ - --rows=67 \ - --cols=135 \ - ${script_options} \ - ${tmp_file} - ./pgo ${tmp_file} ${tmp_file} ${tmp_file} - fi - - rm "${tmp_file}" - - if [[ ${compiler} == clang ]]; then - llvm-profdata merge default_*profraw --output=default.profdata - fi - - meson configure -Db_pgo=use - fi - - ninja + rm -rf * + ../pgo/pgo.sh ${PGO} .. . } check() { From e907ec209cf9b3e2f7ef06e0ffd71b9735f1e702 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 4 Sep 2021 18:29:20 +0200 Subject: [PATCH 20/29] pgo: pgo.sh: allow a pre-existing build directory --- pgo/pgo.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pgo/pgo.sh b/pgo/pgo.sh index d608930d..39da2a30 100755 --- a/pgo/pgo.sh +++ b/pgo/pgo.sh @@ -14,10 +14,10 @@ srcdir=$(realpath "${2}") blddir=$(realpath "${3}") shift 3 -if [ -e "${blddir}" ]; then - echo "error: ${blddir}: build directory already exists" - exit 1 -fi +# if [ -e "${blddir}" ]; then +# echo "error: ${blddir}: build directory already exists" +# exit 1 +# fi compiler=other do_pgo=no From 6d67c2b4ab3194df40d383841fb95bcc2f033fa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 4 Sep 2021 18:29:55 +0200 Subject: [PATCH 21/29] =?UTF-8?q?pgo:=20pgo.sh:=20run=20=E2=80=98find?= =?UTF-8?q?=E2=80=99=20in=20the=20build-directory,=20not=20cwd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pgo/pgo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pgo/pgo.sh b/pgo/pgo.sh index 39da2a30..af84e7ce 100755 --- a/pgo/pgo.sh +++ b/pgo/pgo.sh @@ -78,7 +78,7 @@ export CFLAGS meson "${@}" "${blddir}" "${srcdir}" --buildtype=release -Db_lto=true if [ ${do_pgo} = yes ]; then - find . -name "*.gcda" -delete + find "${blddir}" -name "*.gcda" -delete meson configure "${blddir}" -Db_pgo=generate ninja -C "${blddir}" From a941253ba74d5ca48cbb1401b4ced8d0fa2b6a1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 4 Sep 2021 18:41:49 +0200 Subject: [PATCH 22/29] pgo: pgo.sh: add meson bld/src dir arguments last --- pgo/pgo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pgo/pgo.sh b/pgo/pgo.sh index af84e7ce..fd7d05a3 100755 --- a/pgo/pgo.sh +++ b/pgo/pgo.sh @@ -75,7 +75,7 @@ esac # echo "CFLAGS: ${CFLAGS}" export CFLAGS -meson "${@}" "${blddir}" "${srcdir}" --buildtype=release -Db_lto=true +meson setup --buildtype=release -Db_lto=true "${@}" "${blddir}" "${srcdir}" if [ ${do_pgo} = yes ]; then find "${blddir}" -name "*.gcda" -delete From 2181af05521dbbf7a02fae632006109dc7d5b5eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 4 Sep 2021 18:42:04 +0200 Subject: [PATCH 23/29] pkgbuild: the pgo script erases the old profdata files --- PKGBUILD | 1 - 1 file changed, 1 deletion(-) diff --git a/PKGBUILD b/PKGBUILD index 68ecfccf..a4e873be 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -16,7 +16,6 @@ pkgver() { } build() { - rm -rf * ../pgo/pgo.sh ${PGO} .. . } From 5493267bf7ca08527e563717b4bf7812388f79f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 4 Sep 2021 18:50:05 +0200 Subject: [PATCH 24/29] pgo: pgo.sh: remove both gcc and clang generated profile stats --- pgo/pgo.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pgo/pgo.sh b/pgo/pgo.sh index fd7d05a3..9db50e08 100755 --- a/pgo/pgo.sh +++ b/pgo/pgo.sh @@ -78,7 +78,14 @@ export CFLAGS meson setup --buildtype=release -Db_lto=true "${@}" "${blddir}" "${srcdir}" if [ ${do_pgo} = yes ]; then - find "${blddir}" -name "*.gcda" -delete + find "${blddir}" \ + '(' \ + -name "*.gcda" -o \ + -name "*.profraw" -o \ + -name default.profdata \ + ')' \ + -delete + meson configure "${blddir}" -Db_pgo=generate ninja -C "${blddir}" From e77c3b3e4f82cf02a03573369900771c12bd0862 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 4 Sep 2021 18:52:36 +0200 Subject: [PATCH 25/29] =?UTF-8?q?pkgbuild:=20add=20=E2=80=98auto=E2=80=99?= =?UTF-8?q?=20to=20the=20list=20of=20possible=20PGO=20values?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PKGBUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PKGBUILD b/PKGBUILD index a4e873be..340f4687 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,4 +1,4 @@ -PGO=auto # none|partial|full-current-session|full-headless-sway|full-headless-cage +PGO=auto # auto|none|partial|full-current-session|full-headless-sway|full-headless-cage pkgname=('foot-git' 'foot-terminfo-git') pkgver=1.9.0 From 7e53de263b4ba15bf7e4b6e91f08dd3d3c5a9d05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 4 Sep 2021 18:59:32 +0200 Subject: [PATCH 26/29] pkgbuild: add back --prefix --wrap-mode=nofallback --- PKGBUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PKGBUILD b/PKGBUILD index 340f4687..4cff4a6c 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -16,7 +16,7 @@ pkgver() { } build() { - ../pgo/pgo.sh ${PGO} .. . + ../pgo/pgo.sh ${PGO} .. . --prefix=/usr --wrap-mode=nofallback } check() { From b6df5f6456f4e4a897cb30f814c7d85254efbc8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 12 Sep 2021 16:11:42 +0200 Subject: [PATCH 27/29] pgo.sh: set -x *after* verifying input --- pgo/pgo.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pgo/pgo.sh b/pgo/pgo.sh index 9db50e08..57a016cc 100755 --- a/pgo/pgo.sh +++ b/pgo/pgo.sh @@ -1,6 +1,6 @@ #!/bin/sh -set -eux +set -eu usage_and_die() { echo "Usage: ${0} none|partial|full-current-session|full-headless-sway|full-headless-cage|[auto] [meson options]" @@ -68,6 +68,8 @@ case ${mode} in ;; esac +set -x + # echo "source: ${srcdir}" # echo "build: ${blddir}" # echo "compiler: ${compiler}" From aa0f2a71cce125ae30c2baa05e7a1802d30fe1f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 12 Sep 2021 16:57:07 +0200 Subject: [PATCH 28/29] install.md: document pgo/*.sh scripts --- INSTALL.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/INSTALL.md b/INSTALL.md index 9543948e..40b128e7 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -274,6 +274,32 @@ slower!) binary. #### Performance optimized, PGO +There are a lot more steps involved in a PGO build, and for this +reason there are a number of helper scripts available. + +`pgo/pgo.sh` is a standalone script that pieces together the other +scripts in the `pgo` directory to do a complete PGO build. This script +is intended to be used when doing manual builds. + +Example: + +```sh +cd foot +./pgo/pgo.sh auto . /tmp/foot-pgo-build-output +``` + +(run `./pgo/pgo.sh` to get help on usage) + +It supports a couple of different PGO builds; partial (covered in +detail below), full (also covered in detail below), and (full) +headless builds using Sway or cage. + +Packagers may want to use it as inspiration, but may choose to support +only a specific build type; e.g. full/headless with Sway. + +To do a manual PGO build, instead of using the script(s) mentioned +above, detailed instructions follows: + First, configure the build directory: ```sh From 32900207f989d2a1e5e54d75e8c0729cd423e176 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 12 Sep 2021 16:59:23 +0200 Subject: [PATCH 29/29] changelog: pgo build scripts --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57984c49..fef6c13f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,9 @@ * Warn when it appears the primary font is not monospaced. Can be disabled by setting `[tweak].font-monospace-warn=no` (https://codeberg.org/dnkl/foot/issues/704). +* PGO build scripts, in the `pgo` directory. See INSTALL.md - + _Performance optimized, PGO_, for details + (https://codeberg.org/dnkl/foot/issues/701). ### Changed