Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
simonmar opened this issue Jan 18, 2013 · 10 comments
Closed

Comments

@simonmar
Copy link
Member

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-3.2.0.3...
Building parallel-3.2.0.3...
Preprocessing library parallel-3.2.0.3...
...
Registering parallel-3.2.0.3...
Installing library in
/home/simon/.cabal/lib/x86_64-linux/parallel-3.2.0.3/ghc-7.7.20130117
Registering parallel-3.2.0.3...

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

@23Skidoo
Copy link
Member

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).

@singpolyma
Copy link

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

@singpolyma
Copy link

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
Copy link
Member

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

@the-real-blackh
Copy link

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.

@the-real-blackh
Copy link

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
Copy link
Member

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!

@the-real-blackh
Copy link

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
Copy link
Collaborator

lukexi commented Feb 20, 2013

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

@23Skidoo
Copy link
Member

23Skidoo commented Mar 3, 2013

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

@23Skidoo 23Skidoo closed this as completed Mar 3, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants