* [RFC] Documentation: kbuild: Add description of git for reproducible builds @ 2022-10-20 10:38 Dan Li 2022-10-20 14:05 ` Bagas Sanjaya 0 siblings, 1 reply; 5+ messages in thread From: Dan Li @ 2022-10-20 10:38 UTC (permalink / raw) To: masahiroy, michal.lkml, ndesaulniers, corbet Cc: linux-kbuild, linux-doc, linux-kernel, Dan Li The status of git will affect the final compilation result, add it to the documentation of reproducible builds. Signed-off-by: Dan Li <ashimida@linux.alibaba.com> --- Documentation/kbuild/reproducible-builds.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Documentation/kbuild/reproducible-builds.rst b/Documentation/kbuild/reproducible-builds.rst index 071f0151a7a4..13397f38c358 100644 --- a/Documentation/kbuild/reproducible-builds.rst +++ b/Documentation/kbuild/reproducible-builds.rst @@ -119,6 +119,16 @@ To avoid this, you can make the vDSO different for different kernel versions by including an arbitrary string of "salt" in it. This is specified by the Kconfig symbol ``CONFIG_BUILD_SALT``. +Git +----------------------- + +Uncommitted changes or different commit ids in git can also lead +to different compilation results. For example, after executing +``git reset HEAD^``, even if the code is the same, the +``include/config/kernel.release`` generated during compilation +will be different, which will eventually lead to binary differences. +See ``scripts/setlocalversion`` for details. + .. _KBUILD_BUILD_TIMESTAMP: kbuild.html#kbuild-build-timestamp .. _KBUILD_BUILD_USER and KBUILD_BUILD_HOST: kbuild.html#kbuild-build-user-kbuild-build-host .. _KCFLAGS: kbuild.html#kcflags -- 2.17.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [RFC] Documentation: kbuild: Add description of git for reproducible builds 2022-10-20 10:38 [RFC] Documentation: kbuild: Add description of git for reproducible builds Dan Li @ 2022-10-20 14:05 ` Bagas Sanjaya 2022-10-21 1:48 ` Dan Li 0 siblings, 1 reply; 5+ messages in thread From: Bagas Sanjaya @ 2022-10-20 14:05 UTC (permalink / raw) To: Dan Li Cc: masahiroy, michal.lkml, ndesaulniers, corbet, linux-kbuild, linux-doc, linux-kernel, Nicolas Schier [-- Attachment #1: Type: text/plain, Size: 1234 bytes --] On Thu, Oct 20, 2022 at 03:38:23AM -0700, Dan Li wrote: > diff --git a/Documentation/kbuild/reproducible-builds.rst b/Documentation/kbuild/reproducible-builds.rst > index 071f0151a7a4..13397f38c358 100644 > --- a/Documentation/kbuild/reproducible-builds.rst > +++ b/Documentation/kbuild/reproducible-builds.rst > @@ -119,6 +119,16 @@ To avoid this, you can make the vDSO different for different > kernel versions by including an arbitrary string of "salt" in it. > This is specified by the Kconfig symbol ``CONFIG_BUILD_SALT``. > > +Git > +----------------------- > + > +Uncommitted changes or different commit ids in git can also lead > +to different compilation results. For example, after executing > +``git reset HEAD^``, even if the code is the same, the > +``include/config/kernel.release`` generated during compilation > +will be different, which will eventually lead to binary differences. > +See ``scripts/setlocalversion`` for details. > + Briefly read the script, I don't see what the correlation between git reset with LOCALVERSION thing is. Also, does the exact state of git repository required for reproducible builds? Thanks. -- An old man doll... just what I always wanted! - Clara [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC] Documentation: kbuild: Add description of git for reproducible builds 2022-10-20 14:05 ` Bagas Sanjaya @ 2022-10-21 1:48 ` Dan Li 2022-10-21 8:00 ` Nicolas Schier 0 siblings, 1 reply; 5+ messages in thread From: Dan Li @ 2022-10-21 1:48 UTC (permalink / raw) To: Bagas Sanjaya Cc: masahiroy, michal.lkml, ndesaulniers, corbet, linux-kbuild, linux-doc, linux-kernel, Nicolas Schier On 10/20/22 07:05, Bagas Sanjaya wrote: > On Thu, Oct 20, 2022 at 03:38:23AM -0700, Dan Li wrote: >> diff --git a/Documentation/kbuild/reproducible-builds.rst b/Documentation/kbuild/reproducible-builds.rst >> index 071f0151a7a4..13397f38c358 100644 >> --- a/Documentation/kbuild/reproducible-builds.rst >> +++ b/Documentation/kbuild/reproducible-builds.rst >> @@ -119,6 +119,16 @@ To avoid this, you can make the vDSO different for different >> kernel versions by including an arbitrary string of "salt" in it. >> This is specified by the Kconfig symbol ``CONFIG_BUILD_SALT``. >> >> +Git >> +----------------------- >> + >> +Uncommitted changes or different commit ids in git can also lead >> +to different compilation results. For example, after executing >> +``git reset HEAD^``, even if the code is the same, the >> +``include/config/kernel.release`` generated during compilation >> +will be different, which will eventually lead to binary differences. >> +See ``scripts/setlocalversion`` for details. >> + > > Briefly read the script, I don't see what the correlation between git > reset with LOCALVERSION thing is. Also, does the exact state of git > repository required for reproducible builds? > Hi Bagas, The Makefile has the following code: filechk_kernel.release = \ echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))" The output of setlocalversion affects kernel.release, while the output of setlocalversion is related to the state of git when the git repository exists (see function scm_version). So changes in git state will result in changes to kernel.release, and this information will be included in the final output vmlinux/modules and in turn affect reproducible builds. For example: $ git log commit 4cd155a93eec...... $ make ... $ cat include/config/kernel.release 6.0.0-rc4-00025-g4cd155a93eec $ git reset HEAD^ $ git log commit 7b4d266b0c41...... $ make ... $ cat include/config/kernel.release 6.0.0-rc4-00024-g7b4d266b0c41-dirty AFAICT, in the presence of a git repository, we can compile a reproducible build kernel in any git state, but we need to ensure that the git state is always the same between compilations (or the same from the perspective of the scm_version function). Thanks, Dan. > Thanks. > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC] Documentation: kbuild: Add description of git for reproducible builds 2022-10-21 1:48 ` Dan Li @ 2022-10-21 8:00 ` Nicolas Schier 2022-10-23 20:02 ` Masahiro Yamada 0 siblings, 1 reply; 5+ messages in thread From: Nicolas Schier @ 2022-10-21 8:00 UTC (permalink / raw) To: Dan Li Cc: Bagas Sanjaya, masahiroy, michal.lkml, ndesaulniers, corbet, linux-kbuild, linux-doc, linux-kernel On Thu, Oct 20, 2022 at 06:48:20PM -0700, Dan Li wrote: > > > On 10/20/22 07:05, Bagas Sanjaya wrote: > > On Thu, Oct 20, 2022 at 03:38:23AM -0700, Dan Li wrote: > > > diff --git a/Documentation/kbuild/reproducible-builds.rst b/Documentation/kbuild/reproducible-builds.rst > > > index 071f0151a7a4..13397f38c358 100644 > > > --- a/Documentation/kbuild/reproducible-builds.rst > > > +++ b/Documentation/kbuild/reproducible-builds.rst > > > @@ -119,6 +119,16 @@ To avoid this, you can make the vDSO different for different > > > kernel versions by including an arbitrary string of "salt" in it. > > > This is specified by the Kconfig symbol ``CONFIG_BUILD_SALT``. > > > +Git > > > +----------------------- > > > + > > > +Uncommitted changes or different commit ids in git can also lead > > > +to different compilation results. For example, after executing > > > +``git reset HEAD^``, even if the code is the same, the > > > +``include/config/kernel.release`` generated during compilation > > > +will be different, which will eventually lead to binary differences. > > > +See ``scripts/setlocalversion`` for details. > > > + > > > > Briefly read the script, I don't see what the correlation between git > > reset with LOCALVERSION thing is. Also, does the exact state of git > > repository required for reproducible builds? > > > > Hi Bagas, > > The Makefile has the following code: > filechk_kernel.release = \ > echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))" > > The output of setlocalversion affects kernel.release, while the output > of setlocalversion is related to the state of git when the git repository > exists (see function scm_version). > > So changes in git state will result in changes to kernel.release, and > this information will be included in the final output vmlinux/modules > and in turn affect reproducible builds. > > For example: > $ git log > commit 4cd155a93eec...... > $ make ... > $ cat include/config/kernel.release > 6.0.0-rc4-00025-g4cd155a93eec > > $ git reset HEAD^ > $ git log > commit 7b4d266b0c41...... > $ make ... > $ cat include/config/kernel.release > 6.0.0-rc4-00024-g7b4d266b0c41-dirty > > > AFAICT, in the presence of a git repository, we can compile a reproducible > build kernel in any git state, but we need to ensure that the git state is > always the same between compilations (or the same from the perspective of > the scm_version function). yes, that definitely true. Absence or presence of git tags can change the output of setlocalversion even more drastically. I think it is sensible to add a stanza about git in Documentation/kbuild/reproducible-builds.rst. Kind regards, Nicolas ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC] Documentation: kbuild: Add description of git for reproducible builds 2022-10-21 8:00 ` Nicolas Schier @ 2022-10-23 20:02 ` Masahiro Yamada 0 siblings, 0 replies; 5+ messages in thread From: Masahiro Yamada @ 2022-10-23 20:02 UTC (permalink / raw) To: Nicolas Schier Cc: Dan Li, Bagas Sanjaya, michal.lkml, ndesaulniers, corbet, linux-kbuild, linux-doc, linux-kernel On Fri, Oct 21, 2022 at 5:00 PM Nicolas Schier <n.schier@avm.de> wrote: > > On Thu, Oct 20, 2022 at 06:48:20PM -0700, Dan Li wrote: > > > > > > On 10/20/22 07:05, Bagas Sanjaya wrote: > > > On Thu, Oct 20, 2022 at 03:38:23AM -0700, Dan Li wrote: > > > > diff --git a/Documentation/kbuild/reproducible-builds.rst b/Documentation/kbuild/reproducible-builds.rst > > > > index 071f0151a7a4..13397f38c358 100644 > > > > --- a/Documentation/kbuild/reproducible-builds.rst > > > > +++ b/Documentation/kbuild/reproducible-builds.rst > > > > @@ -119,6 +119,16 @@ To avoid this, you can make the vDSO different for different > > > > kernel versions by including an arbitrary string of "salt" in it. > > > > This is specified by the Kconfig symbol ``CONFIG_BUILD_SALT``. > > > > +Git > > > > +----------------------- > > > > + > > > > +Uncommitted changes or different commit ids in git can also lead > > > > +to different compilation results. For example, after executing > > > > +``git reset HEAD^``, even if the code is the same, the > > > > +``include/config/kernel.release`` generated during compilation > > > > +will be different, which will eventually lead to binary differences. > > > > +See ``scripts/setlocalversion`` for details. > > > > + > > > > > > Briefly read the script, I don't see what the correlation between git > > > reset with LOCALVERSION thing is. Also, does the exact state of git > > > repository required for reproducible builds? > > > > > > > Hi Bagas, > > > > The Makefile has the following code: > > filechk_kernel.release = \ > > echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))" > > > > The output of setlocalversion affects kernel.release, while the output > > of setlocalversion is related to the state of git when the git repository > > exists (see function scm_version). > > > > So changes in git state will result in changes to kernel.release, and > > this information will be included in the final output vmlinux/modules > > and in turn affect reproducible builds. > > > > For example: > > $ git log > > commit 4cd155a93eec...... > > $ make ... > > $ cat include/config/kernel.release > > 6.0.0-rc4-00025-g4cd155a93eec > > > > $ git reset HEAD^ > > $ git log > > commit 7b4d266b0c41...... > > $ make ... > > $ cat include/config/kernel.release > > 6.0.0-rc4-00024-g7b4d266b0c41-dirty > > > > > > AFAICT, in the presence of a git repository, we can compile a reproducible > > build kernel in any git state, but we need to ensure that the git state is > > always the same between compilations (or the same from the perspective of > > the scm_version function). > > yes, that definitely true. Absence or presence of git tags can change > the output of setlocalversion even more drastically. > > I think it is sensible to add a stanza about git in > Documentation/kbuild/reproducible-builds.rst. Make sense. Applied to linux-kbuild. Thanks. -- Best Regards Masahiro Yamada ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-10-23 20:03 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-10-20 10:38 [RFC] Documentation: kbuild: Add description of git for reproducible builds Dan Li 2022-10-20 14:05 ` Bagas Sanjaya 2022-10-21 1:48 ` Dan Li 2022-10-21 8:00 ` Nicolas Schier 2022-10-23 20:02 ` Masahiro Yamada
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox