Skip to content

Commit b85c2dd

Browse files
committed
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 golang#38485. Change-Id: I45125b9c263fd21d6847aa6b14ecaea3a2989b29 Reviewed-on: https://go-review.googlesource.com/c/go/+/265121 Trust: Cherry Zhang <cherryyz@google.com> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
1 parent 7c8d82e commit b85c2dd

File tree

7 files changed

+3
-22
lines changed

7 files changed

+3
-22
lines changed

src/cmd/go/internal/load/pkg.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,10 +1964,6 @@ func externalLinkingForced(p *Package) bool {
19641964
}
19651965
case "ios":
19661966
return true
1967-
case "darwin":
1968-
if cfg.BuildContext.GOARCH == "arm64" {
1969-
return true
1970-
}
19711967
}
19721968

19731969
// Currently build modes c-shared, pie (on systems that do not

src/cmd/internal/sys/supported.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func MustLinkExternal(goos, goarch string) bool {
3939
if goarch != "arm64" {
4040
return true
4141
}
42-
case "darwin", "ios":
42+
case "ios":
4343
if goarch == "arm64" {
4444
return true
4545
}

src/cmd/link/internal/ld/config.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ func mustLinkExternal(ctxt *Link) (res bool, reason string) {
185185
}()
186186
}
187187

188-
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
188+
if sys.MustLinkExternal(objabi.GOOS, objabi.GOARCH) {
189189
return true, fmt.Sprintf("%s/%s requires external linking", objabi.GOOS, objabi.GOARCH)
190190
}
191191

@@ -261,8 +261,6 @@ func determineLinkMode(ctxt *Link) {
261261
default:
262262
if extNeeded || (iscgo && externalobj) {
263263
ctxt.LinkMode = LinkExternal
264-
} else if ctxt.IsDarwin() && ctxt.IsARM64() {
265-
ctxt.LinkMode = LinkExternal // default to external linking for now
266264
} else {
267265
ctxt.LinkMode = LinkInternal
268266
}

src/cmd/nm/nm_cgo_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ func canInternalLink() bool {
1515
switch runtime.GOOS {
1616
case "aix":
1717
return false
18-
case "darwin":
19-
switch runtime.GOARCH {
20-
case "arm64":
21-
return false
22-
}
2318
case "dragonfly":
2419
return false
2520
case "freebsd":

src/internal/testenv/testenv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ func CanInternalLink() bool {
201201
if runtime.GOARCH != "arm64" {
202202
return false
203203
}
204-
case "darwin", "ios":
204+
case "ios":
205205
if runtime.GOARCH == "arm64" {
206206
return false
207207
}

test/fixedbugs/bug429_run.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
// run
22

33
// +build !nacl,!js
4-
// +build !darwin !arm64
5-
6-
// Skip on darwin/arm64 as it requires external linking, which brings in
7-
// cgo, causing deadlock detection not working.
84

95
// Copyright 2014 The Go Authors. All rights reserved.
106
// Use of this source code is governed by a BSD-style

test/fixedbugs/issue21576.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
// run
22

33
// +build !nacl,!js
4-
// +build !darwin !arm64
5-
6-
// Skip on darwin/arm64 as it requires external linking, which brings in
7-
// cgo, causing deadlock detection not working.
84

95
// Copyright 2019 The Go Authors. All rights reserved.
106
// Use of this source code is governed by a BSD-style

0 commit comments

Comments
 (0)