543831c570dde525a822be7c70b755f8da5b9796
[nodoc-overlay.git] / dev-libs / boost-static / boost-static-1.90.0-r2.ebuild
1 # Copyright 1999-2026 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=8
5
6 # Keep an eye on releases: https://www.boost.org/releases/
7
8 PYTHON_COMPAT=( python3_{11..14} )
9
10 inherit dot-a edo flag-o-matic multiprocessing python-r1 toolchain-funcs multilib-minimal
11
12 MY_PV="$(ver_rs 1- _)"
13
14 DESCRIPTION="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}"
18
19 LICENSE="Boost-1.0"
20 SLOT="0/${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"
23 REQUIRED_USE="
24 python? ( ${PYTHON_REQUIRED_USE} )
25 test-full? ( test )
26 "
27 RESTRICT="!test? ( test )"
28
29 RDEPEND="
30 dev-libs/boost[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] )
39 bzip2? (
40 dev-libs/boost[bzip2]
41 app-arch/bzip2:=[${MULTILIB_USEDEP}]
42 )
43 icu? (
44 dev-libs/boost[icu]
45 dev-libs/icu:=[${MULTILIB_USEDEP}]
46 )
47 !icu? ( virtual/libiconv[${MULTILIB_USEDEP}] )
48 lzma? (
49 dev-libs/boost[lzma]
50 app-arch/xz-utils:=[${MULTILIB_USEDEP}]
51 )
52 mpi? (
53 dev-libs/boost[mpi]
54 virtual/mpi[${MULTILIB_USEDEP},threads]
55 )
56 python? (
57 dev-libs/boost[python]
58 ${PYTHON_DEPS}
59 numpy? ( dev-python/numpy:=[${PYTHON_USEDEP}] )
60 )
61 zlib? (
62 dev-libs/boost[zlib]
63 virtual/zlib:=[${MULTILIB_USEDEP}]
64 )
65 zstd? (
66 dev-libs/boost[zstd]
67 app-arch/zstd:=[${MULTILIB_USEDEP}]
68 )"
69 DEPEND="${RDEPEND}"
70 BDEPEND=">=dev-build/b2-5.1.0"
71
72 PATCHES=(
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-algorithm-reverse_copy.patch
76 "${FILESDIR}"/${PN}-1.88.0-beast-network-sandbox.patch
77 "${FILESDIR}"/${PN}-1.88.0-bind-no-Werror.patch
78 "${FILESDIR}"/${PN}-1.88.0-range-any_iterator.patch
79 "${FILESDIR}"/${PN}-1.88.0-system-crashing-test.patch
80 "${FILESDIR}"/${PN}-1.88.0-yap-cstdint.patch
81 # https://github.com/boostorg/dll/issues/108
82 "${FILESDIR}"/${PN}-1.89.0-dll-no-lto.patch
83 "${FILESDIR}"/${PN}-1.89.0-graph-remove-system-dependency.patch
84 "${FILESDIR}"/${PN}-1.89.0-predef-include-path.patch
85 "${FILESDIR}"/${PN}-1.89.0-python-exclude-broken-tests.patch
86 "${FILESDIR}"/${PN}-1.89.0-unordered-no-tbb.patch
87 "${FILESDIR}"/${PN}-1.90.0-cobalt.patch
88 "${FILESDIR}"/${PN}-1.90.0-msm-std.patch
89 "${FILESDIR}"/${PN}-1.90.0-unsigned-char-EOF.patch
90 )
91
92 create_user-config.jam() {
93 local user_config_jam="${BUILD_DIR}"/user-config.jam
94 if [[ -s ${user_config_jam} ]]; then
95 einfo "${user_config_jam} already exists, skipping configuration"
96 return
97 else
98 einfo "Creating configuration in ${user_config_jam}"
99 fi
100
101 local compiler compiler_version compiler_executable="$(tc-getCXX)"
102 compiler="gcc"
103 compiler_version="$(gcc-version)"
104
105 if use mpi; then
106 local mpi_configuration="using mpi ;"
107 fi
108
109 cat > "${user_config_jam}" <<- __EOF__ || die
110 using ${compiler} : ${compiler_version} : ${compiler_executable} : <cflags>"${CPPFLAGS} ${CFLAGS}" <cxxflags>"${CPPFLAGS} ${CXXFLAGS}" <linkflags>"${LDFLAGS}" <archiver>"$(tc-getAR)" <ranlib>"$(tc-getRANLIB)" ;
111 ${mpi_configuration}
112 __EOF__
113
114 if multilib_native_use python; then
115 append_to_user_config() {
116 local py_config
117 if tc-is-cross-compiler; then
118 py_config="using python : ${EPYTHON#python} : : ${ESYSROOT}/usr/include/${EPYTHON} : ${ESYSROOT}/usr/$(get_libdir) ;"
119 else
120 py_config="using python : ${EPYTHON#python} : ${PYTHON} : $(python_get_includedir) ;"
121 fi
122 echo "${py_config}" >> "${user_config_jam}" || die
123 }
124 python_foreach_impl append_to_user_config
125 fi
126
127 if multilib_native_use python && use numpy; then
128 einfo "Enabling support for NumPy extensions in Boost.Python"
129 else
130 einfo "Disabling support for NumPy extensions in Boost.Python"
131
132 # Boost.Build does not allow for disabling of numpy
133 # extensions, thereby leading to automagic numpy
134 # https://github.com/boostorg/python/issues/111#issuecomment-280447482
135 sed \
136 -e 's/\[ unless \[ python\.numpy \] : <build>no \]/<build>no/g' \
137 -i "${BUILD_DIR}"/libs/python/build/Jamfile || die
138 fi
139 }
140
141 pkg_setup() {
142 # Bail out on unsupported build configuration, bug #456792
143 if [[ -f "${EROOT}"/etc/site-config.jam ]]; then
144 if ! grep -q 'gentoo\(debug\|release\)' "${EROOT}"/etc/site-config.jam; then
145 eerror "You are using custom ${EROOT}/etc/site-config.jam without defined gentoorelease/gentoodebug targets."
146 eerror "Boost can not be built in such configuration."
147 eerror "Please, either remove this file or add targets from ${EROOT}/usr/share/boost-build/site-config.jam to it."
148 die "Unsupported target in ${EROOT}/etc/site-config.jam"
149 fi
150 fi
151 }
152
153 src_prepare() {
154 default
155 multilib_copy_sources
156 }
157
158 ejam() {
159 create_user-config.jam
160
161 local b2_opts=( "--user-config=${BUILD_DIR}/user-config.jam" )
162 if multilib_native_use python; then
163 append_to_b2_opts() {
164 b2_opts+=( python="${EPYTHON#python}" )
165 }
166 python_foreach_impl append_to_b2_opts
167 else
168 b2_opts+=( --without-python )
169 fi
170 b2_opts+=( "$@" )
171
172 echo b2 "${b2_opts[@]}" >&2
173 b2 "${b2_opts[@]}"
174 }
175
176 src_configure() {
177 # -Werror=odr
178 # https://bugs.gentoo.org/943975
179 # https://github.com/boostorg/quickbook/issues/27
180 # https://github.com/boostorg/spirit/issues/800
181 #
182 # Tests also fail:
183 # https://bugs.gentoo.org/956660
184 # https://github.com/boostorg/smart_ptr/issues/121
185 # https://github.com/boostorg/thread/issues/415
186 filter-lto
187
188 lto-guarantee-fat
189
190 # Workaround for too many parallel processes requested, bug #506064
191 [[ "$(makeopts_jobs)" -gt 64 ]] && MAKEOPTS="${MAKEOPTS} -j64"
192
193 # We don't want to end up with -L/usr/lib on our linker lines
194 # which then gives us lots of
195 # skipping incompatible /usr/lib/libc.a when searching for -lc
196 # warnings
197 [[ -n ${ESYSROOT} ]] && local icuarg="-sICU_PATH=${ESYSROOT}/usr"
198
199 OPTIONS=(
200 $(usex debug gentoodebug gentoorelease)
201 "-j$(makeopts_jobs)"
202 -q
203 -d+2
204 pch=off
205 $(usex icu "${icuarg}" '--disable-icu boost.locale.icu=off')
206 $(usev !mpi --without-mpi)
207 $(usev !nls --without-locale)
208 $(usev !context '--without-context --without-coroutine --without-fiber')
209 $(usev !stacktrace --without-stacktrace)
210 --boost-build="${BROOT}"/usr/share/b2/src
211 --layout=system
212 # building with threading=single is currently not possible
213 # https://svn.boost.org/trac/boost/ticket/7105
214 threading=multi
215 link=static
216 # this seems to be the only way to disable compression algorithms
217 # https://www.boost.org/doc/libs/1_70_0/libs/iostreams/doc/installation.html#boost-build
218 -sNO_BZIP2=$(usex bzip2 0 1)
219 -sNO_LZMA=$(usex lzma 0 1)
220 -sNO_ZLIB=$(usex zlib 0 1)
221 -sNO_ZSTD=$(usex zstd 0 1)
222 boost.stacktrace.from_exception=off
223 )
224
225 if [[ ${CHOST} == *-darwin* ]]; then
226 # We need to add the prefix, and in two cases this exceeds, so prepare
227 # for the largest possible space allocation.
228 append-ldflags -Wl,-headerpad_max_install_names
229 fi
230
231 # Use C++17 globally as of 1.80
232 append-cxxflags -std=c++17
233
234 if [[ ${CHOST} != *-darwin* ]]; then
235 # On modern macOS, file I/O is already 64-bit by default,
236 # there's no support for special options like O_LARGEFILE.
237 # Thus, LFS must be disabled.
238 #
239 # On other systems, we need to enable LFS explicitly for 64-bit
240 # offsets on 32-bit hosts (#894564)
241 append-lfs-flags
242 fi
243 }
244
245 multilib_src_compile() {
246 ejam \
247 --prefix="${EPREFIX}"/usr \
248 "${OPTIONS[@]}" || die
249 }
250
251 multilib_src_test() {
252 ##
253 ## Test exclusions
254 ##
255
256 # The following libraries do not compile or fail their tests:
257 local libs_excluded=(
258 # it seems tests are no longer built
259 "callable_traits"
260 # test output comparison failure
261 "config"
262 # undefined reference to `boost::math::concepts::real_concept boost::math::bernoulli_b2n<boost::math::concepts::real_concept>(int)
263 "math"
264 # In function 'PyObject* boost::parameter::python::aux::unspecified_type()':
265 # /usr/include/python3.13/object.h:339:30: error: lvalue required as left operand of assignment
266 # #define Py_TYPE(ob) Py_TYPE(_PyObject_CAST(ob))
267 # ~~~~~~~^~~~~~~~~~~~~~~~~~~~
268 "parameter_python"
269 # scope/lambda_tests22.cpp(27): test 'x == 1' failed in function 'int main()'
270 "phoenix"
271 # vec_access.hpp:95:223: error: static assertion failed: Boost QVM static assertion failure
272 "qvm"
273 # Processing file ../boost_1_89_0/libs/regex/example/../include/boost/regex/v5/regex_iterator.hpp
274 # terminate called after throwing an instance of 'std::length_error'
275 # what(): basic_string::_M_create
276 "regex"
277 # in function `boost::archive::tmpnam(char*)': test_array.cpp:(.text+0x108):
278 # undefined reference to `boost::filesystem::detail::unique_path(...)'
279 "serialization"
280 # TuTestMain.cpp(22) fatal error: in "test_main_caller( argc_ argv )":
281 # std::runtime_error: Event was not consumed!
282 "statechart"
283 # t_5_007.cpp(22): error: could not find include file: boost/version.hpp
284 "wave"
285 )
286
287 if ! use mpi; then
288 # graph_parallel tries to use MPI even with use=-mpi
289 local no_mpi=( "mpi" "graph_parallel" )
290 einfo "Disabling tests due to USE=-mpi: ${no_mpi[@]}"
291 libs_excluded+=( ${no_mpi[@]} )
292 fi
293
294 if ! use test-full; then
295 # passes its tests but takes a very long time to build
296 local no_full=( "geometry" "multiprecision" )
297 einfo "Disabling expensive tests due to USE=-test-full: ${no_full[@]}"
298 libs_excluded+=( ${no_full[@]} )
299 fi
300
301 einfo "Skipping the following tests: ${libs_excluded[@]}"
302
303 ##
304 ## Find and run tests
305 ##
306
307 # Prepare to find libraries but without exclusions
308 local excluded findlibs="find ${BUILD_DIR}/libs -maxdepth 1 -mindepth 1 -type d "
309 for excluded in ${libs_excluded[@]}; do
310 findlibs+="-not -name ${excluded} "
311 done
312
313 # Must come as last argument
314 findlibs+="-print0"
315
316 # Collect libraries to test, with full path.
317 # The list is then sorted to provide predictable execution order,
318 # which would otherwise depend on the file system.
319 local libs
320 readarray -td '' libs < <(${findlibs})
321 readarray -td '' libs < <(printf '%s\0' "${libs[@]}" | sort -z)
322
323 # Build the list of test names we are about to run
324 local lib_names
325 for lib in ${libs[@]}; do
326 lib_names+=("${lib##*/}")
327 done
328
329 # Create custom options for tests based on the build settings
330 TEST_OPTIONS=("${OPTIONS[@]}")
331
332 # Dial down log output - the full b2 command used to compile & run
333 # a test suite will be printed by ejam and can be used to build
334 # and run the tests in a test suite's directory.
335 TEST_OPTIONS=("${TEST_OPTIONS[@]/-d+2/-d0}")
336
337 # Finally build & run all test suites
338 einfo "Running the following tests: ${lib_names[*]}"
339
340 local failed_tests=()
341 for lib in "${libs[@]}"; do
342 # Skip libraries without test directory
343 [[ ! -d "${lib}/test" ]] && continue
344
345 # Move into library test dir & run all tests
346 pushd "${lib}/test" >/dev/null || die
347 nonfatal edob -m "Running tests in: $(pwd)" ejam --prefix="${EPREFIX}"/usr "${TEST_OPTIONS[@]}" || failed_tests+=( "${lib}" )
348 popd >/dev/null || die
349 done
350
351 if (( ${#failed_tests[@]} )); then
352 eerror "Failed tests. Printing summary."
353 local failed_test
354 for failed_test in "${failed_tests[@]}" ; do
355 eerror "Failed test: ${failed_test}"
356 done
357 die "Tests failed."
358 fi
359 }
360
361 multilib_src_install() {
362 ejam \
363 --prefix="${ED}"/usr \
364 --includedir="${ED}"/usr/include \
365 --libdir="${ED}"/usr/$(get_libdir) \
366 "${OPTIONS[@]}" install || die "Installation of Boost libraries failed"
367
368 # boost's build system truely sucks for not having a destdir. Because for
369 # this reason we are forced to build with a prefix that includes the
370 # DESTROOT, dynamic libraries on Darwin end messed up, referencing the
371 # DESTROOT instread of the actual EPREFIX. There is no way out of here
372 # but to do it the dirty way of manually setting the right install_names.
373 if [[ ${CHOST} == *-darwin* ]]; then
374 einfo "Working around completely broken build-system(tm)"
375 local d
376 for d in "${ED}"/usr/lib/*.dylib; do
377 if [[ -f ${d} ]]; then
378 # fix the "soname"
379 ebegin " correcting install_name of ${d#${ED}}"
380 install_name_tool -id "/${d#${D}}" "${d}"
381 eend $?
382 # fix references to other libs
383 # these paths look like this:
384 # bin.v2/libs/thread/build/gcc-12.1/gentoorelease/pch-off/
385 # threadapi-pthread/threading-multi/visibility-hidden/
386 # libboost_thread.dylib
387 refs=$(otool -XL "${d}" | \
388 sed -e '1d' -e 's/^\t//' | \
389 grep "libboost_" | \
390 cut -f1 -d' ')
391 local r
392 for r in ${refs}; do
393 # strip path prefix from references, so we obtain
394 # something like libboost_thread.dylib.
395 local r_basename=${r##*/}
396
397 ebegin " correcting reference to ${r_basename}"
398 install_name_tool -change \
399 "${r}" \
400 "${EPREFIX}/usr/lib/${r_basename}" \
401 "${d}"
402 eend $?
403 done
404 fi
405 done
406 fi
407 }
408
409 multilib_src_install_all() {
410 rm -r "${ED}"/usr/include/boost || die
411 rm -r "${ED}"/usr/$(get_libdir)/cmake || die
412
413 local dlib
414 for dlib in /usr/lib64/libboost_regex.a /usr/lib64/libboost_exception.a /usr/lib64/libboost_test_exec_monitor.a; do
415 rm "${ED}${dlib}" || die
416 done
417
418
419 if use python; then
420 if use mpi; then
421 move_mpi_py_into_sitedir() {
422 python_moduleinto boost
423
424 python_domodule "${ED}"/usr/$(get_libdir)/boost-${EPYTHON}/mpi.so
425 rm -r "${ED}"/usr/$(get_libdir)/boost-${EPYTHON} || die
426
427 python_optimize
428 }
429 python_foreach_impl move_mpi_py_into_sitedir
430 fi
431 fi
432
433 strip-lto-bytecode
434 }
435
436 pkg_preinst() {
437 # Yay for having symlinks that are nigh-impossible to remove without
438 # resorting to dirty hacks like these. Removes lingering symlinks
439 # from the slotted versions.
440 local symlink
441 for symlink in "${EROOT}"/usr/share/boostbook; do
442 if [[ -L ${symlink} ]]; then
443 rm -f "${symlink}" || die
444 fi
445 done
446 }
447
448 pkg_postinst() {
449 elog "Boost.Regex is *extremely* ABI sensitive. If you get errors such as"
450 elog
451 elog " undefined reference to \`boost::re_detail_$(ver_cut 1)0$(ver_cut 2)00::cpp_regex_traits_implementation"
452 elog " <char>::transform_primary[abi:cxx11](char const*, char const*) const'"
453 elog
454 elog "Then you need to recompile Boost and all its reverse dependencies"
455 elog "using the same toolchain. In general, *every* change of the C++ toolchain"
456 elog "requires a complete rebuild of the Boost-dependent ecosystem."
457 elog
458 elog "See for instance https://bugs.gentoo.org/638138"
459 }