public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: "Moessbauer, Felix" <felix.moessbauer@siemens.com>
To: "jan.kiszka@siemens.com" <jan.kiszka@siemens.com>
Cc: "isar-users@googlegroups.com" <isar-users@googlegroups.com>
Subject: RE: [PATCH 1/1] add support to set KBUILD_BUILD_TIMESTAMP for custom kernels
Date: Tue, 22 Mar 2022 17:27:03 +0000	[thread overview]
Message-ID: <AM9PR10MB4869ADBA17BB9BF4F09B298289179@AM9PR10MB4869.EURPRD10.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <e6fa34e6-6e79-6361-0369-66eafae4af51@siemens.com>

> -----Original Message-----
> From: Kiszka, Jan (T CED) <jan.kiszka@siemens.com>
> Sent: Tuesday, March 22, 2022 3:49 PM
> To: Moessbauer, Felix (T CED SES-DE) <felix.moessbauer@siemens.com>
> Cc: isar-users@googlegroups.com
> Subject: Re: [PATCH 1/1] add support to set KBUILD_BUILD_TIMESTAMP for
> custom kernels
> 
> On 22.03.22 09:54, Moessbauer, Felix (T CED SES-DE) wrote:
> >> -----Original Message-----
> >> From: Kiszka, Jan (T CED) <jan.kiszka@siemens.com>
> >> Sent: Monday, March 21, 2022 6:52 PM
> >> To: Moessbauer, Felix (T CED SES-DE) <felix.moessbauer@siemens.com>;
> >> isar- users@googlegroups.com
> >> Subject: Re: [PATCH 1/1] add support to set KBUILD_BUILD_TIMESTAMP
> >> for custom kernels
> >>
> >> On 21.03.22 18:33, Moessbauer, Felix (T CED SES-DE) wrote:
> >>> Hi Jan,
> >>>
> >>>> -----Original Message-----
> >>>> From: Kiszka, Jan (T CED) <jan.kiszka@siemens.com>
> >>>> Sent: Monday, March 21, 2022 6:18 PM
> >>>> To: Moessbauer, Felix (T CED SES-DE)
> >>>> <felix.moessbauer@siemens.com>;
> >>>> isar- users@googlegroups.com
> >>>> Subject: Re: [PATCH 1/1] add support to set KBUILD_BUILD_TIMESTAMP
> >>>> for custom kernels
> >>>>
> >>>> On 21.03.22 15:40, Felix Moessbauer wrote:
> >>>>> This patch adds the infrastructure to overwrite the
> >>>>> KBUILD_BUILD_TIMESTAMP environment variable for custom kernel
> builds.
> >>>>> By that, we improve the support for reproducible kernel builds.
> >>>>>
> >>>>
> >>>> Agreed.
> >>>>
> >>>>> Setting this to a fixed string further helps to profit from ccache
> >>>>> caching on repeated builds.
> >>>>
> >>>> Hmm, but the practical impact of this variable should have been
> >>>> limited /wrt ccache. I was seeing significant build-time reduction
> >>>> before the
> >> commit already.
> >>>
> >>> Yes, but of course depends on configuration.
> >>>
> >>>>
> >>>>>
> >>>>> Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
> >>>>> ---
> >>>>>  meta/recipes-kernel/linux/files/debian/isar/build.tmpl  | 1 +
> >>>>> meta/recipes-kernel/linux/files/debian/isar/common.tmpl | 2 ++
> >>>>>  meta/recipes-kernel/linux/linux-custom.inc              | 3 +++
> >>>>>  3 files changed, 6 insertions(+)
> >>>>>
> >>>>> diff --git
> >>>>> a/meta/recipes-kernel/linux/files/debian/isar/build.tmpl
> >>>>> b/meta/recipes-kernel/linux/files/debian/isar/build.tmpl
> >>>>> index b7749cec..32d2eb23 100644
> >>>>> --- a/meta/recipes-kernel/linux/files/debian/isar/build.tmpl
> >>>>> +++ b/meta/recipes-kernel/linux/files/debian/isar/build.tmpl
> >>>>> @@ -34,6 +34,7 @@ print_settings() {  # ---------------  #
> >>>>> ARCH=${ARCH}  # CROSS_COMPILE=${CROSS_COMPILE}
> >>>>> +# KBUILD_BUILD_TIMESTAMP=${KBUILD_BUILD_TIMESTAMP}
> >>>>>  EOF
> >>>>>  }
> >>>>>
> >>>>> diff --git
> >>>>> a/meta/recipes-kernel/linux/files/debian/isar/common.tmpl
> >>>>> b/meta/recipes-kernel/linux/files/debian/isar/common.tmpl
> >>>>> index b7752fb6..ffe84745 100644
> >>>>> --- a/meta/recipes-kernel/linux/files/debian/isar/common.tmpl
> >>>>> +++ b/meta/recipes-kernel/linux/files/debian/isar/common.tmpl
> >>>>> @@ -7,6 +7,7 @@ ARCH=${KERNEL_ARCH}
> >>>>> KERNEL_PKG_IMAGE=linux-image-${KERNEL_NAME_PROVIDED}
> >>>>>  KERNEL_PKG_KERN_HEADERS=linux-headers-
> ${KERNEL_NAME_PROVIDED}
> >>>>>  KERNEL_PKG_LIBC_HEADERS=linux-libc-dev
> >>>>> +KBUILD_BUILD_TIMESTAMP="${KBUILD_BUILD_TIMESTAMP}"
> >>>>>
> >>>>>  # Constants
> >>>>>  KCONF=.config
> >>>>> @@ -36,6 +37,7 @@ main() {
> >>>>>
> >>>>>      # variables to be exported
> >>>>>      export ARCH
> >>>>> +    export KBUILD_BUILD_TIMESTAMP
> >>>>>
> >>>>>      # are we cross-compiling?
> >>>>>      BUILD_ARCH=$(dpkg-architecture -qDEB_BUILD_ARCH) diff --git
> >>>>> a/meta/recipes-kernel/linux/linux-custom.inc
> >>>>> b/meta/recipes-kernel/linux/linux-custom.inc
> >>>>> index 8a5dbf82..f8e87453 100644
> >>>>> --- a/meta/recipes-kernel/linux/linux-custom.inc
> >>>>> +++ b/meta/recipes-kernel/linux/linux-custom.inc
> >>>>> @@ -33,6 +33,8 @@ KERNEL_HEADERS_DEBIAN_DEPENDS ?= "libc6, \
> >>>>>
> >>>>>  KERNEL_LIBC_DEV_DEPLOY ?= "0"
> >>>>>
> >>>>> +KBUILD_BUILD_TIMESTAMP ??= "LANG=C $(date)"
> >>>>
> >>>> Can't we use SOURCE_DATE_EPOCH like the rest?
> >>>
> >>> This variable is still not honored by the kernel (AFAIK).
> >>> Also the kernel documentation only mentions KBUILD_BUILD_TIMESTAMP.
> >>> There is a patch from 2015 which has not been applied [1].
> >>>
> >>> We could do the mapping in ISAR, but I prefer to have it explicit.
> >>>
> >>>
> >>
> >> Then how does the regular Debian kernel set a stable date? We should
> >> align to that and surely not force the user to set anything manually
> >> (that is my interpretation of the behavior of the current patch).
> >
> > They set it in the rules file to "$(SOURCE_DATE)" [1], which itself is computed
> from the changelog:
> > SOURCE_DATE := $(shell dpkg-parsechangelog -SDate)
> >
> > Unfortunately, this is not possible for us because we generate the changelog
> on the fly.
> > Setting "KBUILD_BUILD_TIMESTAMP" to the current build time (as
> > default) should be reasonable, Simply because we do not have better
> information. That's also how it was previously.
> > The only addition here is do give the user support to set it to something
> different.
> >
> 
> There must be more information in the build env because other packages that
> do evaluate SOURCE_DATE_EPOCH find that properly set, automatically.

Well... the SOURCE_DATE_EPOCH variable is set by debhelper to the date of the last entry in the changelog [1], [2].
This is technically the same as stated above, but already happens automatically.

In our use-case, that does not help much, as the changelog is auto-generated by ISAR.
Actually, it points to the begin of the Unix epoch, which is questionable.
At least there, we should add the current build time (and add an option to overwrite, otherwise dpkg-raw recipes can no longer be cached).

Maybe the better strategy is to add a BB variable "SOURCE_DATE_EPOCH" to the debianize.class and use the value in the kernel recipe to set KBUILD_BUILD_TIMESTAMP.
By that, we would fix the questionable entry in the changelog, as well as still support reproducible builds.

Felix

[1] https://reproducible-builds.org/docs/source-date-epoch/
[2] https://www.debian.org/doc/manuals/debmake-doc/ch05.en.html#reproducible

> 
> Jan
> 
> --
> Siemens AG, Technology
> Competence Center Embedded Linux

  reply	other threads:[~2022-03-22 17:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-21 14:40 Felix Moessbauer
2022-03-21 17:18 ` Jan Kiszka
2022-03-21 17:33   ` Moessbauer, Felix
2022-03-21 17:51     ` Jan Kiszka
2022-03-22  8:54       ` Moessbauer, Felix
2022-03-22 14:49         ` Jan Kiszka
2022-03-22 17:27           ` Moessbauer, Felix [this message]
2022-03-22 18:52             ` Jan Kiszka

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=AM9PR10MB4869ADBA17BB9BF4F09B298289179@AM9PR10MB4869.EURPRD10.PROD.OUTLOOK.COM \
    --to=felix.moessbauer@siemens.com \
    --cc=isar-users@googlegroups.com \
    --cc=jan.kiszka@siemens.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox