casaroli commented on code in PR #20723:
URL: https://github.com/apache/nuttx/pull/20723#discussion_r4576305609


##########
libs/libc/tls/Kconfig:
##########
@@ -5,6 +5,23 @@
 
 menu "Thread Local Storage (TLS)"
 
+config TLS_EMUTLS
+       bool "Per-thread copies of emulated TLS variables"
+       default y
+       depends on (ARCH_TOOLCHAIN_GNU && !ARCH_TOOLCHAIN_ARMCLANG && 
!ARCH_TOOLCHAIN_GHS && !ARCH_AVR && !ARCH_SIM) || (ARCH_SIM && 
SIM_TOOLCHAIN_GCC && !HOST_MACOS && !WINDOWS_NATIVE)

Review Comment:
   Done.



##########
libs/libc/tls/CMakeLists.txt:
##########
@@ -22,6 +22,30 @@
 
 set(SRCS task_getinfo.c tls_getinfo.c)
 
+# Send the calls to __emutls_get_address() to the per-thread version of libc
+# (see tools/Config.mk).
+
+if(CONFIG_TLS_EMUTLS)
+  list(APPEND SRCS tls_emutls.c)
+  set(EMUTLS_WRAP -Wl,--wrap=__emutls_get_address
+                  -Wl,--wrap=__emutls_register_common)
+  # with LTO the calls appear only after the linker has chosen the archive
+  # members: take the libc functions in from the start
+  if(CONFIG_LTO_FULL OR CONFIG_LTO_THIN)

Review Comment:
   Done.



##########
tools/Config.mk:
##########
@@ -909,3 +909,30 @@ LOWER_CASE = $(call ULMAP,$(LOWERMAP),$(1))
 ifeq ($(CONFIG_ITERABLE_SECTIONS_LINKER_INSERT),y)
   ARCHSCRIPT += 
$(TOPDIR)$(DELIM)include$(DELIM)nuttx$(DELIM)linker$(DELIM)common-insert.ld
 endif
+
+# Send the calls to __emutls_get_address() to the per-thread version of
+# libc, never to the single copy of libgcc.  LDFLAGS is for the image link;
+# the sim links NuttX with "$(LD) -r $(LDLINKFLAGS)" first.  The arch
+# Toolchain.defs adds EMUTLS_LDFLAGS to LDELFFLAGS and LDMODULEFLAGS.
+
+ifeq ($(CONFIG_TLS_EMUTLS),y)
+  EMUTLS_WRAP = --wrap=__emutls_get_address --wrap=__emutls_register_common
+  EMUTLS_IMAGE = $(EMUTLS_WRAP)
+
+  # With LTO the compiler makes the calls only after the linker has chosen
+  # the archive members, so take the libc functions in from the start.
+
+  ifneq ($(CONFIG_LTO_FULL)$(CONFIG_LTO_THIN),)

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to