Skip to content

Commit f7b4f02

Browse files
committed
cmd/go: default to PIE linking on darwin/amd64
The recent version of darwin linker ld64 emits an warning about deprecation of the -no_pie flag. Further, the new darwin linker ld-prime ignores -no_pie flag and generates a PIE binary anyway. Switch to building PIE binaries by default. Updates #54482. Updates #61229. Change-Id: I81294dcd07a368a20e1349d56556ee2fdcb8df44 Reviewed-on: https://go-review.googlesource.com/c/go/+/461697 Run-TryBot: Cherry Mui <[email protected]> Reviewed-by: Than McIntosh <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent 74caf47 commit f7b4f02

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

src/cmd/cgo/internal/test/issue4029.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build !windows && !static && (!darwin || (!internal_pie && !arm64))
5+
//go:build !windows && !static && !(darwin && internal)
66

77
#include <stdint.h>
88
#include <dlfcn.h>

src/cmd/cgo/internal/test/issue4029.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build !windows && !static && (!darwin || (!internal_pie && !arm64))
5+
//go:build !windows && !static && !(darwin && internal)
66

7-
// Excluded in darwin internal linking PIE mode, as dynamic export is not
8-
// supported.
9-
// Excluded in internal linking mode on darwin/arm64, as it is always PIE.
7+
// Excluded in darwin internal linking PIE (which is the default) mode,
8+
// as dynamic export is not supported.
109

1110
package cgotest
1211

src/cmd/cgo/internal/test/issue4029w.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build windows || static || (darwin && internal_pie) || (darwin && arm64)
5+
//go:build windows || static || (darwin && internal)
66

77
package cgotest
88

src/internal/platform/supported.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ func DefaultPIE(goos, goarch string, isRace bool) bool {
245245
}
246246
return true
247247
case "darwin":
248-
return goarch == "arm64"
248+
return true
249249
}
250250
return false
251251
}

0 commit comments

Comments
 (0)