From acfb82e611f205c6d609ad59b1779a9bd55cb15d Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Mon, 25 Mar 2013 10:31:49 +0000 Subject: [PATCH] [Sanitizer] Compile sanitizer runtimes with -Wno-non-virtual-dtor. Virtual dtors may be a problem for us, as sanitizer runtime should not generally assume libstdc++ presence. llvm-svn: 177860 --- compiler-rt/CMakeLists.txt | 6 ++++++ .../lib/sanitizer_common/sanitizer_thread_registry.cc | 3 +-- .../lib/sanitizer_common/sanitizer_thread_registry.h | 5 +---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt index 240572e300f6..5ce55bd9f5f6 100644 --- a/compiler-rt/CMakeLists.txt +++ b/compiler-rt/CMakeLists.txt @@ -147,6 +147,12 @@ check_cxx_compiler_flag(-Wno-c99-extensions SUPPORTS_NO_C99_EXTENSIONS_FLAG) if(SUPPORTS_NO_C99_EXTENSIONS_FLAG) list(APPEND SANITIZER_COMMON_CFLAGS -Wno-c99-extensions) endif() +# Sanitizer may not have libstdc++, so we can have problems with virtual +# destructors. +check_cxx_compiler_flag(-Wno-non-virtual-dtor SUPPORTS_NO_NON_VIRTUAL_DTOR_FLAG) +if (SUPPORTS_NO_NON_VIRTUAL_DTOR_FLAG) + list(APPEND SANITIZER_COMMON_CFLAGS -Wno-non-virtual-dtor) +endif() # Setup min Mac OS X version. if(APPLE) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_thread_registry.cc b/compiler-rt/lib/sanitizer_common/sanitizer_thread_registry.cc index 5b3dacc56142..22c7c5e19679 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_thread_registry.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_thread_registry.cc @@ -22,11 +22,10 @@ ThreadContextBase::ThreadContextBase(u32 tid) name[0] = '\0'; } -#ifndef SANITIZER_GO ThreadContextBase::~ThreadContextBase() { + // ThreadContextBase should never be deleted. CHECK(0); } -#endif void ThreadContextBase::SetName(const char *new_name) { name[0] = '\0'; diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_thread_registry.h b/compiler-rt/lib/sanitizer_common/sanitizer_thread_registry.h index 66eb4ca184e9..fde969c6c5fa 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_thread_registry.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_thread_registry.h @@ -34,10 +34,7 @@ enum ThreadStatus { class ThreadContextBase { public: explicit ThreadContextBase(u32 tid); -#ifndef SANITIZER_GO // Go does not have libstdc++ - virtual -#endif - ~ThreadContextBase(); + ~ThreadContextBase(); // Should never be called. const u32 tid; // Thread ID. Main thread should have tid = 0. u64 unique_id; // Unique thread ID.