Lines Matching +full:test +full:- +full:docs

1 # SPDX-License-Identifier: GPL-2.0
6 obj-$(CONFIG_RUST) += core.o compiler_builtins.o ffi.o
7 always-$(CONFIG_RUST) += exports_core_generated.h
11 obj-$(CONFIG_RUST) += helpers/helpers.o
12 CFLAGS_REMOVE_helpers/helpers.o = -Wmissing-prototypes -Wmissing-declarations
14 always-$(CONFIG_RUST) += bindings/bindings_generated.rs bindings/bindings_helpers_generated.rs
15 obj-$(CONFIG_RUST) += bindings.o pin_init.o kernel.o
16 always-$(CONFIG_RUST) += exports_helpers_generated.h \
19 always-$(CONFIG_RUST) += uapi/uapi_generated.rs
20 obj-$(CONFIG_RUST) += uapi.o
23 obj-$(CONFIG_RUST) += build_error.o
25 always-$(CONFIG_RUST) += build_error.o
28 obj-$(CONFIG_RUST) += exports.o
30 always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated.rs
31 always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated_kunit.c
33 obj-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated.o
34 obj-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated_kunit.o
36 always-$(subst y,$(CONFIG_RUST),$(CONFIG_JUMP_LABEL)) += kernel/generated_arch_static_branch_asm.rs
38 always-$(subst y,$(CONFIG_RUST),$(CONFIG_BUG)) += kernel/generated_arch_warn_asm.rs kernel/generate…
44 …bmacros_name := $(shell MAKEFLAGS= $(RUSTC) --print file-names --crate-name macros --crate-type pr…
47 …al_name := $(shell MAKEFLAGS= $(RUSTC) --print file-names --crate-name pin_init_internal --crate-t…
50 always-$(CONFIG_RUST) += $(libmacros_name) $(libpin_init_internal_name)
52 # `$(rust_flags)` is passed in case the user added `--sysroot`.
53 rustc_sysroot := $(shell MAKEFLAGS= $(RUSTC) $(rust_flags) --print sysroot)
54 rustc_host_target := $(shell $(RUSTC) --version --verbose | grep -F 'host: ' | cut -d' ' -f2)
58 rust_test_quiet=-q
59 rustdoc_test_quiet=--test-args -q
63 core-cfgs = \
64 --cfg no_fp_fmt_parse
66 core-edition := $(if $(call rustc-min-version,108700),2024,2021)
69 # the time being (https://github.com/rust-lang/rust/issues/144521).
70 rustdoc_modifiers_workaround := $(if $(call rustc-min-version,108800),-Cunsafe-allow-abi-mismatch=f…
72 # Similarly, for doctests (https://github.com/rust-lang/rust/issues/146465).
73 doctests_modifiers_workaround := $(rustdoc_modifiers_workaround)$(if $(call rustc-min-version,10910…
75 # `rustc` recognizes `--remap-path-prefix` since 1.26.0, but `rustdoc` only
76 # since Rust 1.81.0. Moreover, `rustdoc` ICEs on out-of-tree builds since Rust
77 # 1.82.0 (https://github.com/rust-lang/rust/issues/138520). Thus workaround both
82 …$(RUSTDOC) $(filter-out $(skip_flags) --remap-path-prefix=%,$(if $(rustdoc_host),$(rust_common_fla…
83 $(rustc_target_flags) -L$(objtree)/$(obj) \
84 -Zunstable-options --generate-link-to-definition \
85 --output $(rustdoc_output) \
86 --crate-name $(subst rustdoc-,,$@) \
88 $(if $(rustdoc_host),,--sysroot=/dev/null) \
93 # - The given value is used as-is, thus it cannot be relative or a local file
94 # (unlike the non-custom case) since the generated docs have subfolders.
95 # - It requires adding it to every crate.
96 # - It requires changing `core` which comes from the sysroot.
98 # Using `-Zcrate-attr` would solve the last two points, but not the first.
99 # The https://github.com/rust-lang/rfcs/pull/3226 RFC suggests two new
100 # command-like flags to solve the issue. Meanwhile, we use the non-custom case
102 rustdoc: rustdoc-core rustdoc-macros rustdoc-compiler_builtins \
103 rustdoc-kernel rustdoc-pin_init
104 $(Q)grep -Ehro '<a href="srctree/([^"]+)"' $(rustdoc_output) | \
105 cut -d'"' -f2 | cut -d/ -f2- | while read f; do \
106 if [ ! -e "$(srctree)/$$f" ]; then \
111 $(Q)cp $(srctree)/Documentation/images/COPYING-logo $(rustdoc_output)/static.files/
112 $(Q)find $(rustdoc_output) -name '*.html' -type f -print0 | xargs -0 sed -Ei \
113 -e 's:rust-logo-[0-9a-f]+\.svg:logo.svg:g' \
114 -e 's:favicon-[0-9a-f]+\.svg:logo.svg:g' \
115-e 's:<link rel="alternate icon" type="image/png" href="[/.]+/static\.files/favicon-(16x16|32x32)-
116 -e 's:<a href="srctree/([^"]+)">:<a href="$(realpath $(srctree))/\1">:g'
117 $(Q)for f in $(rustdoc_output)/static.files/rustdoc-*.css; do \
118 echo ".logo-container > img { object-fit: contain; }" >> $$f; done
120 rustdoc-macros: private rustdoc_host = yes
121 rustdoc-macros: private rustc_target_flags = --crate-type proc-macro \
122 --extern proc_macro
123 rustdoc-macros: $(src)/macros/lib.rs rustdoc-clean FORCE
126 # Starting with Rust 1.82.0, skipping `-Wrustdoc::unescaped_backticks` should
127 # not be needed -- see https://github.com/rust-lang/rust/pull/128307.
128 rustdoc-core: private skip_flags = --edition=2021 -Wrustdoc::unescaped_backticks
129 rustdoc-core: private rustc_target_flags = --edition=$(core-edition) $(core-cfgs)
130 rustdoc-core: $(RUST_LIB_SRC)/core/src/lib.rs rustdoc-clean FORCE
136 rustdoc-compiler_builtins: private is-kernel-object := y
137 rustdoc-compiler_builtins: $(src)/compiler_builtins.rs rustdoc-core FORCE
140 rustdoc-ffi: private is-kernel-object := y
141 rustdoc-ffi: $(src)/ffi.rs rustdoc-core FORCE
144 rustdoc-pin_init_internal: private rustdoc_host = yes
145 rustdoc-pin_init_internal: private rustc_target_flags = --cfg kernel \
146 --extern proc_macro --crate-type proc-macro
147 rustdoc-pin_init_internal: $(src)/pin-init/internal/src/lib.rs \
148 rustdoc-clean FORCE
151 rustdoc-pin_init: private rustdoc_host = yes
152 rustdoc-pin_init: private rustc_target_flags = --extern pin_init_internal \
153 --extern macros --extern alloc --cfg kernel --cfg feature=\"alloc\"
154 rustdoc-pin_init: $(src)/pin-init/src/lib.rs rustdoc-pin_init_internal \
155 rustdoc-macros FORCE
158 rustdoc-kernel: private is-kernel-object := y
159 rustdoc-kernel: private rustc_target_flags = --extern ffi --extern pin_init \
160 --extern build_error --extern macros \
161 --extern bindings --extern uapi
162 rustdoc-kernel: $(src)/kernel/lib.rs rustdoc-core rustdoc-ffi rustdoc-macros \
163 rustdoc-pin_init rustdoc-compiler_builtins $(obj)/$(libmacros_name) \
167 rustdoc-clean: FORCE
168 $(Q)rm -rf $(rustdoc_output)
175 --crate-type $(if $(rustc_test_library_proc),proc-macro,rlib) \
176 --out-dir $(objtree)/$(obj)/test --cfg testlib \
177 -L$(objtree)/$(obj)/test \
178 --crate-name $(subst rusttest-,,$(subst rusttestlib-,,$@)) $<
180 rusttestlib-build_error: $(src)/build_error.rs FORCE
183 rusttestlib-ffi: $(src)/ffi.rs FORCE
186 rusttestlib-macros: private rustc_target_flags = --extern proc_macro
187 rusttestlib-macros: private rustc_test_library_proc = yes
188 rusttestlib-macros: $(src)/macros/lib.rs FORCE
191 rusttestlib-pin_init_internal: private rustc_target_flags = --cfg kernel \
192 --extern proc_macro
193 rusttestlib-pin_init_internal: private rustc_test_library_proc = yes
194 rusttestlib-pin_init_internal: $(src)/pin-init/internal/src/lib.rs FORCE
197 rusttestlib-pin_init: private rustc_target_flags = --extern pin_init_internal \
198 --extern macros --cfg kernel
199 rusttestlib-pin_init: $(src)/pin-init/src/lib.rs rusttestlib-macros \
200 rusttestlib-pin_init_internal $(obj)/$(libpin_init_internal_name) FORCE
203 rusttestlib-kernel: private rustc_target_flags = --extern ffi \
204 --extern build_error --extern macros --extern pin_init \
205 --extern bindings --extern uapi
206 rusttestlib-kernel: $(src)/kernel/lib.rs rusttestlib-bindings rusttestlib-uapi \
207 rusttestlib-build_error rusttestlib-pin_init $(obj)/$(libmacros_name) \
211 rusttestlib-bindings: private rustc_target_flags = --extern ffi --extern pin_init
212 rusttestlib-bindings: $(src)/bindings/lib.rs rusttestlib-ffi rusttestlib-pin_init FORCE
215 rusttestlib-uapi: private rustc_target_flags = --extern ffi --extern pin_init
216 rusttestlib-uapi: $(src)/uapi/lib.rs rusttestlib-ffi rusttestlib-pin_init FORCE
221 RUST_MODFILE=test.rs \
223 $(RUSTDOC) --test $(rust_common_flags) \
224 -Zcrate-attr='feature(used_with_arg)' \
228 -L$(objtree)/$(obj)/test --output $(rustdoc_output) \
229 --crate-name $(subst rusttest-,,$@) $<
233 rm -rf $(objtree)/$(obj)/test/doctests/kernel; \
234 mkdir -p $(objtree)/$(obj)/test/doctests/kernel; \
236 $(RUSTDOC) --test $(filter-out --remap-path-prefix=%,$(rust_flags)) \
237 -L$(objtree)/$(obj) --extern ffi --extern pin_init \
238 --extern kernel --extern build_error --extern macros \
239 --extern bindings --extern uapi \
240 --no-run --crate-name kernel -Zunstable-options \
241 --sysroot=/dev/null \
243 --test-builder $(objtree)/scripts/rustdoc_test_builder \
253 # We cannot use `-Zpanic-abort-tests` because some tests are dynamic,
254 # so for the moment we skip `-Cpanic=abort`.
258 $(RUSTC_OR_CLIPPY) --test $(rust_common_flags) \
260 $(rustc_target_flags) --out-dir $(objtree)/$(obj)/test \
261 -L$(objtree)/$(obj)/test \
262 --crate-name $(subst rusttest-,,$@) $<; \
263 $(objtree)/$(obj)/test/$(subst rusttest-,,$@) $(rust_test_quiet) \
266 rusttest: rusttest-macros
268 rusttest-macros: private rustc_target_flags = --extern proc_macro \
269 --extern macros --extern kernel --extern pin_init
270 rusttest-macros: private rustdoc_test_target_flags = --crate-type proc-macro
271 rusttest-macros: $(src)/macros/lib.rs \
272 rusttestlib-macros rusttestlib-kernel rusttestlib-pin_init FORCE
285 bindgen_skip_c_flags := -mno-fp-ret-in-387 -mpreferred-stack-boundary=% \
286 -mskip-rax-setup -mgeneral-regs-only -msign-return-address=% \
287 -mindirect-branch=thunk-extern -mindirect-branch-register \
288 -mfunction-return=thunk-extern -mrecord-mcount -mabi=lp64 \
289 -mindirect-branch-cs-prefix -mstack-protector-guard% -mtraceback=no \
290 -mno-pointers-to-nested-functions -mno-string \
291 -mno-strict-align -mstrict-align -mdirect-extern-access \
292 -mexplicit-relocs -mno-check-zero-division \
293 -fconserve-stack -falign-jumps=% -falign-loops=% \
294 -femit-struct-debug-baseonly -fno-ipa-cp-clone -fno-ipa-sra \
295 -fno-partial-inlining -fplugin-arg-arm_ssp_per_task_plugin-% \
296 -fno-reorder-blocks -fno-allow-store-data-races -fasan-shadow-offset=% \
297 -fzero-call-used-regs=% -fno-stack-clash-protection \
298 -fno-inline-functions-called-once -fsanitize=bounds-strict \
299 -fstrict-flex-arrays=% -fmin-function-alignment=% \
300 -fzero-init-padding-bits=% -mno-fdpic \
301 --param=% --param asan-% -fno-isolate-erroneous-paths-dereference
304 BINDGEN_TARGET_x86 := x86_64-linux-gnu
305 BINDGEN_TARGET_arm64 := aarch64-linux-gnu
306 BINDGEN_TARGET_arm := arm-linux-gnueabi
307 BINDGEN_TARGET_loongarch := loongarch64-linux-gnusf
314 bindgen_extra_c_flags = -w --target=$(BINDGEN_TARGET)
316 # Auto variable zero-initialization requires an additional special option with
318 # clang-18), so make sure to pass this option only if clang supports it
321 # https://github.com/llvm/llvm-project/issues/44842
322 # https://github.com/llvm/llvm-project/blob/llvmorg-16.0.0-rc2/clang/docs/ReleaseNotes.rst#deprecat…
324 …tree)/scripts/rust_is_available_bindgen_libclang.h 2>&1 | sed -ne 's/.*clang version \([0-9]*\).*/…
326 bindgen_extra_c_flags += -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
330 bindgen_c_flags = $(filter-out $(bindgen_skip_c_flags), $(c_flags)) \
335 bindgen_c_flags_lto = $(filter-out $(CC_FLAGS_LTO), $(bindgen_c_flags))
340 # `-fno-builtin` is passed to avoid `bindgen` from using `clang` builtin
341 # prototypes for functions like `memcpy` -- if this flag is not passed,
342 # `bindgen`-generated prototypes use `c_ulong` or `c_uint` depending on
344 bindgen_c_flags_final = $(bindgen_c_flags_lto) -fno-builtin -D__BINDGEN__
348 # a `--rust-target` to avoid future `bindgen` releases emitting code that
355 # is, if we do not test the actual `rustc`/`bindgen` versions running).
361 $(BINDGEN) $< $(bindgen_target_flags) --rust-target 1.68 \
362 --use-core --with-derive-default --ctypes-prefix ffi --no-layout-tests \
363 --no-debug '.*' --enable-function-attribute-detection \
364 -o $@ -- $(bindgen_c_flags_final) -DMODULE \
368 $(shell grep -Ev '^#|^$$' $(src)/bindgen_parameters)
370 sed -Ei 's/pub const RUST_CONST_HELPER_([a-zA-Z0-9_]*)/pub const \1/g' $@
376 $(shell grep -Ev '^#|^$$' $(src)/bindgen_parameters)
382 # with `-Wmissing-declarations` (unlike GCC), so it is not strictly needed here
386 --blocklist-type '.*' --allowlist-var '' \
387 --allowlist-function 'rust_helper_.*'
389 -I$(objtree)/$(obj) -Wno-missing-prototypes -Wno-missing-declarations
391 sed -Ei 's/pub fn rust_helper_([a-zA-Z0-9_]*)/#[link_name="rust_helper_\1"]\n pub fn \1/g' $@
395 rust_exports = $(NM) -p --defined-only $(1) | awk '$$2~/(T|R|D|B)/ && $$3!~/__(pfx|cfi|odr_asan)/ {…
407 # in the crate where they are defined. Other helpers, called from non-inline
409 # compiler does not guarantee codegen will be performed for a non-inline
425 -Clinker-flavor=gcc -Clinker=$(HOSTCC) \
426 -Clink-args='$(call escsq,$(KBUILD_PROCMACROLDFLAGS))' \
427 --emit=dep-info=$(depfile) --emit=link=$@ --extern proc_macro \
428 --crate-type proc-macro \
429 --crate-name $(patsubst lib%.$(libmacros_extension),%,$(notdir $@)) \
436 $(obj)/$(libpin_init_internal_name): private rustc_target_flags = --cfg kernel
437 $(obj)/$(libpin_init_internal_name): $(src)/pin-init/internal/src/lib.rs FORCE
444 $(filter-out $(skip_flags),$(rust_flags)) $(rustc_target_flags) \
445 --emit=dep-info=$(depfile) --emit=obj=$@ \
446 --emit=metadata=$(dir $@)$(patsubst %.o,lib%.rmeta,$(notdir $@)) \
447 --crate-type rlib -L$(objtree)/$(obj) \
448 --crate-name $(patsubst %.o,%,$(notdir $@)) $< \
449 --sysroot=/dev/null \
453 rust-analyzer:
455 --cfgs='core=$(core-cfgs)' $(core-edition) \
458 > rust-project.json
460 redirect-intrinsics = \
467 # Add eabi initrinsics for ARM 32-bit
468 redirect-intrinsics += \
475 redirect-intrinsics += \
484 $(if $(KBUILD_GENDWARFKSYMS_STABLE), --stable) \
485 $(if $(KBUILD_SYMTYPES), --symtypes $(@:.o=.symtypes),) \
486 $@ >> $(dot-target).cmd)
511 $(obj)/core.o: private skip_flags = --edition=2021 -Wunreachable_pub
512 $(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=_…
513 $(obj)/core.o: private rustc_target_flags = --edition=$(core-edition) $(core-cfgs)
523 $(obj)/compiler_builtins.o: private rustc_objcopy = -w -W '__*'
528 $(obj)/pin_init.o: private rustc_target_flags = --extern pin_init_internal \
529 --extern macros --cfg kernel
530 $(obj)/pin_init.o: $(src)/pin-init/src/lib.rs $(obj)/compiler_builtins.o \
537 $(obj)/build_error.o: private is-kernel-object := y
546 $(obj)/bindings.o: private rustc_target_flags = --extern ffi --extern pin_init
554 $(obj)/uapi.o: private rustc_target_flags = --extern ffi --extern pin_init
562 $(obj)/kernel.o: private rustc_target_flags = --extern ffi --extern pin_init \
563 --extern build_error --extern macros --extern bindings --extern uapi