All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Alan Maguire <alan.maguire@oracle.com>
Cc: Dominique Martinet <asmadeus@codewreck.org>,
	andrii.nakryiko@gmail.com, dwarves@vger.kernel.org,
	jolsa@kernel.org, williams@redhat.com, kcarcia@redhat.com,
	dxu@dxuuu.xyz, eddyz87@gmail.com
Subject: Re: [PATCH dwarves] pahole: enable --reproducible_build when SOURCE_DATE_EPOCH is set
Date: Fri, 28 Jun 2024 10:59:54 -0300	[thread overview]
Message-ID: <Zn7B2ioa62DC_SAK@x1> (raw)
In-Reply-To: <1213004a-c75a-4882-bd51-47d458c67e04@oracle.com>

On Fri, Jun 28, 2024 at 09:31:17AM +0100, Alan Maguire wrote:
> On 27/06/2024 18:25, Alan Maguire wrote:
> > On 27/06/2024 00:01, Dominique Martinet wrote:
> >> Alan Maguire wrote on Wed, Jun 26, 2024 at 03:29:37PM +0100:
> >>> On 26/06/2024 04:22, Dominique Martinet wrote:
> >>>> The SOURCE_DATE_EPOCH environment variable is used in reproducible
> >>>> builds to set build timestamps and is generally synonymous with
> >>>> reproducible builds: instead of making users figure out how to pass
> >>>> pahole flags (e.g. explicitly setting PAHOLE_FLAGS in linux) just assume
> >>>> that the user wants a reproducible build if this variable is set.

> >>> From the kernel perspective it looks like as a result of [1]
> >>> [1] https://patchwork.kernel.org/project/linux-kbuild/patch/1443741332.2730.75.camel@decadent.org.ukOB/
> >>> the setting of SOURCE_DATE_EPOCH will be converted into
> >>> KBUILD_BUILD_TIMESTAMP; I thought the plan was to add the
> >>> BTF feature flag explicitly if KBUILD_BUILD_TIMESTAMP was set?

> >> Hmm, that patch (2015) never got in apparently?...
> >> And I don't see anythiing that'd make pahole output reproducible if
> >> either variables are set in the kernel either right now; we still build
> > 
> > I can send a patch for this to bpf-next if it's needed. But it'd be good
> > to figure out the right approach first, more below...
> > 
> >> plenty of older kernels so even if such a patch gets in I'd rather this
> >> is checked in pahole than kbuild.

> > I'm not sure that's the right answer though - there's a bunch of
> > existing infrastructure in the kernel tree that relies on
> > KBUILD_BUILD_TIMESTAMP, so to integrate properly with the existing
> > kbuild infrastructure around reproducible builds feels like the right
> > direction to me. It's a bit more work, but not too much. Arnaldo may
> > disagree of course, and he's the maintainer so it's his decision - this
> > is just my personal take.
> > 
> > We've tried to explicitly enable flags in pahole Makefile.btf so that
> > it's obvious from pahole invocations which features are wanted, and to
> > get that support on older kernels it would just be a matter of
> > backporting the
> > 
> > if > 1.26
> > 	use --btf_features
> > 
> > ...patch, and a patch for adding the reproducible build option to stable
> > kernels. Similar has been done in the past for other pahole features.
> > 
> > All that's needed here for bpf-next tree is I think is the below 3-line
> > addition:
> > 
> > diff --git a/scripts/Makefile.btf b/scripts/Makefile.btf
> > index b75f09f3f424..40bb72662967 100644
> > --- a/scripts/Makefile.btf
> > +++ b/scripts/Makefile.btf
> > @@ -21,6 +21,10 @@ else
> >  # Switch to using --btf_features for v1.26 and later.
> >  pahole-flags-$(call test-ge, $(pahole-ver), 126)  = -j
> > --btf_features=encode_force,var,float,enum64,decl_tag,type_tag,optimized_func,consistent_func,decl_tag_kfuncs
> > 
> > +ifneq ($(KBUILD_BUILD_TIMESTAMP),)
> > +pahole-flags-$(call test-ge, $(pahole-ver), 126) +=
> > --btf_features=reproducible_build
> > +endif
> > +
> >  ifneq ($(KBUILD_EXTMOD),)
> >  module-pahole-flags-$(call test-ge, $(pahole-ver), 126) +=
> > --btf_features=distilled_base
> >  endif
> > 
> > 
> > Can you test at your end if that does the right thing? Thanks!
> 
> FWIW I verified that with the above change, and
> 
> export KBUILD_BUILD_TIMESTAMP=$(date -I)
> 
> ...the feature flag is added to pahole and as a result we get
> reproducible BTF in vmlinux; .btf.vmlinux.bin.o is identical across
> multiple kernel builds.

This sounds reasonable, pahole doesn't have to look at something so
specific for a particular use case (the kernel) while using what pahole
would look (KBUILD_BUILD_TIMESTAMP) but in the kernel build scripts,
that in turn uses the prefered, self-documenting way of asking for some
specific BTF feature (--btf_features).

- Arnaldo

  reply	other threads:[~2024-06-28 13:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-26  3:22 [PATCH dwarves] pahole: enable --reproducible_build when SOURCE_DATE_EPOCH is set Dominique Martinet
2024-06-26 14:29 ` Alan Maguire
2024-06-26 23:01   ` Dominique Martinet
2024-06-27 17:25     ` Alan Maguire
2024-06-28  8:31       ` Alan Maguire
2024-06-28 13:59         ` Arnaldo Carvalho de Melo [this message]
2024-06-28 19:44         ` Dominique Martinet
2024-07-01 16:44           ` Alan Maguire
2024-07-01 23:35             ` Dominique Martinet

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=Zn7B2ioa62DC_SAK@x1 \
    --to=acme@kernel.org \
    --cc=alan.maguire@oracle.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=asmadeus@codewreck.org \
    --cc=dwarves@vger.kernel.org \
    --cc=dxu@dxuuu.xyz \
    --cc=eddyz87@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kcarcia@redhat.com \
    --cc=williams@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.