[OE-core] [PATCH v3 10/11] kernel.bbclass: improve reproducibility

Christopher Larson kergoth at gmail.com
Thu Aug 17 16:14:26 UTC 2017


On Wed, Aug 9, 2017 at 10:48 AM, Juro Bystricky <juro.bystricky at intel.com>
wrote:

> Several tweaks to improve reproducibility:
>
> 1. If BUILD_REPRODUCIBLE_BINARIES == 1, set KBUILD_BUILD_TIMESTAMP
> to a reproducible value. This is either a non-zero SOURCE_DATE_EPOCH, or
> the
> value obtained from top entry of GIT repo, or (if there is no GIT repo)
> fallback to REPRODUCIBLE_TIMESTAMP_ROOTFS as the last resort.
> Also export KCONFIG_NOTIMESTAMP=1.
>
> 2. When compressing vmlinux.gz, use gzip "-n" option
>
> 3. Kernel and kernel modules contain hard coded paths referencing the host
> build system. This is usually because the source code contains __FILE__
> at some place. This prevents binary reproducibility. However, some
> compilers
> allow remapping of the __FILE__ value. If we detect the compiler is capable
> of doing this, we replace the source path $(S) part of __FILE__ by a
> string "/kernel-source".
> For example:
>
> ​/data/master/build/tmp/work-shared/qemux86/kernel-source/
> drivers/media/v4l2-core/videobuf2-core.​c
>
> will be replaced by a reproducible value:
>
> /kernel-source/drivers/media/v4l2-core/videobuf2-core.c.
>
> Signed-off-by: Juro Bystricky <juro.bystricky at intel.com>
> ---
>  meta/classes/kernel.bbclass | 39 ++++++++++++++++++++++++++++++++++++---
>  1 file changed, 36 insertions(+), 3 deletions(-)
>
> diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
> index ce2cab6..2a76554 100644
> --- a/meta/classes/kernel.bbclass
> +++ b/meta/classes/kernel.bbclass
> @@ -255,8 +255,39 @@ python do_devshell_prepend () {
>
>  addtask bundle_initramfs after do_install before do_deploy
>
> +get_cc_option () {
> +               # Check if KERNEL_CC supports the option "file-prefix-map".
> +               # This option allows us to build images with __FILE__
> values that do not
> +               # contain the host build path.
> +               cc_option_supported=`${KERNEL_CC} -Q --help=joined | grep
> ffile-prefix-map`
>

This fails the do_compile task if ffile-prefix-map isn’t found in the help
output, resulting in build failures with an external toolchain, for
example. This function doesn’t work the way you intended at all. It also
fails to quote things properly, uses the old `` syntax rather than $(), and
relies on grep output rather than grep exit codes.

At a minimum we need a “|| true” or “|| :” on the end of the
cc_option_supported= line. I don’t see why this doesn’t just do this,
instead, though:

    if ${KERNEL_CC} -Q —help=joined | grep -q
“\-ffile-prefix-map=<old=new>”; then
        echo “\-ffile-prefix-map=${S}=/kernel-source/“
    fi
-- 
Christopher Larson
kergoth at gmail dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Senior Software Engineer, Mentor Graphics
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openembedded.org/pipermail/openembedded-core/attachments/20170817/395f5e9e/attachment-0002.html>


More information about the Openembedded-core mailing list