TLS autodetection support in the X server
Jeremy Huddleston
jeremyhu at apple.com
Tue Mar 22 18:50:58 PDT 2011
This change introduced a regression when building with clang on darwin (and possibly other configurations as well):
http://tinderbox.x.org/builds/2011-03-22-0007
http://cgit.freedesktop.org/xorg/xserver/commit/?id=93393411e39fbb0f72cf6c2f79ebde177aa86932
This is because the AX_TLS macro tests for __thread and __declspec(thread), but the server assumes __thread.
This issue probably exists elsewhere as well... I'll try to come up with something later this week...
--Jeremy
On Dec 22, 2010, at 14:30, tom fogal wrote:
> Attached are two patches, one for util/macros and the second for
> xorg/xserver, which are aimed at getting --enable/--disable-glx-tls to
> be identified automatically, instead of defaulting to disabled. Lack
> of TLS leads to non-PIC code, which is particularly annoying in an
> SELinux environment.
>
> See:
>
> http://www.mail-archive.com/mesa-dev@lists.freedesktop.org/msg04310.html
> http://lists.x.org/archives/xorg-devel/2009-November/003411.html
> http://www.mail-archive.com/mesa-dev@lists.freedesktop.org/msg04289.html
>
> for a little more background.
>
> I'm not really sure about any policy of adding a macro and requiring
> it in another package; I had to bump the version number so that the X
> server could be sure the macro exists. Not sure if that's the correct
> thing to do. Please educate me.
>
> PLEASE NOTE: that the XORG_TLS macro is derived from a macro I got from
> the autoconf macro archive, which is GPLd. The output (configure) has
> no restrictions, and I hear this is okay at least for Mesa [1], but
> it's definitely worth noting.
>
> -tom
>
> [1] http://www.mail-archive.com/mesa3d-dev@lists.sourceforge.net/msg12457.html
>
> From c3db2935b6e3883a8dec61eacf482b514f011fa1 Mon Sep 17 00:00:00 2001
> From: Tom Fogal <tfogal at alumni.unh.edu>
> Date: Wed, 22 Dec 2010 14:34:55 -0700
> Subject: [PATCH] Add macro for detecting thread local storage support.
>
> This adds an XORG_TLS macro which attempts to identify if the
> underlying compiler/platform supports thread local storage (TLS).
>
> It also increases the package version number, so that a dependent
> package can be sure the macro exists.
>
> Signed-off-by: Tom Fogal <tfogal at alumni.unh.edu>
> ---
> configure.ac | 2 +-
> xorg-macros.m4.in | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 76 insertions(+), 1 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index a64a5bb..c83b8b2 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -23,7 +23,7 @@ dnl Process this file with autoconf to create configure.
>
> AC_PREREQ([2.60])
> AC_INIT([util-macros],
> - [1.11.0],
> + [1.12.0],
> [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
> [util-macros])
> AC_CONFIG_SRCDIR([Makefile.am])
> diff --git a/xorg-macros.m4.in b/xorg-macros.m4.in
> index c7df523..b5f52d8 100644
> --- a/xorg-macros.m4.in
> +++ b/xorg-macros.m4.in
> @@ -1128,3 +1128,78 @@ mv \$(top_srcdir)/.INSTALL.tmp \$(top_srcdir)/INSTALL) \
> echo 'util-macros \"pkgdatadir\" from xorg-macros.pc not found: installing possibly empty INSTALL.' >&2)"
> AC_SUBST([INSTALL_CMD])
> ]) # XORG_INSTALL
> +
> +# ===========================================================================
> +# http://www.nongnu.org/autoconf-archive/ax_tls.html
> +# ===========================================================================
> +#
> +# SYNOPSIS
> +#
> +# XORG_TLS (renamed from AX_TLS)
> +#
> +# DESCRIPTION
> +#
> +# Provides a test for the compiler support of thread local storage (TLS)
> +# extensions. Defines TLS if it is found. Currently only knows about GCC
> +# and MSVC. I think SunPro uses the same as GCC, and Borland apparently
> +# supports either.
> +#
> +# LICENSE
> +#
> +# Copyright (c) 2008 Alan Woodland <ajw05 at aber.ac.uk>
> +#
> +# This program is free software: you can redistribute it and/or modify it
> +# under the terms of the GNU General Public License as published by the
> +# Free Software Foundation, either version 3 of the License, or (at your
> +# option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful, but
> +# WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
> +# Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License along
> +# with this program. If not, see <http://www.gnu.org/licenses/>.
> +#
> +# As a special exception, the respective Autoconf Macro's copyright owner
> +# gives unlimited permission to copy, distribute and modify the configure
> +# scripts that are the output of Autoconf when processing the Macro. You
> +# need not follow the terms of the GNU General Public License when using
> +# or distributing such scripts, even though portions of the text of the
> +# Macro appear in them. The GNU General Public License (GPL) does govern
> +# all other use of the material that constitutes the Autoconf Macro.
> +#
> +# This special exception to the GPL applies to versions of the Autoconf
> +# Macro released by the Autoconf Archive. When you make and distribute a
> +# modified version of the Autoconf Macro, you may extend this special
> +# exception to the GPL to apply to your modified version as well.
> +
> +AC_DEFUN([XORG_TLS], [
> + AC_MSG_CHECKING(for thread local storage (TLS) class)
> + AC_CACHE_VAL(ac_cv_tls, [
> + ax_tls_keywords="__thread __declspec(thread) none"
> + for ax_tls_keyword in $ax_tls_keywords; do
> + case $ax_tls_keyword in
> + none) ac_cv_tls=none ; break ;;
> + *)
> + AC_TRY_COMPILE(
> + [#include <stdlib.h>
> + static void
> + foo(void) {
> + static ] $ax_tls_keyword [ int bar;
> + exit(1);
> + }],
> + [],
> + [ac_cv_tls=$ax_tls_keyword ; break],
> + ac_cv_tls=none
> + )
> + esac
> + done
> +])
> +
> + if test "$ac_cv_tls" != "none"; then
> + dnl AC_DEFINE([TLS], [], [If the compiler supports a TLS storage class define it to that here])
> + AC_DEFINE_UNQUOTED([TLS], $ac_cv_tls, [If the compiler supports a TLS storage class define it to that here])
> + fi
> + AC_MSG_RESULT($ac_cv_tls)
> +])
> --
> 1.7.0.2
>
> From 1f5d0c4a4c93c0379ccf4ba962a461423b2e756c Mon Sep 17 00:00:00 2001
> From: Tom Fogal <tfogal at alumni.unh.edu>
> Date: Wed, 22 Dec 2010 14:39:48 -0700
> Subject: [PATCH] Autodetect TLS support instead of defaulting to disabled.
>
> Uses the XORG_TLS macro to figure out if the current platform
> supports TLS. If it does, enable TLS automagically. Still
> respects --enable option, regardless.
>
> Require 1.12 of the macros package, because that is when the
> XORG_TLS macro was introduced.
>
> Signed-off-by: Tom Fogal <tfogal at alumni.unh.edu>
> ---
> configure.ac | 11 ++++++++---
> 1 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index 1ceffe7..f667ff2 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -35,7 +35,7 @@ AM_MAINTAINER_MODE
> # Require xorg-macros minimum of 1.10 for XORG_CHECK_SGML_DOCTOOLS
> m4_ifndef([XORG_MACROS_VERSION],
> [m4_fatal([must install xorg-macros 1.10 or later before running autoconf/autogen])])
> -XORG_MACROS_VERSION(1.10)
> +XORG_MACROS_VERSION(1.12)
> XORG_DEFAULT_OPTIONS
> XORG_WITH_DOXYGEN(1.6.1)
> XORG_CHECK_SGML_DOCTOOLS(1.5)
> @@ -597,9 +597,14 @@ dnl GLX build options
> AC_ARG_ENABLE(aiglx, AS_HELP_STRING([--enable-aiglx], [Build accelerated indirect GLX (default: enabled)]),
> [AIGLX=$enableval],
> [AIGLX=yes])
> -AC_ARG_ENABLE(glx-tls, AS_HELP_STRING([--enable-glx-tls], [Build GLX with TLS support (default: disabled)]),
> +XORG_TLS
> +AC_ARG_ENABLE(glx-tls, AS_HELP_STRING([--enable-glx-tls], [Build GLX with TLS support (default: auto)]),
> [GLX_USE_TLS=$enableval],
> - [GLX_USE_TLS=no])
> + [GLX_USE_TLS=no
> + if test "${ac_cv_tls}" != "none" ; then
> + GLX_USE_TLS=yes
> + fi])
> +AC_SUBST(GLX_TLS, ${GLX_USE_TLS})
>
> dnl Extensions.
> AC_ARG_ENABLE(registry, AS_HELP_STRING([--disable-registry], [Build string registry module (default: enabled)]), [XREGISTRY=$enableval], [XREGISTRY=yes])
> --
> 1.7.0.2
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
More information about the xorg-devel
mailing list