Skip to content

Commit cfc17fe

Browse files
committed
rust: bindgen: ignore RISC-V extensions for GCC builds
Clang does not recognize some of the new `-march` arguments GCC accepts, and which the kernel uses since commit 6df2a01 ("riscv: fix build with binutils 2.38"), thus `bindgen` fails with a message like: error: invalid arch name 'rv64imac_zicsr_zifencei_zihintpause', unsupported standard user-level extension 'zicsr', err: true The temporary solution is to ignore it -- yet another hack on top of the existing ones for GCC builds. This is needed to update the CI to the new Ubuntu 22.04 base images which come with a newer GCC. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent fcad53c commit cfc17fe

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

rust/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,11 @@ bindgen_skip_c_flags := -mno-fp-ret-in-387 -mpreferred-stack-boundary=% \
278278
-fno-inline-functions-called-once \
279279
--param=% --param asan-%
280280

281+
# Ignore RISC-V extensions that Clang does not recognize.
282+
bindgen_c_flags_patsubst2 = $(patsubst -march=rv%_zihintpause,-march=rv%,$(c_flags))
283+
bindgen_c_flags_patsubst1 = $(patsubst -march=rv%_zicbom,-march=rv%,$(bindgen_c_flags_patsubst2))
284+
bindgen_c_flags_patsubst = $(patsubst -march=rv%_zicsr_zifencei,-march=rv%,$(bindgen_c_flags_patsubst1))
285+
281286
# Derived from `scripts/Makefile.clang`.
282287
BINDGEN_TARGET_arm := arm-linux-gnueabi
283288
BINDGEN_TARGET_arm64 := aarch64-linux-gnu
@@ -291,7 +296,7 @@ BINDGEN_TARGET := $(BINDGEN_TARGET_$(SRCARCH))
291296
# some configurations, with new GCC versions, etc.
292297
bindgen_extra_c_flags = -w --target=$(BINDGEN_TARGET)
293298

294-
bindgen_c_flags = $(filter-out $(bindgen_skip_c_flags), $(c_flags)) \
299+
bindgen_c_flags = $(filter-out $(bindgen_skip_c_flags), $(bindgen_c_flags_patsubst)) \
295300
$(bindgen_extra_c_flags)
296301
endif
297302

0 commit comments

Comments
 (0)