diff mbox series

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

Message ID 20250910132452.3929251-1-pkj@axis.com
State New
Headers show
Series meson: Backport patches to support dependencies on header-only Boost libs | expand

Commit Message

Peter Kjellerstedt Sept. 10, 2025, 1:24 p.m. UTC
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.

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---
 ...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

Comments

Koen Kooi Sept. 12, 2025, 12:03 p.m. UTC | #1
> Op 10 sep 2025, om 15:24 heeft Peter Kjellerstedt via lists.openembedded.org <peter.kjellerstedt=axis.com@lists.openembedded.org> het volgende geschreven:
> 
> 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.

Thanks for fixing meson, I ran into this exact issue earlier today!

regards,

Koen

> 
> Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
> ---
> ...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
> 
> diff --git a/meta/recipes-devtools/meson/meson/0001-Check-for-header-only-Boost-libraries.patch b/meta/recipes-devtools/meson/meson/0001-Check-for-header-only-Boost-libraries.patch
> new file mode 100644
> index 0000000000..3d2810aff9
> --- /dev/null
> +++ b/meta/recipes-devtools/meson/meson/0001-Check-for-header-only-Boost-libraries.patch
> @@ -0,0 +1,58 @@
> +From f16897135c394d36656da0078613864076300e07 Mon Sep 17 00:00:00 2001
> +From: Jussi Pakkanen <jussi.pakkanen@mailbox.org>
> +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 <peter.kjellerstedt@axis.com>
> +---
> + 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:')
> diff --git a/meta/recipes-devtools/meson/meson/0002-Boost-python-must-have-a-library-component.patch b/meta/recipes-devtools/meson/meson/0002-Boost-python-must-have-a-library-component.patch
> new file mode 100644
> index 0000000000..c03c47534e
> --- /dev/null
> +++ b/meta/recipes-devtools/meson/meson/0002-Boost-python-must-have-a-library-component.patch
> @@ -0,0 +1,34 @@
> +From d0644d543f4df39cf2ba14337000ee019cb20b6d Mon Sep 17 00:00:00 2001
> +From: Jussi Pakkanen <jussi.pakkanen@mailbox.org>
> +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 <peter.kjellerstedt@axis.com>
> +---
> + 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:
> diff --git a/meta/recipes-devtools/meson/meson_1.8.2.bb b/meta/recipes-devtools/meson/meson_1.8.2.bb
> index bfeaab0a79..0dd0544e14 100644
> --- a/meta/recipes-devtools/meson/meson_1.8.2.bb
> +++ b/meta/recipes-devtools/meson/meson_1.8.2.bb
> @@ -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+)+)$"
> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#223209): https://lists.openembedded.org/g/openembedded-core/message/223209
> Mute This Topic: https://lists.openembedded.org/mt/115169173/9418801
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [koen.kooi@oss.qualcomm.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/meta/recipes-devtools/meson/meson/0001-Check-for-header-only-Boost-libraries.patch b/meta/recipes-devtools/meson/meson/0001-Check-for-header-only-Boost-libraries.patch
new file mode 100644
index 0000000000..3d2810aff9
--- /dev/null
+++ b/meta/recipes-devtools/meson/meson/0001-Check-for-header-only-Boost-libraries.patch
@@ -0,0 +1,58 @@ 
+From f16897135c394d36656da0078613864076300e07 Mon Sep 17 00:00:00 2001
+From: Jussi Pakkanen <jussi.pakkanen@mailbox.org>
+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 <peter.kjellerstedt@axis.com>
+---
+ 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:')
diff --git a/meta/recipes-devtools/meson/meson/0002-Boost-python-must-have-a-library-component.patch b/meta/recipes-devtools/meson/meson/0002-Boost-python-must-have-a-library-component.patch
new file mode 100644
index 0000000000..c03c47534e
--- /dev/null
+++ b/meta/recipes-devtools/meson/meson/0002-Boost-python-must-have-a-library-component.patch
@@ -0,0 +1,34 @@ 
+From d0644d543f4df39cf2ba14337000ee019cb20b6d Mon Sep 17 00:00:00 2001
+From: Jussi Pakkanen <jussi.pakkanen@mailbox.org>
+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 <peter.kjellerstedt@axis.com>
+---
+ 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:
diff --git a/meta/recipes-devtools/meson/meson_1.8.2.bb b/meta/recipes-devtools/meson/meson_1.8.2.bb
index bfeaab0a79..0dd0544e14 100644
--- a/meta/recipes-devtools/meson/meson_1.8.2.bb
+++ b/meta/recipes-devtools/meson/meson_1.8.2.bb
@@ -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+)+)$"