diff options
author | Khem Raj <raj.khem@gmail.com> | 2021-12-01 21:12:01 -0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-12-03 23:37:16 +0000 |
commit | 5c8c4dd925bbb9d29014ffd717ffe69ebb3553e3 (patch) | |
tree | 3bae0569aae36a712817f2005f28e50ec78d57ee /meta/recipes-support/boost | |
parent | 8b99e34fb2d00a611d03bb30b619fe09faf9c21b (diff) | |
download | poky-5c8c4dd925bbb9d29014ffd717ffe69ebb3553e3.tar.gz |
boost: Fix build on arches with no atomics
1.77 is broken on architectures which dont have lockfree atomics e.g.
armv5 [1], backport relevant fixes from upstream to unbreak the build
[1] https://github.com/boostorg/math/issues/673
(From OE-Core rev: 57dc797712abcf83b63694b21d2b3a3f09b1c9bc)
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-support/boost')
3 files changed, 206 insertions, 0 deletions
diff --git a/meta/recipes-support/boost/boost/0002-math-allow-definition-of-boost_math_no_atomic_int-on-the-command-line.patch b/meta/recipes-support/boost/boost/0002-math-allow-definition-of-boost_math_no_atomic_int-on-the-command-line.patch new file mode 100644 index 0000000000..b05b795084 --- /dev/null +++ b/meta/recipes-support/boost/boost/0002-math-allow-definition-of-boost_math_no_atomic_int-on-the-command-line.patch | |||
@@ -0,0 +1,53 @@ | |||
1 | From 32bd6197353f6ea8e5bef01f09e25c944141acfc Mon Sep 17 00:00:00 2001 | ||
2 | From: jzmaddock <john@johnmaddock.co.uk> | ||
3 | Date: Wed, 1 Sep 2021 18:54:54 +0100 | ||
4 | Subject: [PATCH] Allow definition of BOOST_MATH_NO_ATOMIC_INT on the command | ||
5 | line. Allows us to test/emulate platforms with no atomic integers. | ||
6 | |||
7 | [buildroot@heine.tech: | ||
8 | - backport from boostorg/math 32bd6197353f6ea8e5bef01f09e25c944141acfc | ||
9 | - alter path to match boost release | ||
10 | ] | ||
11 | Signed-off-by: Michael Nosthoff <buildroot@heine.tech> | ||
12 | --- | ||
13 | Upstream-Status: Backport [https://github.com/boostorg/math/pull/684/commits/32bd6197353f6ea8e5bef01f09e25c944141acfc] | ||
14 | boost/math/tools/atomic.hpp | 10 +++++----- | ||
15 | 1 file changed, 5 insertions(+), 5 deletions(-) | ||
16 | |||
17 | diff --git a/boost/math/tools/atomic.hpp b/boost/math/tools/atomic.hpp | ||
18 | index cc76ed269f..e3cbf5db89 100644 | ||
19 | --- a/boost/math/tools/atomic.hpp | ||
20 | +++ b/boost/math/tools/atomic.hpp | ||
21 | @@ -16,27 +16,27 @@ | ||
22 | namespace boost { | ||
23 | namespace math { | ||
24 | namespace detail { | ||
25 | -#if ATOMIC_INT_LOCK_FREE == 2 | ||
26 | +#if (ATOMIC_INT_LOCK_FREE == 2) && !defined(BOOST_MATH_NO_ATOMIC_INT) | ||
27 | typedef std::atomic<int> atomic_counter_type; | ||
28 | typedef std::atomic<unsigned> atomic_unsigned_type; | ||
29 | typedef int atomic_integer_type; | ||
30 | typedef unsigned atomic_unsigned_integer_type; | ||
31 | -#elif ATOMIC_SHORT_LOCK_FREE == 2 | ||
32 | +#elif (ATOMIC_SHORT_LOCK_FREE == 2) && !defined(BOOST_MATH_NO_ATOMIC_INT) | ||
33 | typedef std::atomic<short> atomic_counter_type; | ||
34 | typedef std::atomic<unsigned short> atomic_unsigned_type; | ||
35 | typedef short atomic_integer_type; | ||
36 | typedef unsigned short atomic_unsigned_type; | ||
37 | -#elif ATOMIC_LONG_LOCK_FREE == 2 | ||
38 | +#elif (ATOMIC_LONG_LOCK_FREE == 2) && !defined(BOOST_MATH_NO_ATOMIC_INT) | ||
39 | typedef std::atomic<long> atomic_unsigned_integer_type; | ||
40 | typedef std::atomic<unsigned long> atomic_unsigned_type; | ||
41 | typedef unsigned long atomic_unsigned_type; | ||
42 | typedef long atomic_integer_type; | ||
43 | -#elif ATOMIC_LLONG_LOCK_FREE == 2 | ||
44 | +#elif (ATOMIC_LLONG_LOCK_FREE == 2) && !defined(BOOST_MATH_NO_ATOMIC_INT) | ||
45 | typedef std::atomic<long long> atomic_unsigned_integer_type; | ||
46 | typedef std::atomic<unsigned long long> atomic_unsigned_type; | ||
47 | typedef long long atomic_integer_type; | ||
48 | typedef unsigned long long atomic_unsigned_integer_type; | ||
49 | -#else | ||
50 | +#elif !defined(BOOST_MATH_NO_ATOMIC_INT) | ||
51 | # define BOOST_MATH_NO_ATOMIC_INT | ||
52 | #endif | ||
53 | } // Namespace detail | ||
diff --git a/meta/recipes-support/boost/boost/0003-math-make-no-atomics-a-soft-failure-in-bernoulli_details_hpp.patch b/meta/recipes-support/boost/boost/0003-math-make-no-atomics-a-soft-failure-in-bernoulli_details_hpp.patch new file mode 100644 index 0000000000..f69e4f21f3 --- /dev/null +++ b/meta/recipes-support/boost/boost/0003-math-make-no-atomics-a-soft-failure-in-bernoulli_details_hpp.patch | |||
@@ -0,0 +1,151 @@ | |||
1 | From 7d482f6ebc356e6ec455ccb5f51a23971bf6ce5b Mon Sep 17 00:00:00 2001 | ||
2 | From: jzmaddock <john@johnmaddock.co.uk> | ||
3 | Date: Wed, 1 Sep 2021 20:31:53 +0100 | ||
4 | Subject: [PATCH] Make no atomics a soft failure in bernoulli_details.hpp. | ||
5 | Include an "escape macro" so thread safety can be disabled if certain | ||
6 | bernoulli features are to be used in a no-atomics environment. Fixes | ||
7 | https://github.com/boostorg/math/issues/673. | ||
8 | |||
9 | [buildroot@heine.tech: | ||
10 | - backport from boostorg/math 7d482f6ebc356e6ec455ccb5f51a23971bf6ce5b | ||
11 | - alter path to match boost release | ||
12 | ] | ||
13 | Signed-off-by: Michael Nosthoff <buildroot@heine.tech> | ||
14 | --- | ||
15 | Upstream-Status: Backport [https://github.com/boostorg/math/pull/684/commits/7d482f6ebc356e6ec455ccb5f51a23971bf6ce5b] | ||
16 | .../detail/bernoulli_details.hpp | 10 +++++++--- | ||
17 | libs/math/test/Jamfile.v2 | 3 +++ | ||
18 | test/compile_test/bernoulli_no_atomic_d.cpp | 14 ++++++++++++++ | ||
19 | test/compile_test/bernoulli_no_atomic_fail.cpp | 15 +++++++++++++++ | ||
20 | test/compile_test/bernoulli_no_atomic_mp.cpp | 16 ++++++++++++++++ | ||
21 | 5 files changed, 55 insertions(+), 3 deletions(-) | ||
22 | create mode 100644 test/compile_test/bernoulli_no_atomic_d.cpp | ||
23 | create mode 100644 test/compile_test/bernoulli_no_atomic_fail.cpp | ||
24 | create mode 100644 test/compile_test/bernoulli_no_atomic_mp.cpp | ||
25 | |||
26 | diff --git a/boost/math/special_functions/detail/bernoulli_details.hpp b/boost/math/special_functions/detail/bernoulli_details.hpp | ||
27 | index cf35545264..8519b7c89c 100644 | ||
28 | --- a/boost/math/special_functions/detail/bernoulli_details.hpp | ||
29 | +++ b/boost/math/special_functions/detail/bernoulli_details.hpp | ||
30 | @@ -360,7 +360,7 @@ class bernoulli_numbers_cache | ||
31 | return out; | ||
32 | } | ||
33 | |||
34 | - #ifndef BOOST_HAS_THREADS | ||
35 | + #if !defined(BOOST_HAS_THREADS) || defined(BOOST_MATH_BERNOULLI_UNTHREADED) | ||
36 | // | ||
37 | // Single threaded code, very simple: | ||
38 | // | ||
39 | @@ -382,6 +382,8 @@ class bernoulli_numbers_cache | ||
40 | *out = (i >= m_overflow_limit) ? policies::raise_overflow_error<T>("boost::math::bernoulli_b2n<%1%>(std::size_t)", 0, T(i), pol) : bn[i]; | ||
41 | ++out; | ||
42 | } | ||
43 | + #elif defined(BOOST_MATH_NO_ATOMIC_INT) | ||
44 | + static_assert(sizeof(T) == 1, "Unsupported configuration: your platform appears to have no atomic integers. If you are happy with thread-unsafe code, then you may define BOOST_MATH_BERNOULLI_UNTHREADED to suppress this error."); | ||
45 | #else | ||
46 | // | ||
47 | // Double-checked locking pattern, lets us access cached already cached values | ||
48 | @@ -464,7 +466,7 @@ class bernoulli_numbers_cache | ||
49 | return out; | ||
50 | } | ||
51 | |||
52 | - #ifndef BOOST_HAS_THREADS | ||
53 | + #if !defined(BOOST_HAS_THREADS) || defined(BOOST_MATH_BERNOULLI_UNTHREADED) | ||
54 | // | ||
55 | // Single threaded code, very simple: | ||
56 | // | ||
57 | @@ -494,6 +496,8 @@ class bernoulli_numbers_cache | ||
58 | } | ||
59 | ++out; | ||
60 | } | ||
61 | + #elif defined(BOOST_MATH_NO_ATOMIC_INT) | ||
62 | + static_assert(sizeof(T) == 1, "Unsupported configuration: your platform appears to have no atomic integers. If you are happy with thread-unsafe code, then you may define BOOST_MATH_BERNOULLI_UNTHREADED to suppress this error."); | ||
63 | #else | ||
64 | // | ||
65 | // Double-checked locking pattern, lets us access cached already cached values | ||
66 | @@ -555,7 +559,7 @@ class bernoulli_numbers_cache | ||
67 | // The value at which we know overflow has already occurred for the Bn: | ||
68 | std::size_t m_overflow_limit; | ||
69 | |||
70 | - #ifdef BOOST_HAS_THREADS | ||
71 | + #if defined(BOOST_HAS_THREADS) && !defined(BOOST_MATH_NO_ATOMIC_INT) | ||
72 | std::mutex m_mutex; | ||
73 | atomic_counter_type m_counter, m_current_precision; | ||
74 | #else | ||
75 | diff --git a/libs/math/test/Jamfile.v2 b/libs/math/test/Jamfile.v2 | ||
76 | index 52fb87f5e5..3ac63f9279 100644 | ||
77 | --- a/libs/math/test/Jamfile.v2 | ||
78 | +++ b/libs/math/test/Jamfile.v2 | ||
79 | @@ -1137,6 +1137,9 @@ test-suite misc : | ||
80 | |||
81 | # [ run __temporary_test.cpp test_instances//test_instances : : : <test-info>always_show_run_output <pch>off ] | ||
82 | [ compile test_no_long_double_policy.cpp ] | ||
83 | + [ compile compile_test/bernoulli_no_atomic_d.cpp ] | ||
84 | + [ compile compile_test/bernoulli_no_atomic_mp.cpp ] | ||
85 | + [ compile-fail compile_test/bernoulli_no_atomic_fail.cpp ] | ||
86 | ; | ||
87 | |||
88 | test-suite interpolators : | ||
89 | diff --git a/test/compile_test/bernoulli_no_atomic_d.cpp b/test/compile_test/bernoulli_no_atomic_d.cpp | ||
90 | new file mode 100644 | ||
91 | index 0000000000..61926f7e1f | ||
92 | --- /dev/null | ||
93 | +++ b/test/compile_test/bernoulli_no_atomic_d.cpp | ||
94 | @@ -0,0 +1,14 @@ | ||
95 | +// (C) Copyright John Maddock 2021. | ||
96 | +// Use, modification and distribution are subject to the | ||
97 | +// Boost Software License, Version 1.0. (See accompanying file | ||
98 | +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
99 | + | ||
100 | +#define BOOST_MATH_NO_ATOMIC_INT | ||
101 | + | ||
102 | +#include <boost/math/special_functions/bernoulli.hpp> | ||
103 | +#include "test_compile_result.hpp" | ||
104 | + | ||
105 | +void compile_and_link_test() | ||
106 | +{ | ||
107 | + check_result<double>(boost::math::bernoulli_b2n<double>(4)); | ||
108 | +} | ||
109 | diff --git a/test/compile_test/bernoulli_no_atomic_fail.cpp b/test/compile_test/bernoulli_no_atomic_fail.cpp | ||
110 | new file mode 100644 | ||
111 | index 0000000000..bbd7152412 | ||
112 | --- /dev/null | ||
113 | +++ b/test/compile_test/bernoulli_no_atomic_fail.cpp | ||
114 | @@ -0,0 +1,15 @@ | ||
115 | +// (C) Copyright John Maddock 2021. | ||
116 | +// Use, modification and distribution are subject to the | ||
117 | +// Boost Software License, Version 1.0. (See accompanying file | ||
118 | +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
119 | + | ||
120 | +#define BOOST_MATH_NO_ATOMIC_INT | ||
121 | + | ||
122 | +#include <boost/math/special_functions/bernoulli.hpp> | ||
123 | +#include <boost/multiprecision/cpp_bin_float.hpp> | ||
124 | +#include "test_compile_result.hpp" | ||
125 | + | ||
126 | +void compile_and_link_test() | ||
127 | +{ | ||
128 | + check_result<boost::multiprecision::cpp_bin_float_50>(boost::math::bernoulli_b2n<boost::multiprecision::cpp_bin_float_50>(4)); | ||
129 | +} | ||
130 | diff --git a/test/compile_test/bernoulli_no_atomic_mp.cpp b/test/compile_test/bernoulli_no_atomic_mp.cpp | ||
131 | new file mode 100644 | ||
132 | index 0000000000..8d5a6e78e6 | ||
133 | --- /dev/null | ||
134 | +++ b/test/compile_test/bernoulli_no_atomic_mp.cpp | ||
135 | @@ -0,0 +1,16 @@ | ||
136 | +// (C) Copyright John Maddock 2021. | ||
137 | +// Use, modification and distribution are subject to the | ||
138 | +// Boost Software License, Version 1.0. (See accompanying file | ||
139 | +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
140 | + | ||
141 | +#define BOOST_MATH_NO_ATOMIC_INT | ||
142 | +#define BOOST_MATH_BERNOULLI_UNTHREADED | ||
143 | + | ||
144 | +#include <boost/math/special_functions/bernoulli.hpp> | ||
145 | +#include <boost/multiprecision/cpp_bin_float.hpp> | ||
146 | +#include "test_compile_result.hpp" | ||
147 | + | ||
148 | +void compile_and_link_test() | ||
149 | +{ | ||
150 | + check_result<boost::multiprecision::cpp_bin_float_50>(boost::math::bernoulli_b2n<boost::multiprecision::cpp_bin_float_50>(4)); | ||
151 | +} | ||
diff --git a/meta/recipes-support/boost/boost_1.77.0.bb b/meta/recipes-support/boost/boost_1.77.0.bb index ba60281950..bde6b14a79 100644 --- a/meta/recipes-support/boost/boost_1.77.0.bb +++ b/meta/recipes-support/boost/boost_1.77.0.bb | |||
@@ -7,4 +7,6 @@ SRC_URI += "file://boost-CVE-2012-2677.patch \ | |||
7 | file://0001-dont-setup-compiler-flags-m32-m64.patch \ | 7 | file://0001-dont-setup-compiler-flags-m32-m64.patch \ |
8 | file://0001-fiber-libs-Define-SYS_futex-if-it-does-not-exist.patch \ | 8 | file://0001-fiber-libs-Define-SYS_futex-if-it-does-not-exist.patch \ |
9 | file://0001-BoostConfig.cmake-allow-searching-for-python310.patch \ | 9 | file://0001-BoostConfig.cmake-allow-searching-for-python310.patch \ |
10 | file://0002-math-allow-definition-of-boost_math_no_atomic_int-on-the-command-line.patch \ | ||
11 | file://0003-math-make-no-atomics-a-soft-failure-in-bernoulli_details_hpp.patch \ | ||
10 | " | 12 | " |