Skip to content

Commit 252fea1

Browse files
committed
rust: kbuild: clean output before running rustdoc
`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: [email protected] # Needed in 6.12.y and later (Rust is pinned in older LTSs). Reported-by: Daniel Almeida <[email protected]> Closes: https://rust-for-linux.zulipchat.com/#narrow/channel/288089/topic/x/near/527201113 Reviewed-by: Tamir Duberstein <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent abbf9a4 commit 252fea1

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

rust/Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,14 @@ rustdoc: rustdoc-core rustdoc-macros rustdoc-compiler_builtins \
111111
rustdoc-macros: private rustdoc_host = yes
112112
rustdoc-macros: private rustc_target_flags = --crate-type proc-macro \
113113
--extern proc_macro
114-
rustdoc-macros: $(src)/macros/lib.rs FORCE
114+
rustdoc-macros: $(src)/macros/lib.rs rustdoc-clean FORCE
115115
+$(call if_changed,rustdoc)
116116

117117
# Starting with Rust 1.82.0, skipping `-Wrustdoc::unescaped_backticks` should
118118
# not be needed -- see https://github.com/rust-lang/rust/pull/128307.
119119
rustdoc-core: private skip_flags = --edition=2021 -Wrustdoc::unescaped_backticks
120120
rustdoc-core: private rustc_target_flags = --edition=$(core-edition) $(core-cfgs)
121-
rustdoc-core: $(RUST_LIB_SRC)/core/src/lib.rs FORCE
121+
rustdoc-core: $(RUST_LIB_SRC)/core/src/lib.rs rustdoc-clean FORCE
122122
+$(call if_changed,rustdoc)
123123

124124
rustdoc-compiler_builtins: $(src)/compiler_builtins.rs rustdoc-core FORCE
@@ -130,7 +130,8 @@ rustdoc-ffi: $(src)/ffi.rs rustdoc-core FORCE
130130
rustdoc-pin_init_internal: private rustdoc_host = yes
131131
rustdoc-pin_init_internal: private rustc_target_flags = --cfg kernel \
132132
--extern proc_macro --crate-type proc-macro
133-
rustdoc-pin_init_internal: $(src)/pin-init/internal/src/lib.rs FORCE
133+
rustdoc-pin_init_internal: $(src)/pin-init/internal/src/lib.rs \
134+
rustdoc-clean FORCE
134135
+$(call if_changed,rustdoc)
135136

136137
rustdoc-pin_init: private rustdoc_host = yes
@@ -148,6 +149,9 @@ rustdoc-kernel: $(src)/kernel/lib.rs rustdoc-core rustdoc-ffi rustdoc-macros \
148149
$(obj)/bindings.o FORCE
149150
+$(call if_changed,rustdoc)
150151

152+
rustdoc-clean: FORCE
153+
$(Q)rm -rf $(rustdoc_output)
154+
151155
quiet_cmd_rustc_test_library = $(RUSTC_OR_CLIPPY_QUIET) TL $<
152156
cmd_rustc_test_library = \
153157
OBJTREE=$(abspath $(objtree)) \

0 commit comments

Comments
 (0)