|
|
|
|
@ -12,7 +12,7 @@ obj-$(CONFIG_RUST) += helpers/helpers.o
|
|
|
|
|
CFLAGS_REMOVE_helpers/helpers.o = -Wmissing-prototypes -Wmissing-declarations
|
|
|
|
|
|
|
|
|
|
always-$(CONFIG_RUST) += bindings/bindings_generated.rs bindings/bindings_helpers_generated.rs
|
|
|
|
|
obj-$(CONFIG_RUST) += bindings.o kernel.o
|
|
|
|
|
obj-$(CONFIG_RUST) += bindings.o pin_init.o kernel.o
|
|
|
|
|
always-$(CONFIG_RUST) += exports_helpers_generated.h \
|
|
|
|
|
exports_bindings_generated.h exports_kernel_generated.h
|
|
|
|
|
|
|
|
|
|
@ -41,7 +41,10 @@ ifdef CONFIG_RUST
|
|
|
|
|
libmacros_name := $(shell MAKEFLAGS= $(RUSTC) --print file-names --crate-name macros --crate-type proc-macro - </dev/null)
|
|
|
|
|
libmacros_extension := $(patsubst libmacros.%,%,$(libmacros_name))
|
|
|
|
|
|
|
|
|
|
always-$(CONFIG_RUST) += $(libmacros_name)
|
|
|
|
|
libpin_init_internal_name := $(shell MAKEFLAGS= $(RUSTC) --print file-names --crate-name pin_init_internal --crate-type proc-macro - </dev/null)
|
|
|
|
|
libpin_init_internal_extension := $(patsubst libpin_init_internal.%,%,$(libpin_init_internal_name))
|
|
|
|
|
|
|
|
|
|
always-$(CONFIG_RUST) += $(libmacros_name) $(libpin_init_internal_name)
|
|
|
|
|
|
|
|
|
|
# `$(rust_flags)` is passed in case the user added `--sysroot`.
|
|
|
|
|
rustc_sysroot := $(shell MAKEFLAGS= $(RUSTC) $(rust_flags) --print sysroot)
|
|
|
|
|
@ -80,7 +83,7 @@ quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
|
|
|
|
|
# command-like flags to solve the issue. Meanwhile, we use the non-custom case
|
|
|
|
|
# and then retouch the generated files.
|
|
|
|
|
rustdoc: rustdoc-core rustdoc-macros rustdoc-compiler_builtins \
|
|
|
|
|
rustdoc-kernel
|
|
|
|
|
rustdoc-kernel rustdoc-pin_init
|
|
|
|
|
$(Q)cp $(srctree)/Documentation/images/logo.svg $(rustdoc_output)/static.files/
|
|
|
|
|
$(Q)cp $(srctree)/Documentation/images/COPYING-logo $(rustdoc_output)/static.files/
|
|
|
|
|
$(Q)find $(rustdoc_output) -name '*.html' -type f -print0 | xargs -0 sed -Ei \
|
|
|
|
|
@ -110,11 +113,24 @@ rustdoc-compiler_builtins: $(src)/compiler_builtins.rs rustdoc-core FORCE
|
|
|
|
|
rustdoc-ffi: $(src)/ffi.rs rustdoc-core FORCE
|
|
|
|
|
+$(call if_changed,rustdoc)
|
|
|
|
|
|
|
|
|
|
rustdoc-kernel: private rustc_target_flags = --extern ffi \
|
|
|
|
|
rustdoc-pin_init_internal: private rustdoc_host = yes
|
|
|
|
|
rustdoc-pin_init_internal: private rustc_target_flags = --cfg kernel \
|
|
|
|
|
--extern proc_macro --crate-type proc-macro
|
|
|
|
|
rustdoc-pin_init_internal: $(src)/pin-init/internal/src/_lib.rs FORCE
|
|
|
|
|
+$(call if_changed,rustdoc)
|
|
|
|
|
|
|
|
|
|
rustdoc-pin_init: private rustdoc_host = yes
|
|
|
|
|
rustdoc-pin_init: private rustc_target_flags = --extern pin_init_internal \
|
|
|
|
|
--extern macros --extern alloc --cfg kernel --cfg feature=\"alloc\"
|
|
|
|
|
rustdoc-pin_init: $(src)/pin-init/src/_lib.rs rustdoc-pin_init_internal \
|
|
|
|
|
rustdoc-macros FORCE
|
|
|
|
|
+$(call if_changed,rustdoc)
|
|
|
|
|
|
|
|
|
|
rustdoc-kernel: private rustc_target_flags = --extern ffi --extern pin_init \
|
|
|
|
|
--extern build_error --extern macros \
|
|
|
|
|
--extern bindings --extern uapi
|
|
|
|
|
rustdoc-kernel: $(src)/kernel/lib.rs rustdoc-core rustdoc-ffi rustdoc-macros \
|
|
|
|
|
rustdoc-compiler_builtins $(obj)/$(libmacros_name) \
|
|
|
|
|
rustdoc-pin_init rustdoc-compiler_builtins $(obj)/$(libmacros_name) \
|
|
|
|
|
$(obj)/bindings.o FORCE
|
|
|
|
|
+$(call if_changed,rustdoc)
|
|
|
|
|
|
|
|
|
|
@ -139,12 +155,24 @@ rusttestlib-macros: private rustc_test_library_proc = yes
|
|
|
|
|
rusttestlib-macros: $(src)/macros/lib.rs FORCE
|
|
|
|
|
+$(call if_changed,rustc_test_library)
|
|
|
|
|
|
|
|
|
|
rusttestlib-pin_init_internal: private rustc_target_flags = --cfg kernel \
|
|
|
|
|
--extern proc_macro
|
|
|
|
|
rusttestlib-pin_init_internal: private rustc_test_library_proc = yes
|
|
|
|
|
rusttestlib-pin_init_internal: $(src)/pin-init/internal/src/_lib.rs FORCE
|
|
|
|
|
+$(call if_changed,rustc_test_library)
|
|
|
|
|
|
|
|
|
|
rusttestlib-pin_init: private rustc_target_flags = --extern pin_init_internal \
|
|
|
|
|
--extern macros --cfg kernel
|
|
|
|
|
rusttestlib-pin_init: $(src)/pin-init/src/_lib.rs rusttestlib-macros \
|
|
|
|
|
rusttestlib-pin_init_internal $(obj)/$(libpin_init_internal_name) FORCE
|
|
|
|
|
+$(call if_changed,rustc_test_library)
|
|
|
|
|
|
|
|
|
|
rusttestlib-kernel: private rustc_target_flags = --extern ffi \
|
|
|
|
|
--extern build_error --extern macros \
|
|
|
|
|
--extern build_error --extern macros --extern pin_init \
|
|
|
|
|
--extern bindings --extern uapi
|
|
|
|
|
rusttestlib-kernel: $(src)/kernel/lib.rs \
|
|
|
|
|
rusttestlib-bindings rusttestlib-uapi rusttestlib-build_error \
|
|
|
|
|
$(obj)/$(libmacros_name) $(obj)/bindings.o FORCE
|
|
|
|
|
rusttestlib-kernel: $(src)/kernel/lib.rs rusttestlib-bindings rusttestlib-uapi \
|
|
|
|
|
rusttestlib-build_error rusttestlib-pin_init $(obj)/$(libmacros_name) \
|
|
|
|
|
$(obj)/bindings.o FORCE
|
|
|
|
|
+$(call if_changed,rustc_test_library)
|
|
|
|
|
|
|
|
|
|
rusttestlib-bindings: private rustc_target_flags = --extern ffi
|
|
|
|
|
@ -172,8 +200,8 @@ quiet_cmd_rustdoc_test_kernel = RUSTDOC TK $<
|
|
|
|
|
mkdir -p $(objtree)/$(obj)/test/doctests/kernel; \
|
|
|
|
|
OBJTREE=$(abspath $(objtree)) \
|
|
|
|
|
$(RUSTDOC) --test $(rust_flags) \
|
|
|
|
|
-L$(objtree)/$(obj) --extern ffi --extern kernel \
|
|
|
|
|
--extern build_error --extern macros \
|
|
|
|
|
-L$(objtree)/$(obj) --extern ffi --extern pin_init \
|
|
|
|
|
--extern kernel --extern build_error --extern macros \
|
|
|
|
|
--extern bindings --extern uapi \
|
|
|
|
|
--no-run --crate-name kernel -Zunstable-options \
|
|
|
|
|
--sysroot=/dev/null \
|
|
|
|
|
@ -203,18 +231,18 @@ quiet_cmd_rustc_test = $(RUSTC_OR_CLIPPY_QUIET) T $<
|
|
|
|
|
rusttest: rusttest-macros rusttest-kernel
|
|
|
|
|
|
|
|
|
|
rusttest-macros: private rustc_target_flags = --extern proc_macro \
|
|
|
|
|
--extern macros --extern kernel
|
|
|
|
|
--extern macros --extern kernel --extern pin_init
|
|
|
|
|
rusttest-macros: private rustdoc_test_target_flags = --crate-type proc-macro
|
|
|
|
|
rusttest-macros: $(src)/macros/lib.rs \
|
|
|
|
|
rusttestlib-macros rusttestlib-kernel FORCE
|
|
|
|
|
rusttestlib-macros rusttestlib-kernel rusttestlib-pin_init FORCE
|
|
|
|
|
+$(call if_changed,rustc_test)
|
|
|
|
|
+$(call if_changed,rustdoc_test)
|
|
|
|
|
|
|
|
|
|
rusttest-kernel: private rustc_target_flags = --extern ffi \
|
|
|
|
|
rusttest-kernel: private rustc_target_flags = --extern ffi --extern pin_init \
|
|
|
|
|
--extern build_error --extern macros --extern bindings --extern uapi
|
|
|
|
|
rusttest-kernel: $(src)/kernel/lib.rs rusttestlib-ffi rusttestlib-kernel \
|
|
|
|
|
rusttestlib-build_error rusttestlib-macros rusttestlib-bindings \
|
|
|
|
|
rusttestlib-uapi FORCE
|
|
|
|
|
rusttestlib-uapi rusttestlib-pin_init FORCE
|
|
|
|
|
+$(call if_changed,rustc_test)
|
|
|
|
|
|
|
|
|
|
ifdef CONFIG_CC_IS_CLANG
|
|
|
|
|
@ -361,7 +389,7 @@ $(obj)/exports_kernel_generated.h: $(obj)/kernel.o FORCE
|
|
|
|
|
|
|
|
|
|
quiet_cmd_rustc_procmacro = $(RUSTC_OR_CLIPPY_QUIET) P $@
|
|
|
|
|
cmd_rustc_procmacro = \
|
|
|
|
|
$(RUSTC_OR_CLIPPY) $(rust_common_flags) \
|
|
|
|
|
$(RUSTC_OR_CLIPPY) $(rust_common_flags) $(rustc_target_flags) \
|
|
|
|
|
-Clinker-flavor=gcc -Clinker=$(HOSTCC) \
|
|
|
|
|
-Clink-args='$(call escsq,$(KBUILD_PROCMACROLDFLAGS))' \
|
|
|
|
|
--emit=dep-info=$(depfile) --emit=link=$@ --extern proc_macro \
|
|
|
|
|
@ -372,6 +400,10 @@ quiet_cmd_rustc_procmacro = $(RUSTC_OR_CLIPPY_QUIET) P $@
|
|
|
|
|
$(obj)/$(libmacros_name): $(src)/macros/lib.rs FORCE
|
|
|
|
|
+$(call if_changed_dep,rustc_procmacro)
|
|
|
|
|
|
|
|
|
|
$(obj)/$(libpin_init_internal_name): private rustc_target_flags = --cfg kernel
|
|
|
|
|
$(obj)/$(libpin_init_internal_name): $(src)/pin-init/internal/src/_lib.rs FORCE
|
|
|
|
|
+$(call if_changed_dep,rustc_procmacro)
|
|
|
|
|
|
|
|
|
|
quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L $@
|
|
|
|
|
cmd_rustc_library = \
|
|
|
|
|
OBJTREE=$(abspath $(objtree)) \
|
|
|
|
|
@ -451,6 +483,13 @@ $(obj)/compiler_builtins.o: private rustc_objcopy = -w -W '__*'
|
|
|
|
|
$(obj)/compiler_builtins.o: $(src)/compiler_builtins.rs $(obj)/core.o FORCE
|
|
|
|
|
+$(call if_changed_rule,rustc_library)
|
|
|
|
|
|
|
|
|
|
$(obj)/pin_init.o: private skip_gendwarfksyms = 1
|
|
|
|
|
$(obj)/pin_init.o: private rustc_target_flags = --extern pin_init_internal \
|
|
|
|
|
--extern macros --cfg kernel
|
|
|
|
|
$(obj)/pin_init.o: $(src)/pin-init/src/_lib.rs $(obj)/compiler_builtins.o \
|
|
|
|
|
$(obj)/$(libpin_init_internal_name) $(obj)/$(libmacros_name) FORCE
|
|
|
|
|
+$(call if_changed_rule,rustc_library)
|
|
|
|
|
|
|
|
|
|
$(obj)/build_error.o: private skip_gendwarfksyms = 1
|
|
|
|
|
$(obj)/build_error.o: $(src)/build_error.rs $(obj)/compiler_builtins.o FORCE
|
|
|
|
|
+$(call if_changed_rule,rustc_library)
|
|
|
|
|
@ -473,9 +512,9 @@ $(obj)/uapi.o: $(src)/uapi/lib.rs \
|
|
|
|
|
$(obj)/uapi/uapi_generated.rs FORCE
|
|
|
|
|
+$(call if_changed_rule,rustc_library)
|
|
|
|
|
|
|
|
|
|
$(obj)/kernel.o: private rustc_target_flags = --extern ffi \
|
|
|
|
|
$(obj)/kernel.o: private rustc_target_flags = --extern ffi --extern pin_init \
|
|
|
|
|
--extern build_error --extern macros --extern bindings --extern uapi
|
|
|
|
|
$(obj)/kernel.o: $(src)/kernel/lib.rs $(obj)/build_error.o \
|
|
|
|
|
$(obj)/kernel.o: $(src)/kernel/lib.rs $(obj)/build_error.o $(obj)/pin_init.o \
|
|
|
|
|
$(obj)/$(libmacros_name) $(obj)/bindings.o $(obj)/uapi.o FORCE
|
|
|
|
|
+$(call if_changed_rule,rustc_library)
|
|
|
|
|
|
|
|
|
|
|