Allow use of ASAN with msvc.

Starting with Visual Studio 2019 version 16.9 (msvc++ 14.28,
__MSC_VER 1928) has support for it's own version of AddressSanitizer.

Change-Id: I106b7e765ac80e4fc6eabd5b88500cbec5e38714
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/537461
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
This commit is contained in:
Ben Wagner 2022-05-05 13:31:21 -04:00 committed by SkCQ
parent e3f2cfc2a4
commit f7daa168cb
3 changed files with 9 additions and 7 deletions

View File

@ -1554,8 +1554,7 @@ int main(int argc, char** argv) {
// TODO(dogben): This is a bit ugly. Find a cleaner way to do this.
bool defaultConfigs = true;
for (int i = 0; i < argc; i++) {
static constexpr char kConfigArg[] = "--config";
if (strcmp(argv[i], kConfigArg) == 0) {
if (strcmp(argv[i], "--config") == 0) {
defaultConfigs = false;
break;
}

View File

@ -276,7 +276,10 @@ config("default") {
ldflags += [ "--sysroot=$skia_emsdk_dir/upstream/emscripten/cache/sysroot" ]
}
if (sanitize != "" && sanitize != "MSVC") {
if (is_win && !is_clang && sanitize == "ASAN") {
sanitizers = "address"
cflags += [ "/fsanitize=$sanitizers" ]
} else if (sanitize != "" && sanitize != "MSVC") {
# You can either pass the sanitizers directly, e.g. "address,undefined",
# or pass one of the couple common aliases used by the bots.
sanitizers = sanitize
@ -342,7 +345,9 @@ config("default") {
# See skia:9731.
config("recover_pointer_overflow") {
cflags = [ "-fsanitize-recover=pointer-overflow" ]
if (sanitize == "ASAN" && !(is_win && !is_clang)) {
cflags = [ "-fsanitize-recover=pointer-overflow" ]
}
}
config("no_exceptions") {

View File

@ -74,9 +74,7 @@ template("third_party") {
if (is_debug) {
configs += [ "//gn/skia:optimize" ]
}
if (sanitize == "ASAN") {
configs += [ "//gn/skia:recover_pointer_overflow" ]
}
configs += [ "//gn/skia:recover_pointer_overflow" ]
# "*" clobbers the current scope; append to existing configs
forward_variables_from(invoker,