Re: [PATCH] rust: build: remap path to avoid absolute path

From: Nathan Chancellor

Date: Sat Feb 07 2026 - 17:06:36 EST


On Sat, Feb 07, 2026 at 04:43:11PM +0000, Gary Guo wrote:
> On Sat Feb 7, 2026 at 3:22 PM GMT, Miguel Ojeda wrote:
> > On Sat, Feb 7, 2026 at 3:44 PM Gary Guo <gary@xxxxxxxxxx> wrote:
> >>
> >> So, fix this by remap all absolute paths to srctree to relative path
> >> instead.
> >
> > In case it matters to Kbuild, we had a relatively recent revert
> > related to this flag:
> >
> > dbdffaf50ff9 ("kbuild, rust: use -fremap-path-prefix to make paths relative")
> > 8cf5b3f83614 ("Revert "kbuild, rust: use -fremap-path-prefix to make
> > paths relative"")
> >
> > https://lore.kernel.org/rust-for-linux/20250511-kbuild-revert-file-prefix-map-v1-0-9ba640c8411e@xxxxxxxxxxxxxx/
>
> Ah, that explains why I recall we had this flag in Kbuild but can only find the
> filter-out directives now. I missed the revert email.
>
> I am not convinced that the ability to launch debugger outside source
> directory overweights the benefit of not leaking absolute paths and making
> builds reproducible.
>
> The reverting cover letter says "As there is no simple or uniform way to
> specify the source directory explicitly" which is clearly not the case as you
> can just invoke the debugger in a different working directory... GDB also
> provides a way to provide source directory search path:
> https://sourceware.org/gdb/current/onlinedocs/gdb.html/Source-Path.html.
> Similarly, LLDB provides `settings set target.source-map`:
> https://lldb.llvm.org/use/map.html#remap-source-file-pathnames-for-the-debug-session
>
> I think we should revert the revert, then.

For what it's worth, the C side revert also mentions that it broke
'objdump -S' [1] and working with GCOV data [2], so it seems like it is
not just debuggers that have a hard time with that loss of information.
Maybe those do not matter for Rust code or developers though.

[1] https://lore.kernel.org/aBEttQH4kimHFScx@xxxxxxxxx/
[2] https://lore.kernel.org/edc50aa7-0740-4942-8c15-96f12f2acc7e@xxxxxxxxxx/

Cheers,
Nathan