From: Constantin Konstantinidis Date: Thu, 26 Jul 2018 14:01:34 +0000 (+0200) Subject: cmd/link: added test of availability of gcc X-Git-Tag: go1.11beta3~77 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=9dab3847785fe16bd050dc53c96f9d2312e51c68;p=gostls13.git cmd/link: added test of availability of gcc The test RuntimeTypeAttr always failed when gcc was unavailable. The test is duplicated for internal and external linking. The usual verification of host linker is added at the beginning of the external link test. Fixes #26621 Change-Id: I076d661f854c8a6de8fa5e7b069942a471445047 Reviewed-on: https://go-review.googlesource.com/126075 Run-TryBot: Heschi Kreinick Reviewed-by: Heschi Kreinick --- diff --git a/src/cmd/link/internal/ld/dwarf_test.go b/src/cmd/link/internal/ld/dwarf_test.go index 12eb1b73f4..157bebbb41 100644 --- a/src/cmd/link/internal/ld/dwarf_test.go +++ b/src/cmd/link/internal/ld/dwarf_test.go @@ -854,23 +854,30 @@ func TestAbstractOriginSanityIssue26237(t *testing.T) { } } -func TestRuntimeTypeAttr(t *testing.T) { +func TestRuntimeTypeAttrInternal(t *testing.T) { testenv.MustHaveGoBuild(t) if runtime.GOOS == "plan9" { t.Skip("skipping on plan9; no DWARF symbol table in executables") } - // Explicitly test external linking, for dsymutil compatility on Darwin. - for _, flags := range []string{"-ldflags=-linkmode=internal", "-ldflags=-linkmode=external"} { - t.Run("flags="+flags, func(t *testing.T) { - if runtime.GOARCH == "ppc64" && strings.Contains(flags, "external") { - t.Skip("-linkmode=external not supported on ppc64") - } + testRuntimeTypeAttr(t, "-ldflags=-linkmode=internal") +} + +// External linking requires a host linker (https://golang.org/src/cmd/cgo/doc.go l.732) +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") + } - testRuntimeTypeAttr(t, flags) - }) + // Explicitly test external linking, for dsymutil compatibility on Darwin. + if runtime.GOARCH == "ppc64" { + t.Skip("-linkmode=external not supported on ppc64") } + testRuntimeTypeAttr(t, "-ldflags=-linkmode=external") } func testRuntimeTypeAttr(t *testing.T, flags string) {