From 11180aa472e82c04b3165aeb0006af970f8bb484 Mon Sep 17 00:00:00 2001 From: psong Date: Mon, 29 Jul 2024 19:45:28 +0800 Subject: [PATCH] fix 'rdcycle' illegal instructor error --- ...aledcycleclock-remove-RISC-V-support.patch | 49 +++++++++++++++++++ autofdo.spec | 14 +++++- 2 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 0002-unscaledcycleclock-remove-RISC-V-support.patch diff --git a/0002-unscaledcycleclock-remove-RISC-V-support.patch b/0002-unscaledcycleclock-remove-RISC-V-support.patch new file mode 100644 index 0000000..f104a2e --- /dev/null +++ b/0002-unscaledcycleclock-remove-RISC-V-support.patch @@ -0,0 +1,49 @@ +diff --git a/third_party/abseil/absl/base/internal/unscaledcycleclock.cc b/third_party/abseil/absl/base/internal/unscaledcycleclock.cc +index 05e0e7b..a0bf3a6 100644 +--- a/third_party/abseil/absl/base/internal/unscaledcycleclock.cc ++++ b/third_party/abseil/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/third_party/abseil/absl/base/internal/unscaledcycleclock_config.h b/third_party/abseil/absl/base/internal/unscaledcycleclock_config.h +index 24b324a..43a3dab 100644 +--- a/third_party/abseil/absl/base/internal/unscaledcycleclock_config.h ++++ b/third_party/abseil/absl/base/internal/unscaledcycleclock_config.h +@@ -21,8 +21,8 @@ + + // 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(_M_IX86) || (defined(_M_X64) && !defined(_M_ARM64EC)) ++ defined(__powerpc__) || defined(__ppc__) || defined(_M_IX86) || \ ++ (defined(_M_X64) && !defined(_M_ARM64EC)) + #define ABSL_HAVE_UNSCALED_CYCLECLOCK_IMPLEMENTATION 1 + #else + #define ABSL_HAVE_UNSCALED_CYCLECLOCK_IMPLEMENTATION 0 +@@ -53,8 +53,8 @@ + #if ABSL_USE_UNSCALED_CYCLECLOCK + // This macro can be used to test if UnscaledCycleClock::Frequency() + // is NominalCPUFrequency() on a particular platform. +-#if (defined(__i386__) || defined(__x86_64__) || defined(__riscv) || \ +- defined(_M_IX86) || defined(_M_X64)) ++#if (defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || \ ++ defined(_M_X64)) + #define ABSL_INTERNAL_UNSCALED_CYCLECLOCK_FREQUENCY_IS_CPU_FREQUENCY + #endif + #endif diff --git a/autofdo.spec b/autofdo.spec index 25ab027..f0a2084 100644 --- a/autofdo.spec +++ b/autofdo.spec @@ -1,6 +1,6 @@ Name: autofdo Version: 0.19 -Release: 3.20231228.git0e296280 +Release: 3.20231228.git0e296280.1 Summary: A tool to convert perf.data profile to AutoFDO profile License: Apache-2.0 URL: https://github.com/google/autofdo @@ -8,15 +8,19 @@ URL: https://github.com/google/autofdo # so remove the GIT information and repackage it. Source0: %{name}-%{version}.tar.xz +Patch0: 0002-unscaledcycleclock-remove-RISC-V-support.patch + BuildRequires: gcc gcc-c++ libtool git cmake elfutils-libelf-devel openssl-devel pkg-config ninja-build gtest libunwind-devel protobuf-devel Requires: glibc openssl-libs elfutils libgcc libstdc++ zlib + + %description This package contains a tool to convert perf.data profile to AutoFDO profile that can be used by GCC and LLVM. %prep -%autosetup +%autosetup -p1 %build cmake -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=. ./ @@ -35,6 +39,12 @@ cp %{_builddir}/%{name}-%{version}/profile_merger ./ %{_bindir}/profile_merger %changelog +* Mon Jul 29 2024 pSomng - 0.19-3.20231228.git0e296280.1 +- Type:update +- ID:NA +- SUG:NA +- DESC: backport absel update for rdcycle + * Fri Dec 22 2023 zhaozhenyu - 0.19-3.20231228.git0e296280 - Type:update - ID:NA -- Gitee