gcc-target.inc: Prevent sysroot from leaking into configargs.h
PATCH 1/2 gcc-target.inc: Prevent sysroot from leaking into configargs.h
Prevent the full recipe-sysroot path from leaking into configargs.h. The configargs.h header is intended to be static and unchanged as the content is used as a means of determining that a gcc plugin is built for the same gcc. This also effects the output of 'gcc -v'. Due to per recipe sysroots and staging, the sysroot path would be replaced with the sysroot local to the recipe thus changing the content of configargs.h. This change also improves gcc binary reproducibility. The sysroot path is replaced with the base target root "/".
--- meta/recipes-devtools/gcc/gcc-target.inc | 8 ++++++++ 1 file changed, 8 insertions(+)
meta/recipes-devtools/gcc/gcc-target.inc +8 -0
@@ -137,6 +137,14 @@ FILES_${PN}-doc = "\ " do_compile () { + # Prevent full target sysroot path from being used in configargs.h header, + # as it will be rewritten when used by other sysroots preventing support + # for gcc plugins. Additionally the path is embeddeded into the output + # binary, this prevents building a reproducible binary. + oe_runmake configure-gcc + sed -i 's@${STAGING_DIR_TARGET}@/@g' ${B}/gcc/configargs.h + sed -i 's@${STAGING_DIR_HOST}@/@g' ${B}/gcc/configargs.h + oe_runmake all-host }
---
2.24.0
PATCH 2/2 gcc: Improve build reproduciblity
Prevent the gcc embedded checksum from containing a checksum that was computed with build specific paths. The checksum-options file included the value of LINKER/LDFLAGS which contains DEBUG_PREFIX_MAP and STAGING_DIR_TARGET.
---
This change along with the previous gcc-target/gcc-cross changes to handle configargs.h are sufficient to have ReproducibleTests of oe-selftest pass when 'tools-sdk' is in IMAGE_FEATURES.
--- meta/recipes-devtools/gcc/gcc-cross.inc | 7 +++++++ meta/recipes-devtools/gcc/gcc-target.inc | 7 +++++++ 2 files changed, 14 insertions(+)
meta/recipes-devtools/gcc/gcc-cross.inc +7 -0
@@ -68,6 +68,13 @@ do_compile () { sed -i 's@${STAGING_DIR_TARGET}@/host@g' ${B}/gcc/configargs.h sed -i 's@${STAGING_DIR_HOST}@/host@g' ${B}/gcc/configargs.h + # Prevent sysroot/workdir paths from being used in checksum-options. + # checksum-options is used to generate a checksum which is embedded into + # the output binary. + oe_runmake TARGET-gcc=checksum-options all-gcc + sed -i 's@${DEBUG_PREFIX_MAP}@@g' ${B}/gcc/checksum-options + sed -i 's@${STAGING_DIR_HOST}@/host@g' ${B}/gcc/checksum-options + oe_runmake all-host configure-target-libgcc (cd ${B}/${TARGET_SYS}/libgcc; oe_runmake enable-execute-stack.c unwind.h md-unwind-support.h sfp-machine.h gthr-default.h) # now generate script to drive testing
meta/recipes-devtools/gcc/gcc-target.inc +7 -0
@@ -145,6 +145,13 @@ do_compile () { sed -i 's@${STAGING_DIR_TARGET}@/@g' ${B}/gcc/configargs.h sed -i 's@${STAGING_DIR_HOST}@/@g' ${B}/gcc/configargs.h + # Prevent sysroot/workdir paths from being used in checksum-options. + # checksum-options is used to generate a checksum which is embedded into + # the output binary. + oe_runmake TARGET-gcc=checksum-options all-gcc + sed -i 's@${DEBUG_PREFIX_MAP}@@g' ${B}/gcc/checksum-options + sed -i 's@${STAGING_DIR_TARGET}@/@g' ${B}/gcc/checksum-options + oe_runmake all-host }
---
2.24.0