!31 [sync] PR-29: riscv64: 修复rdcycle汇编指令导致的崩溃问题
From: @openeuler-sync-bot Reviewed-by: @sinever Signed-off-by: @sinever
This commit is contained in:
commit
b685e4a0bc
13
04-riscv-distdir_deps.patch
Normal file
13
04-riscv-distdir_deps.patch
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
--- a/distdir_deps.bzl 2024-07-09 14:42:34.465863400 +0800
|
||||||
|
+++ b/distdir_deps.bzl 2024-07-09 15:18:31.432886425 +0800
|
||||||
|
@@ -163,6 +163,10 @@
|
||||||
|
},
|
||||||
|
"com_google_absl": {
|
||||||
|
"archive": "20211102.0.tar.gz",
|
||||||
|
+ "patch_args": ["-p1"],
|
||||||
|
+ "patches": [
|
||||||
|
+ "//third_party:abseil-cpp/abseil-cpp-riscv.patch",
|
||||||
|
+ ],
|
||||||
|
"sha256": "dcf71b9cba8dc0ca9940c4b316a0c796be8fab42b070bb6b7cab62b48f0e66c4",
|
||||||
|
"urls": [
|
||||||
|
"https://mirror.bazel.build/github.com/abseil/abseil-cpp/archive/refs/tags/20211102.0.tar.gz",
|
||||||
76
abseil-cpp-riscv.patch
Normal file
76
abseil-cpp-riscv.patch
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
From 7335a36d0b5c1c597566f9aa3f458a5b6817c3b4 Mon Sep 17 00:00:00 2001
|
||||||
|
From: aurel32 <aurelien@aurel32.net>
|
||||||
|
Date: Fri, 22 Mar 2024 14:21:13 -0700
|
||||||
|
Subject: [PATCH] PR #1644: unscaledcycleclock: remove RISC-V support
|
||||||
|
|
||||||
|
Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1644
|
||||||
|
|
||||||
|
Starting 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.
|
||||||
|
|
||||||
|
The 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].
|
||||||
|
|
||||||
|
Therefore 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.
|
||||||
|
|
||||||
|
This fixes the testsuite on riscv64, tested on a VisionFive 2 board.
|
||||||
|
|
||||||
|
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=cc4c07c89aada16229084eeb93895c95b7eabaa3
|
||||||
|
[2] https://github.com/abseil/abseil-cpp/pull/1631
|
||||||
|
Merge 43356a2548cfde76e164d446cb69004b488c6a71 into 76f8011beabdaee872b5fde7546e02407b220cb1
|
||||||
|
|
||||||
|
Merging this change closes #1644
|
||||||
|
|
||||||
|
COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1644 from aurel32:rv64-no-unscaledcycleclock 43356a2548cfde76e164d446cb69004b488c6a71
|
||||||
|
PiperOrigin-RevId: 618286262
|
||||||
|
Change-Id: Ie4120a727e7d0bb185df6e06ea145c780ebe6652
|
||||||
|
---
|
||||||
|
absl/base/internal/unscaledcycleclock.cc | 12 ------------
|
||||||
|
absl/base/internal/unscaledcycleclock.h | 8 ++++----
|
||||||
|
2 files changed, 4 insertions(+), 16 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/absl/base/internal/unscaledcycleclock.cc b/absl/base/internal/unscaledcycleclock.cc
|
||||||
|
index 05e0e7ba..a0bf3a65 100644
|
||||||
|
--- a/absl/base/internal/unscaledcycleclock.cc
|
||||||
|
+++ b/absl/base/internal/unscaledcycleclock.cc
|
||||||
|
@@ -121,18 +121,6 @@ double UnscaledCycleClock::Frequency() {
|
||||||
|
return aarch64_timer_frequency;
|
||||||
|
}
|
||||||
|
|
||||||
|
-#elif defined(__riscv)
|
||||||
|
-
|
||||||
|
-int64_t UnscaledCycleClock::Now() {
|
||||||
|
- int64_t virtual_timer_value;
|
||||||
|
- asm volatile("rdcycle %0" : "=r"(virtual_timer_value));
|
||||||
|
- return virtual_timer_value;
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-double UnscaledCycleClock::Frequency() {
|
||||||
|
- return base_internal::NominalCPUFrequency();
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
#elif defined(_M_IX86) || defined(_M_X64)
|
||||||
|
|
||||||
|
#pragma intrinsic(__rdtsc)
|
||||||
|
diff --git a/absl/base/internal/unscaledcycleclock.h b/absl/base/internal/unscaledcycleclock.h
|
||||||
|
index 24b324ac..43a3dabe 100644
|
||||||
|
--- a/absl/base/internal/unscaledcycleclock.h
|
||||||
|
+++ b/absl/base/internal/unscaledcycleclock.h
|
||||||
|
@@ -46,7 +46,7 @@
|
||||||
|
|
||||||
|
// The following platforms have an implementation of a hardware counter.
|
||||||
|
#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) || \
|
||||||
|
- defined(__powerpc__) || defined(__ppc__) || defined(__riscv) || \
|
||||||
|
+ defined(__powerpc__) || defined(__ppc__) || \
|
||||||
|
defined(_M_IX86) || defined(_M_X64)
|
||||||
|
#define ABSL_HAVE_UNSCALED_CYCLECLOCK_IMPLEMENTATION 1
|
||||||
|
#else
|
||||||
|
@@ -80,7 +80,7 @@
|
||||||
|
|
||||||
|
// This macro can be used to test if UnscaledCycleClock::Frequency()
|
||||||
|
// is NominalCPUFrequency() on a particular platform.
|
||||||
|
-#if (defined(__i386__) || defined(__x86_64__) || defined(__riscv) || \
|
||||||
|
+#if (defined(__i386__) || defined(__x86_64__) || \
|
||||||
|
defined(_M_IX86) || defined(_M_X64))
|
||||||
|
#define ABSL_INTERNAL_UNSCALED_CYCLECLOCK_FREQUENCY_IS_CPU_FREQUENCY
|
||||||
|
#endif
|
||||||
|
--
|
||||||
|
2.39.2
|
||||||
12
bazel.spec
12
bazel.spec
@ -2,15 +2,17 @@
|
|||||||
|
|
||||||
Name: bazel
|
Name: bazel
|
||||||
Version: 5.3.0
|
Version: 5.3.0
|
||||||
Release: 1
|
Release: 2
|
||||||
Summary: Correct, reproducible, and fast builds for everyone.
|
Summary: Correct, reproducible, and fast builds for everyone.
|
||||||
License: Apache License 2.0
|
License: Apache License 2.0
|
||||||
URL: http://bazel.io/
|
URL: http://bazel.io/
|
||||||
Source0: https://github.com/bazelbuild/bazel/releases/download/%{version}/bazel-%{version}-dist.zip
|
Source0: https://github.com/bazelbuild/bazel/releases/download/%{version}/bazel-%{version}-dist.zip
|
||||||
|
Source1: abseil-cpp-riscv.patch
|
||||||
Patch0: 01-fix-invalid-jni_md-select.patch
|
Patch0: 01-fix-invalid-jni_md-select.patch
|
||||||
Patch1: 02-use-riscv64-jdk.patch
|
Patch1: 02-use-riscv64-jdk.patch
|
||||||
Patch2: 03-set-default-nojdk.patch
|
Patch2: 03-set-default-nojdk.patch
|
||||||
Patch3: linux-bazel-path-from-getauxval.patch
|
Patch3: linux-bazel-path-from-getauxval.patch
|
||||||
|
Patch4: 04-riscv-distdir_deps.patch
|
||||||
# for folks with 'bazel' v1 package installed
|
# for folks with 'bazel' v1 package installed
|
||||||
Conflicts: bazel
|
Conflicts: bazel
|
||||||
Conflicts: bazel2
|
Conflicts: bazel2
|
||||||
@ -33,6 +35,11 @@ Correct, reproducible, and fast builds for everyone.
|
|||||||
#%patch1 -p1
|
#%patch1 -p1
|
||||||
%patch2 -p1
|
%patch2 -p1
|
||||||
%patch3 -p1
|
%patch3 -p1
|
||||||
|
%ifarch riscv64
|
||||||
|
%patch4 -p1
|
||||||
|
mkdir third_party/abseil-cpp
|
||||||
|
cp %{SOURCE1} third_party/abseil-cpp
|
||||||
|
%endif
|
||||||
|
|
||||||
%build
|
%build
|
||||||
find . -type f -regextype posix-extended -iregex '.*(sh|txt|py|_stub|stub_.*|bazel|get_workspace_status|protobuf_support|_so)' -exec %{__sed} -i -e '1s|^#!/usr/bin/env python$|#!/usr/bin/env python3|' "{}" \;
|
find . -type f -regextype posix-extended -iregex '.*(sh|txt|py|_stub|stub_.*|bazel|get_workspace_status|protobuf_support|_so)' -exec %{__sed} -i -e '1s|^#!/usr/bin/env python$|#!/usr/bin/env python3|' "{}" \;
|
||||||
@ -92,6 +99,9 @@ env ./scripts/generate_bash_completion.sh --bazel=output/bazel --output=output/b
|
|||||||
%attr(0755,root,root) %{bashcompdir}/bazel
|
%attr(0755,root,root) %{bashcompdir}/bazel
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Jul 09 2024 laokz <zhangkai@iscas.ac.cn> - 5.3.0-2
|
||||||
|
- riscv64: fix 'rdcycle' SIGILL of dependency abseil-cpp
|
||||||
|
|
||||||
* Tue Sep 12 2023 Jincheng Miao <jincheng.miao@intel.com> - 5.3.0-1
|
* Tue Sep 12 2023 Jincheng Miao <jincheng.miao@intel.com> - 5.3.0-1
|
||||||
- add bazel-%{version}-%{_os}-%{_arch} to install root path
|
- add bazel-%{version}-%{_os}-%{_arch} to install root path
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user