mirror of
https://github.com/golang/go
synced 2024-11-24 09:30:07 -07:00
cmd/link: fix StackCheckOutput on AIX
This test forces GOARCH to amd64, but currently uses the default GOOS. This works on every OS that supports amd64, which is every OS we support except AIX. Hence, on AIX this fails with an unsupported GOOS/GOARCH combination. Fix this by forcing GOOS to linux. Fixes #52451. Change-Id: I9321dd6386c7ef0fe2b47d77ed900aafc53f2a46 Reviewed-on: https://go-review.googlesource.com/c/go/+/401334 Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Austin Clements <austin@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
a2f7d9d95a
commit
5834024057
@ -101,7 +101,7 @@ func (ctxt *Link) doStackCheck() {
|
|||||||
// the same function multiple times at different
|
// the same function multiple times at different
|
||||||
// depths, but lets us find all paths.
|
// depths, but lets us find all paths.
|
||||||
for _, root := range roots {
|
for _, root := range roots {
|
||||||
ctxt.Errorf(root, "nosplit stack overflow")
|
ctxt.Errorf(root, "nosplit stack over %d byte limit", limit)
|
||||||
chain := []stackCheckChain{{stackCheckEdge{0, root}, false}}
|
chain := []stackCheckChain{{stackCheckEdge{0, root}, false}}
|
||||||
sc.report(root, limit, &chain)
|
sc.report(root, limit, &chain)
|
||||||
}
|
}
|
||||||
|
@ -5,13 +5,12 @@
|
|||||||
package ld
|
package ld
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"cmd/internal/objabi"
|
|
||||||
"cmd/internal/sys"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -24,7 +23,7 @@ func TestStackCheckOutput(t *testing.T) {
|
|||||||
cmd := exec.Command(testenv.GoToolPath(t), "build", "-o", os.DevNull, "./testdata/stackcheck")
|
cmd := exec.Command(testenv.GoToolPath(t), "build", "-o", os.DevNull, "./testdata/stackcheck")
|
||||||
// The rules for computing frame sizes on all of the
|
// The rules for computing frame sizes on all of the
|
||||||
// architectures are complicated, so just do this on amd64.
|
// architectures are complicated, so just do this on amd64.
|
||||||
cmd.Env = append(os.Environ(), "GOARCH=amd64")
|
cmd.Env = append(os.Environ(), "GOARCH=amd64", "GOOS=linux")
|
||||||
outB, err := cmd.CombinedOutput()
|
outB, err := cmd.CombinedOutput()
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@ -34,13 +33,13 @@ func TestStackCheckOutput(t *testing.T) {
|
|||||||
|
|
||||||
t.Logf("linker output:\n%s", out)
|
t.Logf("linker output:\n%s", out)
|
||||||
|
|
||||||
// Construct expected stanzas
|
// Get expected limit.
|
||||||
arch := sys.ArchAMD64
|
limitRe := regexp.MustCompile("nosplit stack over ([0-9]+) byte limit")
|
||||||
call := 0
|
m := limitRe.FindStringSubmatch(out)
|
||||||
if !arch.HasLR {
|
if m == nil {
|
||||||
call = arch.RegSize
|
t.Fatalf("no overflow errors in output")
|
||||||
}
|
}
|
||||||
limit := objabi.StackLimit - call
|
limit, _ := strconv.Atoi(m[1])
|
||||||
|
|
||||||
wantMap := map[string]string{
|
wantMap := map[string]string{
|
||||||
"main.startSelf": fmt.Sprintf(
|
"main.startSelf": fmt.Sprintf(
|
||||||
@ -67,7 +66,7 @@ func TestStackCheckOutput(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parse stanzas
|
// Parse stanzas
|
||||||
stanza := regexp.MustCompile(`^(.*): nosplit stack overflow\n(.*\n(?: .*\n)*)`)
|
stanza := regexp.MustCompile(`^(.*): nosplit stack over [0-9]+ byte limit\n(.*\n(?: .*\n)*)`)
|
||||||
// Strip comments from cmd/go
|
// Strip comments from cmd/go
|
||||||
out = regexp.MustCompile(`(?m)^#.*\n`).ReplaceAllString(out, "")
|
out = regexp.MustCompile(`(?m)^#.*\n`).ReplaceAllString(out, "")
|
||||||
for len(out) > 0 {
|
for len(out) > 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user