Add RISC-V support by David Abdurachmanov

This commit is contained in:
Andrew Lukoshko 2025-08-21 15:29:01 +00:00
commit e33eb0e121
2 changed files with 79 additions and 0 deletions

15
config.yaml Normal file
View File

@ -0,0 +1,15 @@
actions:
- modify_release:
- suffix: ".alma.1"
enabled: true
- changelog_entry:
- name: "Andrew Lukoshko"
email: "alukoshko@almalinux.org"
line:
- "Add RISC-V support by David Abdurachmanov <davidlt@rivosinc.com>"
- add_files:
- type: "patch"
name: "0001-Add-support-for-riscv64.patch"
number: 1001

View File

@ -0,0 +1,64 @@
From b42d1b1d3fb5447c2804b56ceb864e2c8b47d54a Mon Sep 17 00:00:00 2001
From: David Abdurachmanov <davidlt@rivosinc.com>
Date: Sun, 20 Apr 2025 05:49:41 +0000
Subject: [PATCH] Add support for riscv64
Signed-off-by: David Abdurachmanov <davidlt@rivosinc.com>
---
Makefile | 11 ++++++++++-
src/stalld.h | 2 +-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index 4585b6c..5d7259c 100644
--- a/Makefile
+++ b/Makefile
@@ -33,6 +33,11 @@ ifeq ($(ARCH),powerpc)
USE_BPF := 0
MTUNE := -mtune=powerpc
endif
+ifeq ($(ARCH),riscv64)
+FCF_PROTECTION := "-fcf-protection=none"
+M64 :=
+MTUNE := -mtune=generic-ooo
+endif
$(info USE_BPF=$(USE_BPF))
$(info FCF_PROTECTION=$(FCF_PROTECTION))
@@ -125,6 +130,10 @@ endif
ifeq ($(ARCH),s390x)
CLANGARCH=-D__s390x__
endif
+ifeq ($(ARCH),riscv64)
+CLANGARCH="-D__riscv"
+CLANGFLAGS="-D__riscv_xlen=64"
+endif
.PHONY: all tests
@@ -145,7 +154,7 @@ bpf/vmlinux.h:
# The .bpf.c needs to be transformed into the .bpf.o.
# The .bpf.o is then required to build the .skel.h.
bpf/stalld.bpf.o: bpf/vmlinux.h bpf/stalld.bpf.c
- @$(CLANG) -g -O2 -target bpf $(CLANGARCH) -D__TARGET_ARCH_$(ARCH) $(INCLUDES) $(CLANG_BPF_SYS_INCLUDES) -c $(filter %.c,$^) -o $@
+ @$(CLANG) -g -O2 -target bpf $(CLANGARCH) $(CLANGFLAGS) -D__TARGET_ARCH_$(ARCH) $(INCLUDES) $(CLANG_BPF_SYS_INCLUDES) -c $(filter %.c,$^) -o $@
@$(LLVM_STRIP) -g $@ # strip useless DWARF info
# This is the second step: The .bpf.o object is translated into
diff --git a/src/stalld.h b/src/stalld.h
index 0c4dcee..8d2f92f 100644
--- a/src/stalld.h
+++ b/src/stalld.h
@@ -121,7 +121,7 @@ struct stalld_backend {
#elif __arm__
# define __NR_sched_setattr 380
# define __NR_sched_getattr 381
-#elif __aarch64__ || __loongarch64
+#elif __aarch64__ || __loongarch64 || __riscv
# define __NR_sched_setattr 274
# define __NR_sched_getattr 275
#elif __powerpc__
--
2.49.0