Is there a way to compile packages in parallel when using cabal install
similar to GNU make's -jN
flag?
Asked
Active
Viewed 4,714 times
20

imz -- Ivan Zakharyaschev
- 4,921
- 6
- 53
- 104

Nordlöw
- 11,838
- 10
- 52
- 99
2 Answers
33
Yes, from version 1.16, cabal does support this using the -j
option to install, like so:
cabal install -j mypackage

user239558
- 6,964
- 1
- 28
- 35
-
n.b. This version of cabal is NOT included in the current version of the Haskell Platform (2012.4.0.0) but is [expected to be included in the next version of the Haskell Platform (2013.2.0.0)](http://stackoverflow.com/a/7872263/86622) (see comments). – dave4420 Dec 24 '12 at 14:17
-
3You can, however, simply `cabal install cabal-install` even on the current Haskell Platform to get this functionality. That doesn't even break things (for me). – nh2 Apr 18 '13 at 10:19
-
You might want to add to your answer this doesn't speed up the installation of a single package - it just installs *multiple packages* at the same time. Therefore `cabal install -j mypackage` will not bring any benefit, only `cabal install -j package1 package2` will. – nh2 Apr 18 '13 at 10:20
-
@nh2 and what if mypackage have mutliple dependencies, they won't be compiled in parallel? (if the dependencies allow it of course) – Alois Cochard Oct 04 '13 at 17:49
-
@AloisCochard You are right, dependencies will be installed in parallel. By the mention of `make -j` in the question, I assumed that the question was about the build step of the package itself. – nh2 Oct 16 '13 at 18:44
-
3Why this option is not enabled by default? – The_Ghost Aug 16 '14 at 20:49
13
No. This has been an open issue for some time. There was an effort to make ghc --make
build the needed modules in parallel, but evidently that ran into issues. Since then doing this at the cabal level has been all the discussion I've heard but has not became reality yet.
See this duplicate question for some links and what is still the state of the art.

Community
- 1
- 1

Thomas M. DuBuisson
- 64,245
- 7
- 109
- 166
-
8Gees guys, easy on the down votes. This was correct when it was written, but the newer answer (written a full year later) has the updated information you are looking for. – Thomas M. DuBuisson Dec 30 '12 at 16:37