From cb53927fd1c781f724e75828681cdeec0dd3d830 Mon Sep 17 00:00:00 2001 From: Ryan Roberts Date: Fri, 2 May 2025 10:21:41 +0100 Subject: [PATCH] config: Make tfa robust to parameter changes The TFA build system does not notice when a build parameter changes between incremental builds and this can lead to stale compilation units. An example of this is when switching between v8.x and v9.x architectures; v9.x adds CTX_INCLUDE_AARCH32_REGS=0. Where the v8.x default is CTX_INCLUDE_AARCH32_REGS=1. Up until now, the advice has been to workaround this by explicitly doing a clean when changing arch versions. But this continues to bite people, so let's workaround this in the tfa config by storing the parameters for each build. Then we can compare to the previous build and do a clean if they have changed. This provides a robust solution that does not incur any performance penalty for the common case of rebuilding without any parameter changes. To make this work, ensure the parameters are always in the same order when generating the parameters string. Previously their order was arbitrary and would change from run to run. Signed-off-by: Ryan Roberts --- config/tfa-base.yaml | 11 +++++++++++ shrinkwrap/utils/config.py | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/config/tfa-base.yaml b/config/tfa-base.yaml index 4bbd5ec..1d141a4 100644 --- a/config/tfa-base.yaml +++ b/config/tfa-base.yaml @@ -22,6 +22,17 @@ build: ARM_DISABLE_TRUSTED_WDOG: 1 FVP_HW_CONFIG_DTS: fdts/fvp-base-gicv3-psci-1t.dts + prebuild: + # tfa does not notice when parameters are changed and can therefore end up + # with stale compilation units. Let's work around that by saving the + # parameters and comparing to the last run. If they have changed, force a + # clean. Also works for the case where shrinkwrap.params doesn't exist. + - 'echo "${param:join_equal}" > ${param:builddir}/shrinkwrap.params.new' + - if ! cmp -s "${param:builddir}/shrinkwrap.params.new" "${param:builddir}/shrinkwrap.params"; then + - make BUILD_BASE=${param:builddir} clean + - fi + - mv ${param:builddir}/shrinkwrap.params.new ${param:builddir}/shrinkwrap.params + build: # tfa has makefile dependency bug that makes parallel make for more than # ~8 jobs unreliable, so limit it to 8. diff --git a/shrinkwrap/utils/config.py b/shrinkwrap/utils/config.py index 372b0c2..d1cfdf9 100644 --- a/shrinkwrap/utils/config.py +++ b/shrinkwrap/utils/config.py @@ -344,7 +344,7 @@ def _string_has_macros(string): def _mk_params(params, separator): pairs = [f'{k}' if v is None else f'{k}{separator}{v}' for k, v in params.items()] - return ' '.join(pairs) + return ' '.join(sorted(pairs)) def filename(name, rel=os.getcwd()): -- GitLab