Skip to content

Commit d0c9974

Browse files
committed
rust support build with O=
Signed-off-by: Finn Behrens <me@kloenk.de>
1 parent 62d4aaa commit d0c9974

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ KBUILD_RUSTCFLAGS :=
513513
# TODO: a simple way to update `Cargo.lock` when we add a new driver
514514
KBUILD_CARGOFLAGS := $(CARGO_VERBOSE) --locked \
515515
-Z build-std=core,alloc -Z unstable-options \
516-
--out-dir=out --target=$(PWD)/$(srctree)/arch/$(SRCARCH)/rust/target.json
516+
--target=$(srctree)/arch/$(SRCARCH)/rust/target.json
517517
KBUILD_AFLAGS_KERNEL :=
518518
KBUILD_CFLAGS_KERNEL :=
519519
KBUILD_RUSTCFLAGS_KERNEL :=

scripts/Makefile.build

+5-5
Original file line numberDiff line numberDiff line change
@@ -307,25 +307,25 @@ $(obj)/%.lst: $(src)/%.c FORCE
307307
# ---------------------------------------------------------------------------
308308

309309
quiet_cmd_cargo = CARGO $(quiet_modtag) $@
310-
cmd_cargo = export RUST_BINDINGS_FILE=$(shell readlink -f $(srctree)/include/generated/rust_bindings.rs) && cd $(src) && $(CARGO) build $(cargo_flags)
310+
cmd_cargo = export RUST_BINDINGS_FILE=$(shell readlink -f $(KCONFIG_RUSTC_CFG)) && $(CARGO) build --manifest-path $(srctree)/$(src)/Cargo.toml --out-dir $(src) $(cargo_flags)
311311

312-
$(srctree)/include/generated/rust_bindings.rs: FORCE
312+
include/generated/rust_bindings.rs: FORCE
313313
$(Q)$(BINDGEN) $(srctree)/rust/kernel/src/bindings_helper.h \
314314
--opaque-type xregs_state \
315315
--opaque-type desc_struct \
316316
--use-core \
317317
--with-derive-default \
318318
--ctypes-prefix c_types \
319319
--size_t-is-usize \
320-
-o $(srctree)/include/generated/rust_bindings.rs \
320+
-o $(KCONFIG_RUSTC_CFG) \
321321
-- $(c_flags)
322322

323323
# The .o from the Rust staticlib
324-
$(obj)/%.o: $(src)/out/lib%.a
324+
$(obj)/%.o: $(src)/lib%.a
325325
$(Q)$(LD) -r -o $@ --whole-archive $<
326326

327327
# The Rust staticlib from cargo
328-
$(obj)/out/lib%.a: $(srctree)/include/generated/rust_bindings.rs FORCE
328+
$(obj)/lib%.a: include/generated/rust_bindings.rs FORCE
329329
$(call cmd,cargo)
330330

331331
# Compile assembler sources (.S)

scripts/Makefile.lib

+2-2
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ endif
196196
endif
197197

198198
# TODO: quick hack
199-
part-of-module = $(if $(filter $(basename $@).o,$(real-obj-m)),y,$(and $(real-obj-m),$(shell echo $@ | sed -E 's!.+/out/lib.+\.a!y!;t;d')))
199+
part-of-module = $(if $(filter $(basename $@).o,$(real-obj-m)),y,$(and $(real-obj-m),$(shell echo $@ | sed -E 's!.+/lib.+\.a!y!;t;d')))
200200
quiet_modtag = $(if $(part-of-module),[M], )
201201

202202
modkern_cflags = \
@@ -229,7 +229,7 @@ c_flags = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
229229
RUST_BINDGEN_CFLAGS = $(c_flags) $(KBUILD_CFLAGS_MODULE)
230230
export RUST_BINDGEN_CFLAGS
231231

232-
KCONFIG_RUSTC_CFG ?= $(srctree)/include/generated/rustc_cfg
232+
KCONFIG_RUSTC_CFG ?= ./include/generated/rustc_cfg
233233

234234
rustc_flags = $(_rustc_flags) $(modkern_rustcflags) @$(shell readlink -f $(KCONFIG_RUSTC_CFG))
235235

0 commit comments

Comments
 (0)