From 06c018012957ab963e2aa5245bf1fcfebcf4909a Mon Sep 17 00:00:00 2001
From: Kenny MacDermid <kenny.macdermid@gmail.com>
Date: Tue, 11 Jul 2017 22:45:22 -0300
Subject: [PATCH 1/2] Add the -mtls-dialect=gnu2 to compile flags.

When this option exists there is no need to add the tls_model attribute.
---
 configure.ac | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 1551ded..39f957b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -701,6 +701,14 @@ if test "x${je_cv_attribute}" = "xyes" ; then
     JE_CXXFLAGS_ADD([-fvisibility=hidden])
   fi
 fi
+dnl Check for tls-dialect support.
+JE_CFLAGS_ADD([-mtls-dialect=gnu2])
+if test "x$je_cv_cflags_added" = "x-mtls-dialect=gnu2" ; then
+  je_cv_tls_dialect_gnu2=yes
+else
+  je_cv_tls_dialect_gnu2=no
+fi
+JE_CXXFLAGS_ADD([-mtls-dialect=gnu2])
 dnl Check for tls_model attribute support (clang 3.0 still lacks support).
 JE_CFLAGS_SAVE()
 JE_CFLAGS_ADD([-Werror])
@@ -711,7 +719,8 @@ JE_COMPILABLE([tls_model attribute], [],
                foo = 0;],
               [je_cv_tls_model])
 JE_CFLAGS_RESTORE()
-if test "x${je_cv_tls_model}" = "xyes" ; then
+if test "x${je_cv_tls_dialect_gnu2}" = "xno" \
+	-a "x${je_cv_tls_model}" = "xyes" ; then
   AC_DEFINE([JEMALLOC_TLS_MODEL],
             [__attribute__((tls_model("initial-exec")))])
 else
-- 
1.9.5 (Apple Git-50.3)

