From 7b8967f3d3cc02170a4611d966258b006d49f0a7 Mon Sep 17 00:00:00 2001 From: d0u9 Date: Tue, 1 Jun 2021 14:42:08 +0800 Subject: [PATCH] rust: Reorder targets in makefile to make second expansion clearly. .SECONDEXPANSION directive instructs targets AFTER it to expand twice. According to GNU make manual, the special target .SECONDEXPANSION must be defined before the first prerequisite list that makes use of this feature. For Rust's makefile, only sources from rust lib requires second expansion. Move those targets to the end of makefile and tag only them as .SECONDEXPANSION to prevent from error-prone bugs. Signed-off-by: d0u9 --- rust/Makefile | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/rust/Makefile b/rust/Makefile index 2738a1f2f9c616..3d8c54b808d744 100644 --- a/rust/Makefile +++ b/rust/Makefile @@ -151,21 +151,11 @@ RUST_LIB_SRC ?= $(rustc_sysroot)/lib/rustlib/src/rust/library rust-analyzer: $(Q)$(srctree)/scripts/generate_rust_analyzer.py $(srctree) $(objtree) $(RUST_LIB_SRC) $(objtree)/rust/bindings_generated.rs > $(objtree)/rust-project.json -.SECONDEXPANSION: -$(objtree)/rust/core.o: private skip_clippy = 1 -$(objtree)/rust/core.o: $$(RUST_LIB_SRC)/core/src/lib.rs FORCE - $(call if_changed_dep,rustc_library) - $(objtree)/rust/compiler_builtins.o: private rustc_objcopy = -w -W '__*' $(objtree)/rust/compiler_builtins.o: $(srctree)/rust/compiler_builtins.rs \ $(objtree)/rust/core.o FORCE $(call if_changed_dep,rustc_library) -$(objtree)/rust/alloc.o: private skip_clippy = 1 -$(objtree)/rust/alloc.o: $$(RUST_LIB_SRC)/alloc/src/lib.rs \ - $(objtree)/rust/compiler_builtins.o FORCE - $(call if_changed_dep,rustc_library) - $(objtree)/rust/build_error.o: $(srctree)/rust/build_error.rs \ $(objtree)/rust/compiler_builtins.o FORCE $(call if_changed_dep,rustc_library) @@ -178,3 +168,14 @@ $(objtree)/rust/kernel.o: $(srctree)/rust/kernel/lib.rs $(objtree)/rust/alloc.o $(objtree)/rust/build_error.o \ $(objtree)/rust/libmacros.so $(objtree)/rust/bindings_generated.rs FORCE $(call if_changed_dep,rustc_library) + +# Targets that need to expand twice +.SECONDEXPANSION: +$(objtree)/rust/core.o: private skip_clippy = 1 +$(objtree)/rust/core.o: $$(RUST_LIB_SRC)/core/src/lib.rs FORCE + $(call if_changed_dep,rustc_library) + +$(objtree)/rust/alloc.o: private skip_clippy = 1 +$(objtree)/rust/alloc.o: $$(RUST_LIB_SRC)/alloc/src/lib.rs \ + $(objtree)/rust/compiler_builtins.o FORCE + $(call if_changed_dep,rustc_library)