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

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 23 07:50:19 PST 2017


aaron.ballman added a comment.

In https://reviews.llvm.org/D28520#652607, @dim wrote:

> 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. :)


I feel like there's still some confusion here (likely on my part). DeLesley was asking if there was a way to turn this off for everyone *except* FreeBSD (that is user-controllable), but your code turns it off specifically *for* FreeBSD with no option to enable. The part that has me confused is that FreeBSD is annotating their functionality specifically to enable thread safety checking; it seems like turning that checking off rather than supporting it is the wrong way to go. I think that may be why DeLesley was saying to disable the functionality for non-FreeBSD systems while still honoring it on FreeBSD, but if I'm confused, hopefully he'll clarify.


https://reviews.llvm.org/D28520





More information about the cfe-commits mailing list