Skip to content
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

cmd/link: PIC support for darwin/arm #12896

Closed
KennyAtBaidu opened this issue Oct 10, 2015 · 17 comments

Comments

Projects
None yet
9 participants
@KennyAtBaidu
Copy link

commented Oct 10, 2015

When including the generated gomobile iOS framework into another iOS framework, calling gomobile generated method from the wrapper framework causes linker failure with message "ld: illegal text-relocation to 'type..eq.[0]string'"

@rakyll

This comment has been minimized.

Copy link
Member

commented Oct 12, 2015

Duplicate of #9210.

@rakyll rakyll closed this Oct 12, 2015

@rakyll

This comment has been minimized.

Copy link
Member

commented Oct 12, 2015

The only workaround before #9210 is fixed is to keep targeting SDK version 22.

<uses-sdk
        android:minSdkVersion="15"
        android:targetSdkVersion="22" />
@KennyAtBaidu

This comment has been minimized.

Copy link
Author

commented Oct 12, 2015

@rakyll Sorry if I wasn't clear. This is for iOS framework. When code of custom iOS framework calling methods that are generated by gomobile cause illegal text-relocation.

@rakyll

This comment has been minimized.

Copy link
Member

commented Oct 12, 2015

Sorry, it was not clear from the text.

/cc @crawshaw

@rakyll rakyll reopened this Oct 12, 2015

@KennyAtBaidu

This comment has been minimized.

Copy link
Author

commented Oct 12, 2015

updated the original report.

@crawshaw

This comment has been minimized.

Copy link
Contributor

commented Oct 14, 2015

Hi @KennyAtBaidu. Can you tell if this is coming from the ARMv7 or ARMv8 (arm64) binary? (You can extract the individual .a files by running gomobile with the -work.)

For ARMv7 it looks like we are not compiling as PIC for iOS, which is easy to fix. For ARMv8 I was under the impression the compiler was generating PC-relative code by default, but I tried to confirm with a quick inspection of the compiler and it's not clear to me.

@KennyAtBaidu

This comment has been minimized.

Copy link
Author

commented Oct 14, 2015

Hi @crawshaw
It seems like

gomobile bind -work

gives me x86_64, armv7, and arm64 architecture.

I tried to toggle around with the Xcode build setting, if I build with simulator, I got the same error.

if I build with armv7, it'll first complain there's no bitcode, then I have the error

illegal text-relocation to 'main.initdone.'

If I build with arm64, it still complains there's no bitcode but once I disable bitcode, it built successfully. :D

@crawshaw

This comment has been minimized.

Copy link
Contributor

commented Oct 14, 2015

Ok great, then this might be easy to fix. I'll try to attach a cl later today.

@hsinhoyeh

This comment has been minimized.

Copy link

commented Oct 20, 2015

do we have any updates? I also hit into this.
can I know how to workaround this if we cann't fix it immediately.

@clsung

This comment has been minimized.

Copy link
Contributor

commented Oct 20, 2015

same here. And thank you for your great effort.

@crawshaw crawshaw self-assigned this Oct 20, 2015

@rsc rsc added this to the Unreleased milestone Oct 23, 2015

@crawshaw crawshaw changed the title x/mobile: ld: illegal text-relocation to 'type..eq.[0]string' cmd/link: PIC support for darwin/arm Nov 5, 2015

@damouse

This comment has been minimized.

Copy link

commented Nov 25, 2015

I can see the individual statics with -work, can you briefly explain how I can get them back into xcode?

Otherwise is there another quick way of getting the embedded framework to function?

@dcu

This comment has been minimized.

Copy link

commented Feb 29, 2016

I just tested this and it works fine (except for a warning) with armv7+arm64. It stops working when I add amd64 to the fat binary.

UPDATE: I talked too soon, it still doesn't work.

@dcu

This comment has been minimized.

Copy link

commented Mar 1, 2016

@crawshaw hi, is there anything we can help with to help you fix this issue?

mtigas added a commit to mtigas/iObfs that referenced this issue Apr 10, 2016

first stab at an iObfs.framework.
this currently doesn't work due to golang/go#12896
@gopherbot

This comment has been minimized.

Copy link

commented Apr 26, 2016

CL https://golang.org/cl/22461 mentions this issue.

@gopherbot gopherbot closed this in 9629f55 Apr 27, 2016

@dcu

This comment has been minimized.

Copy link

commented Apr 27, 2016

@crawshaw @cherrymui thanks for your hard work on this issue.

I tested this on tip but I'm getting the following error:

gomobile bind -target=ios
gomobile: reading export data: /var/folders/y_/ws09jpg90_b5y710wmd7kvj5sbl416/T/gomobile-work-499035079/fakegopath/pkg/darwin_arm/path/to/my/sdk.a: unknown version:
make: *** [ios] Error 1

so I backported the commit to go 1.6 but when compiling I'm getting a similar error to the previous one:

ld: illegal text-relocation to 'go.string.*' in /test/sdk.framework/sdk(go.o) from 'runtime.interhash' in /test/sdk.framework/sdk(go.o) for architecture armv7

Let me know if we can provide more information.

@crawshaw

This comment has been minimized.

Copy link
Contributor

commented May 16, 2016

@dcu is the first error in your comment, about "reading export data", fixed? I believe I saw the CL go by updating the gcimporter, and have no been able to replicate that error message.

@dcu

This comment has been minimized.

Copy link

commented May 16, 2016

@crawshaw no, sorry I forgot to update here.

This got fixed after #15519 and updating gomobile. it works on both 1.6 and 1.7.
Now we are getting errors when trying to install on a armv7 device because of a signature (according to the error message). Some of the issues are reported here: #15657
The other issue is that enabling armv7 requires the 386 sim I'm not sure why.

@golang golang locked and limited conversation to collaborators May 16, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.