haskell / haskell/cabal

build Setup.hs with local compiler when cross-compiling

Open
#1,493 41 comments 0 reactions 0 assignees View on GitHub
cabal-install: other Cabal: custom can-workaround type: bug
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

I have a script that invokes cabal with `--with-ghc=...`, `--with-ghc-pkg=...`, `--with-gcc=...`, etc. for cross-compiling to Android. It works great for most packages, but fails for a package with Build-type: Custom, because it builds `Setup.hs` with the cross-compiler specified on the command-line, and then obviously it can't run `dist/setup/setup` because it's an ARM executable.

I can work around the issue by doing an ordinary cabal configure with no `--with-ghc=...` options first, then doing a cabal install with my cross-compiler script, because the second invocation uses the cached `dist/setup/setup` from the first one. But that's a hack, obviously, and annoying to do when the package I'm installing is a dependency of the one I actually want.

What I would like is a separate set of options for specifying the program configuration to use to build `Setup.hs`; or at least an option to tell cabal to just use the ones on my path. I found that using `defaultSetupScriptOptions` for `setupScriptOptions` in `configure` and `performInstallations` seemed to do the trick for me, to give an idea of what I want to happen, though I haven't tested the resulting libraries. I couldn't determine whether there is already a way to achieve the same effect through command-line options.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the configure and performInstallations paths mentioned in the issue, along with setupScriptOptions and defaultSetupScriptOptions. Reproduce a Custom build while passing cross-compiler options, then verify that Setup.hs uses a runnable local compiler while the package continues using the requested cross compiler.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.