summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEfraim Flashner <efraim@flashner.co.il>2024-05-20 10:28:46 +0300
committerEfraim Flashner <efraim@flashner.co.il>2024-05-21 09:10:33 +0300
commite50fc5380ea0f875790e5cd924b4048cae55df3c (patch)
treeaed01815f0f01c041e450a3b0379cb03ffc65475
parent24db97c10d93d9e650810a35c405eaa524401b8f (diff)
downloadguix-patches-e50fc5380ea0f875790e5cd924b4048cae55df3c.tar
guix-patches-e50fc5380ea0f875790e5cd924b4048cae55df3c.tar.gz
gnu: abseil-cpp-20200923.3: Fix test suite on some architectures.
* gnu/packages/cpp.scm (abseil-cpp-20200923.3)[source]: Add patches. * gnu/packages/patches/abseil-cpp-20200923.3-adjust-sysinfo.patch, gnu/packages/patches/abseil-cpp-20200923.3-duration-test.patch: New files. * gnu/local.mk (dist_patch_DATA): Register them. Change-Id: I3a0a6c3396a7c2854236c68ec77a68bbdd6af1f4
-rw-r--r--gnu/local.mk2
-rw-r--r--gnu/packages/cpp.scm4
-rw-r--r--gnu/packages/patches/abseil-cpp-20200923.3-adjust-sysinfo.patch60
-rw-r--r--gnu/packages/patches/abseil-cpp-20200923.3-duration-test.patch86
4 files changed, 151 insertions, 1 deletions
diff --git a/gnu/local.mk b/gnu/local.mk
index 89839f799e..3624d6a2a8 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -911,6 +911,8 @@ dist_patch_DATA = \
%D%/packages/patches/abcl-fix-build-xml.patch \
%D%/packages/patches/ableton-link-system-libraries-debian.patch \
%D%/packages/patches/abiword-explictly-cast-bools.patch \
+ %D%/packages/patches/abseil-cpp-20200923.3-adjust-sysinfo.patch \
+ %D%/packages/patches/abseil-cpp-20200923.3-duration-test.patch \
%D%/packages/patches/abseil-cpp-fix-strerror_test.patch \
%D%/packages/patches/adb-add-libraries.patch \
%D%/packages/patches/adb-libssl_11-compatibility.patch \
diff --git a/gnu/packages/cpp.scm b/gnu/packages/cpp.scm
index 0b6b556a6b..5c7ca8965b 100644
--- a/gnu/packages/cpp.scm
+++ b/gnu/packages/cpp.scm
@@ -1379,7 +1379,9 @@ point and then, after each tween step, plugging back the result.")
(base32
"1p4djhm1f011ficbjjxx3n8428p8481p20j4glpaawnpsi362hkl"))
(patches
- (search-patches "abseil-cpp-fix-strerror_test.patch"))))
+ (search-patches "abseil-cpp-fix-strerror_test.patch"
+ "abseil-cpp-20200923.3-adjust-sysinfo.patch"
+ "abseil-cpp-20200923.3-duration-test.patch"))))
(build-system cmake-build-system)
(arguments
`(#:configure-flags (list "-DBUILD_SHARED_LIBS=ON"
diff --git a/gnu/packages/patches/abseil-cpp-20200923.3-adjust-sysinfo.patch b/gnu/packages/patches/abseil-cpp-20200923.3-adjust-sysinfo.patch
new file mode 100644
index 0000000000..ae52e103a7
--- /dev/null
+++ b/gnu/packages/patches/abseil-cpp-20200923.3-adjust-sysinfo.patch
@@ -0,0 +1,60 @@
+https://sources.debian.org/data/main/a/abseil/0~20200923.3-2/debian/patches/cpu-frequency.diff
+This patch is taken from Debian instead of the upstream URL because the
+upstream URL contains far more changes than occur in this patch.
+
+It was then modified to also work for armhf.
+
+From: Benjamin Barenblat <bbaren@google.com>
+Subject: Ignore missing CPU frequency on more architectures
+Forwarded: yes
+Applied-Upstream: https://github.com/abseil/abseil-cpp/commit/1918ad2ae38aa32c74b558b322479a8efdd76363
+
+Linux on MIPS, PA-RISC, RISC-V, and SystemZ doesn’t expose the nominal CPU
+frequency via /sys, so don’t worry if `NominalCPUFrequency` returns 1.0 on those
+platforms.
+
+Some POWER machines expose the CPU frequency; others do not. Since we can’t
+predict which type of machine the tests will run on, simply disable testing for
+`NominalCPUFrequency` on POWER.
+
+The author works at Google. Upstream applied this patch as Piper revision
+347079873 and exported it to GitHub; the Applied-Upstream URL above points to
+the exported commit.
+
+--- a/absl/base/internal/sysinfo_test.cc
++++ b/absl/base/internal/sysinfo_test.cc
+@@ -37,17 +37,28 @@ TEST(SysinfoTest, NumCPUs) {
+ << "NumCPUs() should not have the default value of 0";
+ }
+
++// Ensure that NominalCPUFrequency returns a reasonable value, or 1.00 on
++// platforms where the CPU frequency is not available through sysfs.
++//
++// POWER is particularly problematic here; some Linux kernels expose the CPU
++// frequency, while others do not. Since we can't predict a priori what a given
++// machine is going to do, just disable this test on POWER on Linux.
++#if !(defined(__linux) && (defined(__ppc64__) || defined(__PPC64__)))
+ TEST(SysinfoTest, NominalCPUFrequency) {
+-#if !(defined(__aarch64__) && defined(__linux__)) && !defined(__EMSCRIPTEN__)
+- EXPECT_GE(NominalCPUFrequency(), 1000.0)
+- << "NominalCPUFrequency() did not return a reasonable value";
+-#else
+- // Aarch64 cannot read the CPU frequency from sysfs, so we get back 1.0.
+- // Emscripten does not have a sysfs to read from at all.
++ // Linux only exposes the CPU frequency on certain architectures, and
++ // Emscripten doesn't expose it at all.
++#if defined(__linux__) && \
++ (defined(__aarch64__) || defined(__hppa__) || defined(__mips__) || \
++ defined(__arm__) || defined(__riscv) || defined(__s390x__)) || \
++ defined(__EMSCRIPTEN__)
+ EXPECT_EQ(NominalCPUFrequency(), 1.0)
+ << "CPU frequency detection was fixed! Please update unittest.";
++#else
++ EXPECT_GE(NominalCPUFrequency(), 1000.0)
++ << "NominalCPUFrequency() did not return a reasonable value";
+ #endif
+ }
++#endif
+
+ TEST(SysinfoTest, GetTID) {
+ EXPECT_EQ(GetTID(), GetTID()); // Basic compile and equality test.
diff --git a/gnu/packages/patches/abseil-cpp-20200923.3-duration-test.patch b/gnu/packages/patches/abseil-cpp-20200923.3-duration-test.patch
new file mode 100644
index 0000000000..9609c2588b
--- /dev/null
+++ b/gnu/packages/patches/abseil-cpp-20200923.3-duration-test.patch
@@ -0,0 +1,86 @@
+This patch is taken from upstream and helps the test pass on all architectures.
+
+The adjustment to absl/numeric/internal/bits.h was removed since the file
+didn't appear in the git checkout.
+
+From b0735979d778a768caee207f01f327535cbd2140 Mon Sep 17 00:00:00 2001
+From: Abseil Team <absl-team@google.com>
+Date: Tue, 2 Mar 2021 14:28:07 -0800
+Subject: [PATCH] Export of internal Abseil changes
+
+--
+a74bdb72c3a6983e08a805938dd0e20e97d55bba by Abseil Team <absl-team@google.com>:
+
+Fix typo: calcualte -> calculate
+
+PiperOrigin-RevId: 360515509
+
+--
+3ddf8ac194e81a13e9de095e59dd061c1beacfe3 by Benjamin Barenblat <bbaren@google.com>:
+
+Make tests tolerant of FMA contraction
+
+Weaken Duration.ToDoubleSecondsCheckEdgeCases and
+Duration.ToDoubleSecondsCheckRandom to make them less sensitive to fused
+multiply/add contraction.
+
+PiperOrigin-RevId: 360297653
+GitOrigin-RevId: a74bdb72c3a6983e08a805938dd0e20e97d55bba
+Change-Id: I0c55383bc13040ea77511c4130d142368103dc57
+---
+ absl/numeric/internal/bits.h | 2 +-
+ absl/time/duration_test.cc | 18 +++++++++++-------
+ 2 files changed, 12 insertions(+), 8 deletions(-)
+
+diff --git a/absl/time/duration_test.cc b/absl/time/duration_test.cc
+index 4d85a2c4f45..fb28fa987f6 100644
+--- a/absl/time/duration_test.cc
++++ b/absl/time/duration_test.cc
+@@ -1369,10 +1369,13 @@ TEST(Duration, SmallConversions) {
+ EXPECT_THAT(ToTimeval(absl::Nanoseconds(2000)), TimevalMatcher(tv));
+ }
+
+-void VerifySameAsMul(double time_as_seconds, int* const misses) {
++void VerifyApproxSameAsMul(double time_as_seconds, int* const misses) {
+ auto direct_seconds = absl::Seconds(time_as_seconds);
+ auto mul_by_one_second = time_as_seconds * absl::Seconds(1);
+- if (direct_seconds != mul_by_one_second) {
++ // These are expected to differ by up to one tick due to fused multiply/add
++ // contraction.
++ if (absl::AbsDuration(direct_seconds - mul_by_one_second) >
++ absl::time_internal::MakeDuration(0, 1u)) {
+ if (*misses > 10) return;
+ ASSERT_LE(++(*misses), 10) << "Too many errors, not reporting more.";
+ EXPECT_EQ(direct_seconds, mul_by_one_second)
+@@ -1384,7 +1387,8 @@ void VerifySameAsMul(double time_as_seconds, int* const misses) {
+ // For a variety of interesting durations, we find the exact point
+ // where one double converts to that duration, and the very next double
+ // converts to the next duration. For both of those points, verify that
+-// Seconds(point) returns the same duration as point * Seconds(1.0)
++// Seconds(point) returns a duration near point * Seconds(1.0). (They may
++// not be exactly equal due to fused multiply/add contraction.)
+ TEST(Duration, ToDoubleSecondsCheckEdgeCases) {
+ constexpr uint32_t kTicksPerSecond = absl::time_internal::kTicksPerSecond;
+ constexpr auto duration_tick = absl::time_internal::MakeDuration(0, 1u);
+@@ -1423,8 +1427,8 @@ TEST(Duration, ToDoubleSecondsCheckEdgeCases) {
+ }
+ // Now low_edge is the highest double that converts to Duration d,
+ // and high_edge is the lowest double that converts to Duration after_d.
+- VerifySameAsMul(low_edge, &misses);
+- VerifySameAsMul(high_edge, &misses);
++ VerifyApproxSameAsMul(low_edge, &misses);
++ VerifyApproxSameAsMul(high_edge, &misses);
+ }
+ }
+ }
+@@ -1444,8 +1448,8 @@ TEST(Duration, ToDoubleSecondsCheckRandom) {
+ int misses = 0;
+ for (int i = 0; i < 1000000; ++i) {
+ double d = std::exp(uniform(gen));
+- VerifySameAsMul(d, &misses);
+- VerifySameAsMul(-d, &misses);
++ VerifyApproxSameAsMul(d, &misses);
++ VerifyApproxSameAsMul(-d, &misses);
+ }
+ }
+