all: turn on cgo/external linking for linux/ppc64

ppc64/linux has been switched to the ELFv2 abi, the same as
ppc64le/linux. Turn on cgo features and remove many of the
hacks which disabled external linking. There should be no
difference between ppc64le and ppc64 linux beyond endianness.

The ppc64x Go to ELF relocation code is cleaned up to simplify
and enable bi-endian support.

Cq-Include-Trybots: luci.golang.try:gotip-linux-ppc64_power10,gotip-linux-ppc64_power8,gotip-linux-ppc64le_power8,gotip-linux-ppc64le_power10,gotip-linux-ppc64le_power9,gotip-openbsd-ppc64
Change-Id: I8f553a8eae067f93ee395c219e20eabd4aeb67c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/770240
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Archana Ravindar <aravinda@redhat.com>
Reviewed-by: Jayanth Krishnamurthy <jayanth.krishnamurthy@ibm.com>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
Paul Murphy 2026-04-23 16:08:49 -05:00
parent 922abf576d
commit 364de84f36
27 changed files with 106 additions and 135 deletions

View 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 (ppc64 || ppc64le) && linux && cgo
package cgotest
// extern int notoc_func(void);

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build ppc64le && linux && cgo
//go:build (ppc64 || ppc64le) && linux && cgo
package cgotest

View 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 (ppc64 || ppc64le) && linux && cgo
// When linking C ELFv2 objects, the Go linker may need to insert calling stubs.
// A call stub is usually needed when the ELFv2 st_other attribute is different
// between caller and callee.

View file

