@@ -415,19 +415,28 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_ADDRESS_SANITIZER],
415415 CHECK_AVAILABLE: [
416416 AC_MSG_CHECKING ( [ if AddressSanitizer (asan) is available] )
417417 if test "x$TOOLCHAIN_TYPE" = "xgcc" ||
418- test "x$TOOLCHAIN_TYPE" = "xclang"; then
418+ test "x$TOOLCHAIN_TYPE" = "xclang" ||
419+ test "x$TOOLCHAIN_TYPE" = "xmicrosoft"; then
419420 AC_MSG_RESULT ( [ yes] )
420421 else
421422 AC_MSG_RESULT ( [ no] )
422423 AVAILABLE=false
423424 fi
424425 ] ,
425426 IF_ENABLED: [
426- # ASan is simply incompatible with gcc -Wstringop-truncation. See
427- # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85650
428- # It's harmless to be suppressed in clang as well.
429- ASAN_CFLAGS="-fsanitize=address -Wno-stringop-truncation -fno-omit-frame-pointer -fno-common -DADDRESS_SANITIZER"
430- ASAN_LDFLAGS="-fsanitize=address"
427+ if test "x$TOOLCHAIN_TYPE" = "xgcc" ||
428+ test "x$TOOLCHAIN_TYPE" = "xclang"; then
429+ # ASan is simply incompatible with gcc -Wstringop-truncation. See
430+ # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85650
431+ # It's harmless to be suppressed in clang as well.
432+ ASAN_CFLAGS="-fsanitize=address -Wno-stringop-truncation -fno-omit-frame-pointer -fno-common -DADDRESS_SANITIZER"
433+ ASAN_LDFLAGS="-fsanitize=address"
434+ elif test "x$TOOLCHAIN_TYPE" = "xmicrosoft"; then
435+ # -Oy- is equivalent to -fno-omit-frame-pointer in GCC/Clang.
436+ ASAN_CFLAGS="-fsanitize=address -Oy- -DADDRESS_SANITIZER"
437+ # MSVC produces a warning if you pass -fsanitize=address to the linker.
438+ ASAN_LDFLAGS=""
439+ fi
431440 JVM_CFLAGS="$JVM_CFLAGS $ASAN_CFLAGS"
432441 JVM_LDFLAGS="$JVM_LDFLAGS $ASAN_LDFLAGS"
433442 CFLAGS_JDKLIB="$CFLAGS_JDKLIB $ASAN_CFLAGS"
0 commit comments