Skip to content
Snippets Groups Projects
Commit 8cd5884f authored by James Robinson's avatar James Robinson Committed by CQ bot account: commit-bot@chromium.org
Browse files

[zircon] Guard general __TA_xx macros behind _LIBCPP check

We use the __TA_xxx macros to annotate code for clang's thread safety
analysis features.  The thread safety analysis feature works by
comparing the annotations on types with the annotations on code using
those types and generating a warning if the code is identified that is
inconsistent with the annotations or the defined semantics of the
annotations.  We frequently use these annotations to describe the
relationship between code and types from the C++ standard library, such
as std::mutex.  These types are annotated in the libc++ standard library
implementation if the preprocessor define
_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS is set.

In the Fuchsia build, we always set -Wthread-safety and -D_LIBCPP_...
compiler flags together so the annotations are consistent internally.
Some SDK customers use the fuchsia SDK and -Wthread-safety flag without
setting the preprocessor define as they use other libraries which use
the C++ standard library types in ways incompatible with thread safety
analysis.  This causes issues when compiling code that uses the
__TA_xxx macros with types like std::mutex.

This updates the __TA_xxx macros to only enable annotations if we can
tell that C++ standard library types are annotated (using the
_LIBCPP_... macro) or if we're in kernel code that we always control.

This also updates zircon/kernel code to use the non-public macros
defined in zircon/system/private so that they are enabled even when
libc++ is not involved.

ZX-4091 #done

Change-Id: I74910f6963d79bd2a53cf5d89a183252c5b58e7e
parent 3fd0d3b7
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment