Skip to content

Commit

Permalink
rust: Reorder targets in makefile to make second expansion clearly.
Browse files Browse the repository at this point in the history
.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 <d0u9.su@outlook.com>
  • Loading branch information
d0u9 committed Jun 2, 2021
1 parent 7884043 commit 7b8967f
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions rust/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

0 comments on commit 7b8967f

Please sign in to comment.