[libc] [llvm] [libc] Change LIBC_THREAD_LOCAL to be dependent on LIBC_THREAD_MODE (PR #151527)

William Huynh via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 1 07:50:10 PDT 2025


https://github.com/saturn691 updated https://github.com/llvm/llvm-project/pull/151527

>From ddc1e5ce1b733117518ed77ded4ccc4e1007a737 Mon Sep 17 00:00:00 2001
From: William Huynh <William.Huynh at arm.com>
Date: Thu, 31 Jul 2025 15:26:33 +0100
Subject: [PATCH 1/2] [libc] Change LIBC_THREAD_LOCAL to be dependent on
 LIBC_THREAD_MODE

This allows baremetal builds to avoid using thread_local. However,
libcxx may be affected by this.
---
 libc/src/__support/macros/attributes.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libc/src/__support/macros/attributes.h b/libc/src/__support/macros/attributes.h
index c6474673de85a..23f973827b6f9 100644
--- a/libc/src/__support/macros/attributes.h
+++ b/libc/src/__support/macros/attributes.h
@@ -28,7 +28,7 @@
 #define LIBC_INLINE_ASM __asm__ __volatile__
 #define LIBC_UNUSED __attribute__((unused))
 
-#ifdef LIBC_TARGET_ARCH_IS_GPU
+#if LIBC_THREAD_MODE == LIBC_THREAD_MODE_SINGLE
 #define LIBC_THREAD_LOCAL
 #else
 #define LIBC_THREAD_LOCAL thread_local

>From b4bc15458770ea37585dbb576d394a8b51b1495d Mon Sep 17 00:00:00 2001
From: William Huynh <William.Huynh at arm.com>
Date: Fri, 1 Aug 2025 15:41:42 +0100
Subject: [PATCH 2/2] Try and get CI to pass

---
 cmake/Modules/FindLibcCommonUtils.cmake | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/cmake/Modules/FindLibcCommonUtils.cmake b/cmake/Modules/FindLibcCommonUtils.cmake
index 95426c51a6041..270f88f771407 100644
--- a/cmake/Modules/FindLibcCommonUtils.cmake
+++ b/cmake/Modules/FindLibcCommonUtils.cmake
@@ -12,6 +12,10 @@ if(NOT TARGET llvm-libc-common-utilities)
     add_library(llvm-libc-common-utilities INTERFACE)
     # TODO: Reorganize the libc shared section so that it can be included without
     # adding the root "libc" directory to the include path.
+    include(${libc_path}/cmake/modules/LLVMLibCCompileOptionRules.cmake)
+    _get_compile_options_from_config(libc_common_options)
+    target_compile_options(llvm-libc-common-utilities INTERFACE ${libc_common_options})
+
     target_include_directories(llvm-libc-common-utilities INTERFACE ${libc_path})
     target_compile_definitions(llvm-libc-common-utilities INTERFACE LIBC_NAMESPACE=__llvm_libc_common_utils)
     target_compile_features(llvm-libc-common-utilities INTERFACE cxx_std_17)



More information about the llvm-commits mailing list