This is an archive of the discontinued LLVM Phabricator instance.

[CMake] Build lib/gwp_asan/tests with -std=c++17
ClosedPublic

Authored by MaskRay on Aug 8 2022, 2:11 PM.

Details

Summary

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.

Diff Detail

Event Timeline

MaskRay created this revision.Aug 8 2022, 2:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 8 2022, 2:11 PM
MaskRay requested review of this revision.Aug 8 2022, 2:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 8 2022, 2:11 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
dyung accepted this revision.Aug 8 2022, 5:46 PM
dyung added a subscriber: dyung.

LGTM. The change fixes the problem on my local machine. Thanks!

This revision is now accepted and ready to land.Aug 8 2022, 5:46 PM
This revision was automatically updated to reflect the committed changes.

Landing this to fix the build bot issue. A dozen *_UNITTEST_CFLAGS lack -std=c++17 but I do not find a good place to add the option...