-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/mobile: gomobile build fails for iOS targets #32963
Comments
@bcmills Should I go ahead and see if I can figure out what's going on here? Happy to chip in. |
I have the same problem on Mojave with XCode 10.2 and 10.3 |
The warning can be fixed with this patch, but it does not fix the build error...
|
Aha, the problem seems to be that the go tools we are using force -headerpad and that bitcode is now enabled by default and these conflict. The following patch to gomobile fixed it for me 😎.
|
I don't know how to create a PR for gomobile, so here is a consolidated patch file instead... |
I just ran into the exact same problem. @andydotxyz solution fixed it! @andydotxyz why did you decide to turn off bitcode instead of turning off headerpad? I ask because I understand that Apple seems to prefer that bitcode is turned on. |
That is a great question @rob-deutsch - it was not my preferred approach either. Unfortunately headerpad is coded into the Go tools which gomobile delegates to (as far as I can tell) - this means that the patch would have to go upstream to the main project which seemed much harder! |
Ha, that's a great reason! Thanks for the info @andydotxyz . I know its unlikely, but would you happen to remember where exactly |
@rob-deutsch I see in ld and some hints in macho_combine_dwarf.go |
Sorry I don't recall @rob-deutsch - I just used grep for "headerpad" I think... |
For people who didn't follow the cl -
Does anyone have an answer? |
@hyangah, which CL? (I don't see one linked here — it's possible that GopherBot missed a cross-reference.) |
@bcmills I believe @hyangah refers to https://golang.org/cl/189857. |
I did some digging and found that the answer to my own question is: nothing changed, but
It seems to me the fix is to figure out why The next best fix is to work around the issue and switch The easiest workaround is for CL 189857 implements the third option, except that it also omits the flag for |
I asked on golang-dev for the purpose of the incompatible flags: https://groups.google.com/forum/#!topic/golang-dev/U1jK3xmmGAk It seems possible that my first suggestion could work: remove -headerpad, -fno_pie, -pagezero_size and see whether I won't have much time before GoLab Florence, and we're approaching the freeze. If someone else could do the experiment, I'd be very grateful. |
With #34501 (comment) we can now target iOS builders with the TRY= directive. |
Change https://golang.org/cl/201358 mentions this issue: |
https://golang.org/cl/201358 seems to complete all.bash (on at least darwin/arm64). Can someone using |
Testing on the latest macOS with gomobile build I get a new error:
|
On Sat Oct 26, 2019 at 10:49 AM Andy Williams wrote:
Testing on the latest macOS with gomobile build I get a new error:
```
ld: -no_pie and -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES) cannot be used together
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```
I didn't make it clear, but the CL only works for darwin/arm64, not (yet) for darwin/arm.
Please use
$ gomobile build -target ios/arm64 ...
to build a binary for arm64 only and test with that. You may have to disable arm in your Xcode
as well.
|
Ah yes, apologies. |
OK, I have attempted the upload and it seems to have no bitcode related errors :) |
Nice, thanks for checking.
… |
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/+/201358 Reviewed-by: Cherry Zhang <[email protected]>
@andydotxyz could you be persuaded to check out Cherry's https://golang.org/cl/205060? It should fix the darwin/arm build as well. |
I would be happy to but am only at a Mac on Wednesday this week - I’ll do my best to get it checked then :) |
We used to pass -no_pie to external linker on darwin/arm, which is incompatible with -fembed-bitcode. CL 201358 attempted to remove the -no_pie flag, but it resulted the darwin linker to complain about absolute addressing in TEXT segment. On darwin/arm, we already get away from absolute addressing in the TEXT section. The complained absolute addressing is in RODATA, which was embedded in the TEXT segment. This CL moves RODATA to the DATA segment, like what we already did on ARM64 and on AMD64 in c-archive/c-shared buildmodes for the same reason. So there is no absolute addressing in the TEXT segment, which allows us to remove -no_pie flag. Fixes #35252. Updates #32963. Change-Id: Id6e3a594cb066d257d4f58fadb4a3ee4672529f7 Reviewed-on: https://go-review.googlesource.com/c/go/+/205060 Reviewed-by: Elias Naur <[email protected]>
Change https://golang.org/cl/205060 mentions this issue: |
With both patches applied I get:
|
Both patches are in go tip, where headerpad is guarded by
so -headerpad shouldn't be emitted on darwin/arm nor darwin/arm64. Can you try again with Go tip? |
arm and arm64 are both working, however the "ios" target is not - so it's still not building for simulator. works:
does not:
|
Thank you, I had forgotten about the simulators. Let me know whether golang.org/cl/205340 works, which fixes the problem for:
|
Change https://golang.org/cl/205340 mentions this issue: |
Excellent, thanks - that fixes "-target ios"
|
The -Wl,-headerpad, -Wl,-no_pie, -Wl,-pagezero_size flags are incompatible with the bitcode-related flags used for iOS. We already omitted the flags on darwin/arm and darwin/arm64; this change omits the flags on all platforms != macOS so that building for the iOS simulator works. Updates #32963 Change-Id: Ic9af0daf01608f5ae0f70858e3045e399de7e95b Reviewed-on: https://go-review.googlesource.com/c/go/+/205340 Run-TryBot: Elias Naur <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
Change https://golang.org/cl/206337 mentions this issue: |
CL 205340 changed the linker to skip certain flags when linking for iOS. However, for host linking on iOS (such as on the Corellium darwin/arm64 builders) the MachO platform defaults to PLATFORM_MACOS, and the flags are not skipped. Avoids warnings such as ld: warning: -no_pie ignored for arm64 Updates #32963 Change-Id: Ib6b4c2375fd14cf89410bf5ff1537b692b7a1c15 Reviewed-on: https://go-review.googlesource.com/c/go/+/206337 Run-TryBot: Elias Naur <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
I guess this can be closed when 1.13.5 comes out? |
The fixes will be in Go 1.14 and are not going to be backported. I left this issue open in case someone wanted to work on a gomobile workaround for Go 1.13. If not, go ahead and close it. |
What would the workaround in gomobile be? |
Probably something like: fyne-io/mobile@9aa5623 |
Yes, but activated only with Go < 1.14. |
Hey peeps! I'm trying to use go mobile for an ios target and I ran into the same problem. It seems like the patch submitted above still hasn't been accepted in the master branch. I clone'd from github, applied the patch manually but now I'm trying to figure out how to rebuild go mobile from source. I did see the docs on fetching subrepositories like mobile, but I couldn't figure out how to rebuild from a local copy. Bear in mind I'm relatively new to go, but an experienced dev. Any help greatly appreciated. |
I'm trying to create a CL. |
Change https://golang.org/cl/214899 mentions this issue: |
Change https://golang.org/cl/214957 mentions this issue: |
iOS's bitcode conflicts with headerpad on Go 1.13 or older. This problem is fixed on Go 1.14. This CL disables bitcode only on Go 1.13 or older. Fixes golang/go#32963 Cherry picked from github.com/golang/mobile
iOS's bitcode conflicts with headerpad on Go 1.13 or older. This problem is fixed on Go 1.14. This CL disables bitcode only on Go 1.13 or older. Fixes golang/go#32963 Cherry picked from github.com/golang/mobile
iOS's bitcode conflicts with headerpad on Go 1.13 or older. This problem is fixed on Go 1.14. This CL disables bitcode only on Go 1.13 or older. Fixes golang/go#32963 Change-Id: Iac9edd56aaf7819288e8f46b9e29d310305acd9d Reviewed-on: https://go-review.googlesource.com/c/mobile/+/214899 Run-TryBot: Hajime Hoshi <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Hyang-Ah Hana Kim <[email protected]>
iOS's bitcode conflicts with headerpad on Go 1.13 or older. This problem is fixed on Go 1.14. This CL disables bitcode only on Go 1.13 or older. Fixes golang/go#32963 Change-Id: Iac9edd56aaf7819288e8f46b9e29d310305acd9d Reviewed-on: https://go-review.googlesource.com/c/mobile/+/214899 Run-TryBot: Hajime Hoshi <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Hyang-Ah Hana Kim <[email protected]>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?macOS Mojave 10.14.5 (18F132)
go env
OutputWhat did you do?
Note: the wiki instructions leave out the
-bundleid
parameter even though it appears to be required.Output
What did you expect to see?
See https://github.com/golang/go/wiki/Mobile#building-and-deploying-to-ios.
What did you see instead?
The text was updated successfully, but these errors were encountered: