is_debug by default makes symbol_level = 2 and !is_debug means by
default symbol_level = 0.
Details
- Reviewers
thakis - Commits
- rGc1f30e581793: [gn build] Add symbol_level to adjust debug info level
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/utils/gn/build/BUILD.gn | ||
---|---|---|
75 | I think this kind of suggests that what we have here is kind of a linear scale with a few steps, and controlling that via a collection of bools is a bit unwieldy. Maybe we should get the route of having a symbol_level thing that can be 0, 1, or 2 (with 0 being the default for !is_debug builds, and 2 being the default for is_debug builds)? That'd match other GN-based builds, and it maps very clearly to a -g flag (at least on non-win clang). And then my CL to turn on gdb indices would turn on indices for symbol level 2 (which would be the default for debug builds), and you could set symbol_level=1 and everyone would be happy, maybe. |
So is_debug = true would just be an alias for symbol_level = 2 and is_debug = false would be symbol_level = 0? Or should we just remove is_debug and have people only use symbol_level? It seems weird that you could specify is_debug = true and symbol_level = 0 (and likewise is_debug = false and symbol_level = 2).
lg with the Zd thing addressed. Thanks!
llvm/utils/gn/build/BUILD.gn | ||
---|---|---|
101 | 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. |
llvm/utils/gn/build/BUILD.gn | ||
---|---|---|
101 | 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" |
llvm/utils/gn/build/BUILD.gn | ||
---|---|---|
101 | 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? |
use /Zi and -gline-tables-only
llvm/utils/gn/build/BUILD.gn | ||
---|---|---|
101 | 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. |
I think this kind of suggests that what we have here is kind of a linear scale with a few steps, and controlling that via a collection of bools is a bit unwieldy.
Maybe we should get the route of having a symbol_level thing that can be 0, 1, or 2 (with 0 being the default for !is_debug builds, and 2 being the default for is_debug builds)? That'd match other GN-based builds, and it maps very clearly to a -g flag (at least on non-win clang).
And then my CL to turn on gdb indices would turn on indices for symbol level 2 (which would be the default for debug builds), and you could set symbol_level=1 and everyone would be happy, maybe.