Re: [PATCH] kbuild, rust: use -fremap-path-prefix to make paths relative

From: Masahiro Yamada
Date: Tue Mar 11 2025 - 07:05:01 EST


On Mon, Feb 17, 2025 at 10:26 PM Miguel Ojeda
<miguel.ojeda.sandonis@xxxxxxxxx> wrote:
>
> On Sat, Feb 15, 2025 at 1:57 PM Masahiro Yamada <masahiroy@xxxxxxxxxx> wrote:
> >
> > I will apply this if Miguel gives Ack.
>
> Thanks Masahiro -- I left some comments above.
>
> This does remove some absolute paths for me, though not all (e.g.
> `core.o` that comes from the sysroot). Since it is an improvement
> already, if you want to apply it:
>
> Acked-by: Miguel Ojeda <ojeda@xxxxxxxxxx>
>
> I leave below a diff that works for `core.o` for me -- it would do it
> in all cases, not just `building_out_of_srctree`, since it is outside
> the repository in all cases, which I think makes sense, e.g. in an
> in-tree build I get:
>
> $ strings rust/core.o | grep validations.rs
> lib/rustlib/src/rust/library/core/src/str/validations.rs
>
> Cheers,
> Miguel
>
> diff --git a/rust/Makefile b/rust/Makefile
> index ea3849eb78f6..42f242472031 100644
> --- a/rust/Makefile
> +++ b/rust/Makefile
> @@ -438,7 +438,7 @@ $(obj)/exports.o: private skip_gendwarfksyms = 1
> $(obj)/core.o: private skip_clippy = 1
> $(obj)/core.o: private skip_flags = -Wunreachable_pub
> $(obj)/core.o: private rustc_objcopy = $(foreach
> sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym))
> -$(obj)/core.o: private rustc_target_flags = $(core-cfgs)
> +$(obj)/core.o: private rustc_target_flags = $(core-cfgs)
> --remap-path-prefix=$(rustc_sysroot)/=
> $(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs \
> $(wildcard $(objtree)/include/config/RUSTC_VERSION_TEXT) FORCE
> +$(call if_changed_rule,rustc_library)

LGTM. Thanks.


--
Best Regards
Masahiro Yamada