Skip to content

Commit d92de44

Browse files
authored
Merge pull request #895 from ojeda/riscv
rust: bindgen: ignore RISC-V extensions for GCC builds
2 parents fcad53c + cfc17fe commit d92de44

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)