@@ -460,9 +460,12 @@ READELF = $(CROSS_COMPILE)readelf
460
460
STRIP = $(CROSS_COMPILE ) strip
461
461
endif
462
462
RUSTC = rustc
463
+ RUSTC_BOOTSTRAP = 1
464
+ RUSTDOC = rustdoc
463
465
RUSTFMT = rustfmt
464
466
CLIPPY_DRIVER = clippy-driver
465
467
BINDGEN = bindgen
468
+ CARGO = cargo
466
469
PAHOLE = pahole
467
470
RESOLVE_BTFIDS = $(objtree ) /tools/bpf/resolve_btfids/resolve_btfids
468
471
LEX = flex
@@ -524,7 +527,7 @@ KBUILD_RUSTCFLAGS := --emit=dep-info,obj,metadata --edition=2018 \
524
527
-Cpanic=abort -Cembed-bitcode=n -Clto=n -Crpath=n \
525
528
-Cforce-unwind-tables=n -Ccodegen-units=1 \
526
529
-Zbinary_dep_depinfo=y -Zsymbol-mangling-version=v0 \
527
- -D unsafe_op_in_unsafe_fn
530
+ -Dunsafe_op_in_unsafe_fn -Wmissing_docs
528
531
KBUILD_AFLAGS_KERNEL :=
529
532
KBUILD_CFLAGS_KERNEL :=
530
533
KBUILD_RUSTCFLAGS_KERNEL :=
@@ -542,13 +545,13 @@ else
542
545
RUSTC_OR_CLIPPY_QUIET := RUSTC
543
546
RUSTC_OR_CLIPPY = $(RUSTC)
544
547
endif
545
- export RUSTC_OR_CLIPPY_QUIET RUSTC_OR_CLIPPY
546
548
547
549
ifdef RUST_LIB_SRC
548
550
export RUST_LIB_SRC
549
551
endif
550
552
551
- export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE LD CC RUSTC BINDGEN
553
+ export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE LD CC
554
+ export RUSTC RUSTC_BOOTSTRAP RUSTDOC RUSTFMT RUSTC_OR_CLIPPY_QUIET RUSTC_OR_CLIPPY BINDGEN CARGO
552
555
export CPP AR NM STRIP OBJCOPY OBJDUMP READELF PAHOLE RESOLVE_BTFIDS LEX YACC AWK INSTALLKERNEL
553
556
export PERL PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
554
557
export KGZIP KBZIP2 KLZOP LZMA LZ4 XZ ZSTD
@@ -1596,7 +1599,7 @@ endif # CONFIG_MODULES
1596
1599
# Directories & files removed with 'make clean'
1597
1600
CLEAN_FILES += include/ksym vmlinux.symvers modules-only.symvers \
1598
1601
modules.builtin modules.builtin.modinfo modules.nsdeps \
1599
- compile_commands.json .thinlto-cache
1602
+ compile_commands.json .thinlto-cache rust/test rust/doc
1600
1603
1601
1604
# Directories & files removed with 'make mrproper'
1602
1605
MRPROPER_FILES += include/config include/generated \
@@ -1726,7 +1729,7 @@ help:
1726
1729
@echo ' rustdoc - Generate Rust documentation'
1727
1730
@echo ' (requires kernel .config)'
1728
1731
@echo ' rusttest - Runs the Rust tests'
1729
- @echo ' (requires kernel .config)'
1732
+ @echo ' (requires kernel .config; downloads external repos )'
1730
1733
@echo ' rust-analyzer - Generate rust-project.json rust-analyzer support file'
1731
1734
@echo ' (requires kernel .config)'
1732
1735
@echo ' '
@@ -1820,11 +1823,21 @@ rusttest: prepare0
1820
1823
# Formatting targets
1821
1824
PHONY += rustfmt rustfmtcheck
1822
1825
1826
+ # We skip `rust/alloc` since we want to minimize the diff w.r.t. upstream.
1827
+ #
1828
+ # We match using absolute paths since `find` does not resolve them
1829
+ # when matching, which is a problem when e.g. `srctree` is `..`.
1830
+ # We `grep` afterwards in order to remove the directory entry itself.
1823
1831
rustfmt :
1824
- find $(srctree ) -type f -name ' *.rs' | xargs $(RUSTFMT )
1825
-
1826
- rustfmtcheck :
1827
- find $(srctree ) -type f -name ' *.rs' | xargs $(RUSTFMT ) --check
1832
+ $(Q ) find $(abs_srctree ) -type f -name ' *.rs' \
1833
+ -o -path $(abs_srctree ) /rust/alloc -prune \
1834
+ -o -path $(abs_objtree ) /rust/test -prune \
1835
+ | grep -Fv $(abs_srctree ) /rust/alloc \
1836
+ | grep -Fv $(abs_objtree ) /rust/test \
1837
+ | xargs $(RUSTFMT ) $(rustfmt_flags )
1838
+
1839
+ rustfmtcheck : rustfmt_flags = --check
1840
+ rustfmtcheck : rustfmt
1828
1841
1829
1842
# IDE support targets
1830
1843
PHONY += rust-analyzer
0 commit comments