From 82d9fd92194c72a9ec9df1ce2907caa2fca91e98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 21 Dec 2020 12:15:59 +0100 Subject: [PATCH 01/10] =?UTF-8?q?install:=20fix=20typo=20in=20=E2=80=98nin?= =?UTF-8?q?ja=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index 43655b81..9b057080 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -177,7 +177,7 @@ To do a regular, non-PGO build optimized for performance: ```sh export CFLAGS="$CFLAGS -O3 -march=native" meson --buildtype=release --prefix=/usr -Db_lto=true ../.. -wninja +ninja ninja test ninja install ``` From 5987b7c85f1b865d65613cb2b557498b0abce7f2 Mon Sep 17 00:00:00 2001 From: sterni Date: Sun, 20 Dec 2020 16:43:42 +0100 Subject: [PATCH 02/10] meson: default to c11 We don't need any C18 specifics, so C11 is also fine and more widely supported (i. e. in older clang versions). --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index a9ce24b7..7ede547e 100644 --- a/meson.build +++ b/meson.build @@ -3,7 +3,7 @@ project('foot', 'c', license: 'MIT', meson_version: '>=0.53.0', default_options: [ - 'c_std=c18', + 'c_std=c11', 'warning_level=1', 'werror=true', 'b_ndebug=if-release']) From 505680087cb6a1d994c1ea8089bc2c44cd36187a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 21 Dec 2020 12:20:08 +0100 Subject: [PATCH 03/10] changelog: use -std=c11 instead of -std=c18 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac335fe7..531c84eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,10 @@ ## 1.6.1 ### Added ### Changed + +* Use `-std=c11` instead of `-std=c18`. + + ### Deprecated ### Removed ### Fixed From 69836ab7958c8bece9a7e30204f4bf6c2c2f62f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 21 Dec 2020 12:24:29 +0100 Subject: [PATCH 04/10] install.md: add -Wno-profile-instr-unprofiled to clang flags in PGO builds --- INSTALL.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index 9b057080..0e0f8ddd 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -201,7 +201,10 @@ later have a regression where PGO with `-O2` is **much** slower. If you are using Clang instead of GCC, use the following `CFLAGS` instead: ```sh -export CFLAGS="$CFLAGS -O3 -march=native -Wno-ignored-optimization-argument -Wno-profile-instr-out-of-date" +export CFLAGS="$CFLAGS -O3 -march=native \ + -Wno-ignored-optimization-argument \ + -Wno-profile-instr-out-of-date \ + -Wno-profile-instr-unprofiled" ``` Then, tell meson we want to _generate_ profiling data, and build: From 84fe48acbb712b177fc4f6de847a420319a971d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 21 Dec 2020 12:24:47 +0100 Subject: [PATCH 05/10] install.md: mention that packagers should not use -march=native --- INSTALL.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/INSTALL.md b/INSTALL.md index 0e0f8ddd..4bfef825 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -157,6 +157,10 @@ optimization. In addition to being faster, PGO builds also tend to be smaller than regular `-O3` builds. +**Note**: if you are packaging foot, you should probably remove +`-march=native`, as that may cause gcc/clang to emit instructions that +may not be available on other computers. + #### Size optimized From 6a03567490d90a28363e2093a416e350b1a3ce89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 21 Dec 2020 13:01:38 +0100 Subject: [PATCH 06/10] install: remove -march=native This simplifies the instructions. People interested in performance are likely to know how to use it. --- INSTALL.md | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 4bfef825..d553544f 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -157,17 +157,13 @@ optimization. In addition to being faster, PGO builds also tend to be smaller than regular `-O3` builds. -**Note**: if you are packaging foot, you should probably remove -`-march=native`, as that may cause gcc/clang to emit instructions that -may not be available on other computers. - #### Size optimized To optimize for size (i.e. produce a small binary): ```sh -export CFLAGS="$CFLAGS -Os -march=native" +export CFLAGS="$CFLAGS -Os" meson --buildtype=release --prefix=/usr -Db_lto=true ../.. ninja ninja test @@ -179,7 +175,7 @@ ninja install To do a regular, non-PGO build optimized for performance: ```sh -export CFLAGS="$CFLAGS -O3 -march=native" +export CFLAGS="$CFLAGS -O3" meson --buildtype=release --prefix=/usr -Db_lto=true ../.. ninja ninja test @@ -195,7 +191,7 @@ slower!) binary. First, configure the build directory: ```sh -export CFLAGS="$CFLAGS -O3 -march=native -Wno-missing-profile" +export CFLAGS="$CFLAGS -O3 -Wno-missing-profile" meson --buildtype=release --prefix=/usr -Db_lto=true ../.. ``` @@ -205,7 +201,7 @@ later have a regression where PGO with `-O2` is **much** slower. If you are using Clang instead of GCC, use the following `CFLAGS` instead: ```sh -export CFLAGS="$CFLAGS -O3 -march=native \ +export CFLAGS="$CFLAGS -O3 \ -Wno-ignored-optimization-argument \ -Wno-profile-instr-out-of-date \ -Wno-profile-instr-unprofiled" From 68dd9c17d5d3aeaa8196d5e31256ccb95429ac2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 21 Dec 2020 13:40:53 +0100 Subject: [PATCH 07/10] generate-alt-random: ioctl(TIOCGWINSZ) may fail in run inside a container MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This _should_ only happen when we’re doing a partial PGO build, since then the script is run in the parent terminal. In this case, the user is expected to use --rows/--cols anyway. --- CHANGELOG.md | 1 + scripts/generate-alt-random-writes.py | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 531c84eb..d02a8e1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ to fail. * Background color when alpha < 1.0 being wrong (https://codeberg.org/dnkl/foot/issues/249). +* `generate-alt-random.py` failing in containers. ### Security diff --git a/scripts/generate-alt-random-writes.py b/scripts/generate-alt-random-writes.py index 202c99c5..2e51082b 100755 --- a/scripts/generate-alt-random-writes.py +++ b/scripts/generate-alt-random-writes.py @@ -37,11 +37,17 @@ def main(): opts = parser.parse_args() out = opts.out if opts.out is not None else sys.stdout - lines, cols, height, width = struct.unpack( - 'HHHH', - fcntl.ioctl(sys.stdout.fileno(), - termios.TIOCGWINSZ, - struct.pack('HHHH', 0, 0, 0, 0))) + try: + lines, cols, height, width = struct.unpack( + 'HHHH', + fcntl.ioctl(sys.stdout.fileno(), + termios.TIOCGWINSZ, + struct.pack('HHHH', 0, 0, 0, 0))) + except OSError: + lines = None + cols = None + height = None + width = None if opts.rows is not None: lines = opts.rows @@ -50,6 +56,9 @@ def main(): cols = opts.cols width = 8 * cols # PGO help binary hardcodes cell width to 8px + if lines is None or cols is None or height is None or width is None: + raise Exception('could not get terminal width/height; use --rows and --cols') + # Number of characters to write to screen count = 256 * 1024**1 From 1ad63a5c584e67fc504c3e4c7c75a4425a74a510 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 21 Dec 2020 13:47:45 +0100 Subject: [PATCH 08/10] changelog: mention --seed in in generate-alt-random.pu --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d02a8e1d..1d15b439 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,11 @@ ## 1.6.1 ### Added + +* `--seed` to `generate-alt-random.py`, enabling deterministic PGO + builds. + + ### Changed * Use `-std=c11` instead of `-std=c18`. From b6b565cc9aa3e4b0d18a287219e09ac9a1b45271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 21 Dec 2020 13:50:06 +0100 Subject: [PATCH 09/10] changelog: mention -Wno-profile-instr-unprofiled --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d15b439..57913417 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,8 @@ ### Changed * Use `-std=c11` instead of `-std=c18`. +* Added `-Wno-profile-instr-unprofiled` to Clang cflags in PGO builds + ([INSTALL.md](https://codeberg.org/dnkl/foot/src/branch/releases/1.6/INSTALL.md#user-content-performance-optimized-pgo)) ### Deprecated From 7c3cb008ec18896f674ed72a24efbb7b5be77784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 21 Dec 2020 13:50:27 +0100 Subject: [PATCH 10/10] changelog: prepare for 1.6.1 --- CHANGELOG.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57913417..1974b2e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,8 +33,6 @@ ([INSTALL.md](https://codeberg.org/dnkl/foot/src/branch/releases/1.6/INSTALL.md#user-content-performance-optimized-pgo)) -### Deprecated -### Removed ### Fixed * Missing dependencies in meson, causing heavily parallelized builds @@ -44,7 +42,6 @@ * `generate-alt-random.py` failing in containers. -### Security ### Contributors * [craigbarnes](https://codeberg.org/craigbarnes)