1 |
commit: b9ebc9717b4378c3bc28b82dfe4cfc268de4d4e3 |
2 |
Author: Sam James <sam <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Jan 30 04:39:00 2023 +0000 |
4 |
Commit: Sam James <sam <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Jan 30 04:39:00 2023 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b9ebc971 |
7 |
|
8 |
dev-cpp/nlohmann_json: (partially) fix build w/ gcc 13 |
9 |
|
10 |
Signed-off-by: Sam James <sam <AT> gentoo.org> |
11 |
|
12 |
.../files/nlohmann_json-3.11.2-gcc13.patch | 76 ++++++++++++++++++++++ |
13 |
.../nlohmann_json/nlohmann_json-3.11.2-r1.ebuild | 69 ++++++++++++++++++++ |
14 |
2 files changed, 145 insertions(+) |
15 |
|
16 |
diff --git a/dev-cpp/nlohmann_json/files/nlohmann_json-3.11.2-gcc13.patch b/dev-cpp/nlohmann_json/files/nlohmann_json-3.11.2-gcc13.patch |
17 |
new file mode 100644 |
18 |
index 000000000000..5205e67a3c2c |
19 |
--- /dev/null |
20 |
+++ b/dev-cpp/nlohmann_json/files/nlohmann_json-3.11.2-gcc13.patch |
21 |
@@ -0,0 +1,76 @@ |
22 |
+https://github.com/nlohmann/json/issues/3927 |
23 |
+https://github.com/nlohmann/json/pull/3895 |
24 |
+ |
25 |
+From a5b09d50b786638ed9deb09ef13860a3cb64eb6b Mon Sep 17 00:00:00 2001 |
26 |
+From: Sergei Trofimovich <slyich@×××××.com> |
27 |
+Date: Tue, 20 Dec 2022 22:08:12 +0000 |
28 |
+Subject: [PATCH] custom allocators: define missing 'rebind' type |
29 |
+ |
30 |
+`gcc-13` added an assert to standard headers to make sure custom |
31 |
+allocators have intended implementation of rebind type instead |
32 |
+of inherited rebind. gcc change: |
33 |
+ https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=64c986b49558a7 |
34 |
+ |
35 |
+Without the fix build fails on this week's `gcc-13` as: |
36 |
+ |
37 |
+ In file included from <<NIX>>-gcc-13.0.0/include/c++/13.0.0/ext/alloc_traits.h:34, |
38 |
+ from <<NIX>>-gcc-13.0.0/include/c++/13.0.0/bits/basic_string.h:39, |
39 |
+ from <<NIX>>-gcc-13.0.0/include/c++/13.0.0/string:54, |
40 |
+ from <<NIX>>-gcc-13.0.0/include/c++/13.0.0/bits/locale_classes.h:40, |
41 |
+ from <<NIX>>-gcc-13.0.0/include/c++/13.0.0/locale:41, |
42 |
+ from tests/src/unit-regression2.cpp:19: |
43 |
+ <<NIX>>-gcc-13.0.0/include/c++/13.0.0/bits/alloc_traits.h: In instantiation of 'struct std::__allocator_traits_base::__rebind<my_allocator<unsigned char>, unsigned char, void>': |
44 |
+ <<NIX>>-gcc-13.0.0/include/c++/13.0.0/bits/alloc_traits.h:94:11: required by substitution of 'template<class _Alloc, class _Up> using std::__alloc_rebind = typename std::__allocator_traits_base::__rebind<_Alloc, _Up>::type [with _Alloc = my_allocator<unsigned char>; _Up = unsigned char]' |
45 |
+ <<NIX>>-gcc-13.0.0/include/c++/13.0.0/bits/alloc_traits.h:228:8: required by substitution of 'template<class _Alloc> template<class _Tp> using std::allocator_traits< <template-parameter-1-1> >::rebind_alloc = std::__alloc_rebind<_Alloc, _Tp> [with _Tp = unsigned char; _Alloc = my_allocator<unsigned char>]' |
46 |
+ <<NIX>>-gcc-13.0.0/include/c++/13.0.0/ext/alloc_traits.h:126:65: required from 'struct __gnu_cxx::__alloc_traits<my_allocator<unsigned char>, unsigned char>::rebind<unsigned char>' |
47 |
+ <<NIX>>-gcc-13.0.0/include/c++/13.0.0/bits/stl_vector.h:88:21: required from 'struct std::_Vector_base<unsigned char, my_allocator<unsigned char> >' |
48 |
+ <<NIX>>-gcc-13.0.0/include/c++/13.0.0/bits/stl_vector.h:423:11: required from 'class std::vector<unsigned char, my_allocator<unsigned char> >' |
49 |
+ tests/src/unit-regression2.cpp:807:63: required from here |
50 |
+ <<NIX>>-gcc-13.0.0/include/c++/13.0.0/bits/alloc_traits.h:70:31: error: static assertion failed: allocator_traits<A>::rebind_alloc<A::value_type> must be A |
51 |
+ 70 | _Tp>::value, |
52 |
+ | ^~~~~ |
53 |
+ |
54 |
+The change adds trivial `rebind` definition with expected return type |
55 |
+and satisfies conversion requirements. |
56 |
+--- a/tests/src/unit-allocator.cpp |
57 |
++++ b/tests/src/unit-allocator.cpp |
58 |
+@@ -20,11 +20,20 @@ struct bad_allocator : std::allocator<T> |
59 |
+ { |
60 |
+ using std::allocator<T>::allocator; |
61 |
+ |
62 |
++ bad_allocator() = default; |
63 |
++ template<class U> bad_allocator(const bad_allocator<U>& /*unused*/) { } |
64 |
++ |
65 |
+ template<class... Args> |
66 |
+ void construct(T* /*unused*/, Args&& ... /*unused*/) |
67 |
+ { |
68 |
+ throw std::bad_alloc(); |
69 |
+ } |
70 |
++ |
71 |
++ template <class U> |
72 |
++ struct rebind |
73 |
++ { |
74 |
++ using other = bad_allocator<U>; |
75 |
++ }; |
76 |
+ }; |
77 |
+ } // namespace |
78 |
+ |
79 |
+--- a/tests/src/unit-regression2.cpp |
80 |
++++ b/tests/src/unit-regression2.cpp |
81 |
+@@ -187,6 +187,15 @@ class my_allocator : public std::allocator<T> |
82 |
+ { |
83 |
+ public: |
84 |
+ using std::allocator<T>::allocator; |
85 |
++ |
86 |
++ my_allocator() = default; |
87 |
++ template<class U> my_allocator(const my_allocator<U>& /*unused*/) { } |
88 |
++ |
89 |
++ template <class U> |
90 |
++ struct rebind |
91 |
++ { |
92 |
++ using other = my_allocator<U>; |
93 |
++ }; |
94 |
+ }; |
95 |
+ |
96 |
+ ///////////////////////////////////////////////////////////////////// |
97 |
+ |
98 |
|
99 |
diff --git a/dev-cpp/nlohmann_json/nlohmann_json-3.11.2-r1.ebuild b/dev-cpp/nlohmann_json/nlohmann_json-3.11.2-r1.ebuild |
100 |
new file mode 100644 |
101 |
index 000000000000..a3d79580696a |
102 |
--- /dev/null |
103 |
+++ b/dev-cpp/nlohmann_json/nlohmann_json-3.11.2-r1.ebuild |
104 |
@@ -0,0 +1,69 @@ |
105 |
+# Copyright 1999-2023 Gentoo Authors |
106 |
+# Distributed under the terms of the GNU General Public License v2 |
107 |
+ |
108 |
+EAPI=8 |
109 |
+ |
110 |
+#DOCS_BUILDER="mkdocs" |
111 |
+# Needs unpackaged plantuml-markdown too |
112 |
+# ... but plantuml (Python bindings anyway) need network access to generate bits at runtime. |
113 |
+#DOCS_DEPEND="dev-python/mkdocs-material-extensions dev-python/mkdocs-minify-plugin" |
114 |
+#DOCS_DIR="doc/mkdocs" |
115 |
+inherit cmake |
116 |
+ |
117 |
+# Check https://github.com/nlohmann/json/blob/develop/cmake/download_test_data.cmake to find test archive version |
118 |
+TEST_VERSION="3.1.0" |
119 |
+DESCRIPTION="JSON for Modern C++" |
120 |
+HOMEPAGE="https://github.com/nlohmann/json https://nlohmann.github.io/json/" |
121 |
+SRC_URI=" |
122 |
+ https://github.com/nlohmann/json/archive/v${PV}.tar.gz -> ${P}.tar.gz |
123 |
+ test? ( https://github.com/nlohmann/json_test_data/archive/v${TEST_VERSION}.tar.gz -> ${PN}-testdata-${TEST_VERSION}.tar.gz )" |
124 |
+S="${WORKDIR}/json-${PV}" |
125 |
+ |
126 |
+LICENSE="MIT" |
127 |
+SLOT="0" |
128 |
+KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~riscv ~x86" |
129 |
+IUSE="test" |
130 |
+RESTRICT="!test? ( test )" |
131 |
+ |
132 |
+DOCS=( ChangeLog.md README.md ) |
133 |
+ |
134 |
+PATCHES=( |
135 |
+ "${FILESDIR}"/${PN}-3.11.2-gcc13.patch |
136 |
+) |
137 |
+ |
138 |
+src_prepare() { |
139 |
+ if use test ; then |
140 |
+ ln -s "${WORKDIR}"/json_test_data-${TEST_VERSION} "${S}"/json_test_data || die |
141 |
+ fi |
142 |
+ |
143 |
+ cmake_src_prepare |
144 |
+} |
145 |
+ |
146 |
+src_configure() { |
147 |
+ # Tests are built by default so we can't group the test logic below |
148 |
+ local mycmakeargs=( |
149 |
+ -DJSON_MultipleHeaders=ON |
150 |
+ -DJSON_BuildTests=$(usex test) |
151 |
+ ) |
152 |
+ |
153 |
+ # Define test data directory here to avoid unused var QA warning, bug #747826 |
154 |
+ use test && mycmakeargs+=( -DJSON_TestDataDirectory="${S}"/json_test_data ) |
155 |
+ |
156 |
+ cmake_src_configure |
157 |
+} |
158 |
+ |
159 |
+src_test() { |
160 |
+ cd "${BUILD_DIR}"/tests || die |
161 |
+ |
162 |
+ # git_required: |
163 |
+ # Skip certain tests needing git per upstream |
164 |
+ # https://github.com/nlohmann/json/issues/2189 |
165 |
+ # |
166 |
+ # cmake_fetch_content_configure, cmake_fetch_content2_configure: |
167 |
+ # Needs network (bug #865027, bug #865105) |
168 |
+ local myctestargs=( |
169 |
+ -E "(git_required|cmake_fetch_content_configure|cmake_fetch_content2_configure|cmake_fetch_content_build|cmake_fetch_content2_build)" |
170 |
+ ) |
171 |
+ |
172 |
+ cmake_src_test |
173 |
+} |