git: 137f2548ad71 - stable/13 - powerpc: enable initial-exec TLS

From: Piotr Kubaj <pkubaj_at_FreeBSD.org>
Date: Tue, 08 Mar 2022 00:29:08 UTC
The branch stable/13 has been updated by pkubaj (ports committer):

URL: https://cgit.FreeBSD.org/src/commit/?id=137f2548ad7131df9ea954be4e419127c428cb3e

commit 137f2548ad7131df9ea954be4e419127c428cb3e
Author:     Piotr Kubaj <pkubaj@FreeBSD.org>
AuthorDate: 2022-02-18 13:22:14 +0000
Commit:     Piotr Kubaj <pkubaj@FreeBSD.org>
CommitDate: 2022-03-08 00:28:33 +0000

    powerpc: enable initial-exec TLS
    
    Summary:
    Use initial-exec, like other architectures.
    
    While here, switch MACHINE_ARCH in lib/libc/Makefile to LIBC_ARCH and consistently use powerpc.
    
    Subscribers: imp, #contributor_reviews_base
    
    Differential Revision: https://reviews.freebsd.org/D34315
    Reviewed by:    luporl
    MFC after:      2 weeks
    
    (cherry picked from commit 884ba43116d4456d5900d3c8824153c604f132b8)
---
 contrib/jemalloc/include/jemalloc/jemalloc_FreeBSD.h | 2 ++
 lib/libc/Makefile                                    | 7 ++++---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/contrib/jemalloc/include/jemalloc/jemalloc_FreeBSD.h b/contrib/jemalloc/include/jemalloc/jemalloc_FreeBSD.h
index 6ff0ce18d5da..00848c0c48e3 100644
--- a/contrib/jemalloc/include/jemalloc/jemalloc_FreeBSD.h
+++ b/contrib/jemalloc/include/jemalloc/jemalloc_FreeBSD.h
@@ -63,9 +63,11 @@
 #ifdef __powerpc64__
 #  define LG_VADDR		64
 #  define LG_SIZEOF_PTR		3
+#  define JEMALLOC_TLS_MODEL	__attribute__((tls_model("initial-exec")))
 #elif defined(__powerpc__)
 #  define LG_VADDR		32
 #  define LG_SIZEOF_PTR		2
+#  define JEMALLOC_TLS_MODEL	__attribute__((tls_model("initial-exec")))
 #endif
 #ifdef __riscv
 #  define LG_VADDR		48
diff --git a/lib/libc/Makefile b/lib/libc/Makefile
index fdf6aa49932b..2f2e07c03438 100644
--- a/lib/libc/Makefile
+++ b/lib/libc/Makefile
@@ -32,7 +32,7 @@ CFLAGS+=-DNO__SCCSID -DNO__RCSID
 LIB=c
 SHLIB_MAJOR= 7
 .if ${MK_SSP} != "no" && \
-    (${LIBC_ARCH} == "i386" || ${MACHINE_ARCH:Mpower*} != "")
+    (${LIBC_ARCH} == "i386" || ${LIBC_ARCH:Mpowerpc*} != "")
 SHLIB_LDSCRIPT=libc.ldscript
 .else
 SHLIB_LDSCRIPT=libc_nossp.ldscript
@@ -57,7 +57,8 @@ CFLAGS+=${CANCELPOINTS_CFLAGS}
 # Use a more efficient TLS model for libc since we can reasonably assume that
 # it will be loaded during program startup.
 .if ${LIBC_ARCH} == "aarch64" || ${LIBC_ARCH} == "amd64" || \
-    ${LIBC_ARCH} == "i386" || ${LIBC_ARCH} == "riscv"
+    ${LIBC_ARCH} == "i386" || ${LIBC_ARCH} == "riscv" || \
+    ${LIBC_ARCH:Mpowerpc*} != ""
 CFLAGS+= -ftls-model=initial-exec
 .endif
 
@@ -68,7 +69,7 @@ LDFLAGS+= -nodefaultlibs
 LIBADD+=	compiler_rt
 
 .if ${MK_SSP} != "no" && \
-    (${LIBC_ARCH} == "i386" || ${MACHINE_ARCH:Mpower*} != "")
+    (${LIBC_ARCH} == "i386" || ${LIBC_ARCH:Mpowerpc*} != "")
 LIBADD+=	ssp_nonshared
 .endif