From b2add7984ea7efce04c5e3922866782beda85b5b Mon Sep 17 00:00:00 2001 From: Oleh Matiusha Date: Fri, 19 Jul 2024 06:33:08 +0000 Subject: [PATCH] clang: improve reproducibility Currently, class-target is reproducible, but class-nativesdk is not. What I did: - noticed that BuildVariables.inc contains meaningless path fragments after running sed, so I adjusted sed commands to remove the rest of paths as well; - moved common code into a function, which is then called twice; - changed do_compile:prepend into do_configure:append, this is more conventional and intuitive; - verified that the resulting code works for both target and nativesdk after these changes. Signed-off-by: Oleh Matiusha --- recipes-devtools/clang/clang_git.bb | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/recipes-devtools/clang/clang_git.bb b/recipes-devtools/clang/clang_git.bb index ad68c3e4..88ae329e 100644 --- a/recipes-devtools/clang/clang_git.bb +++ b/recipes-devtools/clang/clang_git.bb @@ -203,14 +203,23 @@ RRECOMMENDS:${PN} = "binutils" RRECOMMENDS:${PN}:append:class-target = " libcxx-dev" # patch out build host paths for reproducibility -do_compile:prepend:class-target() { - sed -i -e "s,${STAGING_DIR_NATIVE},,g" \ - -e "s,${STAGING_DIR_TARGET},,g" \ - -e "s,${S},,g" \ +reproducible_build_variables() { + sed -i -e "s,${DEBUG_PREFIX_MAP},,g" \ + -e "s,--sysroot=${RECIPE_SYSROOT},,g" \ + -e "s,${STAGING_DIR_HOST},,g" \ + -e "s,${S}/llvm,,g" \ -e "s,${B},,g" \ ${B}/tools/llvm-config/BuildVariables.inc } +do_configure:append:class-target() { + reproducible_build_variables +} + +do_configure:append:class-nativesdk() { + reproducible_build_variables +} + do_install:append() { rm -rf ${D}${libdir}/python*/site-packages/six.py } @@ -276,6 +285,9 @@ do_install:append:class-nativesdk () { ln -sf llvm-config ${D}${bindir}/llvm-config${PV} rm -rf ${D}${datadir}/llvm/cmake rm -rf ${D}${datadir}/llvm + + #reproducibility + sed -i -e 's,${B},,g' ${D}${libdir}/cmake/llvm/LLVMConfig.cmake } PACKAGES =+ "${PN}-libllvm ${PN}-lldb-python ${PN}-libclang-cpp ${PN}-tidy ${PN}-format ${PN}-tools \