From de0e3effb51bbe7b6f0c111a9fa65b7d70737d35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Chru=C5=9Bci=C5=84ski?= Date: Mon, 8 Jul 2024 12:24:50 +0200 Subject: [PATCH] kernel: fatal: Fix NO_OPTIMIZATIONS build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When logging is on and optimization and multithreading is off then build fails to link because unoptimized compiler/linker seems to not look beyond the function and it fails trying to link k_thread_name_get. Reworking the code to make it known to the compiler without optimization that k_thread_name_get is not needed and not logging current thread name in that case. Signed-off-by: Krzysztof Chruściński (cherry picked from commit 28b4bab01c3e76d7e9eeafd8522f85dc32edc0c6) --- kernel/fatal.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/fatal.c b/kernel/fatal.c index 06966066e30205..3cf3114364da87 100644 --- a/kernel/fatal.c +++ b/kernel/fatal.c @@ -110,8 +110,9 @@ void z_fatal_error(unsigned int reason, const struct arch_esf *esf) } #endif /* CONFIG_ARCH_HAS_NESTED_EXCEPTION_DETECTION */ - LOG_ERR("Current thread: %p (%s)", thread, - thread_name_get(thread)); + if (IS_ENABLED(CONFIG_MULTITHREADING)) { + LOG_ERR("Current thread: %p (%s)", thread, thread_name_get(thread)); + } coredump(reason, esf, thread);