Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

cabal-install infers the wrong $arch/$os when used with a cross-compiler #1184

simonmar opened this Issue Jan 18, 2013 · 10 comments


None yet
6 participants

simonmar commented Jan 18, 2013

I want to install packages using cabal with a GHC cross-compiler, and have them installed into .cabal/lib/$arch-$os/... so that they don't conflict with my native packages. Unfortunately, cabal uses the host rather than the target $arch-$os, so the cross-compiled packages will conflict with my native packages.

In my ~/.cabal/config I have

install-dirs user
  libsubdir: $arch-$os/$pkgid/$compiler

where my local $arch-$os is x86_64-linux and the target is arm-linux.

$ cabal install --with-ghc=$HOME/code/ghc-pi/inplace/bin/ghc-stage1 --with-ld=$HOME/tmp/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-ld parallel --reinstall
Resolving dependencies...
Configuring parallel-
Building parallel-
Preprocessing library parallel-
Registering parallel-
Installing library in
Registering parallel-

The correct target platform could be obtained by passing --info to the GHC named in --with-ghc.


23Skidoo commented Jan 18, 2013

Currently, the values from System.Info are always used for $arch and $os. To fix this, we need to make initialPathTemplateEnv take a Platform parameter and add a way to get a Platform given a CompilerId and a ProgramDb (for GHC, this means parsing ghc --info).

Can I suggest that, once this is supported, it become the default setting for libsubdir, with similar defaults for datasubdir and docs?

This also causes packages like primitive to fail to install under a cross-compiler, because they use arch tests to enable certain gcc flags.


23Skidoo commented Jan 19, 2013

@singpolyma Good point. The target platform should be also used instead of the host platform in conditions.

I've done some work on this at https://github.com/ghc-ios/packages-Cabal because I'm going to need this for cross-compiling to iOS to work properly.

This patch https://gist.github.com/the-real-blackh/4983885 adds --host-os=XX and --host-arch=XX options, and also an OS called "ios". I need this functionality for the iOS cross-compile changes in ghc.

It doesn't specifically address the naming of the directory as .cabal/lib/$arch-$os/..., but this would be easy to add to what I've already done.


tibbe commented Feb 19, 2013

@the-real-blackh Would you mind creating a pull request once you think the code is ready so we can review it? Thanks!

Thanks for that. I've decided that the only proper way to do it would be to do what Simon M says and extract the hostOS and hostArch automatically from the selected ghc. So I'll work on that and prepare a pull request.


lukexi commented Feb 20, 2013

Hi guys, on behalf of @the-real-blackh and I here's a pull request addressing this. #1210


23Skidoo commented Mar 3, 2013

#1214 should have fixed this. Feel free to reopen.

@23Skidoo 23Skidoo closed this Mar 3, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment