[compiler-rt] r326032 - [ubsan-minimal] Fix the ubsan_minimal debug build (COMPILER_RT_DEBUG=1) on macOS.

Dan Liew via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 24 05:14:44 PST 2018


Author: delcypher
Date: Sat Feb 24 05:14:44 2018
New Revision: 326032

URL: http://llvm.org/viewvc/llvm-project?rev=326032&view=rev
Log:
[ubsan-minimal] Fix the ubsan_minimal debug build (COMPILER_RT_DEBUG=1) on macOS.

`ubsan_minimal` makes use of the `_sanitizer::atomic_load` function.
This function uses the `DCHECK` macro which in debug builds will use
the `_sanitizer::CheckFailed` function.

This function is part of `sanitizer_common` but `ubsan_minimal` doesn't
use this so the implementation is missing which leads to link failures
on macOS when trying to link `libclang_rt.ubsan_minimal_osx_dynamic.dylib`.
This is in contrast to the BFD linker on Linux which doesn't seem to care
about the missing symbol.

A basic implementation of `_sanitizer::CheckFailed` has been added to
the `ubsan_minimal` debug build to avoid the link error. The
implementation could definitely be improved but I don't know which
functions can be used in this context so I decided to restrict myself to
functions only being used in `ubsan_minimal` already.

Modified:
    compiler-rt/trunk/lib/ubsan_minimal/ubsan_minimal_handlers.cc

Modified: compiler-rt/trunk/lib/ubsan_minimal/ubsan_minimal_handlers.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan_minimal/ubsan_minimal_handlers.cc?rev=326032&r1=326031&r2=326032&view=diff
==============================================================================
--- compiler-rt/trunk/lib/ubsan_minimal/ubsan_minimal_handlers.cc (original)
+++ compiler-rt/trunk/lib/ubsan_minimal/ubsan_minimal_handlers.cc Sat Feb 24 05:14:44 2018
@@ -61,6 +61,19 @@ static void abort_with_message(const cha
 static void abort_with_message(const char *) { abort(); }
 #endif
 
+#if SANITIZER_DEBUG
+namespace __sanitizer {
+// The DCHECK macro needs this symbol to be defined.
+void NORETURN CheckFailed(const char *file, int, const char *cond, u64, u64) {
+  message("Sanitizer CHECK failed: ");
+  message(file);
+  message(":?? : "); // FIXME: Show line number.
+  message(cond);
+  abort();
+}
+} // namespace __sanitizer
+#endif
+
 #define INTERFACE extern "C" __attribute__((visibility("default")))
 
 // FIXME: add caller pc to the error message (possibly as "ubsan: error-type




More information about the llvm-commits mailing list