[GWP-ASan] Mutex implementation [2].
authorMitch Phillips <mitchphillips@outlook.com>
Thu, 30 May 2019 19:45:32 +0000 (19:45 +0000)
committerMitch Phillips <mitchphillips@outlook.com>
Thu, 30 May 2019 19:45:32 +0000 (19:45 +0000)
commit5f0f4e3ae03afa84034c01ddaac559e0b5cb6532
treea4d1f0c352380fb97a3eef96bf4537a179f0dac8
parent04a38b924e7e37ad166b3f73f229411e3a2dfa25
[GWP-ASan] Mutex implementation [2].

Summary:
See D60593 for further information.
This patch pulls out the mutex implementation and the required definitions file.

We implement our own mutex for GWP-ASan currently, because:

1. We must be compatible with the sum of the most restrictive elements of the supporting allocator's build system. Current targets for GWP-ASan include Scudo (on Linux and Fuchsia), and bionic (on Android).
2. Scudo specifies `-nostdlib++ -nonodefaultlibs`, meaning we can't use `std::mutex` or `mtx_t`.
3. We can't use `sanitizer_common`'s mutex, as the supporting allocators cannot afford the extra maintenance (Android, Fuchsia) and code size (Fuchsia) overheads that this would incur.

In future, we would like to implement a shared base mutex for GWP-ASan, Scudo and sanitizer_common. This will likely happen when both GWP-ASan and Scudo standalone are not in the development phase, at which point they will have stable requirements.

Reviewers: vlad.tsyrklevich, morehouse, jfb

Reviewed By: morehouse

Subscribers: dexonsmith, srhines, cfe-commits, kubamracek, mgorny, cryptoad, jfb, #sanitizers, llvm-commits, vitalybuka, eugenis

Tags: #sanitizers, #llvm, #clang

Differential Revision: https://reviews.llvm.org/D61923

llvm-svn: 362138
12 files changed:
clang/runtime/CMakeLists.txt
compiler-rt/lib/gwp_asan/CMakeLists.txt
compiler-rt/lib/gwp_asan/mutex.h [new file with mode: 0644]
compiler-rt/lib/gwp_asan/platform_specific/mutex_posix.cpp [new file with mode: 0644]
compiler-rt/lib/gwp_asan/tests/CMakeLists.txt [new file with mode: 0644]
compiler-rt/lib/gwp_asan/tests/driver.cpp [new file with mode: 0644]
compiler-rt/lib/gwp_asan/tests/mutex_test.cpp [new file with mode: 0644]
compiler-rt/test/gwp_asan/CMakeLists.txt
compiler-rt/test/gwp_asan/dummy_test.cc [new file with mode: 0644]
compiler-rt/test/gwp_asan/lit.cfg [new file with mode: 0644]
compiler-rt/test/gwp_asan/lit.site.cfg.in [new file with mode: 0644]
compiler-rt/test/gwp_asan/unit/lit.site.cfg.in [new file with mode: 0644]