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

Commit

Permalink
Kbuild: Always rerun Cargo, trust Cargo to no-op if nothing changed
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
geofft committed Aug 15, 2020
1 parent e56c2af commit b355d71
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion hello-world/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ CARGO ?= cargo

export c_flags

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

.PHONY: cargo_will_determine_dependencies

%.rust.o: target/x86_64-linux-kernel/debug/lib%.a
$(LD) -r -o $@ --whole-archive $<
4 changes: 3 additions & 1 deletion tests/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ CARGO ?= cargo

export c_flags

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

.PHONY: cargo_will_determine_dependencies

%.rust.o: target/x86_64-linux-kernel/debug/lib%.a
$(LD) -r -o $@ --whole-archive $<

0 comments on commit b355d71

Please sign in to comment.