kbuild: remove sed commands after rustc rules
authorMasahiro Yamada <masahiroy@kernel.org>
Sat, 7 Jan 2023 09:18:17 +0000 (18:18 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Sun, 22 Jan 2023 14:43:33 +0000 (23:43 +0900)
rustc may put comments in dep-info, so sed is used to drop them before
passing it to fixdep.

Now that fixdep can remove comments, Makefiles do not need to run sed.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Miguel Ojeda <ojeda@kernel.org>
Tested-by: Miguel Ojeda <ojeda@kernel.org>
Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
rust/Makefile
scripts/Makefile.build
scripts/Makefile.host

index 865afb87bc9b9a80f6d87e93e201cf5ea338e71c..f403b79cae5a04724d12517a8496eb39cc0d8d0a 100644 (file)
@@ -333,8 +333,7 @@ quiet_cmd_rustc_procmacro = $(RUSTC_OR_CLIPPY_QUIET) P $@
        $(RUSTC_OR_CLIPPY) $(rust_common_flags) \
                --emit=dep-info=$(depfile) --emit=link=$@ --extern proc_macro \
                --crate-type proc-macro \
-               --crate-name $(patsubst lib%.so,%,$(notdir $@)) $<; \
-       sed -i '/^\#/d' $(depfile)
+               --crate-name $(patsubst lib%.so,%,$(notdir $@)) $<
 
 # Procedural macros can only be used with the `rustc` that compiled it.
 # Therefore, to get `libmacros.so` automatically recompiled when the compiler
@@ -350,8 +349,7 @@ quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L
                --emit=dep-info=$(depfile) --emit=obj=$@ \
                --emit=metadata=$(dir $@)$(patsubst %.o,lib%.rmeta,$(notdir $@)) \
                --crate-type rlib -L$(objtree)/$(obj) \
-               --crate-name $(patsubst %.o,%,$(notdir $@)) $<; \
-       sed -i '/^\#/d' $(depfile) \
+               --crate-name $(patsubst %.o,%,$(notdir $@)) $< \
        $(if $(rustc_objcopy),;$(OBJCOPY) $(rustc_objcopy) $@)
 
 rust-analyzer:
index 40de20246e504e946ac7e027b73c4e8f445dd40e..76323201232a5402b8918fb4cbc27de20701a766 100644 (file)
@@ -289,9 +289,6 @@ rust_common_cmd = \
        --crate-name $(basename $(notdir $@)) \
        --emit=dep-info=$(depfile)
 
-rust_handle_depfile = \
-       sed -i '/^\#/d' $(depfile)
-
 # `--emit=obj`, `--emit=asm` and `--emit=llvm-ir` imply a single codegen unit
 # will be used. We explicitly request `-Ccodegen-units=1` in any case, and
 # the compiler shows a warning if it is not 1. However, if we ever stop
@@ -301,9 +298,7 @@ rust_handle_depfile = \
 # would not match each other.
 
 quiet_cmd_rustc_o_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@
-      cmd_rustc_o_rs = \
-       $(rust_common_cmd) --emit=obj=$@ $<; \
-       $(rust_handle_depfile)
+      cmd_rustc_o_rs = $(rust_common_cmd) --emit=obj=$@ $<
 
 $(obj)/%.o: $(src)/%.rs FORCE
        $(call if_changed_dep,rustc_o_rs)
@@ -311,24 +306,19 @@ $(obj)/%.o: $(src)/%.rs FORCE
 quiet_cmd_rustc_rsi_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@
       cmd_rustc_rsi_rs = \
        $(rust_common_cmd) -Zunpretty=expanded $< >$@; \
-       command -v $(RUSTFMT) >/dev/null && $(RUSTFMT) $@; \
-       $(rust_handle_depfile)
+       command -v $(RUSTFMT) >/dev/null && $(RUSTFMT) $@
 
 $(obj)/%.rsi: $(src)/%.rs FORCE
        $(call if_changed_dep,rustc_rsi_rs)
 
 quiet_cmd_rustc_s_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@
-      cmd_rustc_s_rs = \
-       $(rust_common_cmd) --emit=asm=$@ $<; \
-       $(rust_handle_depfile)
+      cmd_rustc_s_rs = $(rust_common_cmd) --emit=asm=$@ $<
 
 $(obj)/%.s: $(src)/%.rs FORCE
        $(call if_changed_dep,rustc_s_rs)
 
 quiet_cmd_rustc_ll_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@
-      cmd_rustc_ll_rs = \
-       $(rust_common_cmd) --emit=llvm-ir=$@ $<; \
-       $(rust_handle_depfile)
+      cmd_rustc_ll_rs = $(rust_common_cmd) --emit=llvm-ir=$@ $<
 
 $(obj)/%.ll: $(src)/%.rs FORCE
        $(call if_changed_dep,rustc_ll_rs)
index d812241144d443c0f4883124774e3fa78e537b4d..7aea9005e497001cbf7c61d1085b3b05b11deb7d 100644 (file)
@@ -148,8 +148,7 @@ $(host-cxxobjs): $(obj)/%.o: $(src)/%.cc FORCE
 # host-rust -> Executable
 quiet_cmd_host-rust    = HOSTRUSTC $@
       cmd_host-rust    = \
-       $(HOSTRUSTC) $(hostrust_flags) --emit=link=$@ $<; \
-       sed -i '/^\#/d' $(depfile)
+       $(HOSTRUSTC) $(hostrust_flags) --emit=link=$@ $<
 $(host-rust): $(obj)/%: $(src)/%.rs FORCE
        $(call if_changed_dep,host-rust)