ghc-android
ghc-android copied to clipboard
Use system linker on android
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
...
Does this mean that you can't cross compile packages like vector at all? Or is there a way to do it manually?
@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 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.
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 package
ghc-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.