From 096aadcd1d6a91213b5305d5001b998d6f688f64 Mon Sep 17 00:00:00 2001 From: ZijianLi Date: Mon, 30 Jun 2025 12:31:42 +0800 Subject: [PATCH] fix cgo enable error on RISCV arch --- prometheus2.spec | 14 +++++++++++++- set-riscv-cgo-enable.patch | 11 +++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 set-riscv-cgo-enable.patch diff --git a/prometheus2.spec b/prometheus2.spec index 45eeb91..5a9d1a9 100644 --- a/prometheus2.spec +++ b/prometheus2.spec @@ -2,7 +2,7 @@ Name: prometheus2 Version: 2.53.3 -Release: 1 +Release: 2 Summary: The Prometheus 2.x monitoring system and time series database. License: Apache-2.0 URL: https://prometheus.io @@ -17,6 +17,7 @@ Source5: prometheus.yml Source6: prometheus.logrotate Patch0: Change-client_golang-dependency-version-to-v1.20.0.patch +Patch1: set-riscv-cgo-enable.patch BuildRequires: systemd BuildRequires: golang @@ -37,12 +38,18 @@ results, and can trigger alerts if some condition is observed to be true. %setup -n prometheus-%{version} tar -xzvf %{SOURCE1} %patch 0 -p1 +%ifarch riscv64 +%patch 1 -p1 +%endif # Compile using the promu installed on the system, not the downloaded one sed -i 's|PROMU[[:space:]]*:=.*$(FIRST_GOPATH)/bin/promu|PROMU := /bin/promu|' Makefile.common %build export GOFLAGS="-mod=vendor -buildmode=pie" export BUILDTAGS="netgo builtinassets" +%ifarch riscv64 +export GOMAXPROCS=1 +%endif make build %install @@ -91,6 +98,11 @@ exit 0 %dir %attr(755, prometheus, prometheus)%{_sharedstatedir}/prometheus %changelog +* Wed Jul 02 2025 ZijianLi - 2.53.3-2 +- Fix cgo enable on RISCV arch + * set cgo enable on RISCV architecture + * On the RISCV architecture, set GOMAXPROCS to 1, otherwise the build will hang. + * Wed Dec 04 2024 jiangxinyu - 2.53.3-1 - Update package to version 2.53.3 * Fix metric name include histogram error diff --git a/set-riscv-cgo-enable.patch b/set-riscv-cgo-enable.patch new file mode 100644 index 0000000..19bb91b --- /dev/null +++ b/set-riscv-cgo-enable.patch @@ -0,0 +1,11 @@ +diff -Naur prometheus-2.53.3.org/.promu.yml prometheus-2.53.3/.promu.yml +--- prometheus-2.53.3.org/.promu.yml 2025-06-29 19:52:07.579569328 +0800 ++++ prometheus-2.53.3/.promu.yml 2025-06-29 22:27:55.798131520 +0800 +@@ -2,6 +2,7 @@ + # Whenever the Go version is updated here, + # .github/workflows should also be updated. + version: 1.22 ++ cgo: true + repository: + path: github.com/prometheus/prometheus + build: -- Gitee