[commit: ghc] master: Tidy up cross-compiling (109a1e5)

Stephen Paul Weber singpolyma at singpolyma.net
Sat Jan 19 05:22:35 CET 2013

Somebody claiming to be Stephen Paul Weber wrote:
>Somebody claiming to be Simon Marlow wrote:
>>On 17/01/13 14:08, Simon Marlow wrote:
>>Ok, new wiki page is here:
>TL;DR: Needs one GHC patch and one base patch, has to use integer-simple, 
>and make install still does not work.  Otherwise works fine.
>So, there it is.  I will try with arm-unknown-nto-qnx8.0.0 (uses LLVM) next.

Start with a pristine GHC checkout.  Apply the QNX patch to GHC< and the 
CLK_TCK patch to base.  Set up as in the wiki page, and also use 
integer-simple (see previous email).

./configure --target=arm-unknown-nto-qnx8.0.0eabi --prefix="${QNX_HOST}/usr"

This eventually results in:

      Error: bad instruction `addl $28,%esp'

/tmp/ghc5601_0/ghc5601_0.bc:1086:0:  Error: bad instruction `ret'

      Error: unrecognized symbol type ""
make[1]: *** [libraries/ghc-prim/dist-install/build/GHC/Types.o] Error 1
make: *** [all] Error 2

And much similar output.  This is because during cross-compiling, the triple 
is not passed through to LLVM, so LLVM assumes it is compiling for native.  
I have mentioned this before, but have now filed it as 

Apply the following as a hack:

diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index 9e8556f..bcc1aa9 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -1393,7 +1393,8 @@ runPhase LlvmOpt input_fn dflags
      liftIO $ SysTools.runLlvmOpt dflags
                 ([ SysTools.FileOption "" input_fn,
                      SysTools.Option "-o",
-                    SysTools.FileOption "" output_fn]
+                    SysTools.FileOption "" output_fn
+                    , SysTools.Option "-mtriple=arm-unknown-nto-qnx8.0.0eabi"]
                  ++ optFlag
                  ++ [SysTools.Option tbaa]
                  ++ map SysTools.Option lo_opts)

I then hit <http://hackage.haskell.org/trac/ghc/ticket/7490>, which is 
expected.  Type make again to continue.

By the way, lots of:

when making flags consistent: Warning:
     No native code generator, so using LLVM

I assume there's some sort of option I can set so that it expects this.

Success!  make install still fails with:

Installing library in
"/home/singpolyma/bbndk/host_10_0_9_404/linux/x86/usr/lib/ghc-7.7.20130118/bin/ghc-pkg" --force --global-package-db "/home/singpolyma/bbndk/host_10_0_9_404/linux/x86/usr/lib/ghc-7.7.20130118/package.conf.d" update rts/package.conf.install
/bin/sh: 1: /home/singpolyma/bbndk/host_10_0_9_404/linux/x86/usr/lib/ghc-7.7.20130118/bin/ghc-pkg: not found
make[1]: *** [install_packages] Error 127
make: *** [install] Error 2

Stephen Paul Weber, @singpolyma
See <http://singpolyma.net> for how I prefer to be contacted
edition right joseph

More information about the ghc-devs mailing list