Skip to content

Commit b8c8687

Browse files
ConchuODpalmer-dabbelt
authored andcommitted
riscv: fix detection of toolchain Zicbom 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 Zicbom but GNU bintutils 2.35.2 does not, leading build errors like so: riscv64-linux-gnu-ld: -march=rv64i2p0_m2p0_a2p0_c2p0_zicbom1p0_zihintpause2p0: Invalid or unknown z ISA extension: 'zicbom' Convert CC_HAS_ZICBOM to TOOLCHAIN_HAS_ZICBOM & check if the linker also supports Zicbom. Reported-by: Kevin Hilman <[email protected]> Link: ClangBuiltLinux#1714 Link: https://storage.kernelci.org/next/master/next-20220920/riscv/defconfig+CONFIG_EFI=n/clang-16/logs/kernel.log Fixes: 1631ba1 ("riscv: Add support for non-coherent devices using zicbom extension") 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] [Palmer: Check for ld-2.38, not 2.39, as 2.38 no longer errors.] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 568035b commit b8c8687

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

arch/riscv/Kconfig

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,14 +401,16 @@ config RISCV_ISA_SVPBMT
401401

402402
If you don't know what to do here, say Y.
403403

404-
config CC_HAS_ZICBOM
404+
config TOOLCHAIN_HAS_ZICBOM
405405
bool
406-
default y if 64BIT && $(cc-option,-mabi=lp64 -march=rv64ima_zicbom)
407-
default y if 32BIT && $(cc-option,-mabi=ilp32 -march=rv32ima_zicbom)
406+
default y
407+
depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zicbom)
408+
depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zicbom)
409+
depends on LLD_VERSION >= 150000 || LD_VERSION >= 23800
408410

409411
config RISCV_ISA_ZICBOM
410412
bool "Zicbom extension support for non-coherent DMA operation"
411-
depends on CC_HAS_ZICBOM
413+
depends on TOOLCHAIN_HAS_ZICBOM
412414
depends on !XIP_KERNEL && MMU
413415
select RISCV_DMA_NONCOHERENT
414416
select RISCV_ALTERNATIVE

arch/riscv/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ toolchain-need-zicsr-zifencei := $(call cc-option-yn, -march=$(riscv-march-y)_zi
5757
riscv-march-$(toolchain-need-zicsr-zifencei) := $(riscv-march-y)_zicsr_zifencei
5858

5959
# Check if the toolchain supports Zicbom extension
60-
toolchain-supports-zicbom := $(call cc-option-yn, -march=$(riscv-march-y)_zicbom)
61-
riscv-march-$(toolchain-supports-zicbom) := $(riscv-march-y)_zicbom
60+
riscv-march-$(CONFIG_TOOLCHAIN_HAS_ZICBOM) := $(riscv-march-y)_zicbom
6261

6362
# Check if the toolchain supports Zihintpause extension
6463
toolchain-supports-zihintpause := $(call cc-option-yn, -march=$(riscv-march-y)_zihintpause)

0 commit comments

Comments
 (0)