summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Clark <christopher.w.clark@gmail.com>2018-08-12 18:55:26 -0700
committerBruce Ashfield <bruce.ashfield@windriver.com>2018-08-14 12:57:25 -0400
commit9ca16e1a6e89c4fac39dc6ef3b8844909e5c19ee (patch)
tree489fdfcf4f3800b06eb9b9227c4cc87772a93b9b
parentf5f8849df623ed5d33d091d42c7b9504b3ce77c5 (diff)
downloadmeta-virtualization-9ca16e1a6e89c4fac39dc6ef3b8844909e5c19ee.tar.gz
Xen: improve build reproducibility
Enable reproducible builds of the hypervisor binaries by defining build variables and setting compiler flags to support this. Signed-off-by: Christopher Clark <christopher.clark6@baesystems.com> Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
-rw-r--r--recipes-extended/xen/xen.inc27
1 files changed, 27 insertions, 0 deletions
diff --git a/recipes-extended/xen/xen.inc b/recipes-extended/xen/xen.inc
index 4894c770..38cecd1d 100644
--- a/recipes-extended/xen/xen.inc
+++ b/recipes-extended/xen/xen.inc
@@ -870,6 +870,24 @@ EXTRA_OEMAKE += "ETHERBOOT_ROMS=${STAGING_DIR_HOST}/usr/share/firmware/rtl8139.r
870EXTRA_OEMAKE += "WGET=/bin/false" 870EXTRA_OEMAKE += "WGET=/bin/false"
871EXTRA_OEMAKE += "GIT=/bin/false" 871EXTRA_OEMAKE += "GIT=/bin/false"
872 872
873# Improve build reproducibility: provide values for build variables.
874def get_build_time_vars(d):
875 source_date_epoch = d.getVar('SOURCE_DATE_EPOCH')
876 if source_date_epoch is not None:
877 import datetime
878 utc_datetime = datetime.datetime.utcfromtimestamp(float(source_date_epoch))
879 return " XEN_BUILD_DATE=" + utc_datetime.strftime("%Y-%m-%d") + \
880 " XEN_BUILD_TIME=" + utc_datetime.strftime("%H:%M:%S")
881 return ""
882EXTRA_OEMAKE += "${@['', 'XEN_WHOAMI=${PF} XEN_DOMAIN=${DISTRO} XEN_BUILD_HOST=${PN}-buildhost'] \
883 [d.getVar('BUILD_REPRODUCIBLE_BINARIES') == '1']}${@get_build_time_vars(d)}"
884
885# Improve build reproducibility: compiler flags to remove filesystem differences.
886# Suppress __FILE__ via an alternative builtin.
887CC += "${@['', '-gno-record-gcc-switches -Wno-builtin-macro-redefined -D__FILE__=__VERSION__ ' + \
888 '-fdebug-prefix-map=${WORKDIR}=${PN}'] \
889 [d.getVar('BUILD_REPRODUCIBLE_BINARIES') == '1']}"
890
873# check for XSM in package config to allow XSM_ENABLE to be set 891# check for XSM in package config to allow XSM_ENABLE to be set
874python () { 892python () {
875 pkgconfig = d.getVar('PACKAGECONFIG') 893 pkgconfig = d.getVar('PACKAGECONFIG')
@@ -889,6 +907,15 @@ do_post_patch() {
889 907
890 # libsystemd-daemon -> libsystemd for newer systemd versions 908 # libsystemd-daemon -> libsystemd for newer systemd versions
891 sed -i 's#libsystemd-daemon#libsystemd#' ${S}/tools/configure 909 sed -i 's#libsystemd-daemon#libsystemd#' ${S}/tools/configure
910
911 # Improve build reproducibility: disable insertion of the build timestamp
912 # into the x86 EFI hypervisor binary.
913 # binutils should allow a user-supplied timestamp or use SOURCE_DATE_EPOCH
914 # for PE but currently does not.
915 if [ "${BUILD_REPRODUCIBLE_BINARIES}" = "1" ] ; then
916 sed '/^EFI_LDFLAGS = /{a EFI_LDFLAGS += --no-insert-timestamp
917}' -i "${S}/xen/arch/x86/Makefile"
918 fi
892} 919}
893 920
894addtask post_patch after do_patch before do_configure 921addtask post_patch after do_patch before do_configure