This reapplies 8fa66c6ca7 ([asan][windows]
Eliminate the static asan runtime on windows) for a second time.
That PR bounced off the tests because it caused failures in the other
sanitizer runtimes, these have been fixed by only building interception,
sanitizer_common, and asan with /MD, and continuing to build the rest of
the runtimes with /MT. This does mean that any usage of the static
ubsan/fuzzer/etc runtimes will mean you're mixing different runtime
library linkages in the same app, the interception, sanitizer_common,
and asan runtimes are designed for this, however it does result in some
linker warnings.
Additionally, it turns out when building in release-mode with
LLVM_ENABLE_PDBs the build system forced /OPT:ICF. This totally breaks
asan's "new" method of doing "weak" functions on windows, and so
/OPT:NOICF was explicitly added to asan's link flags.
---------
Co-authored-by: Amy Wishnousky <amyw@microsoft.com>
22 lines
415 B
C++
22 lines
415 B
C++
// RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
// Required for dyld macOS 12.0+
|
|
#if (__APPLE__)
|
|
__attribute__((weak))
|
|
#endif
|
|
extern "C" void
|
|
__asan_on_error() {
|
|
fprintf(stderr, "__asan_on_error called\n");
|
|
fflush(stderr);
|
|
}
|
|
|
|
int main() {
|
|
char *x = (char*)malloc(10 * sizeof(char));
|
|
free(x);
|
|
return x[5];
|
|
// CHECK: __asan_on_error called
|
|
}
|