diff options
| author | Ross Burton <ross.burton@arm.com> | 2025-07-18 14:58:40 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-07-21 23:00:18 +0100 |
| commit | f1035d5f50810f88cb4f59d318f1f5299c7ae6f2 (patch) | |
| tree | 88d6a83776ca13e0d25ad35d3809f095be162e59 | |
| parent | a52e89ba8e27f0da247c82c525427ec38fb6ff8f (diff) | |
| download | poky-f1035d5f50810f88cb4f59d318f1f5299c7ae6f2.tar.gz | |
harfbuzz: build with -Os
Upstream explicitly say in their CONFIG.md file to build with -Os:
Make sure you build with your compiler's "optimize for size" option.
On `gcc` this is `-Os` [ ... ] HarfBuzz heavily uses inline functions
and the optimize-size flag can make the library smaller by 20% or
more. Moreover, sometimes, based on the target CPU, the optimize-size
builds perform *faster* as well, thanks to lower code footprint and
caching effects
Drop the patch to build just hb-subset-plan-layout.cc with -Os (which
was a workaround for a GCC bug), and pass -Os globally.
This manages to reduce the duration to harfbuzz:do_compile on my machine
from 75s to 47s, and has a big impact on the library sizes:
harfbuzz: PKGSIZE changed from 1769358 to 1237070 (-30%)
harfbuzz-dbg: PKGSIZE changed from 84920168 to 71203208 (-16%)
harfbuzz-subset: PKGSIZE changed from 1579247 to 940191 (-40%)
(From OE-Core rev: d795b3e16ed01d7273d4f3779684eb41cc16f809)
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | meta/recipes-graphics/harfbuzz/harfbuzz/0001-Use-Os-to-compile-hb-subset-plan-layout.cc.patch | 72 | ||||
| -rw-r--r-- | meta/recipes-graphics/harfbuzz/harfbuzz_11.2.1.bb | 4 |
2 files changed, 3 insertions, 73 deletions
diff --git a/meta/recipes-graphics/harfbuzz/harfbuzz/0001-Use-Os-to-compile-hb-subset-plan-layout.cc.patch b/meta/recipes-graphics/harfbuzz/harfbuzz/0001-Use-Os-to-compile-hb-subset-plan-layout.cc.patch deleted file mode 100644 index 38ff58fce5..0000000000 --- a/meta/recipes-graphics/harfbuzz/harfbuzz/0001-Use-Os-to-compile-hb-subset-plan-layout.cc.patch +++ /dev/null | |||
| @@ -1,72 +0,0 @@ | |||
| 1 | From a4325b6f6ddbebf3ecaee8f3825a2f03096adb6d Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Khem Raj <raj.khem@gmail.com> | ||
| 3 | Date: Sun, 27 Apr 2025 15:26:09 -0700 | ||
| 4 | Subject: [PATCH] Use -Os to compile hb-subset-plan-layout.cc | ||
| 5 | |||
| 6 | This helps compiling with GCC 15 | ||
| 7 | |||
| 8 | Reported upstream with GH Issues [1] | ||
| 9 | |||
| 10 | [1] https://github.com/harfbuzz/harfbuzz/issues/5306 | ||
| 11 | |||
| 12 | Upstream-Status: Inappropriate [GCC-15 workaround] | ||
| 13 | |||
| 14 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 15 | --- | ||
| 16 | src/meson.build | 15 ++++++++++++--- | ||
| 17 | 1 file changed, 12 insertions(+), 3 deletions(-) | ||
| 18 | |||
| 19 | diff --git a/src/meson.build b/src/meson.build | ||
| 20 | index cbe5d9e..d7fc764 100644 | ||
| 21 | --- a/src/meson.build | ||
| 22 | +++ b/src/meson.build | ||
| 23 | @@ -398,7 +398,6 @@ hb_subset_sources = files( | ||
| 24 | 'hb-subset-instancer-solver.hh', | ||
| 25 | 'hb-subset-instancer-solver.cc', | ||
| 26 | 'hb-subset-plan.cc', | ||
| 27 | - 'hb-subset-plan-layout.cc', | ||
| 28 | 'hb-subset-plan-var.cc', | ||
| 29 | 'hb-subset-plan.hh', | ||
| 30 | 'hb-subset-plan-member-list.hh', | ||
| 31 | @@ -415,6 +414,10 @@ hb_subset_sources = files( | ||
| 32 | 'hb-subset.hh', | ||
| 33 | ) | ||
| 34 | |||
| 35 | +hb_subset_sources_os = files( | ||
| 36 | + 'hb-subset-plan-layout.cc', | ||
| 37 | +) | ||
| 38 | + | ||
| 39 | hb_subset_headers = files( | ||
| 40 | 'hb-subset.h', | ||
| 41 | 'hb-subset-serialize.h' | ||
| 42 | @@ -629,6 +632,12 @@ endif | ||
| 43 | |||
| 44 | darwin_versions = [hb_version_int, '@0@.0.0'.format(hb_version_int)] | ||
| 45 | |||
| 46 | +special_subset_layout_lib = static_library('special_subset_layout', | ||
| 47 | + 'hb-subset-plan-layout.cc', | ||
| 48 | + include_directories: incconfig, | ||
| 49 | + cpp_args: cpp_args + extra_hb_cpp_args + ['-Os'], # <== compile this one with -Os | ||
| 50 | +) | ||
| 51 | + | ||
| 52 | libharfbuzz = library('harfbuzz', hb_sources, | ||
| 53 | include_directories: incconfig, | ||
| 54 | dependencies: harfbuzz_deps, | ||
| 55 | @@ -656,7 +665,7 @@ defs_list += [harfbuzz_subset_def] | ||
| 56 | libharfbuzz_subset = library('harfbuzz-subset', hb_subset_sources, | ||
| 57 | include_directories: incconfig, | ||
| 58 | dependencies: [m_dep], | ||
| 59 | - link_with: [libharfbuzz], | ||
| 60 | + link_with: [libharfbuzz] + [special_subset_layout_lib], | ||
| 61 | cpp_args: cpp_args + extra_hb_cpp_args, | ||
| 62 | soversion: hb_so_version, | ||
| 63 | version: version, | ||
| 64 | @@ -668,7 +677,7 @@ libharfbuzz_subset = library('harfbuzz-subset', hb_subset_sources, | ||
| 65 | custom_target('harfbuzz-subset.cc', | ||
| 66 | build_by_default: true, | ||
| 67 | output: 'harfbuzz-subset.cc', | ||
| 68 | - input: hb_base_sources + hb_subset_sources, | ||
| 69 | + input: hb_base_sources + hb_subset_sources + hb_subset_sources_os, | ||
| 70 | command: [find_program('gen-harfbuzzcc.py'), | ||
| 71 | '@OUTPUT@', meson.current_source_dir(), '@INPUT@'], | ||
| 72 | ) | ||
diff --git a/meta/recipes-graphics/harfbuzz/harfbuzz_11.2.1.bb b/meta/recipes-graphics/harfbuzz/harfbuzz_11.2.1.bb index bc2c6acdae..2c8a1363d0 100644 --- a/meta/recipes-graphics/harfbuzz/harfbuzz_11.2.1.bb +++ b/meta/recipes-graphics/harfbuzz/harfbuzz_11.2.1.bb | |||
| @@ -9,7 +9,6 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=b98429b8e8e3c2a67cfef01e99e4893d \ | |||
| 9 | " | 9 | " |
| 10 | 10 | ||
| 11 | SRC_URI = "${GITHUB_BASE_URI}/download/${PV}/${BPN}-${PV}.tar.xz" | 11 | SRC_URI = "${GITHUB_BASE_URI}/download/${PV}/${BPN}-${PV}.tar.xz" |
| 12 | SRC_URI += "file://0001-Use-Os-to-compile-hb-subset-plan-layout.cc.patch" | ||
| 13 | SRC_URI[sha256sum] = "093714c8548a285094685f0bdc999e202d666b59eeb3df2ff921ab68b8336a49" | 12 | SRC_URI[sha256sum] = "093714c8548a285094685f0bdc999e202d666b59eeb3df2ff921ab68b8336a49" |
| 14 | 13 | ||
| 15 | DEPENDS += "glib-2.0-native" | 14 | DEPENDS += "glib-2.0-native" |
| @@ -21,6 +20,9 @@ GIR_MESON_DISABLE_FLAG = 'disabled' | |||
| 21 | GTKDOC_MESON_ENABLE_FLAG = 'enabled' | 20 | GTKDOC_MESON_ENABLE_FLAG = 'enabled' |
| 22 | GTKDOC_MESON_DISABLE_FLAG = 'disabled' | 21 | GTKDOC_MESON_DISABLE_FLAG = 'disabled' |
| 23 | 22 | ||
| 23 | # As per upstream CONFIG.md, it is recommended to always build with -Os. | ||
| 24 | FULL_OPTIMIZATION = "-Os ${DEBUG_LEVELFLAG}" | ||
| 25 | |||
| 24 | EXTRA_OEMESON = "-Dtests=disabled" | 26 | EXTRA_OEMESON = "-Dtests=disabled" |
| 25 | 27 | ||
| 26 | PACKAGECONFIG ??= "cairo freetype glib icu" | 28 | PACKAGECONFIG ??= "cairo freetype glib icu" |
