rebuildall bool
defaultclang bool
+ noOpt bool
vflag int // verbosity
)
}
gogcflags = os.Getenv("GO_GCFLAGS") // we were using $BOOT_GO_GCFLAGS until now
+ setNoOpt()
goldflags = os.Getenv("GO_LDFLAGS") // we were using $BOOT_GO_LDFLAGS until now
goBootstrap := pathf("%s/go_bootstrap", tooldir)
cmdGo := pathf("%s/go", gorootBin)
func goCmd(goBinary string, cmd string, args ...string) {
goCmd := []string{goBinary, cmd}
+ if noOpt {
+ goCmd = append(goCmd, "-tags=noopt")
+ }
goCmd = appendCompilerFlags(goCmd)
if vflag > 0 {
goCmd = append(goCmd, "-v")
func checkNotStale(goBinary string, targets ...string) {
goCmd := []string{goBinary, "list"}
+ if noOpt {
+ goCmd = append(goCmd, "-tags=noopt")
+ }
goCmd = appendCompilerFlags(goCmd)
goCmd = append(goCmd, "-f={{if .Stale}}\tSTALE {{.ImportPath}}: {{.StaleReason}}{{end}}")
}
return rval
}
+
+func setNoOpt() {
+ for _, gcflag := range strings.Split(gogcflags, " ") {
+ if gcflag == "-N" || gcflag == "-l" {
+ noOpt = true
+ break
+ }
+ }
+}
func cmdtest() {
gogcflags = os.Getenv("GO_GCFLAGS")
+ setNoOpt()
var t tester
}
func (t *tester) tags() string {
- if t.iOS() {
+ ios := t.iOS()
+ switch {
+ case ios && noOpt:
+ return "-tags=lldb,noopt"
+ case ios:
return "-tags=lldb"
+ case noOpt:
+ return "-tags=noopt"
+ default:
+ return "-tags="
}
- return "-tags="
}
// timeoutDuration converts the provided number of seconds into a
--- /dev/null
+// Copyright 2022 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build noopt
+
+package testenv
+
+// OptimizationOff reports whether optimization is disabled.
+func OptimizationOff() bool {
+ return true
+}
--- /dev/null
+// Copyright 2022 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build !noopt
+
+package testenv
+
+// OptimizationOff reports whether optimization is disabled.
+func OptimizationOff() bool {
+ return false
+}
func SkipIfOptimizationOff(t testing.TB) {
if OptimizationOff() {
t.Helper()
- t.Skip("skipping test with optimization disabled on builder")
+ t.Skip("skipping test with optimization disabled")
}
}
-// OptimizationOff reports whether optimization is disabled.
-func OptimizationOff() bool {
- return strings.HasSuffix(Builder(), "-noopt")
-}
-
// RunWithTimeout runs cmd and returns its combined output. If the
// subprocess exits with a non-zero status, it will log that status
// and return a non-nil error, but this is not considered fatal.