@ -4211,7 +4211,7 @@ func addTailCall(pos src.XPos, fn *ir.Func, recv ir.Node, method *types.Field) {
!types.IsInterfaceMethod(method.Type) && !unifiedHaveInlineBody(ir.MethodExprName(dot).Func)) &&
// TODO: implement wasm indirect tail calls
// TODO: do we need the ppc64le/dynlink restriction for interface tail calls?
!(base.Ctxt.Arch.Name == "ppc64le" && base.Ctxt.Flag_dynlink) {
!((base.Ctxt.Arch.Name == "ppc64le" || base.Ctxt.Arch.Name == "ppc64") && base.Ctxt.Flag_dynlink) {
if base.Debug.TailCall != 0 {
base.WarnfAt(fn.Nname.Type().Recv().Type.Elem().Pos(), "tail call emitted for the method %v wrapper", method.Nname)
}

View file

@ -796,7 +796,7 @@ func (s *regAllocState) init(f *Func) {
// nothing to do
case "loong64": // R2 (aka TP) already reserved.
// nothing to do
case "ppc64le": // R2 already reserved.
case "ppc64", "ppc64le": // R2 already reserved.
// nothing to do
case "riscv64": // X3 (aka GP) and X4 (aka TP) already reserved.
// nothing to do

View file

@ -317,7 +317,7 @@ func makeABIWrapper(f *ir.Func, wrapperABI obj.ABI) {
// extra work in typecheck/walk/ssa, might want to add a new node
// OTAILCALL or something to this effect.
tailcall := fn.Type().NumResults() == 0 && fn.Type().NumParams() == 0 && fn.Type().NumRecvs() == 0
if base.Ctxt.Arch.Name == "ppc64le" && base.Ctxt.Flag_dynlink {
if (base.Ctxt.Arch.Name == "ppc64le" || base.Ctxt.Arch.Name == "ppc64") && base.Ctxt.Flag_dynlink {
// cannot tailcall on PPC64 with dynamic linking, as we need
// to restore R2 after call.
tailcall = false

View file

@ -640,8 +640,8 @@ func mustLinkExternal(goos, goarch string, cgoEnabled bool) bool {
// https://golang.org/issue/14449
return true
case "ppc64":
// Big Endian PPC64 cgo internal linking is not implemented for aix or linux.
if goos == "aix" || goos == "linux" {
// Big Endian PPC64 cgo internal linking is not implemented for aix.
if goos == "aix" {
return true
}
}
@ -1796,7 +1796,7 @@ var cgoEnabled = map[string]bool{
"linux/arm": true,
"linux/arm64": true,
"linux/loong64": true,
"linux/ppc64": false,
"linux/ppc64": true,
"linux/ppc64le": true,
"linux/mips": true,
"linux/mipsle": true,

16
src/cmd/dist/test.go vendored
View file

@ -1204,7 +1204,7 @@ func (t *tester) extLink() bool {
if !cgoEnabled[goos+"/"+goarch] {
return false
}
if goarch == "ppc64" && goos != "aix" {
if goarch == "ppc64" && goos != "aix" && goos != "linux" {
return false
}
return true
@ -1245,7 +1245,7 @@ func (t *tester) internalLinkPIE() bool {
}
switch goos + "-" + goarch {
case "darwin-amd64", "darwin-arm64",
"linux-amd64", "linux-arm64", "linux-loong64", "linux-ppc64le", "linux-s390x",
"linux-amd64", "linux-arm64", "linux-loong64", "linux-ppc64", "linux-ppc64le", "linux-s390x",
"android-arm64",
"windows-amd64", "windows-386", "windows-arm64":
return true
@ -1752,9 +1752,7 @@ func buildModeSupported(compiler, buildmode, goos, goarch string) bool {
return true
case "linux":
switch goarch {
case "386", "amd64", "arm", "armbe", "arm64", "arm64be", "loong64", "ppc64le", "riscv64", "s390x":
// linux/ppc64 not supported because it does
// not support external linking mode yet.
case "386", "amd64", "arm", "armbe", "arm64", "arm64be", "loong64", "ppc64", "ppc64le", "riscv64", "s390x":
return true
default:
// Other targets do not support -shared,
@ -1772,7 +1770,7 @@ func buildModeSupported(compiler, buildmode, goos, goarch string) bool {
case "c-shared":
switch platform {
case "linux/amd64", "linux/arm", "linux/arm64", "linux/loong64", "linux/386", "linux/ppc64le", "linux/riscv64", "linux/s390x",
case "linux/amd64", "linux/arm", "linux/arm64", "linux/loong64", "linux/386", "linux/ppc64", "linux/ppc64le", "linux/riscv64", "linux/s390x",
"android/amd64", "android/arm", "android/arm64", "android/386",
"freebsd/amd64",
"darwin/amd64", "darwin/arm64",
@ -1790,7 +1788,7 @@ func buildModeSupported(compiler, buildmode, goos, goarch string) bool {
case "pie":
switch platform {
case "linux/386", "linux/amd64", "linux/arm", "linux/arm64", "linux/loong64", "linux/ppc64le", "linux/riscv64", "linux/s390x",
case "linux/386", "linux/amd64", "linux/arm", "linux/arm64", "linux/loong64", "linux/ppc64", "linux/ppc64le", "linux/riscv64", "linux/s390x",
"android/amd64", "android/arm", "android/arm64", "android/386",
"freebsd/amd64",
"darwin/amd64", "darwin/arm64",
@ -1804,14 +1802,14 @@ func buildModeSupported(compiler, buildmode, goos, goarch string) bool {
case "shared":
switch platform {
case "linux/386", "linux/amd64", "linux/arm", "linux/arm64", "linux/ppc64le", "linux/s390x":
case "linux/386", "linux/amd64", "linux/arm", "linux/arm64", "linux/ppc64", "linux/ppc64le", "linux/s390x":
return true
}
return false
case "plugin":
switch platform {
case "linux/amd64", "linux/arm", "linux/arm64", "linux/386", "linux/loong64", "linux/riscv64", "linux/s390x", "linux/ppc64le",
case "linux/amd64", "linux/arm", "linux/arm64", "linux/386", "linux/loong64", "linux/riscv64", "linux/s390x", "linux/ppc64", "linux/ppc64le",
"android/amd64", "android/386",
"darwin/amd64", "darwin/arm64",
"freebsd/amd64":

View file

@ -213,15 +213,7 @@ func determineLinkMode(ctxt *Link) {
}
}
switch ctxt.LinkMode {
case LinkInternal:
if extNeeded {
Exitf("internal linking requested %sbut external linking required: %s", via, extReason)
}
case LinkExternal:
switch {
case buildcfg.GOARCH == "ppc64" && buildcfg.GOOS == "linux":
Exitf("external linking not supported for %s/ppc64", buildcfg.GOOS)
}
if ctxt.LinkMode == LinkInternal && extNeeded {
Exitf("internal linking requested %sbut external linking required: %s", via, extReason)
}
}

View file

@ -868,11 +868,12 @@ func TestRuntimeTypeAttrExternal(t *testing.T) {
mustHaveDWARF(t)
// Explicitly test external linking, for dsymutil compatibility on Darwin.
if runtime.GOARCH == "ppc64" {
t.Skip("-linkmode=external not supported on ppc64")
if runtime.GOOS == "aix" {
// This fails with something like: DWARF type offset was 0xf18+0x200008b8, but test program said 0x1100017d0
t.Skip("-linkmode=external not supported on aix")
}
// Explicitly test external linking, for dsymutil compatibility on Darwin.
testRuntimeTypeAttr(t, "-ldflags=-linkmode=external")
}

View file

@ -905,15 +905,20 @@ func xcoffreloc1(arch *sys.Arch, out *ld.OutBuf, ldr *loader.Loader, s loader.Sy
}
func elfreloc1(ctxt *ld.Link, out *ld.OutBuf, ldr *loader.Loader, s loader.Sym, r loader.ExtReloc, ri int, sectoff int64) bool {
// Beware that bit0~bit15 start from the third byte of an instruction in Big-Endian machines.
rt := r.Type
if rt == objabi.R_ADDR || rt == objabi.R_POWER_TLS || rt == objabi.R_CALLPOWER || rt == objabi.R_DWARFSECREF {
} else {
if ctxt.Arch.ByteOrder == binary.BigEndian {
sectoff += 2
}
fixupBe := int64(0)
// 32 bit Go relocations which translate into two 16 bit ELF relocations need to be adjusted
// to account for BE ordering.
if ctxt.Arch.ByteOrder == binary.BigEndian {
fixupBe = 2
}
// Helper to write one 64b ELF relocation entry.
writeElfReloc := func(rtyp elf.R_PPC64, offset int64, sym int32, addend int64) {
out.Write64(uint64(offset))
out.Write64(uint64(rtyp) | uint64(sym)<<32)
out.Write64(uint64(addend))
}
out.Write64(uint64(sectoff))
elfsym := ld.ElfSymForReloc(ctxt, r.Xsym)
switch rt {
@ -922,78 +927,68 @@ func elfreloc1(ctxt *ld.Link, out *ld.OutBuf, ldr *loader.Loader, s loader.Sym,
case objabi.R_ADDR, objabi.R_DWARFSECREF:
switch r.Size {
case 4:
out.Write64(uint64(elf.R_PPC64_ADDR32) | uint64(elfsym)<<32)
writeElfReloc(elf.R_PPC64_ADDR32, sectoff, elfsym, r.Xadd)
case 8:
out.Write64(uint64(elf.R_PPC64_ADDR64) | uint64(elfsym)<<32)
writeElfReloc(elf.R_PPC64_ADDR64, sectoff, elfsym, r.Xadd)
default:
return false
}
case objabi.R_ADDRPOWER_D34:
out.Write64(uint64(elf.R_PPC64_D34) | uint64(elfsym)<<32)
writeElfReloc(elf.R_PPC64_D34, sectoff, elfsym, r.Xadd)
case objabi.R_ADDRPOWER_PCREL34:
out.Write64(uint64(elf.R_PPC64_PCREL34) | uint64(elfsym)<<32)
writeElfReloc(elf.R_PPC64_PCREL34, sectoff, elfsym, r.Xadd)
case objabi.R_POWER_TLS:
out.Write64(uint64(elf.R_PPC64_TLS) | uint64(elfsym)<<32)
writeElfReloc(elf.R_PPC64_TLS, sectoff, elfsym, r.Xadd)
case objabi.R_POWER_TLS_LE:
out.Write64(uint64(elf.R_PPC64_TPREL16_HA) | uint64(elfsym)<<32)
out.Write64(uint64(r.Xadd))
out.Write64(uint64(sectoff + 4))
out.Write64(uint64(elf.R_PPC64_TPREL16_LO) | uint64(elfsym)<<32)
sectoff += fixupBe
writeElfReloc(elf.R_PPC64_TPREL16_HA, sectoff, elfsym, r.Xadd)
writeElfReloc(elf.R_PPC64_TPREL16_LO, sectoff+4, elfsym, r.Xadd)
case objabi.R_POWER_TLS_LE_TPREL34:
out.Write64(uint64(elf.R_PPC64_TPREL34) | uint64(elfsym)<<32)
writeElfReloc(elf.R_PPC64_TPREL34, sectoff, elfsym, r.Xadd)
case objabi.R_POWER_TLS_IE_PCREL34:
out.Write64(uint64(elf.R_PPC64_GOT_TPREL_PCREL34) | uint64(elfsym)<<32)
writeElfReloc(elf.R_PPC64_GOT_TPREL_PCREL34, sectoff, elfsym, r.Xadd)
case objabi.R_POWER_TLS_IE:
out.Write64(uint64(elf.R_PPC64_GOT_TPREL16_HA) | uint64(elfsym)<<32)
out.Write64(uint64(r.Xadd))
out.Write64(uint64(sectoff + 4))
out.Write64(uint64(elf.R_PPC64_GOT_TPREL16_LO_DS) | uint64(elfsym)<<32)
sectoff += fixupBe
writeElfReloc(elf.R_PPC64_GOT_TPREL16_HA, sectoff, elfsym, r.Xadd)
writeElfReloc(elf.R_PPC64_GOT_TPREL16_LO_DS, sectoff+4, elfsym, r.Xadd)
case objabi.R_ADDRPOWER:
out.Write64(uint64(elf.R_PPC64_ADDR16_HA) | uint64(elfsym)<<32)
out.Write64(uint64(r.Xadd))
out.Write64(uint64(sectoff + 4))
out.Write64(uint64(elf.R_PPC64_ADDR16_LO) | uint64(elfsym)<<32)
sectoff += fixupBe
writeElfReloc(elf.R_PPC64_ADDR16_HA, sectoff, elfsym, r.Xadd)
writeElfReloc(elf.R_PPC64_ADDR16_LO, sectoff+4, elfsym, r.Xadd)
case objabi.R_ADDRPOWER_DS:
out.Write64(uint64(elf.R_PPC64_ADDR16_HA) | uint64(elfsym)<<32)
out.Write64(uint64(r.Xadd))
out.Write64(uint64(sectoff + 4))
out.Write64(uint64(elf.R_PPC64_ADDR16_LO_DS) | uint64(elfsym)<<32)
sectoff += fixupBe
writeElfReloc(elf.R_PPC64_ADDR16_HA, sectoff, elfsym, r.Xadd)
writeElfReloc(elf.R_PPC64_ADDR16_LO_DS, sectoff+4, elfsym, r.Xadd)
case objabi.R_ADDRPOWER_GOT:
out.Write64(uint64(elf.R_PPC64_GOT16_HA) | uint64(elfsym)<<32)
out.Write64(uint64(r.Xadd))
out.Write64(uint64(sectoff + 4))
out.Write64(uint64(elf.R_PPC64_GOT16_LO_DS) | uint64(elfsym)<<32)
sectoff += fixupBe
writeElfReloc(elf.R_PPC64_GOT16_HA, sectoff, elfsym, r.Xadd)
writeElfReloc(elf.R_PPC64_GOT16_LO_DS, sectoff+4, elfsym, r.Xadd)
case objabi.R_ADDRPOWER_GOT_PCREL34:
out.Write64(uint64(elf.R_PPC64_GOT_PCREL34) | uint64(elfsym)<<32)
writeElfReloc(elf.R_PPC64_GOT_PCREL34, sectoff, elfsym, r.Xadd)
case objabi.R_ADDRPOWER_PCREL:
out.Write64(uint64(elf.R_PPC64_REL16_HA) | uint64(elfsym)<<32)
out.Write64(uint64(r.Xadd))
out.Write64(uint64(sectoff + 4))
out.Write64(uint64(elf.R_PPC64_REL16_LO) | uint64(elfsym)<<32)
r.Xadd += 4
sectoff += fixupBe
addend := r.Xadd + fixupBe
writeElfReloc(elf.R_PPC64_REL16_HA, sectoff, elfsym, addend)
writeElfReloc(elf.R_PPC64_REL16_LO, sectoff+4, elfsym, addend+4)
case objabi.R_ADDRPOWER_TOCREL:
out.Write64(uint64(elf.R_PPC64_TOC16_HA) | uint64(elfsym)<<32)
out.Write64(uint64(r.Xadd))
out.Write64(uint64(sectoff + 4))
out.Write64(uint64(elf.R_PPC64_TOC16_LO) | uint64(elfsym)<<32)
sectoff += fixupBe
writeElfReloc(elf.R_PPC64_TOC16_HA, sectoff, elfsym, r.Xadd)
writeElfReloc(elf.R_PPC64_TOC16_LO, sectoff+4, elfsym, r.Xadd)
case objabi.R_ADDRPOWER_TOCREL_DS:
out.Write64(uint64(elf.R_PPC64_TOC16_HA) | uint64(elfsym)<<32)
out.Write64(uint64(r.Xadd))
out.Write64(uint64(sectoff + 4))
out.Write64(uint64(elf.R_PPC64_TOC16_LO_DS) | uint64(elfsym)<<32)
sectoff += fixupBe
writeElfReloc(elf.R_PPC64_TOC16_HA, sectoff, elfsym, r.Xadd)
writeElfReloc(elf.R_PPC64_TOC16_LO_DS, sectoff+4, elfsym, r.Xadd)
case objabi.R_CALLPOWER:
if r.Size != 4 {
return false
}
if !hasPCrel {
out.Write64(uint64(elf.R_PPC64_REL24) | uint64(elfsym)<<32)
writeElfReloc(elf.R_PPC64_REL24, sectoff, elfsym, r.Xadd)
} else {
// TOC is not used in PCrel compiled Go code.
out.Write64(uint64(elf.R_PPC64_REL24_NOTOC) | uint64(elfsym)<<32)
writeElfReloc(elf.R_PPC64_REL24_NOTOC, sectoff, elfsym, r.Xadd)
}
}
out.Write64(uint64(r.Xadd))
return true
}

View file

@ -44,7 +44,7 @@ func Init() (*sys.Arch, ld.Arch) {
if buildcfg.GOARCH == "ppc64" {
arch = sys.ArchPPC64
dynld = "/lib64/ld64.so.1"
dynld = "/lib64/ld64.so.2"
musl = "/lib/ld-musl-powerpc64.so.1"
}

View file

@ -919,10 +919,16 @@ func TestTrampoline(t *testing.T) {
// calls will use trampolines.
buildmodes := []string{"default"}
switch runtime.GOARCH {
case "arm", "arm64", "ppc64", "loong64":
case "ppc64le":
// Trampolines are generated differently when internal linking PIE, test them too.
buildmodes = append(buildmodes, "pie")
case "arm", "arm64", "loong64":
case "ppc64le", "ppc64":
switch runtime.GOOS {
case "aix":
case "linux":
// Trampolines are generated differently when internal linking PIE, test them too.
buildmodes = append(buildmodes, "pie")
default:
t.Skipf("trampoline insertion is not implemented on %s-%s", runtime.GOARCH, runtime.GOOS)
}
default:
t.Skipf("trampoline insertion is not implemented on %s", runtime.GOARCH)
}
@ -984,8 +990,8 @@ func TestTrampolineCgo(t *testing.T) {
// calls will use trampolines.
buildmodes := []string{"default"}
switch runtime.GOARCH {
case "arm", "arm64", "ppc64", "loong64":
case "ppc64le":
case "arm", "arm64", "loong64":
case "ppc64le", "ppc64":
// Trampolines are generated differently when internal linking PIE, test them too.
buildmodes = append(buildmodes, "pie")
default:

View file

@ -90,9 +90,9 @@ func MustLinkExternal(goos, goarch string, withCgo bool) bool {
// https://go.dev/issue/14449
return true
case "ppc64":
// Big Endian PPC64 cgo internal linking is not implemented for aix or linux.
// Big Endian PPC64 cgo internal linking is not implemented for aix.
// https://go.dev/issue/8912
if goos == "aix" || goos == "linux" {
if goos == "aix" {
return true
}
}
@ -144,9 +144,7 @@ func BuildModeSupported(compiler, buildmode, goos, goarch string) bool {
return true
case "linux":
switch goarch {
case "386", "amd64", "arm", "armbe", "arm64", "arm64be", "loong64", "ppc64le", "riscv64", "s390x":
// linux/ppc64 not supported because it does
// not support external linking mode yet.
case "386", "amd64", "arm", "armbe", "arm64", "arm64be", "loong64", "ppc64", "ppc64le", "riscv64", "s390x":
return true
default:
// Other targets do not support -shared,
@ -164,7 +162,7 @@ func BuildModeSupported(compiler, buildmode, goos, goarch string) bool {
case "c-shared":
switch platform {
case "linux/amd64", "linux/arm", "linux/arm64", "linux/loong64", "linux/386", "linux/ppc64le", "linux/riscv64", "linux/s390x",
case "linux/amd64", "linux/arm", "linux/arm64", "linux/loong64", "linux/386", "linux/ppc64", "linux/ppc64le", "linux/riscv64", "linux/s390x",
"android/amd64", "android/arm", "android/arm64", "android/386",
"freebsd/amd64",
"darwin/amd64", "darwin/arm64",
@ -182,7 +180,7 @@ func BuildModeSupported(compiler, buildmode, goos, goarch string) bool {
case "pie":
switch platform {
case "linux/386", "linux/amd64", "linux/arm", "linux/arm64", "linux/loong64", "linux/ppc64le", "linux/riscv64", "linux/s390x",
case "linux/386", "linux/amd64", "linux/arm", "linux/arm64", "linux/loong64", "linux/ppc64", "linux/ppc64le", "linux/riscv64", "linux/s390x",
"android/amd64", "android/arm", "android/arm64", "android/386",
"freebsd/amd64",
"darwin/amd64", "darwin/arm64",
@ -196,14 +194,14 @@ func BuildModeSupported(compiler, buildmode, goos, goarch string) bool {
case "shared":
switch platform {
case "linux/386", "linux/amd64", "linux/arm", "linux/arm64", "linux/ppc64le", "linux/s390x":
case "linux/386", "linux/amd64", "linux/arm", "linux/arm64", "linux/ppc64", "linux/ppc64le", "linux/s390x":
return true
}
return false
case "plugin":
switch platform {
case "linux/amd64", "linux/arm", "linux/arm64", "linux/386", "linux/loong64", "linux/riscv64", "linux/s390x", "linux/ppc64le",
case "linux/amd64", "linux/arm", "linux/arm64", "linux/386", "linux/loong64", "linux/riscv64", "linux/s390x", "linux/ppc64", "linux/ppc64le",
"android/amd64", "android/386",
"darwin/amd64", "darwin/arm64",
"freebsd/amd64":
@ -220,7 +218,7 @@ func InternalLinkPIESupported(goos, goarch string) bool {
switch goos + "/" + goarch {
case "android/arm64",
"darwin/amd64", "darwin/arm64",
"linux/amd64", "linux/arm64", "linux/loong64", "linux/ppc64le", "linux/s390x",
"linux/amd64", "linux/arm64", "linux/loong64", "linux/ppc64", "linux/ppc64le", "linux/s390x",
"windows/386", "windows/amd64", "windows/arm64":
return true
}

View file

@ -86,7 +86,7 @@ var distInfo = map[OSArch]osArchInfo{
{"linux", "mips64"}: {CgoSupported: true},
{"linux", "mips64le"}: {CgoSupported: true},
{"linux", "mipsle"}: {CgoSupported: true},
{"linux", "ppc64"}: {},
{"linux", "ppc64"}: {CgoSupported: true},
{"linux", "ppc64le"}: {CgoSupported: true},
{"linux", "riscv64"}: {CgoSupported: true},
{"linux", "s390x"}: {CgoSupported: true},

View file

@ -153,7 +153,7 @@ nocgo:
BL runtime·mstart(SB)
// Prevent dead-code elimination of debugCallV2 and debugPinnerV1, which are
// intended to be called by debuggers.
#ifdef GOARCH_ppc64le
#ifdef GOOS_linux
MOVD $runtime·debugPinnerV1<ABIInternal>(SB), R31
MOVD $runtime·debugCallV2<ABIInternal>(SB), R31
#endif
@ -1214,7 +1214,7 @@ GLOBL debugCallFrameTooLarge<>(SB), RODATA, $20 // Size duplicated below
//
// This is ABIInternal because Go code injects its PC directly into new
// goroutine stacks.
#ifdef GOARCH_ppc64le
#ifdef GOOS_linux
TEXT runtime·debugCallV2<ABIInternal>(SB), NOSPLIT|NOFRAME, $0-0
// save scratch register R31 first
MOVD R31, -184(R1)
@ -1374,7 +1374,7 @@ DEBUG_CALL_FN(debugCall16384<>, 16384)
DEBUG_CALL_FN(debugCall32768<>, 32768)
DEBUG_CALL_FN(debugCall65536<>, 65536)
#ifdef GOARCH_ppc64le
#ifdef GOOS_linux
// func debugCallPanicked(val interface{})
TEXT runtime·debugCallPanicked(SB),NOSPLIT,$32-16
// Copy the panic value to the top of stack at SP+32.

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build linux && (386 || amd64 || arm64 || loong64 || ppc64le)
//go:build linux && (386 || amd64 || arm64 || loong64 || ppc64 || ppc64le)
#include <errno.h>
#include <stddef.h>

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build (linux && (386 || amd64 || arm64 || loong64 || ppc64le)) || (freebsd && amd64)
//go:build (linux && (386 || amd64 || arm64 || loong64 || ppc64 || ppc64le)) || (freebsd && amd64)
package cgo

View file

@ -6,7 +6,7 @@
// Also used on linux/386 to clear the SA_RESTORER flag
// when using cgo; see issue #75253.
//go:build (linux && (386 || amd64 || arm64 || loong64 || ppc64le)) || (freebsd && amd64)
//go:build (linux && (386 || amd64 || arm64 || loong64 || ppc64 || ppc64le)) || (freebsd && amd64)
package runtime

View file

@ -315,6 +315,7 @@ func TestCgoCrashTraceback(t *testing.T) {
case "linux/amd64":
case "linux/arm64":
case "linux/loong64":
case "linux/ppc64":
case "linux/ppc64le":
default:
t.Skipf("not yet supported on %s", platform)
@ -340,6 +341,7 @@ func TestCgoCrashTracebackGo(t *testing.T) {
case "linux/amd64":
case "linux/arm64":
case "linux/loong64":
case "linux/ppc64":
case "linux/ppc64le":
default:
t.Skipf("not yet supported on %s", platform)
@ -394,7 +396,7 @@ func TestCgoTracebackContextProfile(t *testing.T) {
func testCgoPprof(t *testing.T, buildArg, runArg, top, bottom string) {
t.Parallel()
if runtime.GOOS != "linux" || (runtime.GOARCH != "amd64" && runtime.GOARCH != "ppc64le" && runtime.GOARCH != "arm64" && runtime.GOARCH != "loong64") {
if runtime.GOOS != "linux" || (runtime.GOARCH != "amd64" && runtime.GOARCH != "ppc64" && runtime.GOARCH != "ppc64le" && runtime.GOARCH != "arm64" && runtime.GOARCH != "loong64") {
t.Skipf("not yet supported on %s/%s", runtime.GOOS, runtime.GOARCH)
}
if runtime.GOOS == "freebsd" && race.Enabled {

View file

@ -9,7 +9,7 @@
// spends all of its time in the race runtime, which isn't a safe
// point.
//go:build (amd64 || arm64 || loong64 || ppc64le) && linux && !race
//go:build (amd64 || arm64 || loong64 || ppc64 || ppc64le) && linux && !race
package runtime_test

View file

@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Though the debug call function feature is not enabled on
// ppc64, inserted ppc64 to avoid missing Go declaration error
// for debugCallPanicked while building runtime.test
//go:build amd64 || arm64 || loong64 || ppc64le || ppc64
package runtime

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build ppc64le && linux
//go:build (ppc64le || ppc64) && linux
package runtime

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build (amd64 || arm64 || loong64 || ppc64le) && linux
//go:build (amd64 || arm64 || loong64 || ppc64 || ppc64le) && linux
package runtime

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build (linux && !386 && !amd64 && !arm64 && !loong64 && !ppc64le) || (freebsd && !amd64)
//go:build (linux && !386 && !amd64 && !arm64 && !loong64 && !ppc64 && !ppc64le) || (freebsd && !amd64)
package runtime

View file

@ -1,12 +0,0 @@
// Copyright 2021 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 linux
package runtime
// This is needed for vet.
//
//go:noescape
func callCgoSigaction(sig uintptr, new, old *sigactiont) int32

View file

@ -417,7 +417,6 @@ TEXT runtime·rt_sigaction(SB),NOSPLIT|NOFRAME,$0-36
MOVW R3, ret+32(FP)
RET
#ifdef GOARCH_ppc64le
// Call the function stored in _cgo_sigaction using the GCC calling convention.
TEXT runtime·callCgoSigaction(SB),NOSPLIT,$0
MOVD sig+0(FP), R3
@ -435,7 +434,6 @@ TEXT runtime·callCgoSigaction(SB),NOSPLIT,$0
MOVD 24(R1), R2 // Restore R2
MOVW R3, ret+24(FP) // Return result
RET
#endif
TEXT runtime·sigfwd(SB),NOSPLIT,$0-32
MOVW sig+8(FP), R3
@ -447,12 +445,6 @@ TEXT runtime·sigfwd(SB),NOSPLIT,$0-32
MOVD 24(R1), R2
RET
#ifdef GOARCH_ppc64
// cgo isn't supported on ppc64, but we need to supply a cgoSigTramp function.
TEXT runtime·cgoSigtramp(SB),NOSPLIT|NOFRAME,$0
BR runtime·sigtramp(SB)
#endif
// Save callee-save registers in the case of signal forwarding.
// Same as on ARM64 https://golang.org/issue/31827 .
//
@ -486,7 +478,6 @@ TEXT runtime·sigtramp(SB),NOSPLIT|NOFRAME,$0
UNSTACK_AND_RESTORE_GO_TO_HOST_ABI(32)
RET
#ifdef GOARCH_ppc64le
TEXT runtime·cgoSigtramp(SB),NOSPLIT|NOFRAME,$0
// The stack unwinder, presumably written in C, may not be able to
// handle Go frame correctly. So, this function is NOFRAME, and we
@ -581,7 +572,6 @@ sigtrampnog:
MOVD R12, CTR
MOVD R10, LR // restore LR
JMP (CTR)
#endif
// Used by cgoSigtramp to inspect without clobbering R30/R31 via runtime.load_g.
GLOBL runtime·tls_g+0(SB), TLSBSS+DUPOK, $8