1 # Copyright 1999-2026 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 # Keep an eye on releases: https://www.boost.org/releases/
8 PYTHON_COMPAT
=( python3_
{11.
.14} )
10 inherit dot
-a edo flag
-o-matic multiprocessing python
-r1 toolchain
-funcs multilib
-minimal
12 MY_PV
="$(ver_rs 1- _)"
14 DESCRIPTION
="Static Boost Libraries for C++"
15 HOMEPAGE
="https://www.boost.org/"
16 SRC_URI
="https://archives.boost.io/release/${PV}/source/boost_${MY_PV}.tar.bz2"
17 S
="${WORKDIR}/${PN%-*}_${MY_PV}"
21 #KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~arm64-macos ~x64-macos ~x64-solaris"
22 IUSE
="bzip2 +context debug doc icu lzma +nls mpi numpy python +stacktrace test test-full tools zlib zstd"
24 python? ( ${PYTHON_REQUIRED_USE} )
27 RESTRICT
="!test? ( test )"
30 ~dev-libs/boost-"${PV}"[static-libs]
31 context? ( dev-libs/boost[context] )
32 debug? ( dev-libs/boost[debug] )
33 doc? ( dev-libs/boost[doc] )
34 nls? ( dev-libs/boost[nls] )
35 stacktrace? ( dev-libs/boost[stacktrace] )
36 test? ( dev-libs/boost[test] )
37 test-full? ( dev-libs/boost[test-full] )
38 tools? ( dev-libs/boost[tools] )
41 app-arch/bzip2:=[${MULTILIB_USEDEP}]
45 dev-libs/icu:=[${MULTILIB_USEDEP}]
47 !icu? ( virtual/libiconv[${MULTILIB_USEDEP}] )
50 app-arch/xz-utils:=[${MULTILIB_USEDEP}]
54 virtual/mpi[${MULTILIB_USEDEP},threads]
57 dev-libs/boost[python]
59 numpy? ( dev-python/numpy:=[${PYTHON_USEDEP}] )
63 virtual/zlib:=[${MULTILIB_USEDEP}]
67 app-arch/zstd:=[${MULTILIB_USEDEP}]
70 BDEPEND
=">=dev-build/b2-5.1.0"
73 "${FILESDIR}"/${PN}-1.88
.0-disable_icu_rpath.
patch
74 "${FILESDIR}"/${PN}-1.88
.0-build-auto_index-tool.
patch
75 "${FILESDIR}"/${PN}-1.88
.0-beast-network-sandbox.
patch
76 "${FILESDIR}"/${PN}-1.88
.0-bind-no-Werror.
patch
77 "${FILESDIR}"/${PN}-1.88
.0-system-crashing-test.
patch
78 "${FILESDIR}"/${PN}-1.88
.0-yap-cstdint.
patch
79 # https://github.com/boostorg/dll/issues/108
80 "${FILESDIR}"/${PN}-1.89
.0-dll-no-lto.
patch
81 "${FILESDIR}"/${PN}-1.89
.0-graph-remove-system-dependency.
patch
82 "${FILESDIR}"/${PN}-1.89
.0-predef-include-path.
patch
83 "${FILESDIR}"/${PN}-1.89
.0-python-exclude-broken-tests.
patch
84 "${FILESDIR}"/${PN}-1.89
.0-unordered-no-tbb.
patch
85 "${FILESDIR}"/${PN}-1.90
.0-cobalt.
patch
86 "${FILESDIR}"/${PN}-1.90
.0-msm-std.
patch
87 "${FILESDIR}"/${PN}-1.90
.0-unsigned-char-EOF.
patch
88 "${FILESDIR}"/${PN}-1.91
.0-spirit-test.
patch
89 "${FILESDIR}"/${PN}-1.91
.0-uninitialised-buffer.
patch
90 "${FILESDIR}"/${PN}-1.91
.0-wave-test-cfg.
patch
93 create_user
-config.jam
() {
94 local user_config_jam
="${BUILD_DIR}"/user
-config.jam
95 if [[ -s ${user_config_jam} ]]; then
96 einfo
"${user_config_jam} already exists, skipping configuration"
99 einfo
"Creating configuration in ${user_config_jam}"
102 local compiler compiler_version compiler_executable
="$(tc-getCXX)"
104 compiler_version
="$(gcc-version)"
107 local mpi_configuration
="using mpi ;"
110 cat > "${user_config_jam}" <<- __EOF__ || die
111 using ${compiler} : ${compiler_version} : ${compiler_executable} : <cflags>"${CPPFLAGS} ${CFLAGS}" <cxxflags>"${CPPFLAGS} ${CXXFLAGS}" <linkflags>"${LDFLAGS}" <archiver>"$(tc-getAR)" <ranlib>"$(tc-getRANLIB)" ;
115 if multilib_native_use python
; then
116 append_to_user_config
() {
118 if tc
-is-cross-compiler; then
119 py_config
="using python : ${EPYTHON#python} : : ${ESYSROOT}/usr/include/${EPYTHON} : ${ESYSROOT}/usr/$(get_libdir) ;"
121 py_config
="using python : ${EPYTHON#python} : ${PYTHON} : $(python_get_includedir) ;"
123 echo "${py_config}" >> "${user_config_jam}" || die
125 python_foreach_impl append_to_user_config
128 if multilib_native_use python
&& use numpy
; then
129 einfo
"Enabling support for NumPy extensions in Boost.Python"
131 einfo
"Disabling support for NumPy extensions in Boost.Python"
133 # Boost.Build does not allow for disabling of numpy
134 # extensions, thereby leading to automagic numpy
135 # https://github.com/boostorg/python/issues/111#issuecomment-280447482
137 -e 's/\[ unless \[ python\.numpy \] : <build>no \]/<build>no/g' \
138 -i "${BUILD_DIR}"/libs
/python
/build
/Jamfile
|| die
143 # Bail out on unsupported build configuration, bug #456792
144 if [[ -f "${EROOT}"/etc
/site
-config.jam
]]; then
145 if ! grep -q 'gentoo\(debug\|release\)' "${EROOT}"/etc
/site
-config.jam
; then
146 eerror
"You are using custom ${EROOT}/etc/site-config.jam without defined gentoorelease/gentoodebug targets."
147 eerror
"Boost can not be built in such configuration."
148 eerror
"Please, either remove this file or add targets from ${EROOT}/usr/share/boost-build/site-config.jam to it."
149 die
"Unsupported target in ${EROOT}/etc/site-config.jam"
156 multilib_copy_sources
160 create_user
-config.jam
162 local b2_opts
=( "--user-config=${BUILD_DIR}/user-config.jam" )
163 if multilib_native_use python
; then
164 append_to_b2_opts
() {
165 b2_opts
+=( python
="${EPYTHON#python}" )
167 python_foreach_impl append_to_b2_opts
169 b2_opts
+=( --without-python )
173 echo b2
"${b2_opts[@]}" >&2
179 # https://bugs.gentoo.org/943975
180 # https://github.com/boostorg/quickbook/issues/27
181 # https://github.com/boostorg/spirit/issues/800
184 # https://bugs.gentoo.org/956660
185 # https://github.com/boostorg/smart_ptr/issues/121
186 # https://github.com/boostorg/thread/issues/415
191 # Workaround for too many parallel processes requested, bug #506064
192 [[ "$(makeopts_jobs)" -gt 64 ]] && MAKEOPTS
="${MAKEOPTS} -j64"
194 # We don't want to end up with -L/usr/lib on our linker lines
195 # which then gives us lots of
196 # skipping incompatible /usr/lib/libc.a when searching for -lc
198 [[ -n ${ESYSROOT} ]] && local icuarg
="-sICU_PATH=${ESYSROOT}/usr"
201 $(usex debug gentoodebug gentoorelease)
206 $(usex icu "${icuarg}" '--disable-icu boost.locale.icu=off')
207 $(usev !mpi --without-mpi)
208 $(usev !nls --without-locale)
209 $(usev !context '--without-context --without-coroutine --without-fiber')
210 $(usev !stacktrace --without-stacktrace)
211 --boost-build="${BROOT}"/usr
/share
/b
2/src
213 # building with threading=single is currently not possible
214 # https://svn.boost.org/trac/boost/ticket/7105
217 # this seems to be the only way to disable compression algorithms
218 # https://www.boost.org/doc/libs/1_70_0/libs/iostreams/doc/installation.html#boost-build
219 -sNO_BZIP2=$(usex bzip2 0 1)
220 -sNO_LZMA=$(usex lzma 0 1)
221 -sNO_ZLIB=$(usex zlib 0 1)
222 -sNO_ZSTD=$(usex zstd 0 1)
223 boost.stacktrace.from_exception
=off
226 if [[ ${CHOST} == *-darwin* ]]; then
227 # We need to add the prefix, and in two cases this exceeds, so prepare
228 # for the largest possible space allocation.
229 append
-ldflags -Wl,-headerpad_max_install_names
232 # Use C++17 globally as of 1.80
234 append
-cxxflags -std=c
++17 -fPIC
236 if [[ ${CHOST} != *-darwin* ]]; then
237 # On modern macOS, file I/O is already 64-bit by default,
238 # there's no support for special options like O_LARGEFILE.
239 # Thus, LFS must be disabled.
241 # On other systems, we need to enable LFS explicitly for 64-bit
242 # offsets on 32-bit hosts (#894564)
247 multilib_src_compile
() {
249 --prefix="${EPREFIX}"/usr \
250 "${OPTIONS[@]}" || die
253 multilib_src_test
() {
258 # The following libraries do not compile or fail their tests:
259 local libs_excluded
=(
260 # it seems tests are no longer built
262 # test output comparison failure
264 # undefined reference to `boost::math::concepts::real_concept boost::math::bernoulli_b2n<boost::math::concepts::real_concept>(int)
266 # In function 'PyObject* boost::parameter::python::aux::unspecified_type()':
267 # /usr/include/python3.13/object.h:339:30: error: lvalue required as left operand of assignment
268 # #define Py_TYPE(ob) Py_TYPE(_PyObject_CAST(ob))
269 # ~~~~~~~^~~~~~~~~~~~~~~~~~~~
271 # scope/lambda_tests22.cpp(27): test 'x == 1' failed in function 'int main()'
273 # vec_access.hpp:95:223: error: static assertion failed: Boost QVM static assertion failure
275 # In function 'void boost::redis::detail::update_sentinel_list(std::vector<boost::redis::address>&,
276 # std::size_t, boost::span<const boost::redis::address>, boost::span<const boost::redis::address>)':
277 # boost/redis/impl/sentinel_utils.hpp:269:20: error: no matching function for call to
278 # 'find(std::vector<boost::redis::address>::iterator, std::vector<boost::redis::address>::iterator,
279 # const boost::redis::address&)'
281 # Processing file ../boost_1_89_0/libs/regex/example/../include/boost/regex/v5/regex_iterator.hpp
282 # terminate called after throwing an instance of 'std::length_error'
283 # what(): basic_string::_M_create
284 # https://github.com/boostorg/regex/issues/274
286 # in function `boost::archive::tmpnam(char*)': test_array.cpp:(.text+0x108):
287 # undefined reference to `boost::filesystem::detail::unique_path(...)'
289 # TuTestMain.cpp(22) fatal error: in "test_main_caller( argc_ argv )":
290 # std::runtime_error: Event was not consumed!
295 # graph_parallel tries to use MPI even with use=-mpi
296 local no_mpi
=( "mpi" "graph_parallel" )
297 einfo
"Disabling tests due to USE=-mpi: ${no_mpi[@]}"
298 libs_excluded
+=( ${no_mpi[@]} )
301 if ! use
test-full; then
302 # passes its tests but takes a very long time to build
303 local no_full
=( "geometry" "multiprecision" )
304 einfo
"Disabling expensive tests due to USE=-test-full: ${no_full[@]}"
305 libs_excluded
+=( ${no_full[@]} )
308 einfo
"Skipping the following tests: ${libs_excluded[@]}"
311 ## Find and run tests
314 # Prepare to find libraries but without exclusions
315 local excluded findlibs
="find ${BUILD_DIR}/libs -maxdepth 1 -mindepth 1 -type d "
316 for excluded
in ${libs_excluded[@]}; do
317 findlibs
+="-not -name ${excluded} "
320 # Must come as last argument
323 # Collect libraries to test, with full path.
324 # The list is then sorted to provide predictable execution order,
325 # which would otherwise depend on the file system.
327 readarray
-td '' libs
< <(${findlibs})
328 readarray
-td '' libs
< <(printf '%s\0' "${libs[@]}" | sort -z)
330 # Build the list of test names we are about to run
332 for lib
in ${libs[@]}; do
333 lib_names
+=("${lib##*/}")
336 # Create custom options for tests based on the build settings
337 TEST_OPTIONS
=("${OPTIONS[@]}")
339 # Dial down log output - the full b2 command used to compile & run
340 # a test suite will be printed by ejam and can be used to build
341 # and run the tests in a test suite's directory.
342 TEST_OPTIONS
=("${TEST_OPTIONS[@]/-d+2/-d0}")
344 # Finally build & run all test suites
345 einfo
"Running the following tests: ${lib_names[*]}"
347 local failed_tests
=()
348 for lib
in "${libs[@]}"; do
349 # Skip libraries without test directory
350 [[ ! -d "${lib}/test" ]] && continue
352 # Move into library test dir & run all tests
353 pushd "${lib}/test" >/dev
/null
|| die
354 nonfatal edob
-m "Running tests in: $(pwd)" ejam
--prefix="${EPREFIX}"/usr
"${TEST_OPTIONS[@]}" || failed_tests
+=( "${lib}" )
355 popd >/dev
/null
|| die
358 if (( ${#failed_tests[@]} )); then
359 eerror
"Failed tests. Printing summary."
361 for failed_test
in "${failed_tests[@]}" ; do
362 eerror
"Failed test: ${failed_test}"
368 multilib_src_install
() {
370 --prefix="${ED}"/usr \
371 --includedir="${ED}"/usr
/include \
372 --libdir="${ED}"/usr
/$(get_libdir) \
373 "${OPTIONS[@]}" install || die
"Installation of Boost libraries failed"
376 multilib_src_install_all
() {
377 rm -r "${ED}"/usr
/include
/boost
|| die
378 find "${ED}"/usr
/$(get_libdir)/cmake
-type f
! -name "*static*" -delete || die
381 for dlib
in /usr
/lib
64/libboost_regex.a
/usr
/lib
64/libboost_exception.a
/usr
/lib
64/libboost_test_exec_monitor.a
; do
382 rm "${ED}${dlib}" || die
388 move_mpi_py_into_sitedir
() {
389 python_moduleinto boost
391 python_domodule
"${ED}"/usr
/$(get_libdir)/boost
-${EPYTHON}/mpi.so
392 rm -r "${ED}"/usr
/$(get_libdir)/boost
-${EPYTHON} || die
396 python_foreach_impl move_mpi_py_into_sitedir
404 # Yay for having symlinks that are nigh-impossible to remove without
405 # resorting to dirty hacks like these. Removes lingering symlinks
406 # from the slotted versions.
408 for symlink
in "${EROOT}"/usr
/share
/boostbook
; do
409 if [[ -L ${symlink} ]]; then
410 rm -f "${symlink}" || die
416 elog
"Boost.Regex is *extremely* ABI sensitive. If you get errors such as"
418 elog
" undefined reference to \`boost::re_detail_$(ver_cut 1)0$(ver_cut 2)00::cpp_regex_traits_implementation"
419 elog
" <char>::transform_primary[abi:cxx11](char const*, char const*) const'"
421 elog
"Then you need to recompile Boost and all its reverse dependencies"
422 elog
"using the same toolchain. In general, *every* change of the C++ toolchain"
423 elog
"requires a complete rebuild of the Boost-dependent ecosystem."
425 elog
"See for instance https://bugs.gentoo.org/638138"