[llvm] c1f30e5 - [gn build] Add symbol_level to adjust debug info level

Arthur Eubanks via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 17 09:21:12 PST 2020


Author: Arthur Eubanks
Date: 2020-12-17T09:20:53-08:00
New Revision: c1f30e581793f8db889b6fad0c3860f163f4afa2

URL: https://github.com/llvm/llvm-project/commit/c1f30e581793f8db889b6fad0c3860f163f4afa2
DIFF: https://github.com/llvm/llvm-project/commit/c1f30e581793f8db889b6fad0c3860f163f4afa2.diff

LOG: [gn build] Add symbol_level to adjust debug info level

is_debug by default makes symbol_level = 2 and !is_debug means by
default symbol_level = 0.

Reviewed By: thakis

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

Added: 
    

Modified: 
    llvm/utils/gn/build/BUILD.gn
    llvm/utils/gn/build/buildflags.gni

Removed: 
    


################################################################################
diff  --git a/llvm/utils/gn/build/BUILD.gn b/llvm/utils/gn/build/BUILD.gn
index a8f4f073de39..49caf447d019 100644
--- a/llvm/utils/gn/build/BUILD.gn
+++ b/llvm/utils/gn/build/BUILD.gn
@@ -72,9 +72,13 @@ config("compiler_defaults") {
     ldflags += [ "-mmacosx-version-min=10.10" ]
   }
 
+  assert(symbol_level == 0 || symbol_level == 1 || symbol_level == 2,
+         "Unexpected symbol_level")
   if (host_os != "win") {
-    if (is_debug) {
+    if (symbol_level == 2) {
       cflags += [ "-g" ]
+    } else if (symbol_level == 1) {
+      cflags += [ "-g1" ]
     }
     if (is_optimized) {
       cflags += [ "-O3" ]
@@ -88,11 +92,14 @@ config("compiler_defaults") {
       "-fvisibility-inlines-hidden",
     ]
   } else {
-    if (is_debug) {
+    if (symbol_level != 0) {
       cflags += [
         "/Zi",
         "/FS",
       ]
+      if (symbol_level == 1 && is_clang) {
+        cflags += [ "-gline-tables-only" ]
+      }
       ldflags += [ "/DEBUG" ]
 
       # Speed up links with ghash on windows.

diff  --git a/llvm/utils/gn/build/buildflags.gni b/llvm/utils/gn/build/buildflags.gni
index 9ad494a3c1e9..e6d7ca1806a9 100644
--- a/llvm/utils/gn/build/buildflags.gni
+++ b/llvm/utils/gn/build/buildflags.gni
@@ -28,4 +28,11 @@ declare_args() {
 declare_args() {
   # Whether to build with optimizations.
   is_optimized = !is_debug
+
+  # Debug info symbol level.
+  if (is_debug) {
+    symbol_level = 2
+  } else {
+    symbol_level = 0
+  }
 }


        


More information about the llvm-commits mailing list