From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF1B444D02F; Thu, 26 Feb 2026 19:23:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772133825; cv=none; b=MdnX62/AZhrM/wRyFLr2mDcVv/hBIogSgCD9J/j1OfWGNYbuoDXNCfMV+s9FyEyBmQU/l/KZi1J+sr4rFzytITtQ8tK2YNLLsyQ4PRFmsuNbuGhmB5drIFcLeKA9oAfEbuvHiLMpnPrIG1CKnYN9YbKRE/jvVLu4hMeX3scY1zM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772133825; c=relaxed/simple; bh=V/abh2PD06BZ9zL+iou+q/cXLDf1mI0cbexVH9eklL8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=UFTWvrK33iK0J22AfFDbb2TdYe8x3fAGfwwBIPu/Rfct0NCiWpzwXQE4ivHXAzKnV2nBNdUw5u5SR0DtM0ZxHgCDxXEt2+ebPX0gBOZdpPJPWVi1r04iMLHT869nmaDmFr0CPiBzAwN6kR1ZInOld70S3ExPEeY/qUwpHXklx80= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=X+xVlYCd; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="X+xVlYCd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81622C116C6; Thu, 26 Feb 2026 19:23:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772133825; bh=V/abh2PD06BZ9zL+iou+q/cXLDf1mI0cbexVH9eklL8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=X+xVlYCd2kcX++rnawQMPmH5HSUSwPpgSUP9ZQtXTjGcx5FIDI5g/HNbAKewJzezS L+rm8A6+NLA5lmDWbKwpOOdRaWlYW4qCW9h9LJKFPg/0oO8vmv+NxGqvdUNmmpaI+u 7pKUKM2tw8B/ee7NWy+CJjb+/PPuMjzDi9GMph7jAGroiUy7RLbt0R2e4kCvoX19Ka vckOKCdHGXiypOKd0/7NazLxqojc1GupuO1Ix33F80Q3QSorD67Ohg9aptJD2g1eQy 8xcjtRyr0OFPm9+rCNIPavWWNiL6hsvYoEnzkrhp+iM2d69t8ZMf/d1JnhpFpXOvX8 LS12PDm9fD2qg== Date: Thu, 26 Feb 2026 20:21:02 +0100 From: Nicolas Schier To: Gary Guo Cc: Nathan Chancellor , Miguel Ojeda , Boqun Feng , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Thomas =?iso-8859-1?Q?Wei=DFschuh?= , Janne Grunau , Asahi Lina , 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 Message-ID: References: <20260226152112.3222886-1-gary@kernel.org> Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 > > 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 > Reported-by: Asahi Lina > 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 > --- > 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 # kbuild