[vm] Support `-d0` on windows with clang
`python3 tools\build.py -ax64 -d0 --clang runtime`
While MSVC expects `/O0`, clang-cl expects `-d0` instead.
However, clang-cl still wants /O2.
Change-Id: I7fa2f480cc9c110c7cd9c86072b5105106fbe76a
Cq-Include-Trybots: luci.dart.try:dart-sdk-win-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/236882
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
index b38dc18..a9e3ca4 100644
--- a/build/config/compiler/BUILD.gn
+++ b/build/config/compiler/BUILD.gn
@@ -777,10 +777,17 @@
if (is_win) {
# The only difference on windows is that the inlining is less aggressive.
# (We accept the default level). Otherwise it is very slow.
- cflags = [
- "/O${debug_optimization_level}", # Do some optimizations.
- "/Oy-", # Disable omitting frame pointers, must be after /O2.
- ]
+ if (is_clang && debug_optimization_level != "2") {
+ cflags = [
+ "-d${debug_optimization_level}", # Do some optimizations.
+ "/Oy-", # Disable omitting frame pointers, must be after /O2.
+ ]
+ } else {
+ cflags = [
+ "/O${debug_optimization_level}", # Do some optimizations.
+ "/Oy-", # Disable omitting frame pointers, must be after /O2.
+ ]
+ }
} else if (is_android) {
# On Android we kind of optimize some things that don't affect debugging
# much even when optimization is disabled to get the binary size down.
diff --git a/runtime/BUILD.gn b/runtime/BUILD.gn
index 12d3dfb..2cce01c 100644
--- a/runtime/BUILD.gn
+++ b/runtime/BUILD.gn
@@ -168,10 +168,17 @@
# flags.
if (is_win) {
if (dart_debug) {
- cflags = [
- "/O${dart_debug_optimization_level}",
- "/Oy-",
- ]
+ if (is_clang && dart_debug_optimization_level != "2") {
+ cflags = [
+ "-d${dart_debug_optimization_level}",
+ "/Oy-",
+ ]
+ } else {
+ cflags = [
+ "/O${dart_debug_optimization_level}",
+ "/Oy-",
+ ]
+ }
} else {
cflags = [
"/O2",