Commit 9dab3847 authored by Constantin Konstantinidis's avatar Constantin Konstantinidis Committed by Heschi Kreinick

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 <heschi@google.com>
Reviewed-by: 's avatarHeschi Kreinick <heschi@google.com>
parent 05f9b369
...@@ -854,23 +854,30 @@ func TestAbstractOriginSanityIssue26237(t *testing.T) { ...@@ -854,23 +854,30 @@ func TestAbstractOriginSanityIssue26237(t *testing.T) {
} }
} }
func TestRuntimeTypeAttr(t *testing.T) { func TestRuntimeTypeAttrInternal(t *testing.T) {
testenv.MustHaveGoBuild(t) testenv.MustHaveGoBuild(t)
if runtime.GOOS == "plan9" { if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables") t.Skip("skipping on plan9; no DWARF symbol table in executables")
} }
// Explicitly test external linking, for dsymutil compatility on Darwin. testRuntimeTypeAttr(t, "-ldflags=-linkmode=internal")
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") { // External linking requires a host linker (https://golang.org/src/cmd/cgo/doc.go l.732)
t.Skip("-linkmode=external not supported on ppc64") 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) { func testRuntimeTypeAttr(t *testing.T, flags string) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment