[ 
https://issues.apache.org/jira/browse/HDFS-10355?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15272602#comment-15272602
 ] 

James Clampffer commented on HDFS-10355:
----------------------------------------

So if it has pthread support we can do something clever to emulate 
thread_local.  Based on a little bit of looking around the __thread qualifier 
isn't supported either unfortunately (please correct me if I'm wrong).

The lack of thread local support is actually very amusing (to me). The OSX 
version of clang could support it but has an explicit check and decides not to. 
 Obviously ABI compatibility is important but disabling chunks of the standard 
it claims to support with a "we'll fix this later with something faster" excuse 
doesn't really help anyone.
{code}
        .Case("cxx_thread_local",
-                 LangOpts.CPlusPlus11 && PP.getTargetInfo().isTLSSupported() &&
-                 !PP.getTargetInfo().getTriple().isOSDarwin())
+                 LangOpts.CPlusPlus11 && PP.getTargetInfo().isTLSSupported())
{code}
(from 
stackoverflow.com/questions/23791060/c-thread-local-storage-clang-503-0-40-mac-osx)

I think options (c) and (d) will cause a lot of pain.  I suppose you could 
disable the C API and any other synchronous calls that interact with asio with 
some #ifdefs to avoid anything that really needs to be thread local.  The 
thread_local variables are only there to make a shim for a synchronous API.  If 
everything is done via callback they aren't needed.

If getting a new compiler installed on OSX is a pain that seems like it's 
preventing potentially interested people from contributing to this then it 
seems like (b) is the clear way to go.  It'd pay for itself with just a couple 
patches from new people.

My personal preference would be (a), but I'm biased because all development I 
do is linux based.  Also clang seems to support undefined behavior more than 
I'd like e.g. calling shared_from_this() on a class deriving from 
enable_shared_from_this works even if std::make_shared hasn't been called which 
led to some confusion a while back.

> Fix thread_local related build issue on Mac OS X
> ------------------------------------------------
>
>                 Key: HDFS-10355
>                 URL: https://issues.apache.org/jira/browse/HDFS-10355
>             Project: Hadoop HDFS
>          Issue Type: Sub-task
>          Components: hdfs-client
>         Environment: OS: Mac OS X 10.11
> clang: Apple LLVM version 7.0.2 (clang-700.1.81)
>            Reporter: Tibor Kiss
>
> The native hdfs library uses C++11 features heavily.
> One of such feature is thread_local storage class which is supported in GCC, 
> Visual Studio and the community version of clang compiler, but not by Apple's 
> clang (which is default on OS X boxes). 
> See further details here: http://stackoverflow.com/a/29929949
> Even though not many Hadoop cluster runs on OS X developers still use this 
> platform for development.
> The problem can be solved multiple ways:
>  a) Stick to gcc/g++ or community based clang on OS X. Developers will need 
> extra steps to build Hadoop.
>  b) Workaround thread_local with a helper class.
>  c) Get rid of all the globals marked with thread_local. Interface change 
> will be erquired.
>  d) Disable multi threading support in the native client on OS X and document 
> this limitation. 
> Compile error related to thread_local:
> {noformat}
>      [exec] 
> /Users/tiborkiss/workspace/apache-hadoop/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/bindings/c/hdfs.cc:66:1:
>  error: thread-local storage is not supported for the current target
>      [exec] thread_local std::string errstr;
>      [exec] ^
>      [exec] 
> /Users/tiborkiss/workspace/apache-hadoop/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/bindings/c/hdfs.cc:87:1:
>  error: thread-local storage is not supported for the current target
>      [exec] thread_local std::experimental::optional<fs_event_callback> 
> fsEventCallback;
>      [exec] ^
>      [exec] 
> /Users/tiborkiss/workspace/apache-hadoop/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/bindings/c/hdfs.cc:88:1:
>  error: thread-local storage is not supported for the current target
>      [exec] thread_local std::experimental::optional<file_event_callback> 
> fileEventCallback;
>      [exec] ^
>      [exec] 1 warning and 3 errors generated.
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to