Skip to content

Commit

Permalink
Merge pull request torvalds#665 from ojeda/missing-declarations
Browse files Browse the repository at this point in the history
rust: helpers: avoid `-Wmissing-declarations` in `W=1` builds
  • Loading branch information
ojeda authored Feb 8, 2022
2 parents d66bb6b + 60f0f3c commit eb2238d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions rust/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ always-$(CONFIG_RUST) += exports_core_generated.h
# Missing prototypes are expected in the helpers since these are exported
# for Rust only, thus there is no header nor prototypes.
obj-$(CONFIG_RUST) += helpers.o
CFLAGS_REMOVE_helpers.o = -Wmissing-prototypes
CFLAGS_REMOVE_helpers.o = -Wmissing-prototypes -Wmissing-declarations

always-$(CONFIG_RUST) += libmacros.so
no-clean-files += libmacros.so
Expand Down Expand Up @@ -269,11 +269,14 @@ $(objtree)/rust/bindings_generated.rs: $(srctree)/rust/kernel/bindings_helper.h
$(srctree)/rust/bindgen_parameters FORCE
$(call if_changed_dep,bindgen)

# See `CFLAGS_REMOVE_helpers.o` above for `-Wno-missing-prototypes`.
# See `CFLAGS_REMOVE_helpers.o` above. In addition, Clang on C does not warn
# with `-Wmissing-declarations` (unlike GCC), so it is not strictly needed here
# given it is `libclang`; but for consistency, future Clang changes and/or
# a potential future GCC backend for `bindgen`, we disable it too.
$(objtree)/rust/bindings_helpers_generated.rs: private bindgen_target_flags = \
--blacklist-type '.*' --whitelist-var '' --whitelist-function 'rust_helper_.*'
$(objtree)/rust/bindings_helpers_generated.rs: private bindgen_target_cflags = \
-I$(objtree)/rust/ -Wno-missing-prototypes
-I$(objtree)/rust/ -Wno-missing-prototypes -Wno-missing-declarations
$(objtree)/rust/bindings_helpers_generated.rs: private bindgen_target_extra = ; \
sed -Ei 's/pub fn rust_helper_([a-zA-Z0-9_]*)/#[link_name="rust_helper_\1"]\n pub fn \1/g' $@
$(objtree)/rust/bindings_helpers_generated.rs: $(srctree)/rust/helpers.c FORCE
Expand Down

0 comments on commit eb2238d

Please sign in to comment.