Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ca5599f

Browse files
committedMar 15, 2025
rust: kbuild: skip --remap-path-prefix for rustdoc
`rustdoc` only recognizes `--remap-path-prefix` starting with Rust 1.81.0, which is later than on minimum, so we cannot pass it unconditionally. Otherwise, we get: error: Unrecognized option: 'remap-path-prefix' Note that `rustc` (the compiler) does recognize the flag since a long time ago (1.26.0). Moreover, `rustdoc` since Rust 1.82.0 ICEs in out-of-tree builds when using `--remap-path-prefix`. The issue has been reduced and reported upstream [1]. Thus workaround both issues by simply skipping the flag when generating the docs -- it is not critical there anyway. Fixes: 6b5747d ("kbuild, rust: use -fremap-path-prefix to make paths relative") Link: rust-lang/rust#138520 [1] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent bc54316 commit ca5599f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed
 

‎rust/Makefile

+6-2
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,14 @@ endif
5757
core-cfgs = \
5858
--cfg no_fp_fmt_parse
5959

60+
# `rustc` recognizes `--remap-path-prefix` since 1.26.0, but `rustdoc` only
61+
# since Rust 1.81.0. Moreover, `rustdoc` ICEs on out-of-tree builds since Rust
62+
# 1.82.0 (https://github.com/rust-lang/rust/issues/138520). Thus workaround both
63+
# issues skipping the flag. Same applies to `RUSTDOC TK` (`rust_flags`).
6064
quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
6165
cmd_rustdoc = \
6266
OBJTREE=$(abspath $(objtree)) \
63-
$(RUSTDOC) $(filter-out $(skip_flags),$(if $(rustdoc_host),$(rust_common_flags),$(rust_flags))) \
67+
$(RUSTDOC) $(filter-out $(skip_flags) --remap-path-prefix=%,$(if $(rustdoc_host),$(rust_common_flags),$(rust_flags))) \
6468
$(rustc_target_flags) -L$(objtree)/$(obj) \
6569
-Zunstable-options --generate-link-to-definition \
6670
--output $(rustdoc_output) \
@@ -171,7 +175,7 @@ quiet_cmd_rustdoc_test_kernel = RUSTDOC TK $<
171175
rm -rf $(objtree)/$(obj)/test/doctests/kernel; \
172176
mkdir -p $(objtree)/$(obj)/test/doctests/kernel; \
173177
OBJTREE=$(abspath $(objtree)) \
174-
$(RUSTDOC) --test $(rust_flags) \
178+
$(RUSTDOC) --test $(filter-out --remap-path-prefix=%,$(rust_flags)) \
175179
-L$(objtree)/$(obj) --extern ffi --extern kernel \
176180
--extern build_error --extern macros \
177181
--extern bindings --extern uapi \

0 commit comments

Comments
 (0)
Failed to load comments.