From owner-freebsd-x11@FreeBSD.ORG Sat Sep 7 00:00:01 2013 Return-Path: Delivered-To: freebsd-x11@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 53C36755 for ; Sat, 7 Sep 2013 00:00:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 288DF2873 for ; Sat, 7 Sep 2013 00:00:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.7/8.14.7) with ESMTP id r87001pl050486 for ; Sat, 7 Sep 2013 00:00:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.7/8.14.7/Submit) id r87000oJ050436; Sat, 7 Sep 2013 00:00:00 GMT (envelope-from gnats) Date: Sat, 7 Sep 2013 00:00:00 GMT Message-Id: <201309070000.r87000oJ050436@freefall.freebsd.org> To: freebsd-x11@FreeBSD.org Cc: From: Niclas Zeising Subject: Re: ports/181838: [patch] x11-servers/xorg-server: fix TLS variables with clang X-BeenThere: freebsd-x11@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Niclas Zeising List-Id: X11 on FreeBSD -- maintaining and support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Sep 2013 00:00:01 -0000 The following reply was made to PR ports/181838; it has been noted by GNATS. From: Niclas Zeising To: Tijl Coosemans Cc: bug-followup@FreeBSD.org Subject: Re: ports/181838: [patch] x11-servers/xorg-server: fix TLS variables with clang Date: Sat, 07 Sep 2013 01:52:44 +0200 On 09/06/13 23:22, Tijl Coosemans wrote: > On Fri, 06 Sep 2013 22:18:27 +0200 Niclas Zeising wrote: >> Can you please elaborate a bit on this, exactly what happends when >> setting that configure variable? > > The configure script tests how to declare a thread-local variable. For > clang and gcc this is done using the __thread keyword like this: > > __thread int thread_specific_int_var; > > Other compilers use __declspec(thread) instead of __thread. > > The code in configure comes from the XORG_TLS call in configure.ac. > XORG_TLS is defined in m4/xorg-tls.m4. Here are the relevant bits: > > 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) > > The for-loop runs over the elements in $keywords and sets ac_cv_tls > to the keyword if the compiler accepts it. The problem is that clang > accepts __declspec(thread) but it doesn't actually work (there's a > warning about this but no error) so when the for-loop ends ac_cv_tls > is set to __declspec(thread). Because the test is inside AC_CACHE_VAL > it can be skipped by defining ac_cv_tls which is what the patch does. > > I found a similar test in pixman but there the for-loop contains a > break so it ends on the first successful keyword (i.e. __thread). > >> Have you tried and ensured that this doesn't break xserver built with >> gcc? > > No, I currently don't have gcc installed, but the keyword for gcc is > also __thread. You could search for __thread in a config.log generated > with gcc to verify this. > Thank you for your very excellent description! I'll look into this more during the weekend or beginning of next week. Your patch looks fine, now that I understand it properly ;). I just want to make sure that gcc still works, check the old xorg-server version, and look through the rest of the xorg ports, in case this is needed somewhere else as well. Regards! -- Niclas Zeising