cmd/compile,cmd/link: skip tests that require DWARF symbols on ios

The linker does not combine DWARF information into the binary on ios.
This generalizes test skips that were already present for a similar
reason on plan9.

Fixes #59939.

Change-Id: Ideda07c9f9a69fd102a7d9a83ea8e7b7c29d0da2
Reviewed-on: https://go-review.googlesource.com/c/go/+/491835
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Bypass: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
This commit is contained in:
Bryan C. Mills 2023-05-02 22:06:11 -04:00 committed by Bryan Mills
parent 27aa60f540
commit 57cb47209c
5 changed files with 52 additions and 81 deletions

View File

@ -7,6 +7,7 @@ package dwarfgen
import (
"debug/dwarf"
"fmt"
"internal/platform"
"internal/testenv"
"os"
"path/filepath"
@ -215,8 +216,8 @@ func TestScopeRanges(t *testing.T) {
testenv.MustHaveGoBuild(t)
t.Parallel()
if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables")
if !platform.ExecutableHasDWARF(runtime.GOOS, runtime.GOARCH) {
t.Skipf("skipping on %s/%s: no DWARF symbol table in executables", runtime.GOOS, runtime.GOARCH)
}
src, f := gobuild(t, t.TempDir(), false, testfile)
@ -486,8 +487,8 @@ func TestEmptyDwarfRanges(t *testing.T) {
testenv.MustHaveGoRun(t)
t.Parallel()
if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables")
if !platform.ExecutableHasDWARF(runtime.GOOS, runtime.GOARCH) {
t.Skipf("skipping on %s/%s: no DWARF symbol table in executables", runtime.GOOS, runtime.GOARCH)
}
_, f := gobuild(t, t.TempDir(), true, []testline{{line: "package main"}, {line: "func main(){ println(\"hello\") }"}})

View File

@ -12,6 +12,7 @@ import (
"debug/macho"
"debug/pe"
"fmt"
"internal/platform"
"internal/testenv"
"internal/xcoff"
"io"
@ -53,8 +54,8 @@ type Line struct {
}
func TestStmtLines(t *testing.T) {
if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables")
if !platform.ExecutableHasDWARF(runtime.GOOS, runtime.GOARCH) {
t.Skipf("skipping on %s/%s: no DWARF symbol table in executables", runtime.GOOS, runtime.GOARCH)
}
if runtime.GOOS == "aix" {

View File

@ -55,8 +55,8 @@ func testDWARF(t *testing.T, buildmode string, expectDWARF bool, env ...string)
testenv.MustHaveCGO(t)
testenv.MustHaveGoBuild(t)
if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables")
if !platform.ExecutableHasDWARF(runtime.GOOS, runtime.GOARCH) {
t.Skipf("skipping on %s/%s: no DWARF symbol table in executables", runtime.GOOS, runtime.GOARCH)
}
t.Parallel()

View File

@ -25,6 +25,13 @@ import (
"cmd/link/internal/dwtest"
)
func mustHaveDWARF(t testing.TB) {
if !platform.ExecutableHasDWARF(runtime.GOOS, runtime.GOARCH) {
t.Helper()
t.Skipf("skipping on %s/%s: no DWARF symbol table in executables", runtime.GOOS, runtime.GOARCH)
}
}
const (
DefaultOpt = "-gcflags="
NoOpt = "-gcflags=-l -N"
@ -36,9 +43,7 @@ func TestRuntimeTypesPresent(t *testing.T) {
t.Parallel()
testenv.MustHaveGoBuild(t)
if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables")
}
mustHaveDWARF(t)
dir := t.TempDir()
@ -179,9 +184,7 @@ func TestEmbeddedStructMarker(t *testing.T) {
t.Parallel()
testenv.MustHaveGoBuild(t)
if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables")
}
mustHaveDWARF(t)
const prog = `
package main
@ -273,9 +276,7 @@ func findMembers(rdr *dwarf.Reader) (map[string]bool, error) {
}
func TestSizes(t *testing.T) {
if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables")
}
mustHaveDWARF(t)
// External linking may bring in C symbols with unknown size. Skip.
testenv.MustInternalLink(t, false)
@ -322,9 +323,7 @@ func main() {
}
func TestFieldOverlap(t *testing.T) {
if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables")
}
mustHaveDWARF(t)
t.Parallel()
// This test grew out of issue 21094, where specific sudog<T> DWARF types
@ -381,9 +380,7 @@ func TestSubprogramDeclFileLine(t *testing.T) {
testenv.MustHaveGoBuild(t)
t.Parallel()
if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables")
}
mustHaveDWARF(t)
const prog = `package main
%s
@ -447,9 +444,7 @@ func TestVarDeclLine(t *testing.T) {
testenv.MustHaveGoBuild(t)
t.Parallel()
if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables")
}
mustHaveDWARF(t)
const prog = `package main
%s
@ -514,9 +509,7 @@ func main() {
func TestInlinedRoutineCallFileLine(t *testing.T) {
testenv.MustHaveGoBuild(t)
if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables")
}
mustHaveDWARF(t)
t.Parallel()
@ -648,9 +641,7 @@ func main() {
func TestInlinedRoutineArgsVars(t *testing.T) {
testenv.MustHaveGoBuild(t)
if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables")
}
mustHaveDWARF(t)
t.Parallel()
@ -840,9 +831,7 @@ func TestAbstractOriginSanity(t *testing.T) {
t.Skip("skipping test in short mode.")
}
if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables")
}
mustHaveDWARF(t)
if wd, err := os.Getwd(); err == nil {
gopathdir := filepath.Join(wd, "testdata", "httptest")
@ -855,9 +844,7 @@ func TestAbstractOriginSanity(t *testing.T) {
func TestAbstractOriginSanityIssue25459(t *testing.T) {
testenv.MustHaveGoBuild(t)
if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables")
}
mustHaveDWARF(t)
if runtime.GOARCH != "amd64" && runtime.GOARCH != "386" {
t.Skip("skipping on not-amd64 not-386; location lists not supported")
}
@ -873,9 +860,7 @@ func TestAbstractOriginSanityIssue25459(t *testing.T) {
func TestAbstractOriginSanityIssue26237(t *testing.T) {
testenv.MustHaveGoBuild(t)
if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables")
}
mustHaveDWARF(t)
if wd, err := os.Getwd(); err == nil {
gopathdir := filepath.Join(wd, "testdata", "issue26237")
abstractOriginSanity(t, gopathdir, DefaultOpt)
@ -888,9 +873,7 @@ func TestRuntimeTypeAttrInternal(t *testing.T) {
testenv.MustHaveGoBuild(t)
testenv.MustInternalLink(t, false)
if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables")
}
mustHaveDWARF(t)
testRuntimeTypeAttr(t, "-ldflags=-linkmode=internal")
}
@ -900,9 +883,7 @@ func TestRuntimeTypeAttrExternal(t *testing.T) {
testenv.MustHaveGoBuild(t)
testenv.MustHaveCGO(t)
if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables")
}
mustHaveDWARF(t)
// Explicitly test external linking, for dsymutil compatibility on Darwin.
if runtime.GOARCH == "ppc64" {
@ -990,9 +971,7 @@ func TestIssue27614(t *testing.T) {
testenv.MustHaveGoBuild(t)
if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables")
}
mustHaveDWARF(t)
t.Parallel()
@ -1104,9 +1083,7 @@ func TestStaticTmp(t *testing.T) {
testenv.MustHaveGoBuild(t)
if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables")
}
mustHaveDWARF(t)
t.Parallel()
@ -1182,9 +1159,7 @@ func TestPackageNameAttr(t *testing.T) {
testenv.MustHaveGoBuild(t)
if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables")
}
mustHaveDWARF(t)
t.Parallel()
@ -1324,9 +1299,7 @@ func main() {
func TestIssue38192(t *testing.T) {
testenv.MustHaveGoBuild(t)
if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables")
}
mustHaveDWARF(t)
t.Parallel()
@ -1434,9 +1407,7 @@ func TestIssue38192(t *testing.T) {
func TestIssue39757(t *testing.T) {
testenv.MustHaveGoBuild(t)
if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables")
}
mustHaveDWARF(t)
t.Parallel()
@ -1546,9 +1517,7 @@ func TestIssue42484(t *testing.T) {
testenv.MustHaveGoBuild(t)
testenv.MustInternalLink(t, false) // Avoid spurious failures from external linkers.
if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables")
}
mustHaveDWARF(t)
t.Parallel()
@ -1676,9 +1645,7 @@ func processParams(die *dwarf.Entry, ex *dwtest.Examiner) string {
func TestOutputParamAbbrevAndAttr(t *testing.T) {
testenv.MustHaveGoBuild(t)
if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables")
}
mustHaveDWARF(t)
t.Parallel()
// This test verifies that the compiler is selecting the correct
@ -1725,9 +1692,7 @@ func TestDictIndex(t *testing.T) {
// have DIEs.
testenv.MustHaveGoBuild(t)
if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables")
}
mustHaveDWARF(t)
t.Parallel()
const prog = `
@ -1821,9 +1786,7 @@ func main() {
func TestOptimizedOutParamHandling(t *testing.T) {
testenv.MustHaveGoBuild(t)
if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables")
}
mustHaveDWARF(t)
t.Parallel()
// This test is intended to verify that the compiler emits DWARF
@ -1950,9 +1913,7 @@ func TestIssue54320(t *testing.T) {
// emitted in the final binary
testenv.MustHaveGoBuild(t)
if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables")
}
mustHaveDWARF(t)
t.Parallel()
@ -2028,9 +1989,7 @@ func main() {
func TestZeroSizedVariable(t *testing.T) {
testenv.MustHaveGoBuild(t)
if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables")
}
mustHaveDWARF(t)
t.Parallel()
// This test verifies that the compiler emits DIEs for zero sized variables

View File

@ -241,7 +241,17 @@ func DefaultPIE(goos, goarch string, isRace bool) bool {
return false
}
// CgoSupported reports whether goos/goarch supports cgo.\n")
// CgoSupported reports whether goos/goarch supports cgo.
func CgoSupported(goos, goarch string) bool {
return osArchSupportsCgo[goos+"/"+goarch]
}
// ExecutableHasDWARF reports whether the linked executable includes DWARF
// symbols on goos/goarch.
func ExecutableHasDWARF(goos, goarch string) bool {
switch goos {
case "plan9", "ios":
return false
}
return true
}