From da67c23fbbd72f2dca280582fc2125e1cb35d830 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Sun, 16 Apr 2017 05:53:06 -0700 Subject: [PATCH] cmd/compile: add flag to disable DWARF generation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DWARF generation has non-trivial cost, and in some cases is not necessary. Provide an option to opt out. Alloc impact of disabling DWARF generation: name old alloc/op new alloc/op delta Template 38.7MB ± 0% 37.6MB ± 0% -2.77% (p=0.016 n=5+4) Unicode 29.8MB ± 0% 29.8MB ± 0% -0.16% (p=0.032 n=5+5) GoTypes 113MB ± 0% 110MB ± 0% -2.38% (p=0.008 n=5+5) Compiler 463MB ± 0% 457MB ± 0% -1.34% (p=0.008 n=5+5) SSA 1.25GB ± 0% 1.23GB ± 0% -1.64% (p=0.008 n=5+5) Flate 25.3MB ± 0% 25.0MB ± 0% -1.05% (p=0.008 n=5+5) GoParser 31.7MB ± 0% 30.9MB ± 0% -2.74% (p=0.008 n=5+5) Reflect 78.2MB ± 0% 76.7MB ± 0% -1.90% (p=0.008 n=5+5) Tar 26.5MB ± 0% 26.0MB ± 0% -2.04% (p=0.008 n=5+5) XML 42.4MB ± 0% 41.1MB ± 0% -2.86% (p=0.008 n=5+5) name old allocs/op new allocs/op delta Template 377k ± 0% 360k ± 1% -4.46% (p=0.008 n=5+5) Unicode 321k ± 0% 320k ± 0% ~ (p=0.151 n=5+5) GoTypes 1.14M ± 0% 1.10M ± 0% -4.13% (p=0.008 n=5+5) Compiler 4.26M ± 0% 4.13M ± 0% -3.14% (p=0.008 n=5+5) SSA 9.70M ± 0% 9.33M ± 0% -3.89% (p=0.008 n=5+5) Flate 233k ± 0% 228k ± 0% -2.40% (p=0.008 n=5+5) GoParser 316k ± 0% 302k ± 0% -4.48% (p=0.008 n=5+5) Reflect 980k ± 0% 945k ± 0% -3.62% (p=0.008 n=5+5) Tar 249k ± 0% 241k ± 0% -3.19% (p=0.008 n=5+5) XML 391k ± 0% 376k ± 0% -3.95% (p=0.008 n=5+5) Change-Id: I97dbfb6b40195d1e0b91be097a4bf0e7f65b26af Reviewed-on: https://go-review.googlesource.com/40857 Run-TryBot: Josh Bleecher Snyder Reviewed-by: Brad Fitzpatrick --- src/cmd/compile/internal/gc/go.go | 2 ++ src/cmd/compile/internal/gc/main.go | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cmd/compile/internal/gc/go.go b/src/cmd/compile/internal/gc/go.go index 72127b052fb..b3edb0ed22c 100644 --- a/src/cmd/compile/internal/gc/go.go +++ b/src/cmd/compile/internal/gc/go.go @@ -201,6 +201,8 @@ var flag_race bool var flag_msan bool +var flagDWARF bool + // Whether we are adding any sort of code instrumentation, such as // when the race detector is enabled. var instrumenting bool diff --git a/src/cmd/compile/internal/gc/main.go b/src/cmd/compile/internal/gc/main.go index 36ec651245b..79e95958ef2 100644 --- a/src/cmd/compile/internal/gc/main.go +++ b/src/cmd/compile/internal/gc/main.go @@ -118,7 +118,6 @@ func Main(archInit func(*Arch)) { archInit(&thearch) Ctxt = obj.Linknew(thearch.LinkArch) - Ctxt.DebugInfo = debuginfo Ctxt.DiagFunc = yyerror Ctxt.Bso = bufio.NewWriter(os.Stdout) @@ -181,6 +180,7 @@ func Main(archInit func(*Arch)) { flag.StringVar(&buildid, "buildid", "", "record `id` as the build id in the export metadata") flag.BoolVar(&pure_go, "complete", false, "compiling complete package (no C or assembly)") flag.StringVar(&debugstr, "d", "", "print debug information about items in `list`") + flag.BoolVar(&flagDWARF, "dwarf", true, "generate DWARF symbols") obj.Flagcount("e", "no limit on number of errors reported", &Debug['e']) obj.Flagcount("f", "debug stack frames", &Debug['f']) obj.Flagcount("h", "halt on error", &Debug['h']) @@ -227,6 +227,9 @@ func Main(archInit func(*Arch)) { Ctxt.Debugasm = Debug_asm Ctxt.Debugvlog = Debug_vlog + if flagDWARF { + Ctxt.DebugInfo = debuginfo + } if flag.NArg() < 1 { usage()