Skip to content

Commit

Permalink
clang: improve reproducibility
Browse files Browse the repository at this point in the history
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 <omatiush@cisco.com>
  • Loading branch information
raburaibu authored and kraj committed Jul 30, 2024
1 parent 79d26d1 commit 0b2616e
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions recipes-devtools/clang/clang_git.bb
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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 \
Expand Down

0 comments on commit 0b2616e

Please sign in to comment.