summaryrefslogtreecommitdiff
path: root/debian/patches
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches')
-rw-r--r--debian/patches/configure.diff115
-rw-r--r--debian/patches/cordrepring-typo.diff20
-rw-r--r--debian/patches/latomic.diff20
-rw-r--r--debian/patches/series5
-rw-r--r--debian/patches/std-hash.diff46
-rw-r--r--debian/patches/thumb-function-bounds.diff96
6 files changed, 302 insertions, 0 deletions
diff --git a/debian/patches/configure.diff b/debian/patches/configure.diff
new file mode 100644
index 00000000..786994b0
--- /dev/null
+++ b/debian/patches/configure.diff
@@ -0,0 +1,115 @@
+From: Benjamin Barenblat <bbaren@google.com>
+Subject: Set package configuration options
+Forwarded: not-needed
+
+Configure Abseil for Debian.
+
+ - Set the SONAME appropriately.
+
+ - To minimize the possibility of future ABI breakage, treat absl::any,
+ absl::optional, absl::string_view, and absl::variant as their own types
+ (rather than aliases for the std:: versions), and compile everything in an
+ inline namespace.
+
+ - Enable upstream's hardened build mode.
+
+ - Disable Intel SSE2 on i386, since Debian supports some i386 processors
+ without that extension. Keep it enabled on amd64, since all amd64 processors
+ have it.
+
+ - Disable Intel SSSE3 entirely, since no i386 processor supports it and Debian
+ supports amd64 processors without it.
+
+--- a/CMake/AbseilHelpers.cmake
++++ b/CMake/AbseilHelpers.cmake
+@@ -263,7 +263,8 @@
+ if(ABSL_ENABLE_INSTALL)
+ set_target_properties(${_NAME} PROPERTIES
+ OUTPUT_NAME "absl_${_NAME}"
+- SOVERSION "2103.0.0"
++ SOVERSION 20210324
++ VERSION "20210324.0.0"
+ )
+ endif()
+ else()
+--- a/absl/base/options.h
++++ b/absl/base/options.h
+@@ -100,7 +100,7 @@
+ // User code should not inspect this macro. To check in the preprocessor if
+ // absl::any is a typedef of std::any, use the feature macro ABSL_USES_STD_ANY.
+
+-#define ABSL_OPTION_USE_STD_ANY 2
++#define ABSL_OPTION_USE_STD_ANY 0
+
+
+ // ABSL_OPTION_USE_STD_OPTIONAL
+@@ -127,7 +127,7 @@
+ // absl::optional is a typedef of std::optional, use the feature macro
+ // ABSL_USES_STD_OPTIONAL.
+
+-#define ABSL_OPTION_USE_STD_OPTIONAL 2
++#define ABSL_OPTION_USE_STD_OPTIONAL 0
+
+
+ // ABSL_OPTION_USE_STD_STRING_VIEW
+@@ -154,7 +154,7 @@
+ // absl::string_view is a typedef of std::string_view, use the feature macro
+ // ABSL_USES_STD_STRING_VIEW.
+
+-#define ABSL_OPTION_USE_STD_STRING_VIEW 2
++#define ABSL_OPTION_USE_STD_STRING_VIEW 0
+
+ // ABSL_OPTION_USE_STD_VARIANT
+ //
+@@ -180,7 +180,7 @@
+ // absl::variant is a typedef of std::variant, use the feature macro
+ // ABSL_USES_STD_VARIANT.
+
+-#define ABSL_OPTION_USE_STD_VARIANT 2
++#define ABSL_OPTION_USE_STD_VARIANT 0
+
+
+ // ABSL_OPTION_USE_INLINE_NAMESPACE
+@@ -206,7 +206,7 @@
+ // allowed.
+
+ #define ABSL_OPTION_USE_INLINE_NAMESPACE 1
+-#define ABSL_OPTION_INLINE_NAMESPACE_NAME lts_20210324
++#define ABSL_OPTION_INLINE_NAMESPACE_NAME debian2
+
+ // ABSL_OPTION_HARDENED
+ //
+@@ -233,6 +233,6 @@
+ // checks enabled by this option may abort the program in a different way and
+ // log additional information when `NDEBUG` is not defined.
+
+-#define ABSL_OPTION_HARDENED 0
++#define ABSL_OPTION_HARDENED 1
+
+ #endif // ABSL_BASE_OPTIONS_H_
+--- a/absl/container/internal/have_sse.h
++++ b/absl/container/internal/have_sse.h
+@@ -17,22 +17,14 @@
+ #define ABSL_CONTAINER_INTERNAL_HAVE_SSE_H_
+
+ #ifndef ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2
+-#if defined(__SSE2__) || \
+- (defined(_MSC_VER) && \
+- (defined(_M_X64) || (defined(_M_IX86) && _M_IX86_FP >= 2)))
++#if defined(__x86_64__) || (defined(_MSC_VER) && defined(_M_X64))
+ #define ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2 1
+ #else
+ #define ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2 0
+ #endif
+ #endif
+
+-#ifndef ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSSE3
+-#ifdef __SSSE3__
+-#define ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSSE3 1
+-#else
+ #define ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSSE3 0
+-#endif
+-#endif
+
+ #if ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSSE3 && \
+ !ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2
diff --git a/debian/patches/cordrepring-typo.diff b/debian/patches/cordrepring-typo.diff
new file mode 100644
index 00000000..6f21896b
--- /dev/null
+++ b/debian/patches/cordrepring-typo.diff
@@ -0,0 +1,20 @@
+From: Benjamin Barenblat <bbaren@google.com>
+Subject: Fix typo in CordRepRing error message
+Forwarded: yes
+Applied-Upstream: https://github.com/abseil/abseil-cpp/commit/b97a1ecda869ca8754d467a56c50275cebfeb328
+
+The author works at Google. Upstream applied this patch as Piper
+revision 367481280 and exported it to GitHub; the Applied-Upstream URL
+above points to the exported commit.
+
+--- a/absl/strings/internal/cord_rep_ring.cc
++++ b/absl/strings/internal/cord_rep_ring.cc
+@@ -301,7 +301,7 @@
+ if (offset >= child->length || entry_length > child->length - offset) {
+ output << "entry[" << head << "] has offset " << offset
+ << " and entry length " << entry_length
+- << " which are outside of the childs length of " << child->length;
++ << " which are outside of the child's length of " << child->length;
+ return false;
+ }
+
diff --git a/debian/patches/latomic.diff b/debian/patches/latomic.diff
new file mode 100644
index 00000000..50e170e4
--- /dev/null
+++ b/debian/patches/latomic.diff
@@ -0,0 +1,20 @@
+From: Benjamin Barenblat <bbaren@google.com>
+Subject: Use libatomic if necessary
+Bug-Debian: https://bugs.debian.org/973492
+
+On some architectures, notably armel, Abseil needs symbols defined in
+libatomic. Abseil does not currently have a well-developed system to
+declare external library dependencies, so just have the linker determine
+if anything needs libatomic and add the DT_NEEDED entry where necessary.
+
+--- a/absl/copts/AbseilConfigureCopts.cmake
++++ b/absl/copts/AbseilConfigureCopts.cmake
+@@ -63,4 +63,8 @@
+ set(ABSL_TEST_COPTS "")
+ endif()
+
++list(APPEND ABSL_DEFAULT_LINKOPTS
++ "-Wl,--as-needed" "-latomic" "-Wl,--no-as-needed"
++)
++
+ set(ABSL_CXX_STANDARD "${CMAKE_CXX_STANDARD}")
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 00000000..e963b998
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1,5 @@
+configure.diff
+std-hash.diff
+latomic.diff
+cordrepring-typo.diff
+thumb-function-bounds.diff
diff --git a/debian/patches/std-hash.diff b/debian/patches/std-hash.diff
new file mode 100644
index 00000000..52096742
--- /dev/null
+++ b/debian/patches/std-hash.diff
@@ -0,0 +1,46 @@
+From: Benjamin Barenblat <bbaren@google.com>
+Subject: Work around broken std::hash on s390x
+Forwarded: no
+Bug-Debian: https://bugs.debian.org/977638
+
+On s390x, std::hash hashes large classes of data to the same value, which
+violates assumptions made by the Abseil tests. #ifdef out the test code that
+depends on those assumptions.
+
+--- a/absl/hash/hash_test.cc
++++ b/absl/hash/hash_test.cc
+@@ -358,6 +358,8 @@
+ TEST(HashValueTest, StdBitset) {
+ EXPECT_TRUE((is_hashable<std::bitset<257>>::value));
+
++ // The following assertions fail on s390x (https://bugs.debian.org/977638).
++#ifndef __s390x__
+ EXPECT_TRUE(absl::VerifyTypeImplementsAbslHashCorrectly(
+ {std::bitset<2>("00"), std::bitset<2>("01"), std::bitset<2>("10"),
+ std::bitset<2>("11")}));
+@@ -379,6 +381,7 @@
+ std::bitset<kNumBits>(bit_strings[3].c_str()),
+ std::bitset<kNumBits>(bit_strings[4].c_str()),
+ std::bitset<kNumBits>(bit_strings[5].c_str())}));
++#endif
+ } // namespace
+
+ template <typename T>
+@@ -400,10 +403,15 @@
+ }
+
+ REGISTER_TYPED_TEST_CASE_P(HashValueSequenceTest, BasicUsage);
++// std::vector<bool> tests fail on s390x, so exclude them. See
++// https://bugs.debian.org/977638.
+ using IntSequenceTypes =
+ testing::Types<std::deque<int>, std::forward_list<int>, std::list<int>,
+- std::vector<int>, std::vector<bool>, std::set<int>,
+- std::multiset<int>>;
++ std::vector<int>,
++#ifndef __s390x__
++ std::vector<bool>,
++#endif
++ std::set<int>, std::multiset<int>>;
+ INSTANTIATE_TYPED_TEST_CASE_P(My, HashValueSequenceTest, IntSequenceTypes);
+
+ // Private type that only supports AbslHashValue to make sure our chosen hash
diff --git a/debian/patches/thumb-function-bounds.diff b/debian/patches/thumb-function-bounds.diff
new file mode 100644
index 00000000..1fd8c729
--- /dev/null
+++ b/debian/patches/thumb-function-bounds.diff
@@ -0,0 +1,96 @@
+From: Benjamin Barenblat <bbaren@google.com>
+Subject: Correct Thumb function bound computation in the symbolizer
+Forwarded: yes
+Applied-Upstream: https://github.com/abseil/abseil-cpp/commit/1ae9b71c474628d60eb251a3f62967fe64151bb2
+
+On 32-bit ARM, all functions are aligned to multiples of two bytes, and
+the lowest-order bit in a function’s address is ignored by the CPU when
+computing branch targets. That bit is still present in instructions and
+ELF symbol tables, though; it’s repurposed to indicate whether the
+function contains ARM or Thumb code. If the symbolizer doesn’t ignore
+that bit, it will believe Thumb functions have boundaries that are off
+by one byte, so instruct the symbolizer to null out the lowest-order bit
+after retrieving it from the symbol table.
+
+The author works at Google. Upstream applied this patch as Piper
+revision 369254082 and exported it to GitHub; the Applied-Upstream URL
+above points to the exported commit.
+
+--- a/absl/debugging/symbolize_elf.inc
++++ b/absl/debugging/symbolize_elf.inc
+@@ -701,6 +701,16 @@
+ const char *start_address =
+ ComputeOffset(original_start_address, relocation);
+
++#ifdef __arm__
++ // ARM functions are always aligned to multiples of two bytes; the
++ // lowest-order bit in start_address is ignored by the CPU and indicates
++ // whether the function contains ARM (0) or Thumb (1) code. We don't care
++ // about what encoding is being used; we just want the real start address
++ // of the function.
++ start_address = reinterpret_cast<const char *>(
++ reinterpret_cast<uintptr_t>(start_address) & ~1);
++#endif
++
+ if (deref_function_descriptor_pointer &&
+ InSection(original_start_address, opd)) {
+ // The opd section is mapped into memory. Just dereference
+--- a/absl/debugging/symbolize_test.cc
++++ b/absl/debugging/symbolize_test.cc
+@@ -477,6 +477,46 @@
+ #endif
+ }
+
++#if defined(__arm__) && ABSL_HAVE_ATTRIBUTE(target)
++// Test that we correctly identify bounds of Thumb functions on ARM.
++//
++// Thumb functions have the lowest-order bit set in their addresses in the ELF
++// symbol table. This requires some extra logic to properly compute function
++// bounds. To test this logic, nudge a Thumb function right up against an ARM
++// function and try to symbolize the ARM function.
++//
++// A naive implementation will simply use the Thumb function's entry point as
++// written in the symbol table and will therefore treat the Thumb function as
++// extending one byte further in the instruction stream than it actually does.
++// When asked to symbolize the start of the ARM function, it will identify an
++// overlap between the Thumb and ARM functions, and it will return the name of
++// the Thumb function.
++//
++// A correct implementation, on the other hand, will null out the lowest-order
++// bit in the Thumb function's entry point. It will correctly compute the end of
++// the Thumb function, it will find no overlap between the Thumb and ARM
++// functions, and it will return the name of the ARM function.
++
++__attribute__((target("thumb"))) int ArmThumbOverlapThumb(int x) {
++ return x * x * x;
++}
++
++__attribute__((target("arm"))) int ArmThumbOverlapArm(int x) {
++ return x * x * x;
++}
++
++void ABSL_ATTRIBUTE_NOINLINE TestArmThumbOverlap() {
++#if defined(ABSL_HAVE_ATTRIBUTE_NOINLINE)
++ const char *symbol = TrySymbolize((void *)&ArmThumbOverlapArm);
++ ABSL_RAW_CHECK(symbol != nullptr, "TestArmThumbOverlap failed");
++ ABSL_RAW_CHECK(strcmp("ArmThumbOverlapArm()", symbol) == 0,
++ "TestArmThumbOverlap failed");
++ std::cout << "TestArmThumbOverlap passed" << std::endl;
++#endif
++}
++
++#endif // defined(__arm__) && ABSL_HAVE_ATTRIBUTE(target)
++
+ #elif defined(_WIN32)
+ #if !defined(ABSL_CONSUME_DLL)
+
+@@ -551,6 +591,9 @@
+ TestWithPCInsideInlineFunction();
+ TestWithPCInsideNonInlineFunction();
+ TestWithReturnAddress();
++#if defined(__arm__) && ABSL_HAVE_ATTRIBUTE(target)
++ TestArmThumbOverlap();
++#endif
+ #endif
+
+ return RUN_ALL_TESTS();