From: Bruce Ashfield <bruce.ashfi...@gmail.com>

If CONFIG_IKHEADERS is set to =m, then reproducibility issues creep
into the modules build, since the variables we are setting for the
main kernel build are not present.

Since the source code must be available for a possibly git query
on the timestamp, there didn't seem to be an easy way to move the
environment variable setting to a common routine. As such, we
duplicate the block of code that exports the required variables for
reproducible builds. There is a maintenance risk to this, but any
issues should be easy enough to catch.

Signed-off-by: Bruce Ashfield <bruce.ashfi...@gmail.com>
Signed-off-by: Richard Purdie <richard.pur...@linuxfoundation.org>
(cherry picked from commit 82cdfcdccfedd320ebc0cdc778c7d4966198b96f)
Signed-off-by: Steve Sakoman <st...@sakoman.com>
---
 meta/classes/kernel.bbclass | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
index a724645466..a3990aaf59 100644
--- a/meta/classes/kernel.bbclass
+++ b/meta/classes/kernel.bbclass
@@ -331,6 +331,21 @@ kernel_do_compile() {
 
 do_compile_kernelmodules() {
        unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
+       if [ "${BUILD_REPRODUCIBLE_BINARIES}" = "1" ]; then
+               # kernel sources do not use do_unpack, so SOURCE_DATE_EPOCH may 
not
+               # be set....
+               if [ "${SOURCE_DATE_EPOCH}" = "" -o "${SOURCE_DATE_EPOCH}" = 
"0" ]; then
+                       # The source directory is not necessarily a git 
repository, so we
+                       # specify the git-dir to ensure that git does not query 
a
+                       # repository in any parent directory.
+                       SOURCE_DATE_EPOCH=`git --git-dir="${S}/.git" log -1 
--pretty=%ct 2>/dev/null || echo "${REPRODUCIBLE_TIMESTAMP_ROOTFS}"`
+               fi
+
+               ts=`LC_ALL=C date -d @$SOURCE_DATE_EPOCH`
+               export KBUILD_BUILD_TIMESTAMP="$ts"
+               export KCONFIG_NOTIMESTAMP=1
+               bbnote "KBUILD_BUILD_TIMESTAMP: $ts"
+       fi
        if (grep -q -i -e '^CONFIG_MODULES=y$' ${B}/.config); then
                cc_extra=$(get_cc_option)
                oe_runmake -C ${B} ${PARALLEL_MAKE} modules CC="${KERNEL_CC} 
$cc_extra " LD="${KERNEL_LD}" ${KERNEL_EXTRA_ARGS}
-- 
2.17.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#139060): 
https://lists.openembedded.org/g/openembedded-core/message/139060
Mute This Topic: https://lists.openembedded.org/mt/74618470/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub  
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to