From: Theo Buehler Subject: [sparc64] build fix for abseil-cpp with gcc/15 To: ports@openbsd.org Cc: Andrew Krasavin , Klemens Nanni Date: Sat, 8 Nov 2025 16:51:07 +0100 Just in case someone is interested in this diff. It builds with gcc/15 (no for need gnu++17 CXXFLAGS). It errors out building some test with gcc/8. That can likely be fixed but I won't be the one debugging that. I haven't tried with gcc/11 at all. It is a somewhat intrusive patch adapted from https://github.com/abseil/abseil-cpp/issues/1634#issuecomment-2576011026 Since upstream doesn't seem keen on fixing this, I'm not sure we would really want this (once we switch to a newer gcc). The constant churn happening in abseil makes it likely that it needs fixing and adapting on every update. That's going to be tedious albeit rather straightforward. I also have no idea why we need this when others seem to run into this problem only when enabling some sanitiers. Tests look reasonable on sparc64 and arm64. Index: Makefile =================================================================== RCS file: /cvs/ports/devel/abseil-cpp/Makefile,v diff -u -p -r1.41 Makefile --- Makefile 23 Sep 2025 18:46:30 -0000 1.41 +++ Makefile 7 Nov 2025 12:41:28 -0000 @@ -1,10 +1,9 @@ -BROKEN-sparc64 = is not a constant expression - COMMENT = abseil common libraries (C++) CATEGORIES = devel V = 20250814.1 DISTNAME = abseil-cpp-${V} +REVISION = 0 HOMEPAGE = https://abseil.io/ SITES = https://github.com/abseil/abseil-cpp/releases/download/${V}/ @@ -57,6 +56,8 @@ WANTLIB += ${COMPILER_LIBCXX} execinfo g COMPILER = base-clang ports-gcc COMPILER_LANGS = c++ MODULES = devel/cmake + +CXXFLAGS_ports-gcc = -std=gnu++17 CONFIGURE_ARGS = -DBUILD_SHARED_LIBS=ON \ -DABSL_USE_EXTERNAL_GOOGLETEST=${LOCALBASE}/include/gtest \ Index: patches/patch-absl_container_flat_hash_map_h =================================================================== RCS file: patches/patch-absl_container_flat_hash_map_h diff -N patches/patch-absl_container_flat_hash_map_h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-absl_container_flat_hash_map_h 7 Nov 2025 12:41:10 -0000 @@ -0,0 +1,27 @@ +https://github.com/abseil/abseil-cpp/issues/1634#issuecomment-2576011026 + +Index: absl/container/flat_hash_map.h +--- absl/container/flat_hash_map.h.orig ++++ absl/container/flat_hash_map.h +@@ -34,6 +34,7 @@ + + #include + #include ++#include + #include + #include + +@@ -661,10 +662,10 @@ struct FlatHashMapPolicy { + } + + template +- static constexpr HashSlotFn get_hash_slot_fn() { ++ static constexpr std::optional get_hash_slot_fn() { + return memory_internal::IsLayoutCompatible::value +- ? &TypeErasedApplyToSlotFn +- : nullptr; ++ ? std::optional(&TypeErasedApplyToSlotFn) ++ : std::nullopt; + } + + static size_t space_used(const slot_type*) { return 0; } Index: patches/patch-absl_container_flat_hash_set_h =================================================================== RCS file: patches/patch-absl_container_flat_hash_set_h diff -N patches/patch-absl_container_flat_hash_set_h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-absl_container_flat_hash_set_h 7 Nov 2025 12:41:10 -0000 @@ -0,0 +1,24 @@ +https://github.com/abseil/abseil-cpp/issues/1634#issuecomment-2576011026 + +Index: absl/container/flat_hash_set.h +--- absl/container/flat_hash_set.h.orig ++++ absl/container/flat_hash_set.h +@@ -34,6 +34,7 @@ + + #include + #include ++#include + #include + #include + +@@ -559,8 +560,8 @@ struct FlatHashSetPolicy { + static size_t space_used(const T*) { return 0; } + + template +- static constexpr HashSlotFn get_hash_slot_fn() { +- return &TypeErasedApplyToSlotFn; ++ static constexpr std::optional get_hash_slot_fn() { ++ return std::optional(&TypeErasedApplyToSlotFn); + } + }; + } // namespace container_internal Index: patches/patch-absl_container_internal_hash_policy_traits_h =================================================================== RCS file: patches/patch-absl_container_internal_hash_policy_traits_h diff -N patches/patch-absl_container_internal_hash_policy_traits_h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-absl_container_internal_hash_policy_traits_h 7 Nov 2025 12:41:10 -0000 @@ -0,0 +1,17 @@ +https://github.com/abseil/abseil-cpp/issues/1634#issuecomment-2576011026 + +Index: absl/container/internal/hash_policy_traits.h +--- absl/container/internal/hash_policy_traits.h.orig ++++ absl/container/internal/hash_policy_traits.h +@@ -155,9 +155,9 @@ struct hash_policy_traits : common_policy_traits() == nullptr ++ return !Policy::template get_hash_slot_fn().has_value() + ? &hash_slot_fn_non_type_erased +- : Policy::template get_hash_slot_fn(); ++ : Policy::template get_hash_slot_fn().value(); + #if defined(__GNUC__) && !defined(__clang__) + #pragma GCC diagnostic pop + #endif Index: patches/patch-absl_container_internal_hash_policy_traits_test_cc =================================================================== RCS file: patches/patch-absl_container_internal_hash_policy_traits_test_cc diff -N patches/patch-absl_container_internal_hash_policy_traits_test_cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-absl_container_internal_hash_policy_traits_test_cc 7 Nov 2025 12:41:10 -0000 @@ -0,0 +1,46 @@ +https://github.com/abseil/abseil-cpp/issues/1634#issuecomment-2576011026 + +Index: absl/container/internal/hash_policy_traits_test.cc +--- absl/container/internal/hash_policy_traits_test.cc.orig ++++ absl/container/internal/hash_policy_traits_test.cc +@@ -18,6 +18,7 @@ + #include + #include + #include ++#include + + #include "gmock/gmock.h" + #include "gtest/gtest.h" +@@ -46,8 +47,8 @@ struct PolicyWithoutOptionalOps { + static std::function value; + + template +- static constexpr HashSlotFn get_hash_slot_fn() { +- return nullptr; ++ static constexpr std::optional get_hash_slot_fn() { ++ return std::nullopt; + } + }; + +@@ -100,8 +101,8 @@ struct PolicyNoHashFn { + } + + template +- static constexpr HashSlotFn get_hash_slot_fn() { +- return nullptr; ++ static constexpr std::optional get_hash_slot_fn() { ++ return std::nullopt; + } + }; + +@@ -109,8 +110,8 @@ size_t* PolicyNoHashFn::apply_called_count; + + struct PolicyCustomHashFn : PolicyNoHashFn { + template +- static constexpr HashSlotFn get_hash_slot_fn() { +- return &TypeErasedApplyToSlotFn; ++ static constexpr std::optional get_hash_slot_fn() { ++ return std::optional(&TypeErasedApplyToSlotFn); + } + }; + Index: patches/patch-absl_container_internal_raw_hash_set_allocator_test_cc =================================================================== RCS file: patches/patch-absl_container_internal_raw_hash_set_allocator_test_cc diff -N patches/patch-absl_container_internal_raw_hash_set_allocator_test_cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-absl_container_internal_raw_hash_set_allocator_test_cc 7 Nov 2025 12:41:10 -0000 @@ -0,0 +1,24 @@ +https://github.com/abseil/abseil-cpp/issues/1634#issuecomment-2576011026 + +Index: absl/container/internal/raw_hash_set_allocator_test.cc +--- absl/container/internal/raw_hash_set_allocator_test.cc.orig ++++ absl/container/internal/raw_hash_set_allocator_test.cc +@@ -17,6 +17,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -181,8 +182,8 @@ struct Policy { + static slot_type& element(slot_type* slot) { return *slot; } + + template +- static constexpr HashSlotFn get_hash_slot_fn() { +- return nullptr; ++ static constexpr std::optional get_hash_slot_fn() { ++ return std::nullopt; + } + }; + Index: patches/patch-absl_container_internal_raw_hash_set_benchmark_cc =================================================================== RCS file: patches/patch-absl_container_internal_raw_hash_set_benchmark_cc diff -N patches/patch-absl_container_internal_raw_hash_set_benchmark_cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-absl_container_internal_raw_hash_set_benchmark_cc 7 Nov 2025 12:41:10 -0000 @@ -0,0 +1,35 @@ +https://github.com/abseil/abseil-cpp/issues/1634#issuecomment-2576011026 + +Index: absl/container/internal/raw_hash_set_benchmark.cc +--- absl/container/internal/raw_hash_set_benchmark.cc.orig ++++ absl/container/internal/raw_hash_set_benchmark.cc +@@ -18,6 +18,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -65,8 +66,8 @@ struct IntPolicy { + } + + template +- static constexpr HashSlotFn get_hash_slot_fn() { +- return nullptr; ++ static constexpr std::optional get_hash_slot_fn() { ++ return std::nullopt; + } + }; + +@@ -128,8 +129,8 @@ class StringPolicy { + } + + template +- static constexpr HashSlotFn get_hash_slot_fn() { +- return nullptr; ++ static constexpr std::optional get_hash_slot_fn() { ++ return std::nullopt; + } + }; + Index: patches/patch-absl_container_internal_raw_hash_set_probe_benchmark_cc =================================================================== RCS file: patches/patch-absl_container_internal_raw_hash_set_probe_benchmark_cc diff -N patches/patch-absl_container_internal_raw_hash_set_probe_benchmark_cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-absl_container_internal_raw_hash_set_probe_benchmark_cc 7 Nov 2025 12:41:10 -0000 @@ -0,0 +1,22 @@ +https://github.com/abseil/abseil-cpp/issues/1634#issuecomment-2576011026 + +Index: absl/container/internal/raw_hash_set_probe_benchmark.cc +--- absl/container/internal/raw_hash_set_probe_benchmark.cc.orig ++++ absl/container/internal/raw_hash_set_probe_benchmark.cc +@@ -16,6 +16,7 @@ + // distributions, all using the default hash function for swisstable. + + #include ++#include + #include // NOLINT + #include + +@@ -73,7 +74,7 @@ struct Policy { + + template + static constexpr auto get_hash_slot_fn() { +- return nullptr; ++ return std::nullopt; + } + }; + Index: patches/patch-absl_container_internal_raw_hash_set_test_cc =================================================================== RCS file: patches/patch-absl_container_internal_raw_hash_set_test_cc diff -N patches/patch-absl_container_internal_raw_hash_set_test_cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-absl_container_internal_raw_hash_set_test_cc 7 Nov 2025 12:41:10 -0000 @@ -0,0 +1,46 @@ +https://github.com/abseil/abseil-cpp/issues/1634#issuecomment-2576011026 + +Index: absl/container/internal/raw_hash_set_test.cc +--- absl/container/internal/raw_hash_set_test.cc.orig ++++ absl/container/internal/raw_hash_set_test.cc +@@ -31,6 +31,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -387,8 +388,8 @@ struct ValuePolicy { + } + + template +- static constexpr HashSlotFn get_hash_slot_fn() { +- return nullptr; ++ static constexpr std::optional get_hash_slot_fn() { ++ return std::nullopt; + } + + static constexpr bool soo_enabled() { return kSoo; } +@@ -535,8 +536,8 @@ class StringPolicy { + } + + template +- static constexpr HashSlotFn get_hash_slot_fn() { +- return nullptr; ++ static constexpr std::optional get_hash_slot_fn() { ++ return std::nullopt; + } + }; + +@@ -1132,8 +1133,8 @@ struct DecomposePolicy { + } + + template +- static constexpr HashSlotFn get_hash_slot_fn() { +- return nullptr; ++ static constexpr std::optional get_hash_slot_fn() { ++ return std::nullopt; + } + }; + Index: patches/patch-absl_container_node_hash_map_h =================================================================== RCS file: patches/patch-absl_container_node_hash_map_h diff -N patches/patch-absl_container_node_hash_map_h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-absl_container_node_hash_map_h 7 Nov 2025 12:41:10 -0000 @@ -0,0 +1,27 @@ +https://github.com/abseil/abseil-cpp/issues/1634#issuecomment-2576011026 + +Index: absl/container/node_hash_map.h +--- absl/container/node_hash_map.h.orig ++++ absl/container/node_hash_map.h +@@ -40,6 +40,7 @@ + + #include + #include ++#include + #include + #include + +@@ -664,10 +665,10 @@ class NodeHashMapPolicy + static const Value& value(const value_type* elem) { return elem->second; } + + template +- static constexpr HashSlotFn get_hash_slot_fn() { ++ static constexpr std::optional get_hash_slot_fn() { + return memory_internal::IsLayoutCompatible::value +- ? &TypeErasedDerefAndApplyToSlotFn +- : nullptr; ++ ? std::optional(&TypeErasedDerefAndApplyToSlotFn) ++ : std::nullopt; + } + }; + } // namespace container_internal Index: patches/patch-absl_container_node_hash_set_h =================================================================== RCS file: patches/patch-absl_container_node_hash_set_h diff -N patches/patch-absl_container_node_hash_set_h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-absl_container_node_hash_set_h 7 Nov 2025 12:41:10 -0000 @@ -0,0 +1,24 @@ +https://github.com/abseil/abseil-cpp/issues/1634#issuecomment-2576011026 + +Index: absl/container/node_hash_set.h +--- absl/container/node_hash_set.h.orig ++++ absl/container/node_hash_set.h +@@ -39,6 +39,7 @@ + + #include + #include ++#include + #include + + #include "absl/algorithm/container.h" +@@ -558,8 +559,8 @@ struct NodeHashSetPolicy + static size_t element_space_used(const T*) { return sizeof(T); } + + template +- static constexpr HashSlotFn get_hash_slot_fn() { +- return &TypeErasedDerefAndApplyToSlotFn; ++ static constexpr std::optional get_hash_slot_fn() { ++ return std::optional(&TypeErasedDerefAndApplyToSlotFn); + } + }; + } // namespace container_internal