Skip to content

Makefile cleanups #562

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

Merged
merged 2 commits into from
Nov 21, 2021
Merged
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
44 changes: 13 additions & 31 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -796,18 +796,6 @@ KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)

ifdef CONFIG_RUST_DEBUG_ASSERTIONS
KBUILD_RUSTFLAGS += -Cdebug-assertions=y
else
KBUILD_RUSTFLAGS += -Cdebug-assertions=n
endif

ifdef CONFIG_RUST_OVERFLOW_CHECKS
KBUILD_RUSTFLAGS += -Coverflow-checks=y
else
KBUILD_RUSTFLAGS += -Coverflow-checks=n
endif

ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE
KBUILD_CFLAGS += -O2
KBUILD_RUSTFLAGS_OPT_LEVEL_MAP := 2
Expand All @@ -819,21 +807,18 @@ KBUILD_CFLAGS += -Os
KBUILD_RUSTFLAGS_OPT_LEVEL_MAP := z
endif

ifdef CONFIG_RUST_OPT_LEVEL_SIMILAR_AS_CHOSEN_FOR_C
KBUILD_RUSTFLAGS += -Copt-level=$(KBUILD_RUSTFLAGS_OPT_LEVEL_MAP)
else ifdef CONFIG_RUST_OPT_LEVEL_0
KBUILD_RUSTFLAGS += -Copt-level=0
else ifdef CONFIG_RUST_OPT_LEVEL_1
KBUILD_RUSTFLAGS += -Copt-level=1
else ifdef CONFIG_RUST_OPT_LEVEL_2
KBUILD_RUSTFLAGS += -Copt-level=2
else ifdef CONFIG_RUST_OPT_LEVEL_3
KBUILD_RUSTFLAGS += -Copt-level=3
else ifdef CONFIG_RUST_OPT_LEVEL_S
KBUILD_RUSTFLAGS += -Copt-level=s
else ifdef CONFIG_RUST_OPT_LEVEL_Z
KBUILD_RUSTFLAGS += -Copt-level=z
endif
# Always set `debug-assertions` and `overflow-checks` because their default
# depends on `opt-level` and `debug-assertions`, respectively.
KBUILD_RUSTFLAGS += -Cdebug-assertions=$(if $(CONFIG_RUST_DEBUG_ASSERTIONS),y,n)
KBUILD_RUSTFLAGS += -Coverflow-checks=$(if $(CONFIG_RUST_OVERFLOW_CHECKS),y,n)
KBUILD_RUSTFLAGS += -Copt-level=$\
$(if $(CONFIG_RUST_OPT_LEVEL_SIMILAR_AS_CHOSEN_FOR_C),$(KBUILD_RUSTFLAGS_OPT_LEVEL_MAP))$\
$(if $(CONFIG_RUST_OPT_LEVEL_0),0)$\
$(if $(CONFIG_RUST_OPT_LEVEL_1),1)$\
$(if $(CONFIG_RUST_OPT_LEVEL_2),2)$\
$(if $(CONFIG_RUST_OPT_LEVEL_3),3)$\
$(if $(CONFIG_RUST_OPT_LEVEL_S),s)$\
$(if $(CONFIG_RUST_OPT_LEVEL_Z),z)

# Tell gcc to never replace conditional load with a non-conditional one
ifdef CONFIG_CC_IS_GCC
Expand Down Expand Up @@ -1172,10 +1157,7 @@ export MODULES_NSDEPS := $(extmod_prefix)modules.nsdeps
ifeq ($(KBUILD_EXTMOD),)
core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/
core-$(CONFIG_BLOCK) += block/

ifdef CONFIG_RUST
core-y += rust/
endif
core-$(CONFIG_RUST) += rust/

vmlinux-dirs := $(patsubst %/,%,$(filter %/, \
$(core-y) $(core-m) $(drivers-y) $(drivers-m) \
Expand Down