import (
"fmt"
"log"
+ "regexp"
"runtime"
"strings"
"time"
// PhaseOption sets the specified flag in the specified ssa phase,
// returning empty string if this was successful or a string explaining
-// the error if it was not. A version of the phase name with "_"
-// replaced by " " is also checked for a match.
-// See gc/lex.go for dissection of the option string. Example use:
-// GO_GCFLAGS=-d=ssa/generic_cse/time,ssa/generic_cse/stats,ssa/generic_cse/debug=3 ./make.bash ...
+// the error if it was not.
+// A version of the phase name with "_" replaced by " " is also checked for a match.
+// If the phase name begins a '~' then the rest of the underscores-replaced-with-blanks
+// version is used as a regular expression to match the phase name(s).
+//
+// Special cases that have turned out to be useful:
+// ssa/check/on enables checking after each phase
+// ssa/all/time enables time reporting for all phases
+//
+// See gc/lex.go for dissection of the option string.
+// Example uses:
+//
+// GO_GCFLAGS=-d=ssa/generic_cse/time,ssa/generic_cse/stats,ssa/generic_cse/debug=3 ./make.bash
+//
+// BOOT_GO_GCFLAGS=-d='ssa/~^.*scc$/off' GO_GCFLAGS='-d=ssa/~^.*scc$/off' ./make.bash
//
func PhaseOption(phase, flag string, val int) string {
if phase == "check" && flag == "on" {
checkEnabled = val == 0
return ""
}
+
+ alltime := false
+ if phase == "all" {
+ if flag == "time" {
+ alltime = val != 0
+ } else {
+ return fmt.Sprintf("Did not find a flag matching %s in -d=ssa/%s debug option", flag, phase)
+ }
+ }
+
underphase := strings.Replace(phase, "_", " ", -1)
+ var re *regexp.Regexp
+ if phase[0] == '~' {
+ r, ok := regexp.Compile(underphase[1:])
+ if ok != nil {
+ return fmt.Sprintf("Error %s in regexp for phase %s, flag %s", ok.Error(), phase, flag)
+ }
+ re = r
+ }
+ matchedOne := false
for i, p := range passes {
- if p.name == phase || p.name == underphase {
+ if phase == "all" {
+ p.time = alltime
+ passes[i] = p
+ matchedOne = true
+ } else if p.name == phase || p.name == underphase || re != nil && re.MatchString(p.name) {
switch flag {
case "on":
p.disabled = val == 0
return fmt.Sprintf("Cannot disable required SSA phase %s using -d=ssa/%s debug option", phase, phase)
}
passes[i] = p
- return ""
+ matchedOne = true
}
}
+ if matchedOne {
+ return ""
+ }
return fmt.Sprintf("Did not find a phase matching %s in -d=ssa/... debug option", phase)
}
goroot string
goroot_final string
goextlinkenabled string
+ gogcflags string // For running built compiler
workdir string
tooldir string
oldgoos string
goextlinkenabled = b
}
+ gogcflags = os.Getenv("GO_GCFLAGS")
+
b = os.Getenv("CC")
if b == "" {
// Use clang on OS X, because gcc is deprecated there.
archive = b
}
compile := []string{pathf("%s/compile", tooldir), "-pack", "-o", b, "-p", pkg}
+ if gogcflags != "" {
+ compile = append(compile, gogcflags)
+ }
if dir == "runtime" {
compile = append(compile, "-+", "-asmhdr", pathf("%s/go_asm.h", workdir))
}