[PATCH 1/2 v2] configure.ac: Enable GLX_USE_TLS if possible.
Zhigang Gong
zhigang.gong at linux.intel.com
Mon Feb 13 01:26:21 PST 2012
If the system support tls, we prefer to enable it by default
just as xserver does. Actually, the checking code is copied
from xserver/configure.ac.
According to nobled's suggestion, move the checking before
enable_asm. As if tls_model is not supported, then asm may
can't work correctly. Then we check the tls model first,
and if doesn't support it, we need to disable the asm code.
Signed-off-by: Zhigang Gong <zhigang.gong at linux.intel.com>
Reviewed-by: Dan Nicholson <dbn.lists at gmail.com>
---
acinclude.m4 | 36 ++++++++++++++++++++++++++++++++++++
configure.ac | 25 ++++++++++++++++++++++---
2 files changed, 58 insertions(+), 3 deletions(-)
diff --git a/acinclude.m4 b/acinclude.m4
index a5b389d..509de5b 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -117,3 +117,39 @@ if test "$enable_pic" != no; then
fi
AC_SUBST([PIC_FLAGS])
])# MESA_PIC_FLAGS
+
+dnl TLS detection
+AC_DEFUN([MESA_TLS],
+[AC_MSG_CHECKING(for thread local storage (TLS) support)
+AC_CACHE_VAL(ac_cv_tls, [
+ ac_cv_tls=none
+ keywords="__thread __declspec(thread)"
+ for kw in $keywords ; do
+ AC_TRY_COMPILE([int $kw test;], [], ac_cv_tls=$kw)
+ done
+])
+AC_MSG_RESULT($ac_cv_tls)
+
+if test "$ac_cv_tls" != "none"; then
+ AC_MSG_CHECKING(for tls_model attribute support)
+ saved_CFLAGS="$CFLAGS"
+ if test "x$acv_mesa_CLANG" = "xyes"; then
+ CFLAGS="$CFLAGS -Wattribute -Werror"
+ fi
+ AC_CACHE_VAL(ac_cv_tls_model, [
+ AC_TRY_COMPILE([int $ac_cv_tls __attribute__((tls_model("initial-exec"))) test;], [],
+ ac_cv_tls_model=yes, ac_cv_tls_model=no)
+ ])
+ CFLAGS="$saved_CFLAGS"
+ AC_MSG_RESULT($ac_cv_tls_model)
+
+ AC_MSG_CHECKING([for $CC option to define TLS variable])
+ if test "x$ac_cv_tls_model" = "xyes" ; then
+ TLS=$ac_cv_tls' __attribute__((tls_model(\"initial-exec\")))'
+ else
+ TLS=$ac_cv_tls
+ fi
+ DEFINES="$DEFINES -DTLS=\"$TLS\""
+ AC_MSG_RESULT([$TLS])
+fi
+])
diff --git a/configure.ac b/configure.ac
index b2b1ab8..3423cb2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -433,6 +433,11 @@ AC_SUBST([VG_LIB_GLOB])
AC_SUBST([GLAPI_LIB_GLOB])
dnl
+dnl Check tls model support
+dnl
+MESA_TLS
+
+dnl
dnl Arch/platform-specific settings
dnl
AC_ARG_ENABLE([asm],
@@ -446,6 +451,14 @@ ASM_FLAGS=""
MESA_ASM_SOURCES=""
GLAPI_ASM_SOURCES=""
AC_MSG_CHECKING([whether to enable assembly])
+
+if test "x$ac_cv_tls_model" = "xno" ; then
+dnl
+dnl If tls model is not supported, disable asm.
+dnl
+ enable_asm=no
+fi
+
test "x$enable_asm" = xno && AC_MSG_RESULT([no])
# disable if cross compiling on x86/x86_64 since we must run gen_matypes
if test "x$enable_asm" = xyes && test "x$cross_compiling" = xyes; then
@@ -1102,9 +1115,15 @@ dnl
AC_ARG_ENABLE([glx-tls],
[AS_HELP_STRING([--enable-glx-tls],
- [enable TLS support in GLX @<:@default=disabled@:>@])],
- [GLX_USE_TLS="$enableval"],
- [GLX_USE_TLS=no])
+ [enable TLS support in GLX @<:@default=auto@:>@])],
+ [GLX_USE_TLS=$enableval
+ if test "x$GLX_USE_TLS" = "xyes" && test "${ac_cv_tls}" = "none" ; then
+ AC_MSG_ERROR([GLX with TLS support requested, but the compiler does not support it.])
+ fi],
+ [GLX_USE_TLS=no
+ if test "${ac_cv_tls}" != "none" ; then
+ GLX_USE_TLS=yes
+ fi])
AC_SUBST(GLX_TLS, ${GLX_USE_TLS})
AS_IF([test "x$GLX_USE_TLS" = xyes],
--
1.7.4.4
More information about the mesa-dev
mailing list