[PATCH] D28520: Disable -Wthread-safety-analysis for some functions in __thread_support

Dimitry Andric via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 22 05:02:45 PST 2017


dim added a comment.

In https://reviews.llvm.org/D28520#648880, @delesley wrote:

> Sorry about the slow response.   My main concern here is that the thread safety analysis was designed for use with a library that wraps the system mutex in a separate Mutex class.  We did that specifically to avoid breaking anything; code has to opt-in to the static checking by defining and using a Mutex class, and the API of that class is restricted to calls that can be easily checked via annotations.  Including attributes directly in the standard library has the potential to cause lots of breakage and false positives.


Yes, I agree with that.  However, on FreeBSD the pthread functions themselves are already annotated, so the libc++ wrapper functions cause -Werror warnings during the tests.  Therefore one of my suggestions was to explicitly turn off warnings using `no_thread_safety_analysis` attributes.  Is there any disadvantage in doing that?

> Is there some way to control the #ifdefs so that the annotations are turned off by default for everyone except possibly freebsd, but there's still a way to turn them on for users who want to see the warnings?  I'm not a libcxx expert.

Yes, that was one of my other suggestions, using `#if defined(__FreeBSD__)` to limit these attributes to FreeBSD only.   We can do that either with the `no_thread_safety_analysis` attributes, or with the 'real' annotations, though the latter are not really useful in this case.

I'm really open to any variant, as long as something that works can get in before the 4.0.0 release. :)


https://reviews.llvm.org/D28520





More information about the cfe-commits mailing list