Skip to content

Commit

Permalink
cmd/link: enable internal linking by default on darwin/arm64
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Austin Clements <[email protected]>
Reviewed-by: Than McIntosh <[email protected]>
  • Loading branch information
cherrymui committed Oct 28, 2020
1 parent 7c8d82e commit b85c2dd
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 22 deletions.
4 changes: 0 additions & 4 deletions src/cmd/go/internal/load/pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/internal/sys/supported.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 1 addition & 3 deletions src/cmd/link/internal/ld/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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
}
Expand Down
5 changes: 0 additions & 5 deletions src/cmd/nm/nm_cgo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
2 changes: 1 addition & 1 deletion src/internal/testenv/testenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func CanInternalLink() bool {
if runtime.GOARCH != "arm64" {
return false
}
case "darwin", "ios":
case "ios":
if runtime.GOARCH == "arm64" {
return false
}
Expand Down
4 changes: 0 additions & 4 deletions test/fixedbugs/bug429_run.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 0 additions & 4 deletions test/fixedbugs/issue21576.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit b85c2dd

Please sign in to comment.