[PATCH v2 04/10] riscv: Implement custom CC_CAN_LINK

From: Thomas Weißschuh

Date: Tue Oct 14 2025 - 09:05:53 EST


The generic CC_CAN_LINK detection relies on -m32/-m64 compiler flags.
These are not supported by riscv compilers.

Use architecture-specific logic using -mabi instead.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@xxxxxxxxxxxxx>
---
arch/riscv/Kconfig | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 0c6038dc5dfd529e1fe623f6bc2729a388b33fde..1faf6e6ec87d1417b4e3213ad54053439c87e331 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -25,6 +25,7 @@ config RISCV
select ARCH_ENABLE_SPLIT_PMD_PTLOCK if PGTABLE_LEVELS > 2
select ARCH_ENABLE_THP_MIGRATION if TRANSPARENT_HUGEPAGE
select ARCH_HAS_BINFMT_FLAT
+ select ARCH_HAS_CC_CAN_LINK
select ARCH_HAS_CURRENT_STACK_POINTER
select ARCH_HAS_DEBUG_VIRTUAL if MMU
select ARCH_HAS_DEBUG_VM_PGTABLE
@@ -1335,6 +1336,16 @@ config PORTABLE
config ARCH_PROC_KCORE_TEXT
def_bool y

+config ARCH_CC_CAN_LINK
+ bool
+ default $(cc_can_link_user,-mabi=lp64d) if 64BIT
+ default $(cc_can_link_user,-mabi=ilp32d)
+
+config ARCH_USERFLAGS
+ string
+ default "-mabi=lp64d" if 64BIT
+ default "-mabi=ilp32d"
+
menu "Power management options"

source "kernel/power/Kconfig"

--
2.51.0