diff mbox series

optee-test: make -Werror conditional and disabled by default

Message ID 20250507163010.3416556-1-denis@denix.org
State New
Headers show
Series optee-test: make -Werror conditional and disabled by default | expand

Commit Message

Denys Dmytriyenko May 7, 2025, 4:30 p.m. UTC
From: Denys Dmytriyenko <denys@konsulko.com>

Unfortunately, new gcc-15 nonstring attribute has just recently been
merged to clang and hasn't made into a release yet - will be part of
clang-21.

For now backport the commit making -Werror conditional and disabled
by default.

Signed-off-by: Denys Dmytriyenko <denys@konsulko.com>
---
 ...cmake-add-Werror-based-on-CFG_WERROR.patch | 74 +++++++++++++++++++
 .../optee/optee-test_4.4.0.bb                 |  1 +
 2 files changed, 75 insertions(+)
 create mode 100644 meta-arm/recipes-security/optee/optee-test/0001-build-make-cmake-add-Werror-based-on-CFG_WERROR.patch
diff mbox series

Patch

diff --git a/meta-arm/recipes-security/optee/optee-test/0001-build-make-cmake-add-Werror-based-on-CFG_WERROR.patch b/meta-arm/recipes-security/optee/optee-test/0001-build-make-cmake-add-Werror-based-on-CFG_WERROR.patch
new file mode 100644
index 00000000..53e6ffdd
--- /dev/null
+++ b/meta-arm/recipes-security/optee/optee-test/0001-build-make-cmake-add-Werror-based-on-CFG_WERROR.patch
@@ -0,0 +1,74 @@ 
+From d068b668800a2bacae006f9b4d5d0fcbdabe9223 Mon Sep 17 00:00:00 2001
+From: Jerome Forissier <jerome.forissier@linaro.org>
+Date: Wed, 7 May 2025 14:01:38 +0200
+Subject: [PATCH] build: make, cmake: add -Werror based on CFG_WERROR
+
+Update the build files that currently set -Werror unconditionally to
+use set it based on the value of CFG_WERROR instead (disabled by
+default).
+
+Upstream-Status: Backport [https://github.com/OP-TEE/optee_test/commit/d068b668800a2bacae006f9b4d5d0fcbdabe9223]
+
+Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
+Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
+Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
+---
+ CMakeLists.txt      | 7 ++++++-
+ host/xtest/Makefile | 6 +++++-
+ 2 files changed, 11 insertions(+), 2 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 77c3a75..0f338b7 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -4,6 +4,8 @@ project (optee_test C)
+ # Default cross compile settings
+ set (CMAKE_TOOLCHAIN_FILE CMakeToolchain.txt)
+ 
++option(CFG_WERROR "Build with -Werror" FALSE)
++
+ set (OPTEE_TEST_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+ ################################################################################
+ # Compiler flags:
+@@ -18,10 +20,13 @@ add_compile_options (
+ 	-Wmissing-prototypes -Wnested-externs
+ 	-Wpointer-arith -Wshadow -Wstrict-prototypes
+ 	-Wswitch-default -Wunsafe-loop-optimizations
+-	-Wwrite-strings -Werror -fPIC
++	-Wwrite-strings -fPIC
+  	-Wno-missing-field-initializers
+ 	-Wno-unused-parameter
+ )
++if(CFG_WERROR)
++    add_compile_options(-Werror)
++endif(CFG_WERROR)
+ 
+ find_program(CCACHE_FOUND ccache)
+ if(CCACHE_FOUND)
+diff --git a/host/xtest/Makefile b/host/xtest/Makefile
+index 2bdf759..37f1d32 100644
+--- a/host/xtest/Makefile
++++ b/host/xtest/Makefile
+@@ -139,7 +139,7 @@ CFLAGS += -DTA_DIR=\"$(TA_DIR)\"
+ # Include configuration file generated by OP-TEE OS (CFG_* macros)
+ CFLAGS += -include conf.h
+ 
+-CFLAGS += -Wall -Wcast-align -Werror \
++CFLAGS += -Wall -Wcast-align \
+ 	  -Werror-implicit-function-declaration -Wextra -Wfloat-equal \
+ 	  -Wformat-nonliteral -Wformat-security -Wformat=2 -Winit-self \
+ 	  -Wmissing-declarations -Wmissing-format-attribute \
+@@ -150,6 +150,10 @@ CFLAGS += -Wall -Wcast-align -Werror \
+ 	  -Wno-declaration-after-statement \
+ 	  -Wno-missing-field-initializers -Wno-format-zero-length
+ 
++ifeq ($(CFG_WERROR),y)
++CFLAGS += -Werror
++endif
++
+ CFLAGS += -g3
+ 
+ LDFLAGS += -L$(OPTEE_CLIENT_EXPORT)/lib -lteec
+-- 
+2.25.1
+
diff --git a/meta-arm/recipes-security/optee/optee-test_4.4.0.bb b/meta-arm/recipes-security/optee/optee-test_4.4.0.bb
index d514c82c..8b88865b 100644
--- a/meta-arm/recipes-security/optee/optee-test_4.4.0.bb
+++ b/meta-arm/recipes-security/optee/optee-test_4.4.0.bb
@@ -5,6 +5,7 @@  SRCREV = "695231ef8987866663a9ed5afd8f77d1bae3dc08"
 
 LIC_FILES_CHKSUM = "file://LICENSE.md;md5=a8fa504109e4cd7ea575bc49ea4be560"
 
+SRC_URI += "file://0001-build-make-cmake-add-Werror-based-on-CFG_WERROR.patch"
 
 # Include ffa_spmc test group if the SPMC test is enabled.
 # Supported after op-tee v3.20