diff --git a/compiler-rt/lib/rtsan/CMakeLists.txt b/compiler-rt/lib/rtsan/CMakeLists.txt index 3f146a757a97..07a21b49eb45 100644 --- a/compiler-rt/lib/rtsan/CMakeLists.txt +++ b/compiler-rt/lib/rtsan/CMakeLists.txt @@ -29,6 +29,8 @@ set(RTSAN_LINK_LIBS ${COMPILER_RT_UNWINDER_LINK_LIBS} ${COMPILER_RT_CXX_LINK_LIBS}) +append_rtti_flag(OFF RTSAN_CFLAGS) + if(APPLE) add_compiler_rt_object_libraries(RTRtsan OS ${SANITIZER_COMMON_SUPPORTED_OS} diff --git a/compiler-rt/test/rtsan/basic.cpp b/compiler-rt/test/rtsan/basic.cpp index 607db90213a3..4edf32336720 100644 --- a/compiler-rt/test/rtsan/basic.cpp +++ b/compiler-rt/test/rtsan/basic.cpp @@ -1,5 +1,4 @@ // RUN: %clangxx -fsanitize=realtime %s -o %t -// RUN: %clang -fsanitize=realtime %s -o %t // RUN: not %run %t 2>&1 | FileCheck %s // UNSUPPORTED: ios diff --git a/compiler-rt/test/rtsan/sanity_check_pure_c.c b/compiler-rt/test/rtsan/sanity_check_pure_c.c new file mode 100644 index 000000000000..bdca6039d932 --- /dev/null +++ b/compiler-rt/test/rtsan/sanity_check_pure_c.c @@ -0,0 +1,28 @@ +// RUN: %clang -fsanitize=realtime %s -o %t +// RUN: not %run %t 2>&1 | FileCheck %s +// RUN: %clang %s -o %t +// RUN: %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-NO-SANITIZE +#ifdef __cplusplus +# error "This test must be built in C mode" +#endif + +#include +#include + +// Check that we can build and run C code. + +void nonblocking_function(void) __attribute__((nonblocking)); + +void nonblocking_function(void) __attribute__((nonblocking)) { + void *ptr = malloc(2); + printf("ptr: %p\n", ptr); // ensure we don't optimize out the malloc +} + +int main() { + nonblocking_function(); + printf("Done\n"); + return 0; +} + +// CHECK: ==ERROR: RealtimeSanitizer +// CHECK-NO-SANITIZE: Done