Skip to content

Commit 4a24082

Browse files
aykevldeadprogram
authored andcommitted
main: add -internal-nodwarf flag
This can be useful during development to avoid generating debug information in IR.
1 parent 92d9f85 commit 4a24082

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

builder/build.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
175175
AutomaticStackSize: config.AutomaticStackSize(),
176176
DefaultStackSize: config.StackSize(),
177177
NeedsStackObjects: config.NeedsStackObjects(),
178-
Debug: true,
178+
Debug: !config.Options.SkipDWARF, // emit DWARF except when -internal-nodwarf is passed
179179
}
180180

181181
// Load the target machine, which is the LLVM object that contains all

compileopts/options.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ type Options struct {
3535
PrintIR bool
3636
DumpSSA bool
3737
VerifyIR bool
38+
SkipDWARF bool
3839
PrintCommands func(cmd string, args ...string) `json:"-"`
3940
Semaphore chan struct{} `json:"-"` // -p flag controls cap
4041
Debug bool

main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,6 +1431,12 @@ func main() {
14311431
printIR := flag.Bool("internal-printir", false, "print LLVM IR")
14321432
dumpSSA := flag.Bool("internal-dumpssa", false, "dump internal Go SSA")
14331433
verifyIR := flag.Bool("internal-verifyir", false, "run extra verification steps on LLVM IR")
1434+
// Don't generate debug information in the IR, to make IR more readable.
1435+
// You generally want debug information in IR for various features, like
1436+
// stack size calculation and features like -size=short, -print-allocs=,
1437+
// etc. The -no-debug flag is used to strip it at link time. But for TinyGo
1438+
// development it can be useful to not emit debug information at all.
1439+
skipDwarf := flag.Bool("internal-nodwarf", false, "internal flag, use -no-debug instead")
14341440

14351441
var flagJSON, flagDeps, flagTest bool
14361442
if command == "help" || command == "list" || command == "info" || command == "build" {
@@ -1508,6 +1514,7 @@ func main() {
15081514
PrintIR: *printIR,
15091515
DumpSSA: *dumpSSA,
15101516
VerifyIR: *verifyIR,
1517+
SkipDWARF: *skipDwarf,
15111518
Semaphore: make(chan struct{}, *parallelism),
15121519
Debug: !*nodebug,
15131520
PrintSizes: *printSize,

0 commit comments

Comments
 (0)