From 3f8f929d60a90c4e4e2b07c8d1972166c1a783b1 Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Wed, 1 Mar 2023 16:11:07 +0000 Subject: cmd/link/internal/ld: move more of mustLinkExternal into internal/platform internal/platform.MustLinkExternal is used in various places to determine whether external linking is required. It should always match what the linker actually requires, but today does not match because the linker imposes additional constraints. Updates #31544. Change-Id: I0cc6ad587e95c607329dea5d60d29a5fb2a9e722 Reviewed-on: https://go-review.googlesource.com/c/go/+/472515 Run-TryBot: Bryan Mills TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor --- src/internal/testenv/testenv.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/internal/testenv') diff --git a/src/internal/testenv/testenv.go b/src/internal/testenv/testenv.go index 65a82fd5f7..816a1a100f 100644 --- a/src/internal/testenv/testenv.go +++ b/src/internal/testenv/testenv.go @@ -288,15 +288,18 @@ func MustHaveCGO(t testing.TB) { // CanInternalLink reports whether the current system can link programs with // internal linking. -func CanInternalLink() bool { - return !platform.MustLinkExternal(runtime.GOOS, runtime.GOARCH) +func CanInternalLink(withCgo bool) bool { + return !platform.MustLinkExternal(runtime.GOOS, runtime.GOARCH, withCgo) } // MustInternalLink checks that the current system can link programs with internal // linking. // If not, MustInternalLink calls t.Skip with an explanation. -func MustInternalLink(t testing.TB) { - if !CanInternalLink() { +func MustInternalLink(t testing.TB, withCgo bool) { + if !CanInternalLink(withCgo) { + if withCgo && CanInternalLink(false) { + t.Skipf("skipping test: internal linking on %s/%s is not supported with cgo", runtime.GOOS, runtime.GOARCH) + } t.Skipf("skipping test: internal linking on %s/%s is not supported", runtime.GOOS, runtime.GOARCH) } } -- cgit v1.3