Add a flag to compile Go code for debugging.

This makes it possible to debug the primary builder without manually
adding the respective flags to the compilation command lines.

Test: "m nothing", "m nothing" with debugging, then "m nothing" again
Change-Id: I7d403af48528a94e5e0033d9a5c1fa9981100cfd
diff --git a/bootstrap/bootstrap.go b/bootstrap/bootstrap.go
index e4828cd..e122bb2 100644
--- a/bootstrap/bootstrap.go
+++ b/bootstrap/bootstrap.go
@@ -59,7 +59,7 @@
 	compile = pctx.StaticRule("compile",
 		blueprint.RuleParams{
 			Command: "GOROOT='$goRoot' $compileCmd $parallelCompile -o $out.tmp " +
-				"-p $pkgPath -complete $incFlags -pack $in && " +
+				"$debugFlags -p $pkgPath -complete $incFlags -pack $in && " +
 				"if cmp --quiet $out.tmp $out; then rm $out.tmp; else mv -f $out.tmp $out; fi",
 			CommandDeps: []string{"$compileCmd"},
 			Description: "compile $out",
diff --git a/bootstrap/config.go b/bootstrap/config.go
index 1f2b255..5cd1712 100644
--- a/bootstrap/config.go
+++ b/bootstrap/config.go
@@ -65,6 +65,13 @@
 	linkCmdVariable = bootstrapVariable("linkCmd", func(c BootstrapConfig) string {
 		return "$goRoot/pkg/tool/" + runtime.GOOS + "_" + runtime.GOARCH + "/link"
 	})
+	debugFlagsVariable = bootstrapVariable("debugFlags", func(c BootstrapConfig) string {
+		if c.DebugCompilation() {
+			return "-N -l"
+		} else {
+			return ""
+		}
+	})
 )
 
 type BootstrapConfig interface {
@@ -77,6 +84,9 @@
 
 	// The output directory for the build.
 	NinjaBuildDir() string
+
+	// Whether to compile Go code in such a way that it can be debugged
+	DebugCompilation() bool
 }
 
 type ConfigRemoveAbandonedFilesUnder interface {