Commit f4e32aee authored by Elias Naur's avatar Elias Naur

cmd/link/internal/ld: remove flags incompatible with -fembed-bitcode

The flags -headerpad, -Wl,-no_pie and -pagezero_size are incompatible with
the -fembed-bitcode flag used by `gomobile build`. Than McIntosh
suggested we might not need the offending flags; this change removes
the flags on darwin/arm64 and -headerpad, -pagezero_size on darwin/arm.

The -Wl,-no_pie flag is left for darwin/arm because linking fails
without it:

ld: warning: PIE disabled. Absolute addressing (perhaps -mdynamic-no-pic) not allowed in code signed PIE, but used in _runtime.rodata from /var/folders/qq/qxn86k813bn9fjxydm095rxw0000gp/T/workdir-host-darwin-amd64-zenly-ios/tmp/go-link-225285265/go.o. To fix this warning, don't compile with -mdynamic-no-pic or link with -Wl,-no_pie

Discussion: https://groups.google.com/d/msg/golang-dev/U1jK3xmmGAk/j0_ty46EDAAJ

I've verified the CL on the builders, built the "flappy" example from
gomobile with `gomobile build`, and verified that flappy runs on an
iPhone 5S.

Updates #32963

Change-Id: I783abc93ccf3c1d2b7ca00144b7164ba223d3529
Reviewed-on: https://go-review.googlesource.com/c/go/+/201358Reviewed-by: default avatarCherry Zhang <cherryyz@google.com>
parent 01e7a152
...@@ -1169,13 +1169,13 @@ func (ctxt *Link) hostlink() { ...@@ -1169,13 +1169,13 @@ func (ctxt *Link) hostlink() {
switch ctxt.HeadType { switch ctxt.HeadType {
case objabi.Hdarwin: case objabi.Hdarwin:
if !ctxt.Arch.InFamily(sys.ARM, sys.ARM64) {
// -headerpad is incompatible with -fembed-bitcode.
argv = append(argv, "-Wl,-headerpad,1144") argv = append(argv, "-Wl,-headerpad,1144")
}
if ctxt.DynlinkingGo() && !ctxt.Arch.InFamily(sys.ARM, sys.ARM64) { if ctxt.DynlinkingGo() && !ctxt.Arch.InFamily(sys.ARM, sys.ARM64) {
argv = append(argv, "-Wl,-flat_namespace") argv = append(argv, "-Wl,-flat_namespace")
} }
if ctxt.BuildMode == BuildModeExe && !ctxt.Arch.InFamily(sys.ARM64) {
argv = append(argv, "-Wl,-no_pie")
}
case objabi.Hopenbsd: case objabi.Hopenbsd:
argv = append(argv, "-Wl,-nopie") argv = append(argv, "-Wl,-nopie")
case objabi.Hwindows: case objabi.Hwindows:
...@@ -1209,11 +1209,10 @@ func (ctxt *Link) hostlink() { ...@@ -1209,11 +1209,10 @@ func (ctxt *Link) hostlink() {
switch ctxt.BuildMode { switch ctxt.BuildMode {
case BuildModeExe: case BuildModeExe:
if ctxt.HeadType == objabi.Hdarwin { if ctxt.HeadType == objabi.Hdarwin {
if ctxt.Arch.Family == sys.ARM64 { if ctxt.Arch.Family != sys.ARM64 {
// __PAGEZERO segment size determined empirically. argv = append(argv, "-Wl,-no_pie")
// XCode 9.0.1 successfully uploads an iOS app with this value. }
argv = append(argv, "-Wl,-pagezero_size,100000000") if !ctxt.Arch.InFamily(sys.ARM, sys.ARM64) {
} else {
argv = append(argv, "-Wl,-pagezero_size,4000000") argv = append(argv, "-Wl,-pagezero_size,4000000")
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment