]> granicus.if.org Git - llvm/commitdiff
[gn build] Separate debug and optimization settings
authorDavid Major <dmajor@mozilla.com>
Tue, 12 Feb 2019 22:24:45 +0000 (22:24 +0000)
committerDavid Major <dmajor@mozilla.com>
Tue, 12 Feb 2019 22:24:45 +0000 (22:24 +0000)
This patch adds an `is_optimized` variable, orthogonal to `is_debug`, to allow for a gn analogue to `RelWithDebInfo` builds.

As part of this we'll want to explicitly enable GC+ICF, for the sake of `is_debug && is_optimized` builds. The flags normally default to true except that if you pass `/DEBUG` they default to false.

Differential Revision: https://reviews.llvm.org/D58075

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353888 91177308-0d34-0410-b5e6-96231b3b80d8

utils/gn/build/BUILD.gn
utils/gn/build/buildflags.gni

index e323f99ac659da549fc0d9638c340f53f2687948..91ea275b3fe97b7a301d271e9e7ec39fa98f2787 100644 (file)
@@ -23,7 +23,8 @@ config("compiler_defaults") {
   if (host_os != "win") {
     if (is_debug) {
       cflags += [ "-g" ]
-    } else {
+    }
+    if (is_optimized) {
       cflags += [ "-O3" ]
     }
     cflags += [ "-fdiagnostics-color" ]
@@ -39,11 +40,16 @@ config("compiler_defaults") {
         "/FS",
       ]
       ldflags += [ "/DEBUG" ]
-    } else {
+    }
+    if (is_optimized) {
       cflags += [
         "/O2",
         "/Zc:inline",
       ]
+      ldflags += [
+        "/OPT:REF",
+        "/OPT:ICF",
+      ]
     }
     defines += [
       "_CRT_SECURE_NO_DEPRECATE",
index a28b788418dac70ea16fe475be805c0d8c9ab772..4dcdc962b7d1164bd212b3ecea94061163747225 100644 (file)
@@ -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
 }