From f7b4f02ba067096650b74426ed1459cbf63a93da Mon Sep 17 00:00:00 2001 From: Cherry Mui Date: Fri, 16 Sep 2022 18:10:56 -0400 Subject: [PATCH] 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 Reviewed-by: Than McIntosh TryBot-Result: Gopher Robot --- src/cmd/cgo/internal/test/issue4029.c | 2 +- src/cmd/cgo/internal/test/issue4029.go | 7 +++---- src/cmd/cgo/internal/test/issue4029w.go | 2 +- src/internal/platform/supported.go | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/cmd/cgo/internal/test/issue4029.c b/src/cmd/cgo/internal/test/issue4029.c index 212d6922f8..7a8fdc11b4 100644 --- a/src/cmd/cgo/internal/test/issue4029.c +++ b/src/cmd/cgo/internal/test/issue4029.c @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build !windows && !static && (!darwin || (!internal_pie && !arm64)) +//go:build !windows && !static && !(darwin && internal) #include #include diff --git a/src/cmd/cgo/internal/test/issue4029.go b/src/cmd/cgo/internal/test/issue4029.go index 686b7679f3..506c999bdb 100644 --- a/src/cmd/cgo/internal/test/issue4029.go +++ b/src/cmd/cgo/internal/test/issue4029.go @@ -2,11 +2,10 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build !windows && !static && (!darwin || (!internal_pie && !arm64)) +//go:build !windows && !static && !(darwin && internal) -// Excluded in darwin internal linking PIE mode, as dynamic export is not -// supported. -// Excluded in internal linking mode on darwin/arm64, as it is always PIE. +// Excluded in darwin internal linking PIE (which is the default) mode, +// as dynamic export is not supported. package cgotest diff --git a/src/cmd/cgo/internal/test/issue4029w.go b/src/cmd/cgo/internal/test/issue4029w.go index 91dad6abcb..aa4c2f59bd 100644 --- a/src/cmd/cgo/internal/test/issue4029w.go +++ b/src/cmd/cgo/internal/test/issue4029w.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build windows || static || (darwin && internal_pie) || (darwin && arm64) +//go:build windows || static || (darwin && internal) package cgotest diff --git a/src/internal/platform/supported.go b/src/internal/platform/supported.go index 230a952d2d..7fc3bfd25d 100644 --- a/src/internal/platform/supported.go +++ b/src/internal/platform/supported.go @@ -245,7 +245,7 @@ func DefaultPIE(goos, goarch string, isRace bool) bool { } return true case "darwin": - return goarch == "arm64" + return true } return false } -- 2.50.0