Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust support build with O= #39

Merged
merged 1 commit into from
Nov 28, 2020
Merged
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ KBUILD_RUSTCFLAGS :=
# TODO: a simple way to update `Cargo.lock` when we add a new driver
KBUILD_CARGOFLAGS := $(CARGO_VERBOSE) --locked \
-Z build-std=core,alloc -Z unstable-options \
--out-dir=out --target=$(PWD)/$(srctree)/arch/$(SRCARCH)/rust/target.json
--target=$(srctree)/arch/$(SRCARCH)/rust/target.json
KBUILD_AFLAGS_KERNEL :=
KBUILD_CFLAGS_KERNEL :=
KBUILD_RUSTCFLAGS_KERNEL :=
Expand Down
10 changes: 5 additions & 5 deletions scripts/Makefile.build
Original file line number Diff line number Diff line change
Expand Up @@ -307,25 +307,25 @@ $(obj)/%.lst: $(src)/%.c FORCE
# ---------------------------------------------------------------------------

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

$(srctree)/include/generated/rust_bindings.rs: FORCE
include/generated/rust_bindings.rs: FORCE
$(Q)$(BINDGEN) $(srctree)/rust/kernel/src/bindings_helper.h \
--opaque-type xregs_state \
--opaque-type desc_struct \
--use-core \
--with-derive-default \
--ctypes-prefix c_types \
--size_t-is-usize \
-o $(srctree)/include/generated/rust_bindings.rs \
-o include/generated/rust_bindings.rs \
-- $(c_flags)

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

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

# Compile assembler sources (.S)
Expand Down
4 changes: 2 additions & 2 deletions scripts/Makefile.lib
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ endif
endif

# TODO: quick hack
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')))
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')))
quiet_modtag = $(if $(part-of-module),[M], )

modkern_cflags = \
Expand Down Expand Up @@ -229,7 +229,7 @@ c_flags = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
RUST_BINDGEN_CFLAGS = $(c_flags) $(KBUILD_CFLAGS_MODULE)
export RUST_BINDGEN_CFLAGS

KCONFIG_RUSTC_CFG ?= $(srctree)/include/generated/rustc_cfg
KCONFIG_RUSTC_CFG ?= ./include/generated/rustc_cfg

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

Expand Down