Index: llvm/utils/gn/build/BUILD.gn =================================================================== --- llvm/utils/gn/build/BUILD.gn +++ llvm/utils/gn/build/BUILD.gn @@ -23,7 +23,8 @@ if (host_os != "win") { if (is_debug) { cflags += [ "-g" ] - } else { + } + if (is_optimized) { cflags += [ "-O3" ] } cflags += [ "-fdiagnostics-color" ] @@ -39,11 +40,16 @@ "/FS", ] ldflags += [ "/DEBUG" ] - } else { + } + if (is_optimized) { cflags += [ "/O2", "/Zc:inline", ] + ldflags += [ + "/OPT:REF", + "/OPT:ICF", + ] } defines += [ "_CRT_SECURE_NO_DEPRECATE", Index: llvm/utils/gn/build/buildflags.gni =================================================================== --- llvm/utils/gn/build/buildflags.gni +++ llvm/utils/gn/build/buildflags.gni @@ -1,10 +1,13 @@ declare_args() { - # Whether to build with debug information and without optimizations. + # Whether to build with debug information. is_debug = false } # args that depend on other args must live in a later declare_args() block. declare_args() { + # Whether to build with optimizations. + is_optimized = !is_debug + # Whether to enable assertions. llvm_enable_assertions = true }