boost-asio: Add recipe
PATCH v6 1/1 boost-asio: Add recipe
This is needed to build boost asio as a shared library rather than a header-only library, which is needed to save memory.
--- meta/conf/distro/include/maintainers.inc | 1 + .../boost/boost-asio/boost_asio.cpp | 1 + .../boost/boost-asio_1.92.0.bb | 33 +++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 meta/recipes-support/boost/boost-asio/boost_asio.cpp create mode 100644 meta/recipes-support/boost/boost-asio_1.92.0.bb
meta/conf/distro/include/maintainers.inc +1 -0
@@ -76,6 +76,7 @@ RECIPE_MAINTAINER:pn-blueprint-compiler = "Liu Yiding <[email protected]>" RECIPE_MAINTAINER:pn-bluez5 = "Unassigned <[email protected]>" RECIPE_MAINTAINER:pn-bmaptool = "Trevor Woerner <[email protected]>" RECIPE_MAINTAINER:pn-boost = "Unassigned <[email protected]>" +RECIPE_MAINTAINER:pn-boost-asio = "Gustav Lindberg <[email protected]>" RECIPE_MAINTAINER:pn-boost-build-native = "Unassigned <[email protected]>" RECIPE_MAINTAINER:pn-bootchart2 = "Unassigned <[email protected]>" RECIPE_MAINTAINER:pn-bsd-headers = "Khem Raj <[email protected]>"
meta/recipes-support/boost/boost-asio/boost_asio.cpp new file +1 -0
@@ -0,0 +1 @@ +#include <boost/asio/impl/src.hpp>
meta/recipes-support/boost/boost-asio_1.92.0.bb new file +33 -0
@@ -0,0 +1,33 @@ +SUMMARY = "Boost.Asio shared library shim" +DESCRIPTION = "Builds libboost_asio as a shared library from boost/asio/impl/src.hpp" +HOMEPAGE = "https://www.boost.org/doc/libs/1_90_0/doc/html/boost_asio.html" + +DEPENDS = "boost" + +# Reuse Boost source and licensing metadata. +require recipes-support/boost/boost-${PV}.inc + +SRC_URI += " file://boost_asio.cpp;subdir=${BOOST_P}" + +MAJOR_VER = "${@oe.utils.trim_version("${PV}", 1)}" + +do_compile() { + ${CXX} ${CPPFLAGS} ${CXXFLAGS} \ + -std=c++23 \ + -DBOOST_ASIO_DYN_LINK=1 \ + -fPIC \ + -shared \ + -Wl,-soname,libboost_asio.so.${MAJOR_VER} \ + ${S}/boost_asio.cpp \ + ${LDFLAGS} \ + -o ${B}/libboost_asio.so.${PV} +} + +do_install() { + install -d ${D}${libdir} + install -m 0755 ${B}/libboost_asio.so.${PV} ${D}${libdir}/ + ln -sf libboost_asio.so.${PV} ${D}${libdir}/libboost_asio.so.${MAJOR_VER} + ln -sf libboost_asio.so.${MAJOR_VER} ${D}${libdir}/libboost_asio.so +} + +BBCLASSEXTEND = "native"
Signature · 3 lines
2.43.0 Add myself as maintainer
Quoted 3 lines · Gustav Lindberg via lists.openembedded.org
This is needed to build boost asio as a shared library rather than a header-only library, which is needed to save memory.
Why specifically asio and nothing else? If we want to build bits of boost as shared libraries where upstream only supports them as header-only libs, then there should be a general solution, and ideally one that is accepted upstream.
I think you need to discuss with boost upstream first before proposing something custom for core.
Alex
Quoted 1 line
Why specifically asio and nothing else?
Because it's the only one we need that's set up this way. Not all boost libraries are set up this way, for example boost-json already has a pre-built shared library (and no header-only option). I don't know if there are any other libraries that are set up this way, but if there are, then people who need them can add them.
Quoted 1 line
If we want to build bits of boost as shared libraries where upstream only supports them as header-only libs, then there should be a general solution, and ideally one that is accepted upstream.
This is the solution that's accepted upstream. Boost-asio is header-only by default for people who don't need a shared library. But it officially supports the BOOST_ASIO_DYN_LINK flag for dynamically linking to a shared library that we have to build ourselves, and they intentionally don't build that shared library since it's not needed by default.
Making these changes upstream would require everyone who uses boost to build the boost-asio shared library whether they need it or not, which would be wasteful. Note that my change doesn't require all openembedded users to build the shared library, it's still possible to use the boost recipe without the boost-asio recipe and get the header-only version of boost-asio without the shared library. The point in making these changes here is that users can decide whether they want to use the header-only version or the shared library by using the correct recipe.
________________________________
Från: Alexander Kanavin <[email protected]>
Skickat: Onsdag, 02 september 2026 13:59
Till: Gustav Lindberg <[email protected]>
Kopia: [email protected] <[email protected]> Ämne: Re: [OE-core] [PATCHv6] boost-asio: Add recipe
[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
Quoted 3 lines · Gustav Lindberg via lists.openembedded.org
This is needed to build boost asio as a shared library rather than a header-only library, which is needed to save memory.
Why specifically asio and nothing else? If we want to build bits of boost as shared libraries where upstream only supports them as header-only libs, then there should be a general solution, and ideally one that is accepted upstream.
I think you need to discuss with boost upstream first before proposing something custom for core.
Alex
Quoted 1 line · Gustav Lindberg
Making these changes upstream would require everyone who uses boost to build the boost-asio shared library whether they need it or not, which would be wasteful. Note that my change doesn't require all openembedded users to build the shared library, it's still possible to use the boost recipe without the boost-asio recipe and get the header-only version of boost-asio without the shared library. The point in making these changes here is that users can decide whether they want to use the header-only version or the shared library by using the correct recipe.
That's not the preferred way. The better way is to keep everything in a single recipe, and enabled the shared library (or not) with a PACKAGECONFIG option, ideally one that passes down a command line option to the boost build system.
Alex