From 442eb4e139e5837c503439bd13a50538d45bfd9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Sun, 28 Jun 2020 20:27:35 +0100 Subject: [PATCH] speed up builds with the compiler's -dwarf=false flag Generating DWARF in the compiler object files could take as much as 10% extra CPU time, while we ignore it entirely at the link stage. Speeds up 'go test -short' from ~19.5s to ~18.5s on my laptop. --- main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.go b/main.go index 04c3f57..25d76e2 100644 --- a/main.go +++ b/main.go @@ -465,6 +465,10 @@ func transformCompile(args []string) ([]string, error) { args = append(args, tempFile.Name()) } + + // We will force the linker to drop DWARF via -w, so don't spend time + // generating it. + flags = append(flags, "-dwarf=false") return args, nil } @@ -876,6 +880,7 @@ func transformLink(args []string) ([]string, error) { flags = append(flags, "-X", "runtime/internal/sys.TheVersion=unknown") flags = append(flags, "-X", "runtime.buildVersion=unknown") + // Strip debug information and symbol tables. flags = append(flags, "-w", "-s") return append(flags, paths...), nil }