11# SPDX-License-Identifier: GPL-2.0
22
3- obj-$(CONFIG_RUST) += core.o compiler_builtins.o helpers.o
3+ obj-$(CONFIG_RUST) += core.o compiler_builtins.o
44always-$(CONFIG_RUST) += exports_core_generated.h
55
6+ # Missing prototypes are expected in the helpers since these are exported
7+ # for Rust only, thus there is no header nor prototypes.
8+ obj-$(CONFIG_RUST) += helpers.o
9+ CFLAGS_REMOVE_helpers.o = -Wmissing-prototypes
10+
611always-$(CONFIG_RUST) += libmacros.so
712no-clean-files += libmacros.so
813
@@ -200,15 +205,13 @@ bindgen_skip_c_flags := -mno-fp-ret-in-387 -mpreferred-stack-boundary=% \
200205 -mindirect-branch=thunk-extern -mindirect-branch-register -mrecord-mcount \
201206 -mabi=lp64 -mstack-protector-guard% -mtraceback=no \
202207 -mno-pointers-to-nested-functions -mno-string -mno-strict-align \
208+ -mstrict-align \
203209 -fconserve-stack -falign-jumps=% -falign-loops=% \
204210 -femit-struct-debug-baseonly -fno-ipa-cp-clone -fno-ipa-sra \
205211 -fno-partial-inlining -fplugin-arg-arm_ssp_per_task_plugin-% \
206212 -fno-reorder-blocks -fno-allow-store-data-races -fasan-shadow-offset=% \
207- -Wno-packed-not-aligned -Wno-format-truncation -Wno-format-overflow \
208- -Wno-stringop-truncation -Wno-unused-but-set-variable \
209- -Wno-stringop-overflow -Wno-restrict -Wno-maybe-uninitialized \
210- -Werror=designated-init -Wno-zero-length-bounds -Wimplicit-fallthrough=% \
211- -Wno-alloc-size-larger-than -Wcast-function-type \
213+ -fzero-call-used-regs=% -fno-stack-clash-protection \
214+ -fno-inline-functions-called-once \
212215 --param=% --param asan-%
213216
214217# Derived from `scripts/Makefile.clang`
@@ -219,9 +222,11 @@ BINDGEN_TARGET_riscv := riscv64-linux-gnu
219222BINDGEN_TARGET_x86 := x86_64-linux-gnu
220223BINDGEN_TARGET := $(BINDGEN_TARGET_$(SRCARCH ) )
221224
222- bindgen_extra_c_flags = --target=$(BINDGEN_TARGET ) \
223- -Wno-address-of-packed-member \
224- -Wno-gnu-variable-sized-type-not-at-end
225+ # All warnings are inhibited since GCC builds are very experimental,
226+ # many GCC warnings are not supported by Clang, they may only appear in
227+ # some configurations, with new GCC versions, etc.
228+ bindgen_extra_c_flags = -w --target=$(BINDGEN_TARGET )
229+
225230bindgen_c_flags = $(filter-out $(bindgen_skip_c_flags ) , $(c_flags ) ) \
226231 $(bindgen_extra_c_flags )
227232endif
@@ -253,9 +258,11 @@ quiet_cmd_bindgen_helper = BINDGEN $@
253258 --use-core --with-derive-default --ctypes-prefix c_types \
254259 --no-debug '.*' \
255260 --size_t-is-usize -o $@ -- $(bindgen_c_flags_final ) \
256- -I$(objtree ) /rust/ -DMODULE; \
261+ -I$(objtree ) /rust/ -DMODULE $( bindgen_target_cflags ) ; \
257262 sed -Ei 's/pub fn rust_helper_([a-zA-Z0-9_]*)/\# [link_name="rust_helper_\1"]\n pub fn \1/g' $@
258263
264+ # See `CFLAGS_REMOVE_helpers.o` above.
265+ $(objtree ) /rust/bindings_helpers_generated.rs : private bindgen_target_cflags = -Wno-missing-prototypes
259266$(objtree ) /rust/bindings_helpers_generated.rs : $(srctree ) /rust/helpers.c FORCE
260267 $(call if_changed_dep,bindgen_helper)
261268
0 commit comments