Extract `pin_init{,_internal}-{cfgs,flags}` to reduce duplication.
Acked-by: Benno Lossin <lossin@kernel.org>
Signed-off-by: Tamir Duberstein <tamird@kernel.org>
---
rust/Makefile | 30 +++++++++++++++++++++---------
1 file changed, 21 insertions(+), 9 deletions(-)
diff --git a/rust/Makefile b/rust/Makefile
index 5d357dce1704..280a18617627 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -210,16 +210,30 @@ rustdoc-ffi: private is-kernel-object := y
rustdoc-ffi: $(src)/ffi.rs rustdoc-core FORCE
+$(call if_changed,rustdoc)
+pin_init_internal-cfgs := \
+ kernel
+
+pin_init_internal-flags := \
+ $(call cfgs-to-flags,$(pin_init_internal-cfgs))
+
rustdoc-pin_init_internal: private rustdoc_host = yes
-rustdoc-pin_init_internal: private rustc_target_flags = --cfg kernel \
+rustdoc-pin_init_internal: private rustc_target_flags = $(pin_init_internal-flags) \
--extern proc_macro --crate-type proc-macro
rustdoc-pin_init_internal: $(src)/pin-init/internal/src/lib.rs \
rustdoc-clean FORCE
+$(call if_changed,rustdoc)
+pin_init-cfgs := \
+ kernel
+
+pin_init-flags := \
+ --extern pin_init_internal \
+ --extern macros \
+ $(call cfgs-to-flags,$(pin_init-cfgs))
+
rustdoc-pin_init: private rustdoc_host = yes
-rustdoc-pin_init: private rustc_target_flags = --extern pin_init_internal \
- --extern macros --extern alloc --cfg kernel --cfg feature=\"alloc\"
+rustdoc-pin_init: private rustc_target_flags = $(pin_init-flags) \
+ --extern alloc --cfg feature=\"alloc\"
rustdoc-pin_init: $(src)/pin-init/src/lib.rs rustdoc-pin_init_internal \
rustdoc-macros FORCE
+$(call if_changed,rustdoc)
@@ -272,14 +286,13 @@ rusttestlib-macros: $(src)/macros/lib.rs \
rusttestlib-proc_macro2 rusttestlib-quote rusttestlib-syn FORCE
+$(call if_changed,rustc_test_library)
-rusttestlib-pin_init_internal: private rustc_target_flags = --cfg kernel \
+rusttestlib-pin_init_internal: private rustc_target_flags = $(pin_init_internal-flags) \
--extern proc_macro
rusttestlib-pin_init_internal: private rustc_test_library_proc = yes
rusttestlib-pin_init_internal: $(src)/pin-init/internal/src/lib.rs FORCE
+$(call if_changed,rustc_test_library)
-rusttestlib-pin_init: private rustc_target_flags = --extern pin_init_internal \
- --extern macros --cfg kernel
+rusttestlib-pin_init: private rustc_target_flags = $(pin_init-flags)
rusttestlib-pin_init: $(src)/pin-init/src/lib.rs rusttestlib-macros \
rusttestlib-pin_init_internal $(obj)/$(libpin_init_internal_name) FORCE
+$(call if_changed,rustc_test_library)
@@ -547,7 +560,7 @@ $(obj)/$(libmacros_name): $(src)/macros/lib.rs $(obj)/libproc_macro2.rlib \
$(obj)/libquote.rlib $(obj)/libsyn.rlib FORCE
+$(call if_changed_dep,rustc_procmacro)
-$(obj)/$(libpin_init_internal_name): private rustc_target_flags = --cfg kernel
+$(obj)/$(libpin_init_internal_name): private rustc_target_flags = $(pin_init_internal-flags)
$(obj)/$(libpin_init_internal_name): $(src)/pin-init/internal/src/lib.rs FORCE
+$(call if_changed_dep,rustc_procmacro)
@@ -642,8 +655,7 @@ $(obj)/compiler_builtins.o: $(src)/compiler_builtins.rs $(obj)/core.o FORCE
+$(call if_changed_rule,rustc_library)
$(obj)/pin_init.o: private skip_gendwarfksyms = 1
-$(obj)/pin_init.o: private rustc_target_flags = --extern pin_init_internal \
- --extern macros --cfg kernel
+$(obj)/pin_init.o: private rustc_target_flags = $(pin_init-flags)
$(obj)/pin_init.o: $(src)/pin-init/src/lib.rs $(obj)/compiler_builtins.o \
$(obj)/$(libpin_init_internal_name) $(obj)/$(libmacros_name) FORCE
+$(call if_changed_rule,rustc_library)
--
2.52.0
On Tue, Jan 27, 2026 at 2:55 PM Tamir Duberstein <tamird@kernel.org> wrote:
>
> Extract `pin_init{,_internal}-{cfgs,flags}` to reduce duplication.
>
> Acked-by: Benno Lossin <lossin@kernel.org>
> Signed-off-by: Tamir Duberstein <tamird@kernel.org>
Applied to `rust-next` -- thanks everyone!
I rebased and things changed a fair bit since now we have a few
`--extern`s more -- Tamir, please double-check that things will still
work with your future rust-analyzer patch on top!
[ The new variables will be used later on to easily pass them to
the `scripts/generate_rust_analyzer.py` script. - Miguel ]
[ Rebased. Moved new variables above. Reworded title. - Miguel ]
Cheers,
Miguel
On Thu, Jan 29, 2026 at 11:43 PM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> On Tue, Jan 27, 2026 at 2:55 PM Tamir Duberstein <tamird@kernel.org> wrote:
> >
> > Extract `pin_init{,_internal}-{cfgs,flags}` to reduce duplication.
> >
> > Acked-by: Benno Lossin <lossin@kernel.org>
> > Signed-off-by: Tamir Duberstein <tamird@kernel.org>
>
> Applied to `rust-next` -- thanks everyone!
>
> I rebased and things changed a fair bit since now we have a few
> `--extern`s more -- Tamir, please double-check that things will still
> work with your future rust-analyzer patch on top!
Looks good.
> [ The new variables will be used later on to easily pass them to
> the `scripts/generate_rust_analyzer.py` script. - Miguel ]
>
> [ Rebased. Moved new variables above. Reworded title. - Miguel ]
>
> Cheers,
> Miguel
Thanks Miguel!
© 2016 - 2026 Red Hat, Inc.