From: Nicolas Schier <nsc@kernel.org>
To: Gary Guo <gary@garyguo.net>
Cc: "Nathan Chancellor" <nathan@kernel.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun@kernel.org>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Thomas Weißschuh" <linux@weissschuh.net>,
"Janne Grunau" <j@jannau.net>,
"Asahi Lina" <lina+kernel@asahilina.net>,
linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
rust-for-linux@vger.kernel.org
Subject: Re: [PATCH v2] rust: build: remap path to avoid absolute path
Date: Thu, 26 Feb 2026 20:21:02 +0100 [thread overview]
Message-ID: <aaCdHs8-A99569M1@derry.ads.avm.de> (raw)
In-Reply-To: <20260226152112.3222886-1-gary@kernel.org>
On Thu, Feb 26, 2026 at 03:21:11PM +0000, Gary Guo wrote:
> From: Gary Guo <gary@garyguo.net>
>
> When building with a out directory (O=), absolute paths can end up in the
> file name in `#[track_caller]` or the panic message. This is not desirable
> as this leaks the exact path being used to build the kernel and means that
> the same location can appear in two forms (relative or absolute).
>
> This is reported by Asahi [1] and is being workaround in [2] previously to
> force everything to be absolute path. Using absolute path for everything
> sovles the inconsistency, however it does not address the reproducibility
> issue. So, fix this by remap all absolute paths to srctree to relative path
> instead.
>
> This is previously attemped in commit dbdffaf50ff9 ("kbuild, rust: use
> -fremap-path-prefix to make paths relative") but that was reverted as
> remapping debug info causes some tool (e.g. objdump) to be unable to find
> sources. Therefore, use `--remap-path-scope` to only remap macros but leave
> debuginfo untouched. `--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; hwoever 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.
>
> This change can be validated by building a kernel with O=, strip debug info
> on vmlinux, and then check if the absolute path exists in `strings
> vmlinux`, e.g. `strings vmlinux |grep \/home`.
>
> Reported-by: Janne Grunau <j@jannau.net>
> Reported-by: Asahi Lina <lina+kernel@asahilina.net>
> Closes: https://rust-for-linux.zulipchat.com/#narrow/channel/288089-General/topic/Per-call-site.20data.20and.20lock.20class.20keys/near/572466559 [1]
> Link: https://github.com/AsahiLinux/linux/commit/54ab88878869036c9d6620101bfe17a81e88c2f9 [2]
> Signed-off-by: Gary Guo <gary@garyguo.net>
> ---
> Changes since v1:
> - Restrict remap scope to macro only
> - Add to RUSTFLAGS instead of adding directly to scripts/Makefile.build
> ---
> Makefile | 3 +++
> rust/Makefile | 5 +++--
> 2 files changed, 6 insertions(+), 2 deletions(-)
>
Acked-by: Nicolas Schier <nsc@kernel.org> # kbuild
next prev parent reply other threads:[~2026-02-26 19:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-26 15:21 [PATCH v2] rust: build: remap path to avoid absolute path Gary Guo
2026-02-26 19:21 ` Nicolas Schier [this message]
2026-03-06 10:07 ` Miguel Ojeda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aaCdHs8-A99569M1@derry.ads.avm.de \
--to=nsc@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=gary@garyguo.net \
--cc=j@jannau.net \
--cc=lina+kernel@asahilina.net \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=lossin@kernel.org \
--cc=nathan@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox