diff --git a/src/cmd/compile/default.pgo b/src/cmd/compile/default.pgo
new file mode 100644
index 0000000000000000000000000000000000000000..2ba79688d4ba4434f531fec90e538471bd3f5d6b
Binary files /dev/null and b/src/cmd/compile/default.pgo differ
diff --git a/src/cmd/compile/profile.sh b/src/cmd/compile/profile.sh
new file mode 100644
index 0000000000000000000000000000000000000000..37d65d84942b58739624dc4b50ae64d0dd057159
--- /dev/null
+++ b/src/cmd/compile/profile.sh
@@ -0,0 +1,21 @@
+# Copyright 2023 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.
+
+# This script collects a CPU profile of the compiler
+# for building all targets in std and cmd, and puts
+# the profile at cmd/compile/default.pgo.
+
+dir=$(mktemp -d)
+cd $dir
+seed=$(date)
+
+for p in $(go list std cmd); do
+	h=$(echo $seed $p | md5sum | cut -d ' ' -f 1)
+	echo $p $h
+	go build -o /dev/null -gcflags=-cpuprofile=$PWD/prof.$h $p
+done
+
+go tool pprof -proto prof.* > $(go env GOROOT)/src/cmd/compile/default.pgo
+
+rm -r $dir
diff --git a/src/cmd/dist/buildtool.go b/src/cmd/dist/buildtool.go
index af3db5f59023bd9e99fdef6884cac49ca2c3de8d..7ecfb3a811b0e83896accae9bc51ddd832ff909b 100644
--- a/src/cmd/dist/buildtool.go
+++ b/src/cmd/dist/buildtool.go
@@ -100,6 +100,10 @@ var ignorePrefixes = []string{
 var ignoreSuffixes = []string{
 	"_test.s",
 	"_test.go",
+	// Skip PGO profile. No need to build toolchain1 compiler
+	// with PGO. And as it is not a text file the import path
+	// rewrite will break it.
+	".pgo",
 }
 
 var tryDirs = []string{