Skip to contentSkip to conversation

meson: Backport patches to support dependencies on header-only Boost libs

PATCH Peter Kjellerstedt 1 participant 1 message Sep 10, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 131 lines

-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Peter Kjellerstedt via lists.openembedded.org
Sent: den 10 september 2025 15:25
To: [email protected]
Subject: [OE-core] [PATCH] meson: Backport patches to support dependencies on header-only Boost libs

With Boost 1.89.0, the Boost.System library was made header-only. Since this is a frequent library to have as dependency in meson.build files, this resulted in build failures.

Backport two patches so that Boost dependencies on header-only libraries work as expected.

---
 ...heck-for-header-only-Boost-libraries.patch | 58 +++++++++++++++++++
 ...python-must-have-a-library-component.patch | 34 +++++++++++
 meta/recipes-devtools/meson/meson_1.8.2.bb    |  2 +
 3 files changed, 94 insertions(+)
 create mode 100644 meta/recipes-devtools/meson/meson/0001-Check-for-header-only-Boost-libraries.patch
 create mode 100644 meta/recipes-devtools/meson/meson/0002-Boost-python-must-have-a-library-component.patch
meta/recipes-devtools/meson/meson/0001-Check-for-header-only-Boost-libraries.patch new file +58 -0
new file mode 100644
index 0000000000..3d2810aff9
@@ -0,0 +1,58 @@
+From f16897135c394d36656da0078613864076300e07 Mon Sep 17 00:00:00 2001
+From: Jussi Pakkanen <[email protected]>
+Date: Fri, 29 Aug 2025 14:57:06 +0300
+Subject: [PATCH] Check for header only Boost libraries.
+
+Upstream-Status: Backport [https://github.com/mesonbuild/meson/commit/6a9a81619c139d0f6ae3d265f7366e61615d92a1]
+Signed-off-by: Peter Kjellerstedt <[email protected]>
+---
+ mesonbuild/dependencies/boost.py | 22 ++++++++++++++++++++--
+ 1 file changed, 20 insertions(+), 2 deletions(-)
+
+diff --git a/mesonbuild/dependencies/boost.py b/mesonbuild/dependencies/boost.py
+index 662f985..e153e8f 100644
+--- a/mesonbuild/dependencies/boost.py
++++ b/mesonbuild/dependencies/boost.py
+@@ -452,6 +452,10 @@ class BoostDependency(SystemDependency):
+                 break
+         libs = sorted(set(libs))
+
++        any_libs_found = len(libs) > 0
++        if not any_libs_found:
++            return False
++
+         modules = ['boost_' + x for x in self.modules]
+         for inc in inc_dirs:
+             mlog.debug(f'  - found boost {inc.version} include dir: {inc.path}')
+@@ -462,7 +466,7 @@ class BoostDependency(SystemDependency):
+                 mlog.debug(f'    - {j}')
+
+             #   3. Select the libraries matching the requested modules
+-            not_found: T.List[str] = []
++            not_found_as_libs: T.List[str] = []
+             selected_modules: T.List[BoostLibraryFile] = []
+             for mod in modules:
+                 found = False
+@@ -472,7 +476,21 @@ class BoostDependency(SystemDependency):
+                         found = True
+                         break
+                 if not found:
+-                    not_found += [mod]
++                    not_found_as_libs += [mod]
++
++            # If a lib is not found, but an include directory exists,
++            # assume it is a header only module.
++            not_found: T.List[str] = []
++            for boost_modulename in not_found_as_libs:
++                assert boost_modulename.startswith('boost_')
++                include_subdir = boost_modulename.replace('boost_', 'boost/', 1)
++                headerdir_found = False
++                for inc_dir in inc_dirs:
++                    if (inc_dir.path / include_subdir).is_dir():
++                        headerdir_found = True
++                        break
++                if not headerdir_found:
++                    not_found.append(boost_modulename)
+
+             # log the result
+             mlog.debug('  - found:')
meta/recipes-devtools/meson/meson/0002-Boost-python-must-have-a-library-component.patch new file +34 -0
new file mode 100644
index 0000000000..c03c47534e
@@ -0,0 +1,34 @@
+From d0644d543f4df39cf2ba14337000ee019cb20b6d Mon Sep 17 00:00:00 2001
+From: Jussi Pakkanen <[email protected]>
+Date: Fri, 29 Aug 2025 22:51:48 +0300
+Subject: [PATCH] Boost python must have a library component.
+
+Upstream-Status: Backport [https://github.com/mesonbuild/meson/commit/80917ca8c1a5af499cc6e004ad5d5a050da9045e]
+Signed-off-by: Peter Kjellerstedt <[email protected]>
+---
+ mesonbuild/dependencies/boost.py | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/mesonbuild/dependencies/boost.py b/mesonbuild/dependencies/boost.py
+index e153e8f..fdb35d4 100644
+--- a/mesonbuild/dependencies/boost.py
++++ b/mesonbuild/dependencies/boost.py
+@@ -440,6 +440,8 @@ class BoostDependency(SystemDependency):
+         mlog.debug('  - potential library dirs: {}'.format([x.as_posix() for x in lib_dirs]))
+         mlog.debug('  - potential include dirs: {}'.format([x.path.as_posix() for x in inc_dirs]))
+
++        must_have_library = ['boost_python']
++
+         #   2. Find all boost libraries
+         libs: T.List[BoostLibraryFile] = []
+         for i in lib_dirs:
+@@ -483,6 +485,9 @@ class BoostDependency(SystemDependency):
+             not_found: T.List[str] = []
+             for boost_modulename in not_found_as_libs:
+                 assert boost_modulename.startswith('boost_')
++                if boost_modulename in must_have_library:
++                    not_found.append(boost_modulename)
++                    continue
+                 include_subdir = boost_modulename.replace('boost_', 'boost/', 1)
+                 headerdir_found = False
+                 for inc_dir in inc_dirs:
meta/recipes-devtools/meson/meson_1.8.2.bb +0 -0
index bfeaab0a79..0dd0544e14 100644

meta/recipes-devtools/meson/meson_1.8.2.bb SRC_URI = "${GITHUB_BASE_URI}/download/${PV}/meson-${PV}.tar.gz \ · line 21

Quoted 8 lines
meta/recipes-devtools/meson/meson_1.8.2.bb +2 -0
@@ -14,6 +14,8 @@ SRC_URI = "${GITHUB_BASE_URI}/download/${PV}/meson-${PV}.tar.gz \
            file://0001-python-module-do-not-manipulate-the-environment-when.patch \
            file://0001-Make-CPU-family-warnings-fatal.patch \
            file://0002-Support-building-allarch-recipes-again.patch \
+           file://0001-Check-for-header-only-Boost-libraries.patch \
+           file://0002-Boost-python-must-have-a-library-component.patch \
            "
 SRC_URI[sha256sum] = "c105816d8158c76b72adcb9ff60297719096da7d07f6b1f000fd8c013cd387af"
 UPSTREAM_CHECK_REGEX = "(?P<pver>\d+(\.\d+)+)$"

Note that these patches are from after 1.9.0 so they are needed even if Wang Mingyu's patch to update the meson recipe to 1.9.0 is applied.

//Peter