Rust for Linux List
 help / color / mirror / Atom feed
* [PATCH v2] rust: kbuild: skip `--remap-path-prefix` for `rustdoc`
@ 2025-03-15 19:40 Miguel Ojeda
  2025-03-15 20:12 ` Tamir Duberstein
  2025-03-16  2:01 ` Masahiro Yamada
  0 siblings, 2 replies; 3+ messages in thread
From: Miguel Ojeda @ 2025-03-15 19:40 UTC (permalink / raw)
  To: Masahiro Yamada, Miguel Ojeda, Alex Gaynor
  Cc: Nathan Chancellor, Nicolas Schier, linux-kbuild, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Alice Ryhl, Trevor Gross, Danilo Krummrich, Thomas Weißschuh,
	rust-for-linux, linux-kernel, patches

`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: 6b5747d07138 ("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>
---
v2:
  - Skip the flag also in `RUSTDOC TK`. The ICE does not apply there,
    but we still need to skip the flag.

 rust/Makefile | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/rust/Makefile b/rust/Makefile
index ea3849eb78f6..089473a89d46 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -57,10 +57,14 @@ endif
 core-cfgs = \
     --cfg no_fp_fmt_parse

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

base-commit: bc5431693696b3f928b0b7acf8d7a120127db7a4
--
2.49.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] rust: kbuild: skip `--remap-path-prefix` for `rustdoc`
  2025-03-15 19:40 [PATCH v2] rust: kbuild: skip `--remap-path-prefix` for `rustdoc` Miguel Ojeda
@ 2025-03-15 20:12 ` Tamir Duberstein
  2025-03-16  2:01 ` Masahiro Yamada
  1 sibling, 0 replies; 3+ messages in thread
From: Tamir Duberstein @ 2025-03-15 20:12 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Masahiro Yamada, Alex Gaynor, Nathan Chancellor, Nicolas Schier,
	linux-kbuild, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich, Thomas Weißschuh, rust-for-linux,
	linux-kernel, patches

On Sat, Mar 15, 2025 at 3:41 PM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> `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: 6b5747d07138 ("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>
> ---
> v2:
>   - Skip the flag also in `RUSTDOC TK`. The ICE does not apply there,
>     but we still need to skip the flag.
>
>  rust/Makefile | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/rust/Makefile b/rust/Makefile
> index ea3849eb78f6..089473a89d46 100644
> --- a/rust/Makefile
> +++ b/rust/Makefile
> @@ -57,10 +57,14 @@ endif
>  core-cfgs = \
>      --cfg no_fp_fmt_parse
>
> +# `rustc` recognizes `--remap-path-prefix` since 1.26.0, but `rustdoc` only
> +# since Rust 1.81.0. Moreover, `rustdoc` ICEs on out-of-tree builds since Rust
> +# 1.82.0 (https://github.com/rust-lang/rust/issues/138520). Thus workaround both
> +# issues skipping the flag. The former also applies to `RUSTDOC TK`.
>  quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
>        cmd_rustdoc = \
>         OBJTREE=$(abspath $(objtree)) \
> -       $(RUSTDOC) $(filter-out $(skip_flags),$(if $(rustdoc_host),$(rust_common_flags),$(rust_flags))) \
> +       $(RUSTDOC) $(filter-out $(skip_flags) --remap-path-prefix=%,$(if $(rustdoc_host),$(rust_common_flags),$(rust_flags))) \
>                 $(rustc_target_flags) -L$(objtree)/$(obj) \
>                 -Zunstable-options --generate-link-to-definition \
>                 --output $(rustdoc_output) \
> @@ -171,7 +175,7 @@ quiet_cmd_rustdoc_test_kernel = RUSTDOC TK $<
>         rm -rf $(objtree)/$(obj)/test/doctests/kernel; \
>         mkdir -p $(objtree)/$(obj)/test/doctests/kernel; \
>         OBJTREE=$(abspath $(objtree)) \
> -       $(RUSTDOC) --test $(rust_flags) \
> +       $(RUSTDOC) --test $(filter-out --remap-path-prefix=%,$(rust_flags)) \
>                 -L$(objtree)/$(obj) --extern ffi --extern kernel \
>                 --extern build_error --extern macros \
>                 --extern bindings --extern uapi \
>
> base-commit: bc5431693696b3f928b0b7acf8d7a120127db7a4
> --
> 2.49.0
>

Reviewed-by: Tamir Duberstein <tamird@gmail.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] rust: kbuild: skip `--remap-path-prefix` for `rustdoc`
  2025-03-15 19:40 [PATCH v2] rust: kbuild: skip `--remap-path-prefix` for `rustdoc` Miguel Ojeda
  2025-03-15 20:12 ` Tamir Duberstein
@ 2025-03-16  2:01 ` Masahiro Yamada
  1 sibling, 0 replies; 3+ messages in thread
