Skip to content

Commit e83f88b

Browse files
marcowidmeraescolar
authored andcommitted
logging: use runtime message creation when logging is disabled
If compiler optimizations are disabled, some compilers (especially arm_cortex_m) are using unrealistic amounts of stack for dead code. Currently, if CONFIG_LOG=y and CONFIG_NO_OPTIMIZATIONS=y, CONFIG_LOG_ALWAYS_RUNTIME is enabled to reduce the stack used by the logging code. However, if CONFIG_LOG=n, CONFIG_LOG_ALWAYS_RUNTIME is not available which causes the compiler to allocate lots of stack space for the (dead) logging code. This patch forces runtime message creation when CONFIG_LOG=n. Since all logging code is dead code when logging is disabled, the behavior should be unchanged. Signed-off-by: Marco Widmer <[email protected]>
1 parent 239c20d commit e83f88b

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

include/zephyr/logging/log_msg.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -499,9 +499,7 @@ do { \
499499
*
500500
* @param ... Optional string with arguments (fmt, ...). It may be empty.
501501
*/
502-
#if defined(CONFIG_LOG_ALWAYS_RUNTIME) || \
503-
(!defined(CONFIG_LOG) && \
504-
(!TOOLCHAIN_HAS_PRAGMA_DIAG || !TOOLCHAIN_HAS_C_AUTO_TYPE))
502+
#if defined(CONFIG_LOG_ALWAYS_RUNTIME) || !defined(CONFIG_LOG)
505503
#define Z_LOG_MSG_CREATE2(_try_0cpy, _mode, _cstr_cnt, _domain_id, _source,\
506504
_level, _data, _dlen, ...) \
507505
do {\
@@ -514,7 +512,7 @@ do {\
514512
Z_LOG_FMT_RUNTIME_ARGS(_fmt, ##__VA_ARGS__));\
515513
_mode = Z_LOG_MSG_MODE_RUNTIME; \
516514
} while (false)
517-
#else /* CONFIG_LOG_ALWAYS_RUNTIME */
515+
#else /* CONFIG_LOG_ALWAYS_RUNTIME || !CONFIG_LOG */
518516
#define Z_LOG_MSG_CREATE3(_try_0cpy, _mode, _cstr_cnt, _domain_id, _source,\
519517
_level, _data, _dlen, ...) \
520518
do { \
@@ -579,9 +577,7 @@ do { \
579577
_level, _data, _dlen, \
580578
FOR_EACH_IDX(Z_LOG_LOCAL_ARG_NAME, (,), __VA_ARGS__)); \
581579
} while (false)
582-
#endif /* CONFIG_LOG_ALWAYS_RUNTIME ||
583-
* (!LOG && (!TOOLCHAIN_HAS_PRAGMA_DIAG || !TOOLCHAIN_HAS_C_AUTO_TYPE))
584-
*/
580+
#endif /* CONFIG_LOG_ALWAYS_RUNTIME || !CONFIG_LOG */
585581

586582

587583
#define Z_LOG_MSG_CREATE(_try_0cpy, _mode, _domain_id, _source,\

0 commit comments

Comments
 (0)