From d74ccc1bdb083735215d76ca8a1d6028de3d6f8d Mon Sep 17 00:00:00 2001 From: Alberto Escolar Piedras Date: Wed, 17 Dec 2025 11:00:51 +0100 Subject: [PATCH] cmake: Do not warn on deprecated symbols w CONFIG_WARN_DEPRECATED=n CONFIG_WARN_DEPRECATED is 'y' by default. When a user actively disables CONFIG_WARN_DEPRECATED, one would expect that they would stop getting all deprecation warnings, not just the ones from kconfig. Otherwise users continue getting tons of these warnings when building deprecated functionality. So let's indeed disable them also for symbols and macros. Signed-off-by: Alberto Escolar Piedras --- CMakeLists.txt | 2 +- Kconfig.zephyr | 3 ++- include/zephyr/toolchain/gcc.h | 2 +- include/zephyr/toolchain/iar/iccarm.h | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e38f42de78..6a716a4a659 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -166,7 +166,7 @@ if(CONFIG_COMPILER_WARNINGS_AS_ERRORS) zephyr_link_libraries($) endif() -if(CONFIG_DEPRECATION_TEST) +if(CONFIG_DEPRECATION_TEST OR NOT CONFIG_WARN_DEPRECATED) zephyr_compile_options($<$:$>) zephyr_compile_options($<$:$>) zephyr_compile_options($<$:$>) diff --git a/Kconfig.zephyr b/Kconfig.zephyr index d534c1c7543..8e3934ac746 100644 --- a/Kconfig.zephyr +++ b/Kconfig.zephyr @@ -1021,7 +1021,8 @@ config WARN_DEPRECATED prompt "Warn on deprecated usage" help Print a warning when the Kconfig tree is parsed if any deprecated - features are enabled. + features are enabled, or at compile time, when deprecated macros or + symbols are used. config EXPERIMENTAL bool diff --git a/include/zephyr/toolchain/gcc.h b/include/zephyr/toolchain/gcc.h index fde3b9c0cb7..899e245ed37 100644 --- a/include/zephyr/toolchain/gcc.h +++ b/include/zephyr/toolchain/gcc.h @@ -349,7 +349,7 @@ do { \ #define __WARN1(s) _Pragma(#s) /* Generic message */ -#ifndef CONFIG_DEPRECATION_TEST +#if !(defined(CONFIG_DEPRECATION_TEST) || !defined(CONFIG_WARN_DEPRECATED)) #define __DEPRECATED_MACRO __WARN("Macro is deprecated") /* When adding this, remember to follow the instructions in * https://docs.zephyrproject.org/latest/develop/api/api_lifecycle.html#deprecated diff --git a/include/zephyr/toolchain/iar/iccarm.h b/include/zephyr/toolchain/iar/iccarm.h index 99d7e2cf1fd..8d197ddf04b 100644 --- a/include/zephyr/toolchain/iar/iccarm.h +++ b/include/zephyr/toolchain/iar/iccarm.h @@ -248,7 +248,7 @@ do { \ #define __WARN1(s) __PRAGMA(message = #s) /* Generic message */ -#ifndef CONFIG_DEPRECATION_TEST +#if !(defined(CONFIG_DEPRECATION_TEST) || !defined(CONFIG_WARN_DEPRECATED)) #define __DEPRECATED_MACRO __WARN("Macro is deprecated") #else #define __DEPRECATED_MACRO