Skip to content

Commit 8d28306

Browse files
ojedajfvogel
authored andcommitted
rust: kbuild: clean output before running rustdoc
commit 252fea131e15aba2cd487119d1a8f546471199e2 upstream. `rustdoc` can get confused when generating documentation into a folder that contains generated files from other `rustdoc` versions. For instance, running something like: rustup default 1.78.0 make LLVM=1 rustdoc rustup default 1.88.0 make LLVM=1 rustdoc may generate errors like: error: couldn't generate documentation: invalid template: last line expected to start with a comment | = note: failed to create or modify "./Documentation/output/rust/rustdoc/src-files.js" Thus just always clean the output folder before generating the documentation -- we are anyway regenerating it every time the `rustdoc` target gets called, at least for the time being. Cc: stable@vger.kernel.org # Needed in 6.12.y and later (Rust is pinned in older LTSs). Reported-by: Daniel Almeida <daniel.almeida@collabora.com> Closes: https://rust-for-linux.zulipchat.com/#narrow/channel/288089/topic/x/near/527201113 Reviewed-by: Tamir Duberstein <tamird@kernel.org> Link: https://lore.kernel.org/r/20250726133435.2460085-1-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit fed5d8679b57d4c52a28c6b7a2be80cb6bd96959) Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
1 parent 818f281 commit 8d28306

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

rust/Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,14 @@ rustdoc: rustdoc-core rustdoc-macros rustdoc-compiler_builtins \
9292
rustdoc-macros: private rustdoc_host = yes
9393
rustdoc-macros: private rustc_target_flags = --crate-type proc-macro \
9494
--extern proc_macro
95-
rustdoc-macros: $(src)/macros/lib.rs FORCE
95+
rustdoc-macros: $(src)/macros/lib.rs rustdoc-clean FORCE
9696
+$(call if_changed,rustdoc)
9797

9898
# Starting with Rust 1.82.0, skipping `-Wrustdoc::unescaped_backticks` should
9999
# not be needed -- see https://github.com/rust-lang/rust/pull/128307.
100100
rustdoc-core: private skip_flags = --edition=2021 -Wrustdoc::unescaped_backticks
101101
rustdoc-core: private rustc_target_flags = --edition=$(core-edition) $(core-cfgs)
102-
rustdoc-core: $(RUST_LIB_SRC)/core/src/lib.rs FORCE
102+
rustdoc-core: $(RUST_LIB_SRC)/core/src/lib.rs rustdoc-clean FORCE
103103
+$(call if_changed,rustdoc)
104104

105105
rustdoc-compiler_builtins: $(src)/compiler_builtins.rs rustdoc-core FORCE
@@ -116,6 +116,9 @@ rustdoc-kernel: $(src)/kernel/lib.rs rustdoc-core rustdoc-ffi rustdoc-macros \
116116
$(obj)/bindings.o FORCE
117117
+$(call if_changed,rustdoc)
118118

119+
rustdoc-clean: FORCE
120+
$(Q)rm -rf $(rustdoc_output)
121+
119122
quiet_cmd_rustc_test_library = RUSTC TL $<
120123
cmd_rustc_test_library = \
121124
OBJTREE=$(abspath $(objtree)) \

0 commit comments

Comments
 (0)