[CMake] Build lib/gwp_asan/tests with -std=c++17
authorFangrui Song <i@maskray.me>
Tue, 9 Aug 2022 00:51:17 +0000 (17:51 -0700)
committerFangrui Song <i@maskray.me>
Tue, 9 Aug 2022 00:51:17 +0000 (17:51 -0700)
commit474145c0b2420cb316bb8a9dcc031d613679d496
tree4894d46f3084cb70a9266314f481b8e5c87c241f
parent30bbb73bb448910f791088bfc3154e752d42241a
[CMake] Build lib/gwp_asan/tests with -std=c++17

With the recent llvm-project C++17 switch (D130689), gwp_asan/tests may fail to
link with some versions of GCC (https://github.com/llvm/llvm-project/issues/56994):

> backtrace.cpp:(.text+0xca6): undefined reference to `gwp_asan::AllocationMetadata::kMaxTraceLengthToCollect'

I cannot reproduce this issue by myself, but notice that currently
lib/gwp_asan/*.cpp get -std=c++17 while lib/gwp_asan/tests/*.cpp don't
(therefore may use -std=g++14 default from Clang and older GCC). Using -std=c++17
for lib/gwp_asan/tests will ensure that backtrace.cpp uses inline variable and will assuredly avoid the
possible GCC issue.

In the long-term, we should add -std=c++17 to a central place like generate_compiler_rt_tests.

Reviewed By: dyung

Differential Revision: https://reviews.llvm.org/D131440
compiler-rt/lib/gwp_asan/tests/CMakeLists.txt