From: Peter Oberparleiter <oberpar@linux.ibm.com>
To: "Matthieu Baerts" <matttbe@kernel.org>,
"Thomas Weißschuh" <linux@weissschuh.net>,
"Masahiro Yamada" <masahiroy@kernel.org>
Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, Nathan Chancellor <nathan@kernel.org>,
Nicolas Schier <nicolas@fjasle.eu>,
Jonathan Corbet <corbet@lwn.net>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
Ben Hutchings <ben@decadent.org.uk>,
MPTCP Linux <mptcp@lists.linux.dev>
Subject: Re: [PATCH v2] kbuild: make all file references relative to source root
Date: Fri, 2 May 2025 13:33:37 +0200 [thread overview]
Message-ID: <70e065c7-8129-4c78-a7a8-72718ceea334@linux.ibm.com> (raw)
In-Reply-To: <edc50aa7-0740-4942-8c15-96f12f2acc7e@kernel.org>
On 29.04.2025 18:12, Matthieu Baerts wrote:
> On 15/03/2025 14:20, Thomas Weißschuh wrote:
>> -fmacro-prefix-map only affects __FILE__ and __BASE_FILE__.
>> Other references, for example in debug information, are not affected.
>> This makes handling of file references in the compiler outputs harder to
>> use and creates problems for reproducible builds.
>>
>> Switch to -ffile-prefix map which affects all references.
>>
>> Also drop the documentation section advising manual specification of
>> -fdebug-prefix-map for reproducible builds, as it is not necessary
>> anymore.
>>
>> Suggested-by: Ben Hutchings <ben@decadent.org.uk>
>> Link: https://lore.kernel.org/lkml/c49cc967294f9a3a4a34f69b6a8727a6d3959ed8.camel@decadent.org.uk/
>> Acked-by: Borislav Petkov (AMD) <bp@alien8.de> # arch/x86/
>> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
>
> Thank you for having worked on that!
>
> (...)
>
>> diff --git a/Makefile b/Makefile
>> index 5c333682dc9142b1aacfe454a5c77f5923554b7d..4f920187cee658ae4d1b807fca365f6994274828 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -1067,7 +1067,7 @@ endif
>>
>> # change __FILE__ to the relative path to the source directory
>> ifdef building_out_of_srctree
>> -KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srcroot)/=)
>> +KBUILD_CPPFLAGS += $(call cc-option,-ffile-prefix-map=$(srcroot)/=)
>> KBUILD_RUSTFLAGS += --remap-path-prefix=$(srcroot)/=
>> endif
>
> Today, I noticed that my CI for the MPTCP subsystem couldn't produce
> code coverage files like before: the source files are not found. A 'git
> bisect' pointed me to this patch. Reverting it seems to fix the issue.
>
>
> My CI is building the kernel out of the source tree, in ".virtme/build".
> Before and after this patch, GCOV seems to do its job properly.
> Capturing GCOV data with this lcov command seems OK too:
>
> lcov --capture --keep-going -j "${INPUT_CPUS}" \
> --rc geninfo_unexecuted_blocks=1 \
> --include '/net/mptcp/' \
> --function-coverage --branch-coverage \
> -b "${PWD}/.virtme/build" -o kernel.lcov
>
> But after this patch, lcov complains some files are not found, e.g.
>
> ERROR: (source) unable to open
> ${WORKDIR}/.virtme/build/net/mptcp/ctrl.c: No such file or directory
I can confirm that the subject kernel commit breaks gcov-kernel for
out-of-srctree builds by making it impossible for a consumer of GCOV
data to determine the actual location of a source file without manually
specifying it.
Sample .gcno file content changes as seen with gcov-dump:
- cwd: /home/.../build
- /home/.../linux/kernel/workqueue.c:8049:19-8057:1
+ cwd: /home/.../build
+ kernel/workqueue.c:8049:19-8057:1
> The output file is different: the path to the source file is wrong
> because it points to the build dir. Instead of ...
>
> SF:${WORKDIR}/net/mptcp/ctrl.c
>
> ... now I have ...
>
> SF:${WORKDIR}/.virtme/build/net/mptcp/ctrl.c
>
>
> Are there modifications needed on GCOV side to adapt to the behaviour
> change introduced by this patch? Or something else needed on the
> userspace side?
I don't see how this could be fixed by changes in userspace nor
gcov-kernel - the source tree directory information is missing from the
relevant data files.
--
Peter Oberparleiter
Linux on IBM Z Development - IBM Germany R&D
next prev parent reply other threads:[~2025-05-02 11:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-15 13:20 Thomas Weißschuh
2025-03-16 2:06 ` Masahiro Yamada
2025-03-16 19:08 ` Ben Hutchings
2025-03-17 17:17 ` Nathan Chancellor
2025-04-29 16:12 ` Matthieu Baerts
2025-05-01 16:48 ` Thomas Weißschuh
2025-05-02 11:33 ` Peter Oberparleiter [this message]
2025-04-29 19:51 ` Ville Syrjälä
2025-05-05 7:30 ` Thomas Weißschuh
2025-05-11 3:37 ` Masahiro Yamada
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=70e065c7-8129-4c78-a7a8-72718ceea334@linux.ibm.com \
--to=oberpar@linux.ibm.com \
--cc=ben@decadent.org.uk \
--cc=bp@alien8.de \
--cc=corbet@lwn.net \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=masahiroy@kernel.org \
--cc=matttbe@kernel.org \
--cc=mingo@redhat.com \
--cc=mptcp@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=nicolas@fjasle.eu \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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
all inboxes | Powered by JetHome®