r180909 - Only evaluate __has_feature(c_thread_local) and __has_feature(cxx_thread_local) true when the target supports thread-local storage.

Richard Smith richard at metafoo.co.uk
Thu May 2 03:03:31 PDT 2013


On Thu, May 2, 2013 at 1:00 AM, Jean-Daniel Dupas <devlists at shadowlab.org>wrote:

> Is it OK to use the same condition for both while they don't require the
> same Target support ?
>
> AFAK, C++ TLS require __cxa_thread_atexit support, and so the target
> should support thread_atexit, while C TLS doesn't need it.
>

This is tricky, because it's a property of the C++ library, not of the
target; a conforming implementation can implement __cxa_thread_atexit
entirely within its std::thread implementation if the underlying threading
library doesn't provide thread_atexit support -- although that would
clearly be suboptimal because it wouldn't interoperate well with threads
not created by std::thread.


> Actually, I think darwin has support for C thread local, but no C++ thread
> local.
>
> Le 2 mai 2013 à 07:28, Douglas Gregor <dgregor at apple.com> a écrit :
>
> > Author: dgregor
> > Date: Thu May  2 00:28:32 2013
> > New Revision: 180909
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=180909&view=rev
> > Log:
> > Only evaluate __has_feature(c_thread_local) and
> __has_feature(cxx_thread_local) true when the target supports thread-local
> storage.
> >
> > Modified:
> >    cfe/trunk/lib/Lex/PPMacroExpansion.cpp
> >    cfe/trunk/test/Lexer/has_feature_cxx0x.cpp
> >
> > Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=180909&r1=180908&r2=180909&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
> > +++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Thu May  2 00:28:32 2013
> > @@ -751,7 +751,8 @@ static bool HasFeature(const Preprocesso
> >            .Case("c_atomic", LangOpts.C11)
> >            .Case("c_generic_selections", LangOpts.C11)
> >            .Case("c_static_assert", LangOpts.C11)
> > -           .Case("c_thread_local", LangOpts.C11)
> > +           .Case("c_thread_local",
> > +                 LangOpts.C11 && PP.getTargetInfo().isTLSSupported())
> >            // C++11 features
> >            .Case("cxx_access_control_sfinae", LangOpts.CPlusPlus11)
> >            .Case("cxx_alias_templates", LangOpts.CPlusPlus11)
> > @@ -783,7 +784,8 @@ static bool HasFeature(const Preprocesso
> >            .Case("cxx_rvalue_references", LangOpts.CPlusPlus11)
> >            .Case("cxx_strong_enums", LangOpts.CPlusPlus11)
> >            .Case("cxx_static_assert", LangOpts.CPlusPlus11)
> > -           .Case("cxx_thread_local", LangOpts.CPlusPlus11)
> > +           .Case("cxx_thread_local",
> > +                 LangOpts.CPlusPlus11 &&
> PP.getTargetInfo().isTLSSupported())
> >            .Case("cxx_trailing_return", LangOpts.CPlusPlus11)
> >            .Case("cxx_unicode_literals", LangOpts.CPlusPlus11)
> >            .Case("cxx_unrestricted_unions", LangOpts.CPlusPlus11)
> >
> > Modified: cfe/trunk/test/Lexer/has_feature_cxx0x.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/has_feature_cxx0x.cpp?rev=180909&r1=180908&r2=180909&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/test/Lexer/has_feature_cxx0x.cpp (original)
> > +++ cfe/trunk/test/Lexer/has_feature_cxx0x.cpp Thu May  2 00:28:32 2013
> > @@ -1,5 +1,6 @@
> > -// RUN: %clang_cc1 -E -std=c++11 %s -o - | FileCheck
> --check-prefix=CHECK-0X %s
> > -// RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-NO-0X %s
> > +// RUN: %clang_cc1 -E -triple x86_64-linux-gnu -std=c++11 %s -o - |
> FileCheck --check-prefix=CHECK-0X %s
> > +// RUN: %clang_cc1 -E -triple armv7-apple-darwin -std=c++11 %s -o - |
> FileCheck --check-prefix=CHECK-NO-TLS %s
> > +// RUN: %clang_cc1 -E -triple x86_64-linux-gnu %s -o - | FileCheck
> --check-prefix=CHECK-NO-0X %s
> >
> > #if __has_feature(cxx_atomic)
> > int has_atomic();
> > @@ -290,3 +291,4 @@ int no_thread_local();
> >
> > // CHECK-0X: has_thread_local
> > // CHECK-NO-0X: no_thread_local
> > +// CHECK-NO-TLS: no_thread_local
> >
> >
> > _______________________________________________
> > cfe-commits mailing list
> > cfe-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
> -- Jean-Daniel
>
>
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130502/7ce3d7b7/attachment.html>


More information about the cfe-commits mailing list