Skip to content

Commit 7b8967f

Browse files
committed
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 <[email protected]>
1 parent 7884043 commit 7b8967f

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

rust/Makefile

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -151,21 +151,11 @@ RUST_LIB_SRC ?= $(rustc_sysroot)/lib/rustlib/src/rust/library
151151
rust-analyzer:
152152
$(Q)$(srctree)/scripts/generate_rust_analyzer.py $(srctree) $(objtree) $(RUST_LIB_SRC) $(objtree)/rust/bindings_generated.rs > $(objtree)/rust-project.json
153153

154-
.SECONDEXPANSION:
155-
$(objtree)/rust/core.o: private skip_clippy = 1
156-
$(objtree)/rust/core.o: $$(RUST_LIB_SRC)/core/src/lib.rs FORCE
157-
$(call if_changed_dep,rustc_library)
158-
159154
$(objtree)/rust/compiler_builtins.o: private rustc_objcopy = -w -W '__*'
160155
$(objtree)/rust/compiler_builtins.o: $(srctree)/rust/compiler_builtins.rs \
161156
$(objtree)/rust/core.o FORCE
162157
$(call if_changed_dep,rustc_library)
163158

164-
$(objtree)/rust/alloc.o: private skip_clippy = 1
165-
$(objtree)/rust/alloc.o: $$(RUST_LIB_SRC)/alloc/src/lib.rs \
166-
$(objtree)/rust/compiler_builtins.o FORCE
167-
$(call if_changed_dep,rustc_library)
168-
169159
$(objtree)/rust/build_error.o: $(srctree)/rust/build_error.rs \
170160
$(objtree)/rust/compiler_builtins.o FORCE
171161
$(call if_changed_dep,rustc_library)
@@ -178,3 +168,14 @@ $(objtree)/rust/kernel.o: $(srctree)/rust/kernel/lib.rs $(objtree)/rust/alloc.o
178168
$(objtree)/rust/build_error.o \
179169
$(objtree)/rust/libmacros.so $(objtree)/rust/bindings_generated.rs FORCE
180170
$(call if_changed_dep,rustc_library)
171+
172+
# Targets that need to expand twice
173+
.SECONDEXPANSION:
174+
$(objtree)/rust/core.o: private skip_clippy = 1
175+
$(objtree)/rust/core.o: $$(RUST_LIB_SRC)/core/src/lib.rs FORCE
176+
$(call if_changed_dep,rustc_library)
177+
178+
$(objtree)/rust/alloc.o: private skip_clippy = 1
179+
$(objtree)/rust/alloc.o: $$(RUST_LIB_SRC)/alloc/src/lib.rs \
180+
$(objtree)/rust/compiler_builtins.o FORCE
181+
$(call if_changed_dep,rustc_library)

0 commit comments

Comments
 (0)