From: Cherry Mui Date: Thu, 15 Sep 2022 01:01:04 +0000 (-0400) Subject: [release-branch.go1.19] cmd/link: suppress -no_pie deprecation warning on darwin X-Git-Tag: go1.19.2~6 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=11728b38dc05b3b82fe5b98b0b5ce7263a3758aa;p=gostls13.git [release-branch.go1.19] cmd/link: suppress -no_pie deprecation warning on darwin Apparently the new darwin linker starts to emit a warning about -no_pie deprecation. Maybe we want to switch to PIE by default. For now, suppress the warning. This also makes it easier for backporting to previous releases. Fixes #55114. Updates #55112, #54482. Change-Id: I1a3b74c237a9d00ec3b030fc3a9940a31e5cd37e Reviewed-on: https://go-review.googlesource.com/c/go/+/430937 Run-TryBot: Cherry Mui Reviewed-by: Than McIntosh TryBot-Result: Gopher Robot (cherry picked from commit 706d84fca2b36fdf670a0d921e6a8a3b481eaa05) Reviewed-on: https://go-review.googlesource.com/c/go/+/431517 --- diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go index 7b32808e51..a2b2bd4208 100644 --- a/src/cmd/link/internal/ld/lib.go +++ b/src/cmd/link/internal/ld/lib.go @@ -1774,6 +1774,13 @@ func (ctxt *Link) hostlink() { if len(out) > 0 { // always print external output even if the command is successful, so that we don't // swallow linker warnings (see https://golang.org/issue/17935). + if ctxt.IsDarwin() && ctxt.IsAMD64() { + const noPieWarning = "ld: warning: -no_pie is deprecated when targeting new OS versions\n" + if i := bytes.Index(out, []byte(noPieWarning)); i >= 0 { + // swallow -no_pie deprecation warning, issue 54482 + out = append(out[:i], out[i+len(noPieWarning):]...) + } + } ctxt.Logf("%s", out) }