From b85c2dd56c4ecc7bf445bd1615467ecd38598eee Mon Sep 17 00:00:00 2001 From: Cherry Zhang Date: Sat, 24 Oct 2020 20:58:38 -0400 Subject: [PATCH] cmd/link: enable internal linking by default on darwin/arm64 With previous CLs, internal linking without cgo should work well. Enable it by default. And stop always requiring cgo. Enable tests that were previously disabled due to the lack of internal linking. Updates #38485. Change-Id: I45125b9c263fd21d6847aa6b14ecaea3a2989b29 Reviewed-on: https://go-review.googlesource.com/c/go/+/265121 Trust: Cherry Zhang Reviewed-by: Austin Clements Reviewed-by: Than McIntosh --- src/cmd/go/internal/load/pkg.go | 4 ---- src/cmd/internal/sys/supported.go | 2 +- src/cmd/link/internal/ld/config.go | 4 +--- src/cmd/nm/nm_cgo_test.go | 5 ----- src/internal/testenv/testenv.go | 2 +- test/fixedbugs/bug429_run.go | 4 ---- test/fixedbugs/issue21576.go | 4 ---- 7 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go index 4c541b9017725..ff744ee9fa2a5 100644 --- a/src/cmd/go/internal/load/pkg.go +++ b/src/cmd/go/internal/load/pkg.go @@ -1964,10 +1964,6 @@ func externalLinkingForced(p *Package) bool { } case "ios": return true - case "darwin": - if cfg.BuildContext.GOARCH == "arm64" { - return true - } } // Currently build modes c-shared, pie (on systems that do not diff --git a/src/cmd/internal/sys/supported.go b/src/cmd/internal/sys/supported.go index 1d813bbb476a2..afc81381fdf08 100644 --- a/src/cmd/internal/sys/supported.go +++ b/src/cmd/internal/sys/supported.go @@ -39,7 +39,7 @@ func MustLinkExternal(goos, goarch string) bool { if goarch != "arm64" { return true } - case "darwin", "ios": + case "ios": if goarch == "arm64" { return true } diff --git a/src/cmd/link/internal/ld/config.go b/src/cmd/link/internal/ld/config.go index 54a94cebbafd2..0cb3cc25c0640 100644 --- a/src/cmd/link/internal/ld/config.go +++ b/src/cmd/link/internal/ld/config.go @@ -185,7 +185,7 @@ func mustLinkExternal(ctxt *Link) (res bool, reason string) { }() } - if sys.MustLinkExternal(objabi.GOOS, objabi.GOARCH) && !(objabi.GOOS == "darwin" && objabi.GOARCH == "arm64") { // XXX allow internal linking for darwin/arm64 but not change the default + if sys.MustLinkExternal(objabi.GOOS, objabi.GOARCH) { return true, fmt.Sprintf("%s/%s requires external linking", objabi.GOOS, objabi.GOARCH) } @@ -261,8 +261,6 @@ func determineLinkMode(ctxt *Link) { default: if extNeeded || (iscgo && externalobj) { ctxt.LinkMode = LinkExternal - } else if ctxt.IsDarwin() && ctxt.IsARM64() { - ctxt.LinkMode = LinkExternal // default to external linking for now } else { ctxt.LinkMode = LinkInternal } diff --git a/src/cmd/nm/nm_cgo_test.go b/src/cmd/nm/nm_cgo_test.go index 58f2c24908d0e..9a257e0ed2ece 100644 --- a/src/cmd/nm/nm_cgo_test.go +++ b/src/cmd/nm/nm_cgo_test.go @@ -15,11 +15,6 @@ func canInternalLink() bool { switch runtime.GOOS { case "aix": return false - case "darwin": - switch runtime.GOARCH { - case "arm64": - return false - } case "dragonfly": return false case "freebsd": diff --git a/src/internal/testenv/testenv.go b/src/internal/testenv/testenv.go index 0ee6355ee38c4..dff68869bd26b 100644 --- a/src/internal/testenv/testenv.go +++ b/src/internal/testenv/testenv.go @@ -201,7 +201,7 @@ func CanInternalLink() bool { if runtime.GOARCH != "arm64" { return false } - case "darwin", "ios": + case "ios": if runtime.GOARCH == "arm64" { return false } diff --git a/test/fixedbugs/bug429_run.go b/test/fixedbugs/bug429_run.go index 60cc5b62de8b6..c2bb1b85cbe57 100644 --- a/test/fixedbugs/bug429_run.go +++ b/test/fixedbugs/bug429_run.go @@ -1,10 +1,6 @@ // run // +build !nacl,!js -// +build !darwin !arm64 - -// Skip on darwin/arm64 as it requires external linking, which brings in -// cgo, causing deadlock detection not working. // Copyright 2014 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style diff --git a/test/fixedbugs/issue21576.go b/test/fixedbugs/issue21576.go index 3797a8c9ba531..ae6161ccf52d3 100644 --- a/test/fixedbugs/issue21576.go +++ b/test/fixedbugs/issue21576.go @@ -1,10 +1,6 @@ // run // +build !nacl,!js -// +build !darwin !arm64 - -// Skip on darwin/arm64 as it requires external linking, which brings in -// cgo, causing deadlock detection not working. // Copyright 2019 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style