Add riscv64 support
This commit is contained in:
parent
667265f91a
commit
6380cdc963
185
1000-add-riscv64-support-for-crc32-and-procfs.patch
Normal file
185
1000-add-riscv64-support-for-crc32-and-procfs.patch
Normal file
@ -0,0 +1,185 @@
|
||||
From 7d847af2666ca6204d66b253b87019eb961f5812 Mon Sep 17 00:00:00 2001
|
||||
From: misaka00251 <liuxin@iscas.ac.cn>
|
||||
Date: Fri, 1 Sep 2023 16:25:48 +0800
|
||||
Subject: [PATCH] Add riscv64 support for crc32 & procfs
|
||||
|
||||
---
|
||||
.../klauspost/crc32/crc32_generic.go | 2 +-
|
||||
.../github.com/prometheus/procfs/cpuinfo.go | 40 +++++++++++++++++++
|
||||
.../prometheus/procfs/cpuinfo_riscvx.go | 20 ++++++++++
|
||||
.../github.com/prometheus/procfs/cpuinfo.go | 41 +++++++++++++++++++
|
||||
.../prometheus/procfs/cpuinfo_riscvx.go | 20 +++++++++
|
||||
5 files changed, 121 insertions(+), 1 deletion(-)
|
||||
create mode 100644 cmd/vendor/github.com/prometheus/procfs/cpuinfo_riscvx.go
|
||||
create mode 100644 vendor/github.com/prometheus/procfs/cpuinfo_riscvx.go
|
||||
|
||||
diff --git a/cmd/vendor/github.com/klauspost/crc32/crc32_generic.go b/cmd/vendor/github.com/klauspost/crc32/crc32_generic.go
|
||||
index c4d06a2..e2673f5 100644
|
||||
--- a/cmd/vendor/github.com/klauspost/crc32/crc32_generic.go
|
||||
+++ b/cmd/vendor/github.com/klauspost/crc32/crc32_generic.go
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
-// +build 386 arm arm64 ppc64 ppc64le appengine loong64
|
||||
+// +build 386 arm arm64 ppc64 ppc64le appengine loong64 riscv64
|
||||
|
||||
package crc32
|
||||
|
||||
diff --git a/cmd/vendor/github.com/prometheus/procfs/cpuinfo.go b/cmd/vendor/github.com/prometheus/procfs/cpuinfo.go
|
||||
index 2c2a27f..ad9761b 100644
|
||||
--- a/cmd/vendor/github.com/prometheus/procfs/cpuinfo.go
|
||||
+++ b/cmd/vendor/github.com/prometheus/procfs/cpuinfo.go
|
||||
@@ -443,6 +443,46 @@ func parseCPUInfoPPC(info []byte) ([]CPUInfo, error) {
|
||||
return cpuinfo, nil
|
||||
}
|
||||
|
||||
+func parseCPUInfoRISCV(info []byte) ([]CPUInfo, error) {
|
||||
+ scanner := bufio.NewScanner(bytes.NewReader(info))
|
||||
+
|
||||
+ firstLine := firstNonEmptyLine(scanner)
|
||||
+ if !strings.HasPrefix(firstLine, "processor") || !strings.Contains(firstLine, ":") {
|
||||
+ return nil, errors.New("invalid cpuinfo file: " + firstLine)
|
||||
+ }
|
||||
+ field := strings.SplitN(firstLine, ": ", 2)
|
||||
+ v, err := strconv.ParseUint(field[1], 0, 32)
|
||||
+ if err != nil {
|
||||
+ return nil, err
|
||||
+ }
|
||||
+ firstcpu := CPUInfo{Processor: uint(v)}
|
||||
+ cpuinfo := []CPUInfo{firstcpu}
|
||||
+ i := 0
|
||||
+
|
||||
+ for scanner.Scan() {
|
||||
+ line := scanner.Text()
|
||||
+ if !strings.Contains(line, ":") {
|
||||
+ continue
|
||||
+ }
|
||||
+ field := strings.SplitN(line, ": ", 2)
|
||||
+ switch strings.TrimSpace(field[0]) {
|
||||
+ case "processor":
|
||||
+ v, err := strconv.ParseUint(field[1], 0, 32)
|
||||
+ if err != nil {
|
||||
+ return nil, err
|
||||
+ }
|
||||
+ i = int(v)
|
||||
+ cpuinfo = append(cpuinfo, CPUInfo{}) // start of the next processor
|
||||
+ cpuinfo[i].Processor = uint(v)
|
||||
+ case "hart":
|
||||
+ cpuinfo[i].CoreID = field[1]
|
||||
+ case "isa":
|
||||
+ cpuinfo[i].ModelName = field[1]
|
||||
+ }
|
||||
+ }
|
||||
+ return cpuinfo, nil
|
||||
+}
|
||||
+
|
||||
// firstNonEmptyLine advances the scanner to the first non-empty line
|
||||
// and returns the contents of that line
|
||||
func firstNonEmptyLine(scanner *bufio.Scanner) string {
|
||||
diff --git a/cmd/vendor/github.com/prometheus/procfs/cpuinfo_riscvx.go b/cmd/vendor/github.com/prometheus/procfs/cpuinfo_riscvx.go
|
||||
new file mode 100644
|
||||
index 0000000..1c9b731
|
||||
--- /dev/null
|
||||
+++ b/cmd/vendor/github.com/prometheus/procfs/cpuinfo_riscvx.go
|
||||
@@ -0,0 +1,20 @@
|
||||
+// Copyright 2020 The Prometheus Authors
|
||||
+// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
+// you may not use this file except in compliance with the License.
|
||||
+// You may obtain a copy of the License at
|
||||
+//
|
||||
+// http://www.apache.org/licenses/LICENSE-2.0
|
||||
+//
|
||||
+// Unless required by applicable law or agreed to in writing, software
|
||||
+// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
+// See the License for the specific language governing permissions and
|
||||
+// limitations under the License.
|
||||
+
|
||||
+//go:build linux && (riscv || riscv64)
|
||||
+// +build linux
|
||||
+// +build riscv riscv64
|
||||
+
|
||||
+package procfs
|
||||
+
|
||||
+var parseCPUInfo = parseCPUInfoRISCV
|
||||
diff --git a/vendor/github.com/prometheus/procfs/cpuinfo.go b/vendor/github.com/prometheus/procfs/cpuinfo.go
|
||||
index 81db195..abd85d8 100644
|
||||
--- a/vendor/github.com/prometheus/procfs/cpuinfo.go
|
||||
+++ b/vendor/github.com/prometheus/procfs/cpuinfo.go
|
||||
@@ -444,6 +444,46 @@ func parseCPUInfoPPC(info []byte) ([]CPUInfo, error) {
|
||||
return cpuinfo, nil
|
||||
}
|
||||
|
||||
+func parseCPUInfoRISCV(info []byte) ([]CPUInfo, error) {
|
||||
+ scanner := bufio.NewScanner(bytes.NewReader(info))
|
||||
+
|
||||
+ firstLine := firstNonEmptyLine(scanner)
|
||||
+ if !strings.HasPrefix(firstLine, "processor") || !strings.Contains(firstLine, ":") {
|
||||
+ return nil, errors.New("invalid cpuinfo file: " + firstLine)
|
||||
+ }
|
||||
+ field := strings.SplitN(firstLine, ": ", 2)
|
||||
+ v, err := strconv.ParseUint(field[1], 0, 32)
|
||||
+ if err != nil {
|
||||
+ return nil, err
|
||||
+ }
|
||||
+ firstcpu := CPUInfo{Processor: uint(v)}
|
||||
+ cpuinfo := []CPUInfo{firstcpu}
|
||||
+ i := 0
|
||||
+
|
||||
+ for scanner.Scan() {
|
||||
+ line := scanner.Text()
|
||||
+ if !strings.Contains(line, ":") {
|
||||
+ continue
|
||||
+ }
|
||||
+ field := strings.SplitN(line, ": ", 2)
|
||||
+ switch strings.TrimSpace(field[0]) {
|
||||
+ case "processor":
|
||||
+ v, err := strconv.ParseUint(field[1], 0, 32)
|
||||
+ if err != nil {
|
||||
+ return nil, err
|
||||
+ }
|
||||
+ i = int(v)
|
||||
+ cpuinfo = append(cpuinfo, CPUInfo{}) // start of the next processor
|
||||
+ cpuinfo[i].Processor = uint(v)
|
||||
+ case "hart":
|
||||
+ cpuinfo[i].CoreID = field[1]
|
||||
+ case "isa":
|
||||
+ cpuinfo[i].ModelName = field[1]
|
||||
+ }
|
||||
+ }
|
||||
+ return cpuinfo, nil
|
||||
+}
|
||||
+
|
||||
// firstNonEmptyLine advances the scanner to the first non-empty line
|
||||
// and returns the contents of that line
|
||||
func firstNonEmptyLine(scanner *bufio.Scanner) string {
|
||||
diff --git a/vendor/github.com/prometheus/procfs/cpuinfo_riscvx.go b/vendor/github.com/prometheus/procfs/cpuinfo_riscvx.go
|
||||
new file mode 100644
|
||||
index 0000000..1c9b731
|
||||
--- /dev/null
|
||||
+++ b/vendor/github.com/prometheus/procfs/cpuinfo_riscvx.go
|
||||
@@ -0,0 +1,20 @@
|
||||
+// Copyright 2020 The Prometheus Authors
|
||||
+// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
+// you may not use this file except in compliance with the License.
|
||||
+// You may obtain a copy of the License at
|
||||
+//
|
||||
+// http://www.apache.org/licenses/LICENSE-2.0
|
||||
+//
|
||||
+// Unless required by applicable law or agreed to in writing, software
|
||||
+// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
+// See the License for the specific language governing permissions and
|
||||
+// limitations under the License.
|
||||
+
|
||||
+//go:build linux && (riscv || riscv64)
|
||||
+// +build linux
|
||||
+// +build riscv riscv64
|
||||
+
|
||||
+package procfs
|
||||
+
|
||||
+var parseCPUInfo = parseCPUInfoRISCV
|
||||
--
|
||||
2.39.2 (Apple Git-143)
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
Name: cadvisor
|
||||
Version: 0.37.0
|
||||
Release: 4
|
||||
Release: 5
|
||||
Summary: Analyzes resource usage and performance characteristics of running containers.
|
||||
License: ASL 2.0
|
||||
URL: https://github.com/google/cadvisor
|
||||
@ -14,6 +14,7 @@ Source2: sys.tar.gz
|
||||
Patch0: use_preinstalled_go-bindata.patch
|
||||
Patch1: add-parameters-to-solve-the-strip.patch
|
||||
Patch2: Add-loong64-support-for-runc-procfs-and-crc32.patch
|
||||
Patch1000: 1000-add-riscv64-support-for-crc32-and-procfs.patch
|
||||
|
||||
BuildRequires: golang >= 1.13
|
||||
|
||||
@ -41,6 +42,9 @@ rm -rf cmd/vendor/golang.org/x/sys/
|
||||
tar -xf %{SOURCE2} -C vendor/golang.org/x/
|
||||
tar -xf %{SOURCE2} -C cmd/vendor/golang.org/x/
|
||||
%endif
|
||||
%ifarch riscv64
|
||||
%patch1000 -p1
|
||||
%endif
|
||||
|
||||
%build
|
||||
export GOFLAGS="-mod=vendor -buildmode=pie"
|
||||
@ -56,6 +60,9 @@ install -D -m 755 cadvisor %{buildroot}%{_bindir}/cadvisor
|
||||
|
||||
|
||||
%changelog
|
||||
* Thu Aug 31 2023 misaka00251 <liuxin@iscas.ac.cn> - 0.37.0-5
|
||||
- Add riscv64 support
|
||||
|
||||
* Tue Jul 11 2023 huajingyun <huajingyun@loongson.cn> - 0.37.0-4
|
||||
- Add loong64 support
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user