xen, xen-tools: reproducible build compiler flags

The change to the method of passing compiler flags into the Xen build
system in 6b697676 omitted passing the compiler flags for improving
build reproducibility, so this commit returns them and includes a change
to use the -ffile-prefix-map compiler option to remove host filesystem
artefacts instead of the prior method of redefining the __FILE__ builtin
macro.

Signed-off-by: Christopher Clark <christopher.w.clark@gmail.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
This commit is contained in:
Christopher Clark 2020-03-08 21:56:56 -07:00 committed by Bruce Ashfield
parent bbbda2aff9
commit e57cf80d54

View File

@ -101,12 +101,12 @@ export LDFLAGS=""
# It must not be compiled with SSE compiler options enabled and the Xen build # It must not be compiled with SSE compiler options enabled and the Xen build
# explicitly clears CFLAGS to ensure that, so such options must not be passed # explicitly clears CFLAGS to ensure that, so such options must not be passed
# in via the tool variable. hvmloader is required to run HVM-mode guest VMs. # in via the tool variable. hvmloader is required to run HVM-mode guest VMs.
CC="${CCACHE}${HOST_PREFIX}gcc ${TOOLCHAIN_OPTIONS}" CC="${CCACHE}${HOST_PREFIX}gcc ${TOOLCHAIN_OPTIONS} ${CC_REPRODUCIBLE_OPTIONS}"
EXTRA_CFLAGS_XEN_CORE="${HOST_CC_ARCH} ${CFLAGS}" EXTRA_CFLAGS_XEN_CORE="${HOST_CC_ARCH} ${CFLAGS}"
EXTRA_CFLAGS_XEN_TOOLS="${HOST_CC_ARCH} ${CFLAGS}" EXTRA_CFLAGS_XEN_TOOLS="${HOST_CC_ARCH} ${CFLAGS}"
# 32-bit ARM needs the TUNE_CCARGS component of HOST_CC_ARCH to be passed # 32-bit ARM needs the TUNE_CCARGS component of HOST_CC_ARCH to be passed
# in CC to ensure that configure can compile binaries for the right arch. # in CC to ensure that configure can compile binaries for the right arch.
CC_arm="${CCACHE}${HOST_PREFIX}gcc ${TUNE_CCARGS} ${TOOLCHAIN_OPTIONS}" CC_arm="${CCACHE}${HOST_PREFIX}gcc ${TUNE_CCARGS} ${TOOLCHAIN_OPTIONS} ${CC_REPRODUCIBLE_OPTIONS}"
EXTRA_CFLAGS_XEN_CORE_arm="${SECURITY_CFLAGS} ${CFLAGS}" EXTRA_CFLAGS_XEN_CORE_arm="${SECURITY_CFLAGS} ${CFLAGS}"
EXTRA_CFLAGS_XEN_TOOLS_arm="${SECURITY_CFLAGS} ${CFLAGS}" EXTRA_CFLAGS_XEN_TOOLS_arm="${SECURITY_CFLAGS} ${CFLAGS}"
@ -155,8 +155,8 @@ EXTRA_OEMAKE += "${@['', 'XEN_WHOAMI=${PF} XEN_DOMAIN=${DISTRO} XEN_BUILD_HOST=$
[d.getVar('BUILD_REPRODUCIBLE_BINARIES') == '1']}${@get_build_time_vars(d)}" [d.getVar('BUILD_REPRODUCIBLE_BINARIES') == '1']}${@get_build_time_vars(d)}"
# Improve build reproducibility: compiler flags to remove filesystem differences. # Improve build reproducibility: compiler flags to remove filesystem differences.
# Suppress __FILE__ via an alternative builtin. CC_REPRODUCIBLE_OPTIONS = "${@['', '-gno-record-gcc-switches ' + \
CC += "${@['', '-gno-record-gcc-switches -Wno-builtin-macro-redefined -D__FILE__=__VERSION__ ' + \ '-ffile-prefix-map=${S}=${PN}-source ' + \
'-fdebug-prefix-map=${WORKDIR}=${PN}'] \ '-fdebug-prefix-map=${WORKDIR}=${PN}'] \
[d.getVar('BUILD_REPRODUCIBLE_BINARIES') == '1']}" [d.getVar('BUILD_REPRODUCIBLE_BINARIES') == '1']}"