From fb1bfd4d37d40cd5e4969ac631cf979d7b08f1a2 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 3 Aug 2022 23:01:08 -0400 Subject: all: remove pre-Go 1.17 workarounds The Go bootstrap toolchain requirement is now Go 1.17. We can finally delete all these pre-Go 1.17 workarounds. For #44505. Change-Id: I59d4dff1cde23da022892b5b6a116eb3dbad9ce4 Reviewed-on: https://go-review.googlesource.com/c/go/+/420903 Auto-Submit: Dmitri Shuralyov Run-TryBot: Russ Cox Reviewed-by: Austin Clements TryBot-Result: Gopher Robot --- src/cmd/compile/internal/gc/bootstrap.go | 17 ----------------- src/cmd/compile/internal/gc/pprof.go | 14 -------------- src/cmd/compile/internal/gc/trace.go | 30 ------------------------------ src/cmd/compile/internal/gc/util.go | 16 +++++++++++----- 4 files changed, 11 insertions(+), 66 deletions(-) delete mode 100644 src/cmd/compile/internal/gc/bootstrap.go delete mode 100644 src/cmd/compile/internal/gc/pprof.go delete mode 100644 src/cmd/compile/internal/gc/trace.go (limited to 'src/cmd/compile/internal/gc') diff --git a/src/cmd/compile/internal/gc/bootstrap.go b/src/cmd/compile/internal/gc/bootstrap.go deleted file mode 100644 index 37b0d59ede..0000000000 --- a/src/cmd/compile/internal/gc/bootstrap.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2017 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 !go1.8 -// +build !go1.8 - -package gc - -import ( - "cmd/compile/internal/base" - "runtime" -) - -func startMutexProfiling() { - base.Fatalf("mutex profiling unavailable in version %v", runtime.Version()) -} diff --git a/src/cmd/compile/internal/gc/pprof.go b/src/cmd/compile/internal/gc/pprof.go deleted file mode 100644 index 5f9b030621..0000000000 --- a/src/cmd/compile/internal/gc/pprof.go +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2017 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 go1.8 -// +build go1.8 - -package gc - -import "runtime" - -func startMutexProfiling() { - runtime.SetMutexProfileFraction(1) -} diff --git a/src/cmd/compile/internal/gc/trace.go b/src/cmd/compile/internal/gc/trace.go deleted file mode 100644 index 8cdbd4b0f3..0000000000 --- a/src/cmd/compile/internal/gc/trace.go +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2016 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 go1.7 -// +build go1.7 - -package gc - -import ( - "os" - tracepkg "runtime/trace" - - "cmd/compile/internal/base" -) - -func init() { - traceHandler = traceHandlerGo17 -} - -func traceHandlerGo17(traceprofile string) { - f, err := os.Create(traceprofile) - if err != nil { - base.Fatalf("%v", err) - } - if err := tracepkg.Start(f); err != nil { - base.Fatalf("%v", err) - } - base.AtExit(tracepkg.Stop) -} diff --git a/src/cmd/compile/internal/gc/util.go b/src/cmd/compile/internal/gc/util.go index 56fd137de2..dcac0ce79a 100644 --- a/src/cmd/compile/internal/gc/util.go +++ b/src/cmd/compile/internal/gc/util.go @@ -8,12 +8,11 @@ import ( "os" "runtime" "runtime/pprof" + tracepkg "runtime/trace" "cmd/compile/internal/base" ) -var traceHandler func(string) - func startProfile() { if base.Flag.CPUProfile != "" { f, err := os.Create(base.Flag.CPUProfile) @@ -64,13 +63,20 @@ func startProfile() { if err != nil { base.Fatalf("%v", err) } - startMutexProfiling() + runtime.SetMutexProfileFraction(1) base.AtExit(func() { pprof.Lookup("mutex").WriteTo(f, 0) f.Close() }) } - if base.Flag.TraceProfile != "" && traceHandler != nil { - traceHandler(base.Flag.TraceProfile) + if base.Flag.TraceProfile != "" { + f, err := os.Create(base.Flag.TraceProfile) + if err != nil { + base.Fatalf("%v", err) + } + if err := tracepkg.Start(f); err != nil { + base.Fatalf("%v", err) + } + base.AtExit(tracepkg.Stop) } } -- cgit v1.2.1