]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: added test of availability of gcc
authorConstantin Konstantinidis <constantinkonstantinidis@gmail.com>
Thu, 26 Jul 2018 14:01:34 +0000 (16:01 +0200)
committerHeschi Kreinick <heschi@google.com>
Fri, 27 Jul 2018 18:35:13 +0000 (18:35 +0000)
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 <heschi@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
src/cmd/link/internal/ld/dwarf_test.go

index 12eb1b73f4b920c0633bbfb737691ac40b1599f7..157bebbb412567544675d7cd59abddab5c61a7d6 100644 (file)
@@ -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) {