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

Update build process to integrate with kernel patches #183

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions hello-world/Kbuild
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
obj-m := helloworld.o
helloworld-objs := hello_world.rust.o

# Don't define these if the kernel we're compiling against already has them.
ifndef CONFIG_RUST
CARGO ?= cargo

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

%.rust.o: target/x86_64-linux-kernel/debug/lib%.a
$(LD) -r -o $@ --whole-archive $<
endif
3 changes: 3 additions & 0 deletions tests/Kbuild
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
obj-m := testmodule.o
testmodule-objs := $(TEST_NAME).rust.o

# Don't define these if the kernel we're compiling against already has them.
ifndef CONFIG_RUST
CARGO ?= cargo

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

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