]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/dist, internal/abi: support bootstrapping with gccgo
authorIan Lance Taylor <iant@golang.org>
Wed, 21 Jun 2023 22:27:20 +0000 (15:27 -0700)
committerGopher Robot <gobot@golang.org>
Tue, 27 Jun 2023 21:15:37 +0000 (21:15 +0000)
The required gc bootstrap compiler, 1.17, has an internal/lazyregexp
package. It permits that package to be imported by internal/profile
while bootstrapping. The gccgo compiler also has an internal/lazyregexp
package, but it does not permit the gc compiler to import it.

Permit bootstrapping with gccgo by adding internal/lazyregexp to the
list of bootstrap directories.

The gccgo compiler recognizes the magic functions internal/abi.FuncPCABI0
and FuncPCABIInternal, but only in the internal/abi package, not
in the bootstrapping internal/abi package.

Permit bootstrapping with gccgo by adding definitions of those functions
with build tags so that they are only used by gccgo.

Fixes #60913

Change-Id: I3a78848d545db13314409d170d63f4cc737ca12e
Reviewed-on: https://go-review.googlesource.com/c/go/+/505036
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>

src/cmd/dist/buildtool.go
src/internal/abi/funcpc.go
src/internal/abi/funcpc_gccgo.go [new file with mode: 0644]

index e638d51af7cac369d9186df02bd651b16683eb30..a528d7aa768e1bcfd03ee3cd15a718e4ea3aaaf4 100644 (file)
@@ -70,6 +70,11 @@ var bootstrapDirs = []string{
        "internal/goexperiment",
        "internal/goroot",
        "internal/goversion",
+       // internal/lazyregexp is provided by Go 1.17, which permits it to
+       // be imported by other packages in this list, but is not provided
+       // by the Go 1.17 version of gccgo. It's on this list only to
+       // support gccgo, and can be removed if we require gccgo 14 or later.
+       "internal/lazyregexp",
        "internal/pkgbits",
        "internal/platform",
        "internal/profile",
index 4db848ee1590df54a69e06094d4d64f2acecbb6c..e038d3658486d2e7827aa09f8e9c2f96dc5993ef 100644 (file)
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build !gccgo
+
 package abi
 
 // FuncPC* intrinsics.
diff --git a/src/internal/abi/funcpc_gccgo.go b/src/internal/abi/funcpc_gccgo.go
new file mode 100644 (file)
index 0000000..ad5fa52
--- /dev/null
@@ -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.
+
+// For bootstrapping with gccgo.
+
+//go:build gccgo
+
+package abi
+
+import "unsafe"
+
+func FuncPCABI0(f interface{}) uintptr {
+       words := (*[2]unsafe.Pointer)(unsafe.Pointer(&f))
+       return *(*uintptr)(unsafe.Pointer(words[1]))
+}
+
+func FuncPCABIInternal(f interface{}) uintptr {
+       words := (*[2]unsafe.Pointer)(unsafe.Pointer(&f))
+       return *(*uintptr)(unsafe.Pointer(words[1]))
+}