Bug 98603 - Thread-local storage not supported on compiler shipped with Xcode
Summary: Thread-local storage not supported on compiler shipped with Xcode
Status: RESOLVED FIXED
Alias: None
Product: PulseAudio
Classification: Unclassified
Component: build-system (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Mac OS X (All)
: medium normal
Assignee: Philip Chimento
QA Contact: pulseaudio-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-05 20:25 UTC by Philip Chimento
Modified: 2016-11-10 16:28 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Patch (1.88 KB, patch)
2016-11-10 05:27 UTC, Philip Chimento
Details | Splinter Review

Description Philip Chimento 2016-11-05 20:25:41 UTC
It's currently not possible to compile PulseAudio master on macOS 10.12 with the compiler shipped with Xcode 8, which does not support thread-local storage.

  CC       pulsecore/libpulsecore_9.0_la-thread-mq.lo
pulsecore/thread-mq.c:35:1: error: thread-local storage is not supported for the
      current target
PA_STATIC_TLS_DECLARE_NO_FREE(thread_mq);
^
./pulsecore/thread.h:100:12: note: expanded from macro
      'PA_STATIC_TLS_DECLARE_NO_FREE'
    static __thread void *name##_tls = NULL;                            \
           ^
1 error generated.

Is it possible to use a portable substitute if one exists? I know Boost has one, though that doesn't help since this is C.
Comment 1 Tanu Kaskinen 2016-11-07 13:53:42 UTC
It seems that we already use an alternative TLS mechanism in case __thread isn't supported. Apparently the TLS support detection doesn't work correctly with Xcode.

configure.ac uses the AX_TLS macro, which I believe is supposed to do the detection. The macro is implemented in m4/ax_tls.m4, and it originates from autoconf-archive. It seems that the upstream version of ax_tls.m4 has changed since we imported it in PulseAudio, but the changes seem mostly cosmetic. In any case, it's worth a try to replace m4/ax_tls.m4 with the current upstream version[1].

The macro looks like it tries to compile a program with the __thread keyword, and apparently that succeeds when you run configure? That suggests that the compiler that the configure script uses is different from what Xcode uses. If that's the case, you need to somehow fix that.

[1] http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=blob_plain;f=m4/ax_tls.m4
Comment 2 Philip Chimento 2016-11-08 07:23:29 UTC
Got it. I looked in my config.log and compared the arguments that the configure test was compiled with, versus the arguments that were used for actually compiling PA. It's -mmacosx-version-min=10.5 that causes the problem. If you configure with --with-mac-version-min=10.7, it builds.

I suggest making 10.7 the default value for that configure flag, or otherwise making sure that the configure flag is added to the CFLAGS before doing the AX_TLS test.

I could make a patch for whichever one of those is preferable.
Comment 3 Tanu Kaskinen 2016-11-08 17:00:35 UTC
A patch would be lovely.

I'm not familiar with the Apple ecosystem. If we require 10.7, does that leave a significant chunk of users out? If not, requiring 10.7 is fine.
Comment 4 Philip Chimento 2016-11-10 05:27:30 UTC
Created attachment 127889 [details] [review]
Patch

OK, here's the patch.

I expect very few people still use 10.5 and 10.6 but if it's trivial anyway to keep supporting them, then why not. I don't have a 10.5 system to test on, but this compiles correctly with -mmacosx-version-min=10.5 on my 10.12 system.
Comment 5 Tanu Kaskinen 2016-11-10 16:28:55 UTC
Thanks! I applied the patch to the "next" branch.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.