From: Masahiro Yamada @ 2025-03-16  2:01 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Alex Gaynor, Nathan Chancellor, Nicolas Schier, linux-kbuild,
	Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
	Thomas Weißschuh, rust-for-linux, linux-kernel, patches

On Sun, Mar 16, 2025 at 4:40 AM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> `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: 6b5747d07138 ("kbuild, rust: use -fremap-path-prefix to make paths relative")

Applied to linux-kbuild. Thanks.

Please note I locally modified the Fixes tag as follows:

Fixes: dbdffaf50ff9 ("kbuild, rust: use -fremap-path-prefix to make
paths relative")

I rebased in order to fix my missing Signed-off-by,
so the commit ID of the former commits changed.






> Link: https://github.com/rust-lang/rust/issues/138520 [1]
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> ---
> v2:
>   - Skip the flag also in `RUSTDOC TK`. The ICE does not apply there,
>     but we still need to skip the flag.
>
>  rust/Makefile | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/rust/Makefile b/rust/Makefile
> index ea3849eb78f6..089473a89d46 100644
> --- a/rust/Makefile
> +++ b/rust/Makefile
> @@ -57,10 +57,14 @@ endif
>  core-cfgs = \
>      --cfg no_fp_fmt_parse
>
> +# `rustc` recognizes `--remap-path-prefix` since 1.26.0, but `rustdoc` only
> +# since Rust 1.81.0. Moreover, `rustdoc` ICEs on out-of-tree builds since Rust
> +# 1.82.0 (https://github.com/rust-lang/rust/issues/138520). Thus workaround both
> +# issues skipping the flag. The former also applies to `RUSTDOC TK`.
>  quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
>        cmd_rustdoc = \
>         OBJTREE=$(abspath $(objtree)) \
> -       $(RUSTDOC) $(filter-out $(skip_flags),$(if $(rustdoc_host),$(rust_common_flags),$(rust_flags))) \
> +       $(RUSTDOC) $(filter-out $(skip_flags) --remap-path-prefix=%,$(if $(rustdoc_host),$(rust_common_flags),$(rust_flags))) \
>                 $(rustc_target_flags) -L$(objtree)/$(obj) \
>                 -Zunstable-options --generate-link-to-definition \
>                 --output $(rustdoc_output) \
> @@ -171,7 +175,7 @@ quiet_cmd_rustdoc_test_kernel = RUSTDOC TK $<
>         rm -rf $(objtree)/$(obj)/test/doctests/kernel; \
>         mkdir -p $(objtree)/$(obj)/test/doctests/kernel; \
>         OBJTREE=$(abspath $(objtree)) \
> -       $(RUSTDOC) --test $(rust_flags) \
> +       $(RUSTDOC) --test $(filter-out --remap-path-prefix=%,$(rust_flags)) \
>                 -L$(objtree)/$(obj) --extern ffi --extern kernel \
>                 --extern build_error --extern macros \
>                 --extern bindings --extern uapi \
>
> base-commit: bc5431693696b3f928b0b7acf8d7a120127db7a4
> --
> 2.49.0



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-03-16  2:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-15 19:40 [PATCH v2] rust: kbuild: skip `--remap-path-prefix` for `rustdoc` Miguel Ojeda
2025-03-15 20:12 ` Tamir Duberstein
2025-03-16  2:01 ` Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox