rust: kbuild: emit dep-info into $(depfile) directly
Gary Guo
reviewerPATCH 1/1 rust: kbuild: emit dep-info into $(depfile) directly
After commit 295d8398c67e ("kbuild: specify output names separately for each emission type from rustc"), the preferred pattern is to ask rustc to emit depedency information into $(depfile) directly, and after commit 2185242faddd ("kbuild: remove sed commands after rustc rules"), the post-processing to remove comments is no longer necessary as fixdep can handle comments directly. Thus, emit dep-ifno into $(depfile) directly and remove the mv and sed invocation.
This fixes the issue where a non-ignored .d file is emitted during compilation and removed shortly afterwards.
--- rust/Makefile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
rust/Makefile +2 -4
@@ -526,11 +526,9 @@ quiet_cmd_rustc_procmacrolibrary = $(RUSTC_OR_CLIPPY_QUIET) PL $@ cmd_rustc_procmacrolibrary = \ $(if $(skip_clippy),$(RUSTC),$(RUSTC_OR_CLIPPY)) \ $(filter-out $(skip_flags),$(rust_common_flags) $(rustc_target_flags)) \ - --emit=dep-info,link --crate-type rlib -O \ + --emit=dep-info=$(depfile) --emit=link=$@ --crate-type rlib -O \ --out-dir $(objtree)/$(obj) -L$(objtree)/$(obj) \ - --crate-name $(patsubst lib%.rlib,%,$(notdir $@)) $<; \ - mv $(objtree)/$(obj)/$(patsubst lib%.rlib,%,$(notdir $@)).d $(depfile); \ - sed -i '/^\#/d' $(depfile) + --crate-name $(patsubst lib%.rlib,%,$(notdir $@)) $< $(obj)/libproc_macro2.rlib: private skip_clippy = 1 $(obj)/libproc_macro2.rlib: private rustc_target_flags = $(proc_macro2-flags)
Signature · 1 line
2.51.2
Quoted 41 lines · On Tue, 24 Feb 2026 15:29:56 +0800 Gary Guo <[email protected]> wrote:
After commit
295d8398c67e("kbuild: specify output names separately for each emission type from rustc"), the preferred pattern is to ask rustc to emit depedency information into $(depfile) directly, and after commit2185242faddd("kbuild: remove sed commands after rustc rules"), the post-processing to remove comments is no longer necessary as fixdep can handle comments directly. Thus, emit dep-ifno into $(depfile) directly and remove the mv and sed invocation.This fixes the issue where a non-ignored .d file is emitted during compilation and removed shortly afterwards.
Reported-by Onur Özkan <[email protected]>Fixes 7dbe46c0b11d ("rust: kbuild: add proc macro library support")Signed-off-by Gary Guo <[email protected]> ---rust/Makefile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)rust/Makefile +2
-6@@ -526,11 +526,9 @@ quiet_cmd_rustc_procmacrolibrary = $(RUSTC_OR_CLIPPY_QUIET) PL $@ cmd_rustc_procmacrolibrary = \ $(if $(skip_clippy),$(RUSTC),$(RUSTC_OR_CLIPPY)) \ $(filter-out $(skip_flags),$(rust_common_flags) $(rustc_target_flags)) \ - --emit=dep-info,link --crate-type rlib -O \ + --emit=dep-info=$(depfile) --emit=link=$@ --crate-type rlib -O \ --out-dir $(objtree)/$(obj) -L$(objtree)/$(obj) \ - --crate-name $(patsubst lib%.rlib,%,$(notdir $@)) $<; \ - mv $(objtree)/$(obj)/$(patsubst lib%.rlib,%,$(notdir $@)).d $(depfile); \ - sed -i '/^\#/d' $(depfile) + --crate-name $(patsubst lib%.rlib,%,$(notdir $@)) $< $(obj)/libproc_macro2.rlib: private skip_clippy = 1 $(obj)/libproc_macro2.rlib: private rustc_target_flags =
Quoted 1 line
$(proc_macro2-flags)
Miguel Ojeda
AppliedQuoted 9 lines · Gary Guo
After commit
295d8398c67e("kbuild: specify output names separately for each emission type from rustc"), the preferred pattern is to ask rustc to emit depedency information into $(depfile) directly, and after commit2185242faddd("kbuild: remove sed commands after rustc rules"), the post-processing to remove comments is no longer necessary as fixdep can handle comments directly. Thus, emit dep-ifno into $(depfile) directly and remove the mv and sed invocation.
Quoted 7 lines
This fixes the issue where a non-ignored .d file is emitted during compilation and removed shortly afterwards.
Reported-by Onur Özkan <[email protected]>Fixes 7dbe46c0b11d ("rust: kbuild: add proc macro library support")Signed-off-by Gary Guo <[email protected]>
Applied to rust-fixes -- thanks everyone!
[ Like Gary mentioned in Zulip, this likely happened due to rebasing
the builds part of the old syn work I had. - Miguel ]
[ Reworded for a couple of typos. - Miguel ]
Also Cc: [email protected]
Cheers,
Miguel