summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta-oe/recipes-devtools/abseil-cpp/abseil-cpp/0004-PR-1644-unscaledcycleclock-remove-RISC-V-support.patch82
-rw-r--r--meta-oe/recipes-devtools/abseil-cpp/abseil-cpp_20240116.2.bb1
2 files changed, 83 insertions, 0 deletions
diff --git a/meta-oe/recipes-devtools/abseil-cpp/abseil-cpp/0004-PR-1644-unscaledcycleclock-remove-RISC-V-support.patch b/meta-oe/recipes-devtools/abseil-cpp/abseil-cpp/0004-PR-1644-unscaledcycleclock-remove-RISC-V-support.patch
new file mode 100644
index 0000000000..461df7a608
--- /dev/null
+++ b/meta-oe/recipes-devtools/abseil-cpp/abseil-cpp/0004-PR-1644-unscaledcycleclock-remove-RISC-V-support.patch
@@ -0,0 +1,82 @@
1From 7335a36d0b5c1c597566f9aa3f458a5b6817c3b4 Mon Sep 17 00:00:00 2001
2From: aurel32 <aurelien@aurel32.net>
3Date: Fri, 22 Mar 2024 14:21:13 -0700
4Subject: [PATCH] PR #1644: unscaledcycleclock: remove RISC-V support
5
6Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1644
7
8Starting with Linux 6.6 [1], RDCYCLE is a privileged instruction on RISC-V and can't be used directly from userland. There is a sysctl option to change that as a transition period, but it will eventually disappear.
9
10The RDTIME instruction is another less accurate alternative, however its frequency varies from board to board, and there is currently now way to get its frequency from userland [2].
11
12Therefore this patch just removes the code for unscaledcycleclock on RISC-V. Without processor specific implementation, abseil relies on std::chrono::steady_clock::now().time_since_epoch() which is basically a wrapper around clock_gettime (CLOCK_MONOTONIC), which in turns use __vdso_clock_gettime(). On RISC-V this VDSO is just a wrapper around RDTIME correctly scaled to use nanoseconds units.
13
14This fixes the testsuite on riscv64, tested on a VisionFive 2 board.
15
16[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=cc4c07c89aada16229084eeb93895c95b7eabaa3
17[2] https://github.com/abseil/abseil-cpp/pull/1631
18Merge 43356a2548cfde76e164d446cb69004b488c6a71 into 76f8011beabdaee872b5fde7546e02407b220cb1
19
20Merging this change closes #1644
21
22COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1644 from aurel32:rv64-no-unscaledcycleclock 43356a2548cfde76e164d446cb69004b488c6a71
23PiperOrigin-RevId: 618286262
24Change-Id: Ie4120a727e7d0bb185df6e06ea145c780ebe6652
25
26Upstream-Status: Backport [https://github.com/abseil/abseil-cpp/commit/7335a36d]
27[Adapted to apply on top of meta-oe's patch stack]
28Signed-off-by: Scott Murray <scott.murray@konsulko.com>
29---
30 absl/base/internal/unscaledcycleclock.cc | 12 ------------
31 absl/base/internal/unscaledcycleclock_config.h | 5 ++---
32 2 files changed, 2 insertions(+), 15 deletions(-)
33
34diff --git a/absl/base/internal/unscaledcycleclock.cc b/absl/base/internal/unscaledcycleclock.cc
35index f11fecb3..103b4f6a 100644
36--- a/absl/base/internal/unscaledcycleclock.cc
37+++ b/absl/base/internal/unscaledcycleclock.cc
38@@ -121,18 +121,6 @@ double UnscaledCycleClock::Frequency() {
39 return aarch64_timer_frequency;
40 }
41
42-#elif defined(__riscv)
43-
44-int64_t UnscaledCycleClock::Now() {
45- int64_t virtual_timer_value;
46- asm volatile("rdcycle %0" : "=r"(virtual_timer_value));
47- return virtual_timer_value;
48-}
49-
50-double UnscaledCycleClock::Frequency() {
51- return base_internal::NominalCPUFrequency();
52-}
53-
54 #elif defined(_M_IX86) || defined(_M_X64)
55
56 #pragma intrinsic(__rdtsc)
57diff --git a/absl/base/internal/unscaledcycleclock_config.h b/absl/base/internal/unscaledcycleclock_config.h
58index 5e232c1a..83552fc5 100644
59--- a/absl/base/internal/unscaledcycleclock_config.h
60+++ b/absl/base/internal/unscaledcycleclock_config.h
61@@ -22,7 +22,6 @@
62 // The following platforms have an implementation of a hardware counter.
63 #if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) || \
64 ((defined(__powerpc__) || defined(__ppc__)) && defined(__GLIBC__)) || \
65- defined(__riscv) || \
66 defined(_M_IX86) || (defined(_M_X64) && !defined(_M_ARM64EC))
67 #define ABSL_HAVE_UNSCALED_CYCLECLOCK_IMPLEMENTATION 1
68 #else
69@@ -54,8 +53,8 @@
70 #if ABSL_USE_UNSCALED_CYCLECLOCK
71 // This macro can be used to test if UnscaledCycleClock::Frequency()
72 // is NominalCPUFrequency() on a particular platform.
73-#if (defined(__i386__) || defined(__x86_64__) || defined(__riscv) || \
74- defined(_M_IX86) || defined(_M_X64))
75+#if (defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || \
76+ defined(_M_X64))
77 #define ABSL_INTERNAL_UNSCALED_CYCLECLOCK_FREQUENCY_IS_CPU_FREQUENCY
78 #endif
79 #endif
80--
812.44.0
82
diff --git a/meta-oe/recipes-devtools/abseil-cpp/abseil-cpp_20240116.2.bb b/meta-oe/recipes-devtools/abseil-cpp/abseil-cpp_20240116.2.bb
index 2aef973910..87ab239311 100644
--- a/meta-oe/recipes-devtools/abseil-cpp/abseil-cpp_20240116.2.bb
+++ b/meta-oe/recipes-devtools/abseil-cpp/abseil-cpp_20240116.2.bb
@@ -14,6 +14,7 @@ SRC_URI = "git://github.com/abseil/abseil-cpp;branch=${BRANCH};protocol=https \
14 file://0002-Remove-maes-option-from-cross-compilation.patch \ 14 file://0002-Remove-maes-option-from-cross-compilation.patch \
15 file://abseil-ppc-fixes.patch \ 15 file://abseil-ppc-fixes.patch \
16 file://0003-Remove-neon-option-from-cross-compilation.patch \ 16 file://0003-Remove-neon-option-from-cross-compilation.patch \
17 file://0004-PR-1644-unscaledcycleclock-remove-RISC-V-support.patch \
17 " 18 "
18 19
19S = "${WORKDIR}/git" 20S = "${WORKDIR}/git"