Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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.

The ICE does not reproduce under `--test`, but we still need to skip
the flag as well for `RUSTDOC TK` since it is not recognized.

Fixes: dbdffaf50ff9 ("kbuild, rust: use -fremap-path-prefix to make paths relative")
Link: https://github.com/rust-lang/rust/issues/138520 [1]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Reviewed-by: Tamir Duberstein <tamird@gmail.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

authored by

Miguel Ojeda and committed by
Masahiro Yamada
2c8725c1 8bdd53e0

+6 -2
+6 -2
rust/Makefile
··· 57 57 core-cfgs = \ 58 58 --cfg no_fp_fmt_parse 59 59 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. The former also applies to `RUSTDOC TK`. 60 64 quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $< 61 65 cmd_rustdoc = \ 62 66 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))) \ 64 68 $(rustc_target_flags) -L$(objtree)/$(obj) \ 65 69 -Zunstable-options --generate-link-to-definition \ 66 70 --output $(rustdoc_output) \ ··· 175 171 rm -rf $(objtree)/$(obj)/test/doctests/kernel; \ 176 172 mkdir -p $(objtree)/$(obj)/test/doctests/kernel; \ 177 173 OBJTREE=$(abspath $(objtree)) \ 178 - $(RUSTDOC) --test $(rust_flags) \ 174 + $(RUSTDOC) --test $(filter-out --remap-path-prefix=%,$(rust_flags)) \ 179 175 -L$(objtree)/$(obj) --extern ffi --extern kernel \ 180 176 --extern build_error --extern macros \ 181 177 --extern bindings --extern uapi \