Skip to content

Commit 5bb8c61

Browse files
Fixing patch for the Abseil constexpr bug on gcc-15 (#29)
1 parent 22f669a commit 5bb8c61

File tree

2 files changed

+283
-84
lines changed

2 files changed

+283
-84
lines changed

recipes/abseil/all/conandata.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ patches:
3131
- patch_file: "patches/0001-fix-absl-gcc-ubsan-constexpr-bug.patch"
3232
patch_description: "Gcc ubsan constexpr compilation fix."
3333
patch_type: "bugfix"
34-
patch_source: "https://github.com/abseil/abseil-cpp/commit/60d1ce9911e6b32ea0c5a2fcfc120f9b392d5643"
34+
patch_source: "https://github.com/abseil/abseil-cpp/issues/1634#issuecomment-2576011026"
3535
"20240722.1":
3636
- patch_file: "patches/0003-absl-string-libm-20240116.patch"
3737
patch_description: "link libm to absl string"
Lines changed: 282 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,282 @@
1-
From 60d1ce9911e6b32ea0c5a2fcfc120f9b392d5643 Mon Sep 17 00:00:00 2001
2-
From: Derek Mauro <dmauro@google.com>
3-
Date: Tue, 7 Jan 2025 07:47:25 -0800
4-
Subject: [PATCH] Import of CCTZ from GitHub.
5-
6-
PiperOrigin-RevId: 712908937
7-
Change-Id: Ifdd783bb4415209a7241131feb79460adb360f64
8-
---
9-
absl/time/internal/cctz/BUILD.bazel | 15 ++++++++++++++-
10-
1 file changed, 14 insertions(+), 1 deletion(-)
11-
12-
diff --git a/absl/time/internal/cctz/BUILD.bazel b/absl/time/internal/cctz/BUILD.bazel
13-
index a2d9c336..da30a0f1 100644
14-
--- a/absl/time/internal/cctz/BUILD.bazel
15-
+++ b/absl/time/internal/cctz/BUILD.bazel
16-
@@ -12,6 +12,8 @@
17-
# See the License for the specific language governing permissions and
18-
# limitations under the License.
19-
20-
+load("//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", "ABSL_DEFAULT_LINKOPTS", "ABSL_TEST_COPTS")
21-
+
22-
package(features = [
23-
"header_modules",
24-
"layering_check",
25-
@@ -28,6 +30,8 @@ cc_library(
26-
hdrs = [
27-
"include/cctz/civil_time.h",
28-
],
29-
+ copts = ABSL_DEFAULT_COPTS,
30-
+ linkopts = ABSL_DEFAULT_LINKOPTS,
31-
textual_hdrs = ["include/cctz/civil_time_detail.h"],
32-
visibility = ["//visibility:public"],
33-
deps = ["//absl/base:config"],
34-
@@ -57,7 +61,8 @@ cc_library(
35-
"include/cctz/time_zone.h",
36-
"include/cctz/zone_info_source.h",
37-
],
38-
- linkopts = select({
39-
+ copts = ABSL_DEFAULT_COPTS,
40-
+ linkopts = ABSL_DEFAULT_LINKOPTS + select({
41-
"@platforms//os:osx": ["-Wl,-framework,CoreFoundation"],
42-
"@platforms//os:ios": ["-Wl,-framework,CoreFoundation"],
43-
"//conditions:default": [],
44-
@@ -84,6 +89,8 @@ cc_test(
45-
name = "civil_time_test",
46-
size = "small",
47-
srcs = ["src/civil_time_test.cc"],
48-
+ copts = ABSL_TEST_COPTS,
49-
+ linkopts = ABSL_DEFAULT_LINKOPTS,
50-
deps = [
51-
":civil_time",
52-
"//absl/base:config",
53-
@@ -96,7 +103,9 @@ cc_test(
54-
name = "time_zone_format_test",
55-
size = "small",
56-
srcs = ["src/time_zone_format_test.cc"],
57-
+ copts = ABSL_TEST_COPTS,
58-
data = [":zoneinfo"],
59-
+ linkopts = ABSL_DEFAULT_LINKOPTS,
60-
tags = [
61-
"no_test_android_arm",
62-
"no_test_android_arm64",
63-
@@ -117,7 +126,9 @@ cc_test(
64-
size = "small",
65-
timeout = "moderate",
66-
srcs = ["src/time_zone_lookup_test.cc"],
67-
+ copts = ABSL_TEST_COPTS,
68-
data = [":zoneinfo"],
69-
+ linkopts = ABSL_DEFAULT_LINKOPTS,
70-
tags = [
71-
"no_test_android_arm",
72-
"no_test_android_arm64",
73-
@@ -144,6 +155,8 @@ cc_test(
74-
"src/time_zone_info.h",
75-
"src/tzfile.h",
76-
],
77-
+ copts = ABSL_TEST_COPTS,
78-
+ linkopts = ABSL_DEFAULT_LINKOPTS,
79-
linkstatic = 1,
80-
tags = ["benchmark"],
81-
deps = [
82-
--
83-
2.43.0
1+
diff --git a/absl/container/flat_hash_map.h b/absl/container/flat_hash_map.h
2+
index 735ee342..d7310e02 100644
3+
--- a/absl/container/flat_hash_map.h
4+
+++ b/absl/container/flat_hash_map.h
5+
@@ -34,6 +34,7 @@
6+
7+
#include <cstddef>
8+
#include <memory>
9+
+#include <optional>
10+
#include <type_traits>
11+
#include <utility>
12+
13+
@@ -656,10 +657,10 @@ struct FlatHashMapPolicy {
14+
}
15+
16+
template <class Hash>
17+
- static constexpr HashSlotFn get_hash_slot_fn() {
18+
+ static constexpr std::optional<HashSlotFn> get_hash_slot_fn() {
19+
return memory_internal::IsLayoutCompatible<K, V>::value
20+
- ? &TypeErasedApplyToSlotFn<Hash, K>
21+
- : nullptr;
22+
+ ? std::optional<HashSlotFn>(&TypeErasedApplyToSlotFn<Hash, K>)
23+
+ : std::nullopt;
24+
}
25+
26+
static size_t space_used(const slot_type*) { return 0; }
27+
diff --git a/absl/container/flat_hash_set.h b/absl/container/flat_hash_set.h
28+
index b5d0f7f9..dfce1529 100644
29+
--- a/absl/container/flat_hash_set.h
30+
+++ b/absl/container/flat_hash_set.h
31+
@@ -34,6 +34,7 @@
32+
33+
#include <cstddef>
34+
#include <memory>
35+
+#include <optional>
36+
#include <type_traits>
37+
#include <utility>
38+
39+
@@ -554,8 +555,8 @@ struct FlatHashSetPolicy {
40+
static size_t space_used(const T*) { return 0; }
41+
42+
template <class Hash>
43+
- static constexpr HashSlotFn get_hash_slot_fn() {
44+
- return &TypeErasedApplyToSlotFn<Hash, T>;
45+
+ static constexpr std::optional<HashSlotFn> get_hash_slot_fn() {
46+
+ return std::optional<HashSlotFn>(&TypeErasedApplyToSlotFn<Hash, T>);
47+
}
48+
};
49+
} // namespace container_internal
50+
diff --git a/absl/container/internal/hash_policy_traits.h b/absl/container/internal/hash_policy_traits.h
51+
index ad835d6f..ee3f1ee6 100644
52+
--- a/absl/container/internal/hash_policy_traits.h
53+
+++ b/absl/container/internal/hash_policy_traits.h
54+
@@ -160,9 +160,9 @@ struct hash_policy_traits : common_policy_traits<Policy> {
55+
// silent error: the address of * will never be NULL [-Werror=address]
56+
#pragma GCC diagnostic ignored "-Waddress"
57+
#endif
58+
- return Policy::template get_hash_slot_fn<Hash>() == nullptr
59+
+ return !Policy::template get_hash_slot_fn<Hash>().has_value()
60+
? &hash_slot_fn_non_type_erased<Hash>
61+
- : Policy::template get_hash_slot_fn<Hash>();
62+
+ : Policy::template get_hash_slot_fn<Hash>().value();
63+
#if defined(__GNUC__) && !defined(__clang__)
64+
#pragma GCC diagnostic pop
65+
#endif
66+
diff --git a/absl/container/internal/hash_policy_traits_test.cc b/absl/container/internal/hash_policy_traits_test.cc
67+
index 2d2c7c2c..66552635 100644
68+
--- a/absl/container/internal/hash_policy_traits_test.cc
69+
+++ b/absl/container/internal/hash_policy_traits_test.cc
70+
@@ -18,6 +18,7 @@
71+
#include <functional>
72+
#include <memory>
73+
#include <new>
74+
+#include <optional>
75+
76+
#include "gmock/gmock.h"
77+
#include "gtest/gtest.h"
78+
@@ -46,8 +47,8 @@ struct PolicyWithoutOptionalOps {
79+
static std::function<Slot&(Slot*)> value;
80+
81+
template <class Hash>
82+
- static constexpr HashSlotFn get_hash_slot_fn() {
83+
- return nullptr;
84+
+ static constexpr std::optional<HashSlotFn> get_hash_slot_fn() {
85+
+ return std::nullopt;
86+
}
87+
};
88+
89+
@@ -100,8 +101,8 @@ struct PolicyNoHashFn {
90+
}
91+
92+
template <class Hash>
93+
- static constexpr HashSlotFn get_hash_slot_fn() {
94+
- return nullptr;
95+
+ static constexpr std::optional<HashSlotFn> get_hash_slot_fn() {
96+
+ return std::nullopt;
97+
}
98+
};
99+
100+
@@ -109,8 +110,8 @@ size_t* PolicyNoHashFn::apply_called_count;
101+
102+
struct PolicyCustomHashFn : PolicyNoHashFn {
103+
template <class Hash>
104+
- static constexpr HashSlotFn get_hash_slot_fn() {
105+
- return &TypeErasedApplyToSlotFn<Hash, int>;
106+
+ static constexpr std::optional<HashSlotFn> get_hash_slot_fn() {
107+
+ return std::optional<HashSlotFn>(&TypeErasedApplyToSlotFn<Hash, int>);
108+
}
109+
};
110+
111+
diff --git a/absl/container/internal/raw_hash_set_allocator_test.cc b/absl/container/internal/raw_hash_set_allocator_test.cc
112+
index 7e7a5063..59907895 100644
113+
--- a/absl/container/internal/raw_hash_set_allocator_test.cc
114+
+++ b/absl/container/internal/raw_hash_set_allocator_test.cc
115+
@@ -17,6 +17,7 @@
116+
#include <functional>
117+
#include <limits>
118+
#include <memory>
119+
+#include <optional>
120+
#include <ostream>
121+
#include <set>
122+
#include <type_traits>
123+
@@ -181,8 +182,8 @@ struct Policy {
124+
static slot_type& element(slot_type* slot) { return *slot; }
125+
126+
template <class Hash>
127+
- static constexpr HashSlotFn get_hash_slot_fn() {
128+
- return nullptr;
129+
+ static constexpr std::optional<HashSlotFn> get_hash_slot_fn() {
130+
+ return std::nullopt;
131+
}
132+
};
133+
134+
diff --git a/absl/container/internal/raw_hash_set_benchmark.cc b/absl/container/internal/raw_hash_set_benchmark.cc
135+
index 424b72cf..db052dae 100644
136+
--- a/absl/container/internal/raw_hash_set_benchmark.cc
137+
+++ b/absl/container/internal/raw_hash_set_benchmark.cc
138+
@@ -19,6 +19,7 @@
139+
#include <cstdint>
140+
#include <limits>
141+
#include <numeric>
142+
+#include <optional>
143+
#include <random>
144+
#include <string>
145+
#include <tuple>
146+
@@ -65,8 +66,8 @@ struct IntPolicy {
147+
}
148+
149+
template <class Hash>
150+
- static constexpr HashSlotFn get_hash_slot_fn() {
151+
- return nullptr;
152+
+ static constexpr std::optional<HashSlotFn> get_hash_slot_fn() {
153+
+ return std::nullopt;
154+
}
155+
};
156+
157+
@@ -128,8 +129,8 @@ class StringPolicy {
158+
}
159+
160+
template <class Hash>
161+
- static constexpr HashSlotFn get_hash_slot_fn() {
162+
- return nullptr;
163+
+ static constexpr std::optional<HashSlotFn> get_hash_slot_fn() {
164+
+ return std::nullopt;
165+
}
166+
};
167+
168+
diff --git a/absl/container/internal/raw_hash_set_probe_benchmark.cc b/absl/container/internal/raw_hash_set_probe_benchmark.cc
169+
index 8f36305d..be46f9e7 100644
170+
--- a/absl/container/internal/raw_hash_set_probe_benchmark.cc
171+
+++ b/absl/container/internal/raw_hash_set_probe_benchmark.cc
172+
@@ -16,6 +16,7 @@
173+
// distributions, all using the default hash function for swisstable.
174+
175+
#include <memory>
176+
+#include <optional>
177+
#include <regex> // NOLINT
178+
#include <vector>
179+
180+
@@ -73,7 +74,7 @@ struct Policy {
181+
182+
template <class Hash>
183+
static constexpr auto get_hash_slot_fn() {
184+
- return nullptr;
185+
+ return std::nullopt;
186+
}
187+
};
188+
189+
diff --git a/absl/container/internal/raw_hash_set_test.cc b/absl/container/internal/raw_hash_set_test.cc
190+
index 8a17c018..ab246ad9 100644
191+
--- a/absl/container/internal/raw_hash_set_test.cc
192+
+++ b/absl/container/internal/raw_hash_set_test.cc
193+
@@ -29,6 +29,7 @@
194+
#include <map>
195+
#include <memory>
196+
#include <numeric>
197+
+#include <optional>
198+
#include <ostream>
199+
#include <random>
200+
#include <set>
201+
@@ -526,8 +527,8 @@ struct ValuePolicy {
202+
}
203+
204+
template <class Hash>
205+
- static constexpr HashSlotFn get_hash_slot_fn() {
206+
- return nullptr;
207+
+ static constexpr std::optional<HashSlotFn> get_hash_slot_fn() {
208+
+ return std::nullopt;
209+
}
210+
211+
static constexpr bool soo_enabled() { return kSoo; }
212+
@@ -634,8 +635,8 @@ class StringPolicy {
213+
}
214+
215+
template <class Hash>
216+
- static constexpr HashSlotFn get_hash_slot_fn() {
217+
- return nullptr;
218+
+ static constexpr std::optional<HashSlotFn> get_hash_slot_fn() {
219+
+ return std::nullopt;
220+
}
221+
};
222+
223+
@@ -1117,8 +1118,8 @@ struct DecomposePolicy {
224+
}
225+
226+
template <class Hash>
227+
- static constexpr HashSlotFn get_hash_slot_fn() {
228+
- return nullptr;
229+
+ static constexpr std::optional<HashSlotFn> get_hash_slot_fn() {
230+
+ return std::nullopt;
231+
}
232+
};
233+
234+
diff --git a/absl/container/node_hash_map.h b/absl/container/node_hash_map.h
235+
index 127c8937..c91335e0 100644
236+
--- a/absl/container/node_hash_map.h
237+
+++ b/absl/container/node_hash_map.h
238+
@@ -40,6 +40,7 @@
239+
240+
#include <cstddef>
241+
#include <memory>
242+
+#include <optional>
243+
#include <type_traits>
244+
#include <utility>
245+
246+
@@ -659,10 +660,10 @@ class NodeHashMapPolicy
247+
static const Value& value(const value_type* elem) { return elem->second; }
248+
249+
template <class Hash>
250+
- static constexpr HashSlotFn get_hash_slot_fn() {
251+
+ static constexpr std::optional<HashSlotFn> get_hash_slot_fn() {
252+
return memory_internal::IsLayoutCompatible<Key, Value>::value
253+
- ? &TypeErasedDerefAndApplyToSlotFn<Hash, Key>
254+
- : nullptr;
255+
+ ? std::optional<HashSlotFn>(&TypeErasedDerefAndApplyToSlotFn<Hash, Key>)
256+
+ : std::nullopt;
257+
}
258+
};
259+
} // namespace container_internal
260+
diff --git a/absl/container/node_hash_set.h b/absl/container/node_hash_set.h
261+
index cffa50ec..43f8d4c5 100644
262+
--- a/absl/container/node_hash_set.h
263+
+++ b/absl/container/node_hash_set.h
264+
@@ -39,6 +39,7 @@
265+
266+
#include <cstddef>
267+
#include <memory>
268+
+#include <optional>
269+
#include <type_traits>
270+
271+
#include "absl/algorithm/container.h"
272+
@@ -553,8 +554,8 @@ struct NodeHashSetPolicy
273+
static size_t element_space_used(const T*) { return sizeof(T); }
274+
275+
template <class Hash>
276+
- static constexpr HashSlotFn get_hash_slot_fn() {
277+
- return &TypeErasedDerefAndApplyToSlotFn<Hash, T>;
278+
+ static constexpr std::optional<HashSlotFn> get_hash_slot_fn() {
279+
+ return std::optional<HashSlotFn>(&TypeErasedDerefAndApplyToSlotFn<Hash, T>);
280+
}
281+
};
282+
} // namespace container_internal

0 commit comments

Comments
 (0)