arm/tf-a-tests: Workaround GCC errors for 'unused-but-set-variable'
PATCH 1/2 arm/tf-a-tests: Workaround GCC errors for 'unused-but-set-variable'
New GCC is logging errors for unused-but-set-variable in tftf/tests/runtime_services/standard_service/psci/api_tests/psci_stat/test_psci_stat.c
Workaround this by adding -Wno-unused-but-set-variable to the Makefile Refer to https://github.com/TrustedFirmware-A/tf-a-tests/issues/4
For the upstream resolution, if/when that arrives.
--- ...1-Fix-GCC-errors-in-test_psci_stat.c.patch | 41 +++++++++++++++++++ .../trusted-firmware-a/tf-a-tests_2.14.0.bb | 2 + 2 files changed, 43 insertions(+) create mode 100644 meta-arm/recipes-bsp/trusted-firmware-a/files/0001-Fix-GCC-errors-in-test_psci_stat.c.patch
meta-arm/recipes-bsp/trusted-firmware-a/files/0001-Fix-GCC-errors-in-test_psci_stat.c.patch new file +41 -0
@@ -0,0 +1,41 @@ +From 042dcbc95249a2311e8a784fa7193299aa2ad651 Mon Sep 17 00:00:00 2001 +From: Jon Mason <[email protected]> +Date: Sat, 30 May 2026 10:24:53 -0400 +Subject: [PATCH] Fix GCC errors in test_psci_stat.c + +With the latest GCC, we're seeing the errors: + +| tftf/tests/runtime_services/standard_service/psci/api_tests/psci_stat/test_psci_stat.c: In function 'test_psci_stats_cpu_off': +| tftf/tests/runtime_services/standard_service/psci/api_tests/psci_stat/test_psci_stat.c:681:23: error: variable 'off_cpu_count' set but not used [-Werror=unused-but-set-variable=] +| 681 | int cpu_node, off_cpu_count = 0, ret; +| | ^~~~~~~~~~~~~ +| tftf/tests/runtime_services/standard_service/psci/api_tests/psci_stat/test_psci_stat.c: In function 'test_psci_stats_system_suspend': +| tftf/tests/runtime_services/standard_service/psci/api_tests/psci_stat/test_psci_stat.c:800:23: error: variable 'off_cpu_count' set but not used [-Werror=unused-but-set-variable=] +| 800 | int cpu_node, off_cpu_count = 0; +| | ^~~~~~~~~~~~~ + +This is because assert is being #ifdef'ed out and thus the variable is +never being used. Add '-Wno-unused-but-set-variable' to the Makefile to +workaround the issue. + +See https://github.com/TrustedFirmware-A/tf-a-tests/issues/4 + +Signed-off-by: Jon Mason <[email protected]> +Upstream-Status: Pending +--- + Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Makefile b/Makefile +index 9d222acc30b4..806329382da5 100644 +--- a/Makefile ++++ b/Makefile +@@ -277,7 +277,7 @@ GCC_ASFLAGS_aarch64 := -mgeneral-regs-only ${march64-directive} + + GCC_WARNINGS += -nostdinc -ffreestanding -Wall -Werror \ + -Wmissing-include-dirs $(GCC_CFLAGS_$(ARCH)) \ +- -std=gnu99 -Os ++ -Wno-unused-but-set-variable -std=gnu99 -Os + + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523 + GCC_CFLAGS += $(call cc_option, --param=min-pagesize=0)
meta-arm/recipes-bsp/trusted-firmware-a/tf-a-tests_2.14.0.bb +2 -0
@@ -12,6 +12,8 @@ SRC_URI = "${SRC_URI_TRUSTED_FIRMWARE_A_TESTS};branch=${SRCBRANCH}" SRCBRANCH = "master" SRCREV = "3b3d800133081b48482b1205a32671b82bc2b640" +SRC_URI += "file://0001-Fix-GCC-errors-in-test_psci_stat.c.patch" + EXTRA_OEMAKE += "USE_NVM=0" EXTRA_OEMAKE += "SHELL_COLOR=1" EXTRA_OEMAKE += "DEBUG=1"
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH 2/2 arm/ts-sp-common: Workaround unused-but-set-variable errors
With the new GCC, we're seeing the following error:
| In file included from /builder/meta-arm/build/tmp/work/armv8-5a-poky-linux/ts-sp-smm-gateway/git/sources/ts/components/common/dlmalloc/malloc_wrapper.c:62: | /builder/meta-arm/build/tmp/work/armv8-5a-poky-linux/ts-sp-smm-gateway/git/sources/ts/components/common/dlmalloc/malloc.c: In function 'add_segment': | /builder/meta-arm/build/tmp/work/armv8-5a-poky-linux/ts-sp-smm-gateway/git/sources/ts/components/common/dlmalloc/malloc.c:4002:7: error: variable 'nfences' set but not used [-Werror=unused-but-set-variable=] | 4002 | int nfences = 0; | | ^~~~~~~
To workaround this issue, add "-Wno-error=unused-but-set-variable" to TARGET_CFLAGS
--- meta-arm/recipes-security/trusted-services/ts-sp-common.inc | 1 + 1 file changed, 1 insertion(+)
meta-arm/recipes-security/trusted-services/ts-sp-common.inc +1 -0
@@ -33,6 +33,7 @@ INSANE_SKIP:${PN}-dev += "ldflags" TOOLCHAIN = "gcc" # FORTIFY_SOURCE is a glibc feature. Disable it for all SPs as these do not use glibc. +TARGET_CFLAGS += "-Wno-error=unused-but-set-variable" TARGET_CFLAGS:remove = "-D_FORTIFY_SOURCE=2" OECMAKE_C_FLAGS:remove = "-D_FORTIFY_SOURCE=2" OECMAKE_CXX_FLAGS:remove = "-D_FORTIFY_SOURCE=2"
Signature · 1 line
2.50.1 (Apple Git-155)
Jon Mason
AppliedQuoted 8 lines · Jon Mason
New GCC is logging errors for unused-but-set-variable in
tftf/tests/runtime_services/standard_service/psci/api_tests/psci_stat/test_psci_stat.cWorkaround this by adding -Wno-unused-but-set-variable to the
MakefileRefer to https://github.com/TrustedFirmware-A/tf-a-tests/issues/4
For the upstream resolution, if/when that arrives.[...]
Applied, thanks!
[1/2] arm/tf-a-tests: Workaround GCC errors for 'unused-but-set-variable'
commit: f23b86a59cb1901d373a8a9912ec75c030813b83
[2/2] arm/ts-sp-common: Workaround unused-but-set-variable errors
commit: 02d361b4359fde9b6646129980f1484f7aa5b09eBest regards,
Signature · 1 line
Jon Mason <[email protected]>