Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ jobs:
name: 'aarch64'
- runner: ubuntu-latest
name: 'x86_64'
# via https://riseproject-dev.github.io/riscv-runner/
- runner: ubuntu-24.04-riscv
name: 'riscv'
- runner: macos-latest
name: 'macos (aarch64)'
- runner: macos-15-intel
Expand Down Expand Up @@ -68,6 +71,9 @@ jobs:
name: 'aarch64'
- runner: ubuntu-latest
name: 'x86_64'
# via https://riseproject-dev.github.io/riscv-runner/
- runner: ubuntu-24.04-riscv
name: 'riscv'
acvp-version: [v1.1.0.39, v1.1.0.40, v1.1.0.41]
exclude:
- {external: true,
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ ifeq ($(ARCH),x86_64)
else ifeq ($(ARCH),aarch64)
@echo "=== AArch64 Feature Support ==="
@echo "SHA3: Host $(if $(filter 1,$(MK_HOST_SUPPORTS_SHA3)),✅,❌) Compiler $(if $(filter 1,$(MK_COMPILER_SUPPORTS_SHA3)),✅,❌)"
else ifeq ($(ARCH),riscv64)
@echo "=== RISC-V 64-bit Feature Support ==="
@echo "RVV: Host $(if $(filter 1,$(MK_HOST_SUPPORTS_RVV)),✅,❌) Compiler $(if $(filter 1,$(MK_COMPILER_SUPPORTS_RVV)),✅,❌)"
else
@echo "=== Architecture Not Supported ==="
@echo "No specific feature detection available for $(ARCH)"
Expand Down
31 changes: 31 additions & 0 deletions test/mk/auto.mk
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ MK_COMPILER_SUPPORTS_SHA3 ?= $(shell echo 'int main() { __asm__("eor3 v0.16b, v1

endif # aarch64 compiler detection

# RISC-V 64-bit compiler feature detection
ifeq ($(ARCH),riscv64)

# Test RVV support using C with inline assembly
MK_COMPILER_SUPPORTS_RVV ?= $(shell echo 'int main() { __asm__("vadd.vv v0, v1, v2"); return 0; }' | $(CC) -march=rv64gcv -x c - -c -o /dev/null 2>/dev/null && echo 1 || echo 0)

endif # riscv64 compiler detection

# Define HOST_PLATFORM if not already defined
HOST_PLATFORM ?= $(shell uname -s)-$(shell uname -m)

Expand Down Expand Up @@ -124,6 +132,25 @@ endif # HOST_PLATFORM aarch64

endif # aarch64

# RISC-V 64-bit architecture detection
ifeq ($(ARCH),riscv64)

# Host CPU feature detection for RISC-V 64-bit
ifeq ($(HOST_PLATFORM),Linux-riscv64)
# Linux: Parse ISA string from /proc/cpuinfo
# Format: rv64imafdcv_sscofpmf_... -- extract single-letter extensions
# (before first '_') and check for 'v'
MK_HOST_SUPPORTS_RVV := $(shell sed -n '/^isa/{s/.*rv64//;s/_.*//;p;q}' /proc/cpuinfo 2>/dev/null | grep -q v && echo 1 || echo 0)
else ifneq ($(CROSS_PREFIX),)
# Cross-compilation: assume all features are supported
MK_HOST_SUPPORTS_RVV := 1
else
# Other platforms: assume no support
MK_HOST_SUPPORTS_RVV := 0
endif # HOST_PLATFORM riscv64

endif # riscv64

# Only apply CFLAGS modifications if AUTO=1
ifeq ($(AUTO),1)

Expand Down Expand Up @@ -159,7 +186,11 @@ endif # aarch64_be
# RISC-V 64-bit CFLAGS configuration
ifeq ($(ARCH),riscv64)
CFLAGS += -DMLK_FORCE_RISCV64

# Add RVV flags only if both compiler and host support it
ifeq ($(MK_COMPILER_SUPPORTS_RVV)$(MK_HOST_SUPPORTS_RVV),11)
CFLAGS += -march=rv64gcv
endif
endif # riscv64

# RISC-V 32-bit CFLAGS configuration
Expand Down
Loading