ghc-android icon indicating copy to clipboard operation
ghc-android copied to clipboard

Use system linker on android

Open bendlas opened this issue 11 years ago • 4 comments

ghc-android builds with 'DYNAMIC_GHC_PROGRAMS = NO', hence uses GHCs builtin linker, whose arm support is inclomplete. This leads to error cases such as:

$ arm-linux-androideabi-cabal install --reinstall --force-reinstall vector
...
[ 5 of 19] Compiling Data.Vector.Fusion.Stream.Monadic ( Data/Vector/Fusion/Stream/Monadic.hs, dist/build/Data/Vector/Fusion/Stream/Monadic.o )
Loading package ghc-prim ... linking ... ghc: /home/androidbuilder/.ghc/android-14/arm-linux-androideabi-4.8/lib/arm-unknown-linux-androideabi-ghc-7.7.20130921/ghc-prim-0.3.1.0/HSghc-prim-0.3.1.0.o: unhandled ELF relocation(Rel) type 28

ghc: unable to load package `ghc-prim'
Failed to install vector-0.10.9.1
...

bendlas avatar Nov 29 '13 18:11 bendlas

Does this mean that you can't cross compile packages like vector at all? Or is there a way to do it manually?

whitehead1415 avatar Mar 04 '15 18:03 whitehead1415

@bendlas, I'm lost, how do you expect this to work? Are you running GHC on an ARM system? If not, how do you expect to link in ARM object files, static or dynamic?

I think recent versions of vector specifically don't require dynamic code loading.

rwbarton avatar Apr 12 '15 03:04 rwbarton

@rwbarton it's been some time since I worked on this. I used a cross-compilation toolchain to compile and link for arm (there are tutorials on this). It mostly worked and even compiled simple binaries, but more complex examples hit the linker limitation of the GHC linker. I even found out about some plans to enable using the system (cross-compile-toolchain) linker for this, but IIRC @neurocyte wanted to hold off until some mainline work was finished.

bendlas avatar Apr 15 '15 01:04 bendlas

The issue just mentioned, Dependency on 'linear' introduces many more recursive dependencies, has status closed but is not resolved (since it is actually a ghc-android issue, probably this issue).

We tried to compile the same code for iOS where we did not encounter this ghc: unable to load packageghc-prim'` issue. Interesting. I expect the linker on iOS to be more capable in some respect(s).

I do not know if this issue is relate, but @rwbarton raised is and seems to describe linker incapabilities on in the ghc-android toolchain.

cies avatar Dec 30 '15 09:12 cies