public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r10-10794] libgcc, emutls: Allow building weak definitions of the emutls functions.
@ 2022-05-29 19:11 Iain D Sandoe
0 siblings, 0 replies; only message in thread
From: Iain D Sandoe @ 2022-05-29 19:11 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:dbdaf3fa2d7a9de8d7cc4682772240f3badb5ffe
commit r10-10794-gdbdaf3fa2d7a9de8d7cc4682772240f3badb5ffe
Author: Iain Sandoe <iain@sandoe.co.uk>
Date: Sun Sep 19 12:35:46 2021 +0100
libgcc, emutls: Allow building weak definitions of the emutls functions.
In order to better support use of the emulated TLS between objects with
DSO dependencies and static-linked libgcc, allow a target to make weak
definitions.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
libgcc/ChangeLog:
* config/t-darwin: Build weak-defined emutls objects.
* emutls.c (__emutls_get_address): Add optional attributes.
(__emutls_register_common): Likewise.
(EMUTLS_ATTR): New.
(cherry picked from commit b9873b4e2c9a9955789318f4d550147ef9405b07)
Diff:
---
libgcc/config/t-darwin | 13 +++++++++++++
libgcc/emutls.c | 17 +++++++++++++++--
2 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/libgcc/config/t-darwin b/libgcc/config/t-darwin
index 4b6317b5d85..7e791b29f7a 100644
--- a/libgcc/config/t-darwin
+++ b/libgcc/config/t-darwin
@@ -15,6 +15,19 @@ crttme.o: $(srcdir)/config/darwin-crt-tm.c
LIB2ADDEH = $(srcdir)/unwind-dw2.c $(srcdir)/config/unwind-dw2-fde-darwin.c \
$(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c
+# Make emutls weak so that we can deal with -static-libgcc, override the
+# hidden visibility when this is present in libgcc_eh.
+emutls.o: HOST_LIBGCC2_CFLAGS += \
+ -DEMUTLS_ATTR='__attribute__((__weak__,__visibility__("default")))'
+emutls_s.o: HOST_LIBGCC2_CFLAGS += \
+ -DEMUTLS_ATTR='__attribute__((__weak__,__visibility__("default")))'
+
+# Make the emutls crt as a convenience lib so that it can be linked
+# optionally, use the shared version so that we can link with DSO.
+libemutls_w.a: emutls_s.o
+ $(AR_CREATE_FOR_TARGET) $@ $<
+ $(RANLIB_FOR_TARGET) $@
+
# Patch to __Unwind_Find_Enclosing_Function for Darwin10.
d10-uwfef.o: $(srcdir)/config/darwin10-unwind-find-enc-func.c
$(crt_compile) -mmacosx-version-min=10.6 -c $<
diff --git a/libgcc/emutls.c b/libgcc/emutls.c
index f8012f6d8d5..a8ebe237d31 100644
--- a/libgcc/emutls.c
+++ b/libgcc/emutls.c
@@ -50,7 +50,16 @@ struct __emutls_array
void **data[];
};
+/* EMUTLS_ATTR is provided to allow targets to build the emulated tls
+ routines as weak definitions, for example.
+ If there is no definition, fall back to the default. */
+#ifndef EMUTLS_ATTR
+# define EMUTLS_ATTR
+#endif
+
+EMUTLS_ATTR
void *__emutls_get_address (struct __emutls_object *);
+EMUTLS_ATTR
void __emutls_register_common (struct __emutls_object *, word, word, void *);
#ifdef __GTHREADS
@@ -123,7 +132,11 @@ emutls_alloc (struct __emutls_object *obj)
return ret;
}
-void *
+/* Despite applying the attribute to the declaration, in this case the mis-
+ match between the builtin's declaration [void * (*)(void *)] and the
+ implementation here, causes the decl. attributes to be discarded. */
+
+EMUTLS_ATTR void *
__emutls_get_address (struct __emutls_object *obj)
{
if (! __gthread_active_p ())
@@ -187,7 +200,7 @@ __emutls_get_address (struct __emutls_object *obj)
#endif
}
-void
+EMUTLS_ATTR void
__emutls_register_common (struct __emutls_object *obj,
word size, word align, void *templ)
{
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-29 19:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-29 19:11 [gcc r10-10794] libgcc, emutls: Allow building weak definitions of the emutls functions Iain D Sandoe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).