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: remove `--remap-path-prefix` workarounds

Commit 8cf5b3f83614 ("Revert "kbuild, rust: use -fremap-path-prefix
to make paths relative"") removed `--remap-path-prefix` from the build
system, so the workarounds are not needed anymore.

Thus remove them.

Note that the flag has landed again in parallel in this cycle in
commit dda135077ecc ("rust: build: remap path to avoid absolute path"),
together with `--remap-path-scope=macro` [1]. However, they are gated on
`rustc-option-yn, --remap-path-scope=macro`, which means they are both
only passed starting with Rust 1.95.0 [2]:

`--remap-path-scope` is only stable in Rust 1.95, so use `rustc-option`
to detect its presence. This feature has been available as
`-Zremap-path-scope` for all versions that we support; however due to
bugs in the Rust compiler, it does not work reliably until 1.94. I opted
to not enable it for 1.94 as it's just a single version that we missed.

In turn, that means the workarounds removed here should not be needed
again (even with the flag added again above), since:

- `rustdoc` now recognizes the `--remap-path-prefix` flag since Rust
1.81.0 [3] (even if it is still an unstable feature [4]).

- The Internal Compiler Error [5] that the comment mentions was fixed in
Rust 1.87.0 [6]. We tested that was the case in a previous version
of this series by making the workaround conditional [7][8].

...which are both older versions than Rust 1.95.0.

We will still need to skip `--remap-path-scope` for `rustdoc` though,
since `rustdoc` does not support that one yet [4].

Link: https://github.com/rust-lang/rust/issues/111540 [1]
Link: https://github.com/rust-lang/rust/pull/147611 [2]
Link: https://github.com/rust-lang/rust/pull/107099 [3]
Link: https://doc.rust-lang.org/nightly/rustdoc/unstable-features.html#--remap-path-prefix-remap-source-code-paths-in-output [4]
Link: https://github.com/rust-lang/rust/issues/138520 [5]
Link: https://github.com/rust-lang/rust/pull/138556 [6]
Link: https://lore.kernel.org/rust-for-linux/20260401114540.30108-9-ojeda@kernel.org/ [7]
Link: https://lore.kernel.org/rust-for-linux/20260401114540.30108-10-ojeda@kernel.org/ [8]
Link: https://patch.msgid.link/20260405235309.418950-2-ojeda@kernel.org
Acked-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Tamir Duberstein <tamird@kernel.org>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

+2 -6
+2 -6
rust/Makefile
··· 145 145 # Similarly, for doctests (https://github.com/rust-lang/rust/issues/146465). 146 146 doctests_modifiers_workaround := $(rustdoc_modifiers_workaround)$(if $(call rustc-min-version,109100),$(comma)sanitizer) 147 147 148 - # `rustc` recognizes `--remap-path-prefix` since 1.26.0, but `rustdoc` only 149 - # since Rust 1.81.0. Moreover, `rustdoc` ICEs on out-of-tree builds since Rust 150 - # 1.82.0 (https://github.com/rust-lang/rust/issues/138520). Thus workaround both 151 - # issues skipping the flag. The former also applies to `RUSTDOC TK`. 152 148 quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $< 153 149 cmd_rustdoc = \ 154 150 OBJTREE=$(abspath $(objtree)) \ 155 - $(RUSTDOC) $(filter-out $(skip_flags) --remap-path-prefix=%,$(if $(rustdoc_host),$(rust_common_flags),$(rust_flags))) \ 151 + $(RUSTDOC) $(filter-out $(skip_flags),$(if $(rustdoc_host),$(rust_common_flags),$(rust_flags))) \ 156 152 $(rustc_target_flags) -L$(objtree)/$(obj) \ 157 153 -Zunstable-options --generate-link-to-definition \ 158 154 --output $(rustdoc_output) \ ··· 334 338 rm -rf $(objtree)/$(obj)/test/doctests/kernel; \ 335 339 mkdir -p $(objtree)/$(obj)/test/doctests/kernel; \ 336 340 OBJTREE=$(abspath $(objtree)) \ 337 - $(RUSTDOC) --test $(filter-out --remap-path-prefix=%,$(rust_flags)) \ 341 + $(RUSTDOC) --test $(rust_flags) \ 338 342 -L$(objtree)/$(obj) --extern ffi --extern pin_init \ 339 343 --extern kernel --extern build_error --extern macros \ 340 344 --extern bindings --extern uapi \