Closed joeyh closed 11 years ago
To use cabal, this seems to work:
Install the NDK's toolchain in standalone mode. I put it into the same directory as the cross ghc, which makes cabal find it automatically when told to use the cross ghc.
android-ndk-r8d/build/tools/make-standalone-toolchain.sh --toolchain=arm-linux-androideabi-4.7 --platform=android-14 --install-dir=$HOME/.ghc-android-14-arm-linux-androideabi-4.7/
I think build should do that for the user!
Then to make cabal use the cross compilers, pass it a lot of flags. Here's a wrapper script that does so:
/usr/bin/cabal $@ -w $HOME/.ghc-android-14-arm-linux-androideabi-4.7/bin/arm-unknown-linux-androideabi-ghc --with-ghc-pkg=$HOME/.ghc-android-14-arm-linux-androideabi-4.7/bin/arm-unknown-linux-androideabi-ghc-pkg --with-ld=$HOME/.ghc-android-14-arm-linux-androideabi-4.7/bin/arm-linux-androideabi-ld
Perhaps build could install that as $HOME/.ghc-android-14-arm-linux-androideabi-4.7/bin/arm-unknown-linux-androideabi-cabal?
I also found I needed a hsc2hs wrapper, just to put it into cross-compile mode. I put this in $HOME/.ghc-android-14-arm-linux-androideabi-4.7/bin/hsc2hs
/usr/bin/hsc2hs $@ --cross-compile
With all of the above done, I have been able to cross build libraries such as regex-posix and text!
Ah, I see you've done some of this 12 hours ago. Looks like you don't install the NDK toolchain in standalone mode where ghc can find it yet. Also, while you link in the system hsc2hs, it does need --cross-compile in order to use the NDK toolchain.
I’ve added some more detail to the readme and added --cross-compile to hsc2hs. Let me know what you think.
I’m not sure what you mean about the NDK not being in standalone mode. It is a standalone toolchain and it is installed in the same directory as ghc. I’d like to know how you’re doing it, because I can’t get cabal to cross compile anything with cbits at the moment.
Aha! I’ve fixed it now. Unlike yours, my cabal wrapper did not use the prefixed versions of the executables. I switched it and now it just works. I guess that’s what kicks cabal into cross compiling mode. Thanks!
(Thanks -- it works! Well, builds, and cross-compiles binaries that look reasonable.)
The README leaves a few open questions that it would help users like me to fill in:
Configuring mtl-2.1.2... cabal: /home/joey/tmp/10048.o: does not exist