Skip to content
This repository was archived by the owner on Mar 7, 2021. It is now read-only.

Commit b355d71

Browse files
committed
Kbuild: Always rerun Cargo, trust Cargo to no-op if nothing changed
This helps ensure a rebuild if build.rs, environment variables, Rust version, target, etc. changed, which weren't being picked up by the Make dependencies.
1 parent e56c2af commit b355d71

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

hello-world/Kbuild

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ CARGO ?= cargo
55

66
export c_flags
77

8-
$(src)/target/x86_64-linux-kernel/debug/libhello_world.a: $(src)/Cargo.toml $(wildcard $(src)/src/*.rs)
8+
$(src)/target/x86_64-linux-kernel/debug/libhello_world.a: cargo_will_determine_dependencies
99
cd $(src); $(CARGO) build -Z build-std=core,alloc --target=x86_64-linux-kernel
1010

11+
.PHONY: cargo_will_determine_dependencies
12+
1113
%.rust.o: target/x86_64-linux-kernel/debug/lib%.a
1214
$(LD) -r -o $@ --whole-archive $<

tests/Kbuild

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ CARGO ?= cargo
55

66
export c_flags
77

8-
$(src)/target/x86_64-linux-kernel/debug/lib%.a: $(src)/$(TEST_PATH)/Cargo.toml $(wildcard $(src)/$(TEST_PATH)/src/*.rs)
8+
$(src)/target/x86_64-linux-kernel/debug/lib%.a: cargo_will_determine_dependencies
99
cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) build -Z build-std=core,alloc --target=x86_64-linux-kernel
1010
cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) clippy -Z build-std=core,alloc --target=x86_64-linux-kernel -- -Dwarnings
1111

12+
.PHONY: cargo_will_determine_dependencies
13+
1214
%.rust.o: target/x86_64-linux-kernel/debug/lib%.a
1315
$(LD) -r -o $@ --whole-archive $<

0 commit comments

Comments
 (0)