Skip to content

Commit

Permalink
riscv: fix detection of toolchain Zicbom support
Browse files Browse the repository at this point in the history
It is not sufficient to check if a toolchain supports a particular
extension without checking if the linker, assembler etc support 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 each of the
compiler, assembler and linker support Zicbom.

Reported-by: Kevin Hilman <khilman@baylibre.com>
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 <conor.dooley@microchip.com>
---
The other extensions with toolchain impact need this too, certainly
Zihintpause does & possibly Zicsr/Zifencei?
  • Loading branch information
ConchuOD committed Oct 5, 2022
1 parent 0ce26a8 commit b2b7cd9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 8 additions & 4 deletions arch/riscv/Kconfig
Expand Up @@ -401,14 +401,18 @@ config RISCV_ISA_SVPBMT

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

config CC_HAS_ZICBOM
config TOOLCHAIN_HAS_ZICBOM
bool
default y if 64BIT && $(cc-option,-mabi=lp64 -march=rv64ima_zicbom)
default y if 32BIT && $(cc-option,-mabi=ilp32 -march=rv32ima_zicbom)
default y
depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zicbom)
depends on !64BIT || $(as-option,-mabi=lp64 -Wa$(comma)-march=rv64ima_zicbom)
depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zicbom)
depends on !32BIT || $(as-option,-mabi=ilp32 -Wa$(comma)-march=rv32ima_zicbom)
depends on LLD_VERSION >= 150000 || LD_VERSION >= 239000

config RISCV_ISA_ZICBOM
bool "Zicbom extension support for non-coherent DMA operation"
depends on CC_HAS_ZICBOM
depends on TOOLCHAIN_HAS_ZICBOM
depends on !XIP_KERNEL && MMU
select RISCV_DMA_NONCOHERENT
select RISCV_ALTERNATIVE
Expand Down
3 changes: 1 addition & 2 deletions arch/riscv/Makefile
Expand Up @@ -57,8 +57,7 @@ toolchain-need-zicsr-zifencei := $(call cc-option-yn, -march=$(riscv-march-y)_zi
riscv-march-$(toolchain-need-zicsr-zifencei) := $(riscv-march-y)_zicsr_zifencei

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

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

0 comments on commit b2b7cd9

Please sign in to comment.