[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DG93P7TMCWCH.3ACJU31B2HELW@garyguo.net>
Date: Sat, 07 Feb 2026 22:59:24 +0000
From: "Gary Guo" <gary@...yguo.net>
To: "Nathan Chancellor" <nathan@...nel.org>, "Gary Guo" <gary@...yguo.net>
Cc: "Miguel Ojeda" <miguel.ojeda.sandonis@...il.com>, "Nicolas Schier"
<nsc@...nel.org>, "Miguel Ojeda" <ojeda@...nel.org>, "Boqun Feng"
<boqun@...nel.org>, Björn Roy Baron
<bjorn3_gh@...tonmail.com>, "Benno Lossin" <lossin@...nel.org>, "Andreas
Hindborg" <a.hindborg@...nel.org>, "Alice Ryhl" <aliceryhl@...gle.com>,
"Trevor Gross" <tmgross@...ch.edu>, "Danilo Krummrich" <dakr@...nel.org>,
"Janne Grunau" <j@...nau.net>, "Asahi Lina" <lina+kernel@...hilina.net>,
<rust-for-linux@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linux-kbuild@...r.kernel.org>
Subject: Re: [PATCH] rust: build: remap path to avoid absolute path
On Sat Feb 7, 2026 at 10:05 PM GMT, Nathan Chancellor wrote:
> 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@...nel.org> 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@weissschuh.net/
>>
>> 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@intel.com/
> [2] https://lore.kernel.org/edc50aa7-0740-4942-8c15-96f12f2acc7e@kernel.org/
Hi Nathan, thanks for the background. I tested that objdump will indeed fail to
find files with Rust `--remap-path-prefix` (even inside correct directory) and
that's indeed problematic (objdump has an `-I` to add search path but it will
only use the file stem and not the full path).
The best path forward is then perhaps to use `-Zremap-path-scope=macro` to limit
the remap to Rust macros (this include `#[track_caller]`). The debug info will
still have non-reproducible parts in it, but at least the ones ended up in
.rodata will be remapped. This flag is going to be stable in Rust 1.95, but is
available unstably for a while, so we can start using it in the kernel already.
I can confirm that objdump is working fine when the remap-path-scope is limited
to macro (default is macro + debuginfo + coverage).
Unfortunately, using remap-path-scope does not give the expected result in older
Rust compiler versions, so the issue reports that I linked will not be resolved
with it. It looks like remap-path-scope is working as intended only since
https://github.com/rust-lang/rust/pull/149709, so Rust 1.94+ (I haven't
double-checked the exact Rust version, but in latest nightly Rust, the remap is
working as intended).
Best,
Gary
Powered by blists - more mailing lists