@@ -6,10 +6,24 @@ rustdoc_output := $(objtree)/Documentation/output/rust/rustdoc
6
6
obj-$(CONFIG_RUST) += core.o compiler_builtins.o
7
7
always-$(CONFIG_RUST) += exports_core_generated.h
8
8
9
- # Missing prototypes are expected in the helpers since these are exported
10
- # for Rust only, thus there is no header nor prototypes.
11
- obj-$(CONFIG_RUST) += helpers.o
12
- CFLAGS_REMOVE_helpers.o = -Wmissing-prototypes -Wmissing-declarations
9
+ RUST_HELPERS := \
10
+ bug \
11
+ build_assert \
12
+ build_bug \
13
+ device \
14
+ err \
15
+ kunit \
16
+ mutex \
17
+ rcu \
18
+ refcount \
19
+ signal \
20
+ spinlock\
21
+ task \
22
+ wait \
23
+ workqueue
24
+
25
+ export RUST_HELPERS
26
+ obj-y += helpers/
13
27
14
28
always-$(CONFIG_RUST) += libmacros.so
15
29
no-clean-files += libmacros.so
@@ -339,6 +353,10 @@ quiet_cmd_bindgen = BINDGEN $@
339
353
-o $@ -- $(bindgen_c_flags_final ) -DMODULE \
340
354
$(bindgen_target_cflags ) $(bindgen_target_extra )
341
355
356
+ quiet_cmd_cat = CAT $@
357
+ cmd_cat = \
358
+ cat $(patsubst % ,$(srctree ) /$(src ) /helpers/% .c, $(RUST_HELPERS ) ) > $@
359
+
342
360
$(obj ) /bindings/bindings_generated.rs : private bindgen_target_flags = \
343
361
$(shell grep -Ev '^# |^$$' $(srctree)/$(src)/bindgen_parameters)
344
362
$(obj ) /bindings/bindings_generated.rs : private bindgen_target_extra = ; \
@@ -353,9 +371,9 @@ $(obj)/uapi/uapi_generated.rs: $(src)/uapi/uapi_helper.h \
353
371
$(src)/bindgen_parameters FORCE
354
372
$(call if_changed_dep,bindgen)
355
373
356
- # See `CFLAGS_REMOVE_helpers.o` above . In addition, Clang on C does not warn
357
- # with `-Wmissing-declarations` (unlike GCC), so it is not strictly needed here
358
- # given it is `libclang`; but for consistency, future Clang changes and/or
374
+ # See `ccflags-remove-y` in helpers/Makefile . In addition, Clang on C does not
375
+ # warn with `-Wmissing-declarations` (unlike GCC), so it is not strictly needed
376
+ # here given it is `libclang`; but for consistency, future Clang changes and/or
359
377
# a potential future GCC backend for `bindgen`, we disable it too.
360
378
$(obj ) /bindings/bindings_helpers_generated.rs : private bindgen_target_flags = \
361
379
--blocklist-type '.*' --allowlist-var '' \
@@ -364,9 +382,13 @@ $(obj)/bindings/bindings_helpers_generated.rs: private bindgen_target_cflags = \
364
382
-I$(objtree)/$(obj) -Wno-missing-prototypes -Wno-missing-declarations
365
383
$(obj ) /bindings/bindings_helpers_generated.rs : private bindgen_target_extra = ; \
366
384
sed -Ei 's/pub fn rust_helper_([a-zA-Z0-9_]*)/# [link_name="rust_helper_\1"]\n pub fn \1/g' $@
367
- $(obj ) /bindings/bindings_helpers_generated.rs : $(src ) /helpers.c FORCE
385
+ $(obj ) /bindings/bindings_helpers_generated.rs : $(obj ) /helpers/helpers_combined .c FORCE
368
386
$(call if_changed_dep,bindgen)
369
387
388
+ targets += helpers/helpers_combined.c
389
+ $(obj ) /helpers/helpers_combined.c : $(patsubst % ,$(src ) /helpers/% .c, $(RUST_HELPERS ) ) FORCE
390
+ $(call if_changed,cat)
391
+
370
392
quiet_cmd_exports = EXPORTS $@
371
393
cmd_exports = \
372
394
$(NM ) -p --defined-only $< \
0 commit comments