Skip to content

Commit

Permalink
rust: Enable incremental compilation
Browse files Browse the repository at this point in the history
Signed-off-by: Asahi Lina <lina@asahilina.net>
  • Loading branch information
asahilina committed Jan 20, 2023
1 parent 01133fd commit 6cb6d0b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ endif

export KBUILD_CHECKSRC

# Enable Rust incremental compilation.
#
# Use 'make RUST_INCREMENTAL=1' to enable it.
ifeq ("$(origin RUST_INCREMENTAL)", "command line")
KBUILD_RUST_INCREMENTAL := $(RUST_INCREMENTAL)
endif

# Enable "clippy" (a linter) as part of the Rust compilation.
#
# Use 'make CLIPPY=1' to enable it.
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/asahi/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# SPDX-License-Identifier: GPL-2.0

obj-$(CONFIG_DRM_ASAHI) += asahi.o
obj-$(CONFIG_DRM_ASAHI) += asahi.a
10 changes: 10 additions & 0 deletions scripts/Makefile.build
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ rust_allowed_features := allocator_api,array_from_fn,bench_black_box,core_ffi_c,

rust_common_cmd = \
RUST_MODFILE=$(modfile) $(RUSTC_OR_CLIPPY) $(rust_flags) \
$(if $(RUST_INCREMENTAL),-Cincremental=$(obj)/rust_incremental,) \
-Zallow-features=$(rust_allowed_features) \
-Zcrate-attr=no_std \
-Zcrate-attr='feature($(rust_allowed_features))' \
Expand Down Expand Up @@ -306,6 +307,15 @@ quiet_cmd_rustc_o_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@
$(obj)/%.o: $(src)/%.rs FORCE
$(call if_changed_dep,rustc_o_rs)

quiet_cmd_rustc_a_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@
cmd_rustc_a_rs = \
$(rust_common_cmd) --emit=dep-info,link -Ccodegen-units=32 $<; \
mv $(dir $@)/$(patsubst %.a,lib%.rlib,$(notdir $@)) $@; \
$(rust_handle_depfile)

$(obj)/%.a: $(src)/%.rs FORCE
$(call if_changed_dep,rustc_a_rs)

quiet_cmd_rustc_rsi_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@
cmd_rustc_rsi_rs = \
$(rust_common_cmd) --emit=dep-info -Zunpretty=expanded $< >$@; \
Expand Down
1 change: 1 addition & 0 deletions scripts/mod/modpost.c
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,7 @@ static const char *const section_white_list[] =
".fmt_slot*", /* EZchip */
".gnu.lto*",
".discard.*",
".rmeta",
NULL
};

Expand Down

0 comments on commit 6cb6d0b

Please sign in to comment.