All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ovmf: Improve reproducibility by enabling prefix mapping
@ 2021-05-09 15:56 Richard Purdie
  0 siblings, 0 replies; only message in thread
From: Richard Purdie @ 2021-05-09 15:56 UTC (permalink / raw)
  To: openembedded-core

We want to pass ${DEBUG_PREFIX_MAP} to gcc commands and also pass in
--debug-prefix-map to nasm (we carry a patch to nasm for this). The
tools commands are built by ovmf-native so we need to patch this in
at target build time when we know the right values. This function also
has to be able to undo what it changed and rerun. By using determininistc
file paths in the ovmf build, it removes the opportunitity for gcc/ld to
change the output binaries due to path lengths overflowing section sizes
and causing small changes in the binary output.

This also means that if builds have reproducibility issues in future, it
becomes much easier to compare intermediate build artefacts.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/recipes-core/ovmf/ovmf_git.bb | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/meta/recipes-core/ovmf/ovmf_git.bb b/meta/recipes-core/ovmf/ovmf_git.bb
index 896b3b63202..91de742c06c 100644
--- a/meta/recipes-core/ovmf/ovmf_git.bb
+++ b/meta/recipes-core/ovmf/ovmf_git.bb
@@ -104,6 +104,33 @@ fix_toolchain_append_class-native() {
         ${S}/BaseTools/Conf/tools_def.template
 }
 
+#
+# We want to pass ${DEBUG_PREFIX_MAP} to gcc commands and also pass in
+# --debug-prefix-map to nasm (we carry a patch to nasm for this). The
+# tools commands are built by ovmf-native so we need to patch this in
+# at target build time when we know the right values. This function also
+# has to be able to undo what it changed and rerun. By using determininistc
+# file paths during the ovmf build, it removes the opportunitity for gcc/ld to
+# change the output binaries due to path lengths overflowing section sizes
+# and causing small changes in the binary output. Previously we relied on 
+# the stripped output being the same which isn't always the case if the 
+# size of the debug symbols varies.
+#
+do_configure_class-target() {
+    sed -i \
+        -e 's# DEF(GCC_PREFIX_MAP)##g' \
+        -e 's# DEF(NASM_PREFIX_MAP)##g' \
+        -e '/^DEFINE \(GCC|NASM\)_PREFIX_MAP/d' \
+        -e 's#^\(DEFINE GCC_ALL_CC_FLAGS.*=.*\)\r$#\1 DEF(GCC_PREFIX_MAP)#' \
+        -e 's#^\(DEFINE GCC_PP_FLAGS.*=.*\)\r$#\1 DEF(GCC_PREFIX_MAP)#' \
+        -e 's#^\(DEFINE GCC_ASM_FLAGS.*=.*\)\r$#\1 DEF(GCC_PREFIX_MAP)#' \
+        -e 's#^\(*_GCC5_IA32_NASM_FLAGS.*=.*\)\r$#\1 DEF(NASM_PREFIX_MAP)#' \
+        -e 's#^\(*_GCC5_X64_NASM_FLAGS.*=.*\)\r$#\1 DEF(NASM_PREFIX_MAP)#' \
+        -e '1 i\DEFINE NASM_PREFIX_MAP = --debug-prefix-map=${WORKDIR}=/usr/src/debug/ovmf/${EXTENDPE}${PV}-${PR}' \
+        -e '1 i\DEFINE GCC_PREFIX_MAP = ${DEBUG_PREFIX_MAP}' \
+        ${STAGING_BINDIR_NATIVE}/${EDK_TOOLS_DIR}/BaseTools/Conf/tools_def.template
+}
+
 GCC_VER="$(${CC} -v 2>&1 | tail -n1 | awk '{print $3}')"
 
 fixup_target_tools() {
-- 
2.30.2


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-05-09 15:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-09 15:56 [PATCH] ovmf: Improve reproducibility by enabling prefix mapping Richard Purdie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.