From 8e7767542cfde43f16c142f05dce06cadb7f7f84 Mon Sep 17 00:00:00 2001 From: sandeepgupta12 Date: Wed, 13 Aug 2025 07:57:46 -0700 Subject: [PATCH] PR #1918: base: add musl + ppc64le fallback for UnscaledCycleClock::Frequency Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1918 Fixes build failures on ppc64le with musl libc, where UnscaledCycleClock::Frequency() had no implementation. This patch adds a fallback for __linux__ + __powerpc64__ when glibc is not present, using a constant 512 MHz timebase frequency. This matches the existing AIX implementation and unblocks projects like Node.js/V8 from building on Alpine Linux (musl). Tested by building Node.js 24.x on ppc64le + musl. Issue- https://github.com/abseil/abseil-cpp/issues/1917 Merge aa7e63a4ffe62cf7787260bdda20d0793bc4ef68 into 274c81389f97afc612d76dc7cb5d38144cd9647f Merging this change closes #1918 COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1918 from sandeepgupta12:master aa7e63a4ffe62cf7787260bdda20d0793bc4ef68 PiperOrigin-RevId: 794579241 Change-Id: I16b9bcb48dc9ff7c1f1fcf9b31ceb5f20dadf3ec --- absl/base/internal/unscaledcycleclock.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/absl/base/internal/unscaledcycleclock.cc b/absl/base/internal/unscaledcycleclock.cc index 68f92730..dca7cbaa 100644 --- a/absl/base/internal/unscaledcycleclock.cc +++ b/absl/base/internal/unscaledcycleclock.cc @@ -85,6 +85,10 @@ int64_t UnscaledCycleClock::Now() { double UnscaledCycleClock::Frequency() { #ifdef __GLIBC__ return __ppc_get_timebase_freq(); +#elif defined(__linux__) + // Fallback for musl + ppc64le: use constant timebase frequency (512 MHz) + // Must come after __GLIBC__. + return static_cast(512000000); #elif defined(_AIX) // This is the same constant value as returned by // __ppc_get_timebase_freq().