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

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 16 21:30:43 PST 2020


aeubanks added inline comments.


================
Comment at: llvm/utils/gn/build/BUILD.gn:99
+      } else if (symbol_level == 1) {
+        cflags += [ "/Zd" ]
+      }
----------------
thakis wrote:
> aeubanks wrote:
> > thakis wrote:
> > > I think you don't need this. As far as I know, `Zd` is a cl.exe-level option that causes it to pass /DEBUG to `link.exe` and does nothing else. But we don't invoke cl.exe for links, we invoke `link.exe` directly. `link.exe /debug` will produce enough symbol information to create symbolized backtraces, but not enough to have line numbers. So you can either do nothing for symbol_level=1 with cflags and just pass /debug to ldflags like we already do, or you could do `if (symbol_level == 1 && is_clang) cflags += -gline-tables-only` (or -g1, same thing) so that we get the same behavior on linux and windows at least with clang as host compiler.
> > using clang, `/Zd` (without `/Zi`) does give line info.
> > 
> > In clang/test/Driver/cl-options.c I see
> > ```
> > // RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s
> > // Zi: "-gcodeview"
> > // Zi: "-debug-info-kind=limited"
> > 
> > // RUN: %clang_cl /Zd /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7GMLT %s
> > // Z7GMLT: "-gcodeview"
> > // Z7GMLT: "-debug-info-kind=line-tables-only"
> > ```
> Huh, weird. https://reviews.llvm.org/rL274991 / https://reviews.llvm.org/rL275826 suggest a) some interesting backstory that I either never knew or since forgot b) that this used to be a cl.exe flag but is no longer. Does current cl.exe still accept /Zd?
Thanks for the backgroun, looks like cl.exe doesn't recognize /Zd.

Now we always pass /Zi and add -gline-tables-only for `is_clang && symbol_level == 1`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92958/new/

https://reviews.llvm.org/D92958



More information about the llvm-commits mailing list