From 2d152ab0198d98d2aa19e1c53a5b2d743424b3d2 Mon Sep 17 00:00:00 2001
From: Daniel Leung <daniel.leung@intel.com>
Date: Tue, 27 Oct 2020 10:50:10 -0700
Subject: [PATCH] kernel: limit thread local storage to Zephyr SDK

Toolchains other than Zephyr SDK may not support generating
code with thread local storage. So limit TLS to Zephyr SDK
for now, and only enable TLS on other toolchains as needed.

Fixes #29541

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
---
 kernel/Kconfig | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/kernel/Kconfig b/kernel/Kconfig
index db845a6bdef..42b50b42cb3 100644
--- a/kernel/Kconfig
+++ b/kernel/Kconfig
@@ -861,9 +861,16 @@ config TICKLESS_KERNEL
 	  This option enables a fully event driven kernel. Periodic system
 	  clock interrupt generation would be stopped at all times.
 
+config TOOLCHAIN_SUPPORTS_THREAD_LOCAL_STORAGE
+	bool
+	default y if "$(ZEPHYR_TOOLCHAIN_VARIANT)" = "zephyr"
+	help
+	  Hidden option to signal that toolchain supports generating code
+	  with thread local storage.
+
 config THREAD_LOCAL_STORAGE
 	bool "Thread Local Storage (TLS)"
-	depends on ARCH_HAS_THREAD_LOCAL_STORAGE
+	depends on ARCH_HAS_THREAD_LOCAL_STORAGE && TOOLCHAIN_SUPPORTS_THREAD_LOCAL_STORAGE
 	select NEED_LIBC_MEM_PARTITION if (CPU_CORTEX_M && USERSPACE)
 	help
 	  This option enables thread local storage (TLS) support in kernel.
-- 
GitLab