Skip to content

Commit 91ae92b

Browse files
committed
rust: move bindgen arguments to a separate file
Lines starting with `#` are filtered out. It's easier to modify and version control when they're listed by lines in a separate file. This would also allow us to use blocklist or switch to allowlist in the future. Signed-off-by: Gary Guo <[email protected]>
1 parent f53aeb7 commit 91ae92b

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

rust/Makefile

+3-4
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,17 @@ bindgen_c_flags = $(filter-out $(bindgen_skip_c_flags), $(c_flags)) \
8484
$(bindgen_extra_c_flags)
8585
endif
8686

87-
bindgen_opaque_types := xregs_state desc_struct arch_lbr_state local_apic
88-
8987
# To avoid several recompilations in PowerPC, which inserts `-D_TASK_CPU`
9088
bindgen_c_flags_final = $(filter-out -D_TASK_CPU=%, $(bindgen_c_flags))
9189

9290
quiet_cmd_bindgen = BINDGEN $@
9391
cmd_bindgen = \
94-
$(BINDGEN) $< $(addprefix --opaque-type , $(bindgen_opaque_types)) \
92+
$(BINDGEN) $< $(shell grep -v '^\#\|^$$' $(srctree)/rust/bindgen_parameters) \
9593
--use-core --with-derive-default --ctypes-prefix c_types \
9694
--size_t-is-usize -o $@ -- $(bindgen_c_flags_final) -DMODULE
9795

98-
$(objtree)/rust/bindings_generated.rs: $(srctree)/rust/kernel/bindings_helper.h FORCE
96+
$(objtree)/rust/bindings_generated.rs: $(srctree)/rust/kernel/bindings_helper.h \
97+
$(srctree)/rust/bindgen_parameters FORCE
9998
$(call if_changed_dep,bindgen)
10099

101100
quiet_cmd_exports = EXPORTS $@

rust/bindgen_parameters

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
3+
--opaque-type xregs_state
4+
--opaque-type desc_struct
5+
--opaque-type arch_lbr_state
6+
--opaque-type local_apic
7+
8+
# If SMP is disabled, `arch_spinlock_t` is defined as a ZST which triggers a Rust
9+
# warning. We don't need to peek into it anyway.
10+
--opaque-type spinlock

0 commit comments

Comments
 (0)