Skip to content

Commit aae538c

Browse files
ConchuODpalmer-dabbelt
authored andcommitted
riscv: fix detection of toolchain Zihintpause support
It is not sufficient to check if a toolchain supports a particular extension without checking if the linker supports that extension too. For example, Clang 15 supports Zihintpause but GNU bintutils 2.35.2 does not, leading build errors like so: riscv64-linux-gnu-ld: -march=rv64i2p0_m2p0_a2p0_c2p0_zihintpause2p0: Invalid or unknown z ISA extension: 'zihintpause' Add a TOOLCHAIN_HAS_ZIHINTPAUSE which checks if each of the compiler, assembler and linker support the extension. Replace the ifdef in the vdso with one depending on this new symbol. Fixes: 8eb060e ("arch/riscv: add Zihintpause support") Signed-off-by: Conor Dooley <[email protected]> Reviewed-by: Heiko Stuebner <[email protected]> Reviewed-by: Nathan Chancellor <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent b8c8687 commit aae538c

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

arch/riscv/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,13 @@ config RISCV_ISA_ZICBOM
425425

426426
If you don't know what to do here, say Y.
427427

428+
config TOOLCHAIN_HAS_ZIHINTPAUSE
429+
bool
430+
default y
431+
depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zihintpause)
432+
depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zihintpause)
433+
depends on LLD_VERSION >= 150000 || LD_VERSION >= 23600
434+
428435
config FPU
429436
bool "FPU support"
430437
default y

arch/riscv/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ riscv-march-$(toolchain-need-zicsr-zifencei) := $(riscv-march-y)_zicsr_zifencei
6060
riscv-march-$(CONFIG_TOOLCHAIN_HAS_ZICBOM) := $(riscv-march-y)_zicbom
6161

6262
# Check if the toolchain supports Zihintpause extension
63-
toolchain-supports-zihintpause := $(call cc-option-yn, -march=$(riscv-march-y)_zihintpause)
64-
riscv-march-$(toolchain-supports-zihintpause) := $(riscv-march-y)_zihintpause
63+
riscv-march-$(CONFIG_TOOLCHAIN_HAS_ZIHINTPAUSE) := $(riscv-march-y)_zihintpause
6564

6665
KBUILD_CFLAGS += -march=$(subst fd,,$(riscv-march-y))
6766
KBUILD_AFLAGS += -march=$(riscv-march-y)

arch/riscv/include/asm/vdso/processor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static inline void cpu_relax(void)
2121
* Reduce instruction retirement.
2222
* This assumes the PC changes.
2323
*/
24-
#ifdef __riscv_zihintpause
24+
#ifdef CONFIG_TOOLCHAIN_HAS_ZIHINTPAUSE
2525
__asm__ __volatile__ ("pause");
2626
#else
2727
/* Encoding of the pause instruction */

0 commit comments

Comments
 (0)