<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>coldwa.st/e - All posts</title>
    <link href="http://coldwa.st/e/rss.xml" rel="self" />
    <link href="http://coldwa.st/e" />
    <id>http://coldwa.st/e/rss.xml</id>
    <author>
        <name>Mikhail Glushenkov</name>
        <email>mikhail.glushenkov@gmail.com</email>
    </author>
    <updated>2017-09-09T00:00:00Z</updated>
    <entry>
    <title>What's new in Cabal/cabal-install 2.0 — improved new-build, Backpack, foreign libraries and more!</title>
    <link href="http://coldwa.st/e/blog/2017-09-09-Cabal-2-0.html" />
    <id>http://coldwa.st/e/blog/2017-09-09-Cabal-2-0.html</id>
    <published>2017-09-09T00:00:00Z</published>
    <updated>2017-09-09T00:00:00Z</updated>
    <summary type="html"><![CDATA[<p>A couple of weeks ago we’ve quietly released versions 2.0 of both Cabal and <code>cabal-install</code> after approximately a year of development. The 2.0 release incorporates more than 1500 commits by <a href="https://gist.github.com/23Skidoo/7109479c43a8de44f8e29fa335e9645c">64 different contributors</a>. This post serves as a formal release announcement and describes what’s new and improved in version 2.0.</p>
<p>There is a number of backwards-incompatible Cabal library API changes in this release that affect packages with Custom setup scripts. Therefore <code>cabal-install</code> will by default use a previous version of Cabal to build setup scripts that don’t <a href="https://www.well-typed.com/blog/2015/07/cabal-setup-deps/">explicitly declare compatibility with Cabal 2.0</a>. The <a href="https://github.com/haskell/cabal/wiki/2.0-migration-guide">2.0 migration guide</a> gives advice for package authors on how to adapt Custom setup scripts to backwards-incompatible changes in this release.</p>
<h2 id="major-new-features">Major new features</h2>
<ul>
<li><p>Much improved <a href="https://www.haskell.org/cabal/users-guide/nix-local-build-overview.html"><code>new-build</code> feature</a> (also known as nix-style local builds), that solves many long-standing problems and is going to become the default mode of operation of <code>cabal-install</code> in version 3.0 (tentative release date: Autumn 2018). Killer features of <code>new-build</code> are reproducible isolated builds with global dependency caching and multi-package projects. For a more extensive introduction to <code>new-build</code>, see <a href="http://blog.ezyang.com/2016/05/announcing-cabal-new-build-nix-style-local-builds/">this blog post by Edward Z. Yang</a>.</p></li>
<li><p>Support for Backpack, a new system for mix-in packages. See <a href="https://github.com/ezyang/ghc-proposals/blob/backpack/proposals/0000-backpack.rst">this article by Edward Z. Yang</a> for an introduction to Backpack and its features.</p></li>
<li><p>Native suport for <a href="https://github.com/haskell/cabal/pull/2540">foreign libraries</a>: Haskell libraries that are intended to be used by non-Haskell code. See <a href="https://www.haskell.org/cabal/users-guide/developing-packages.html#foreign-libraries">this section of the user guide</a> for an introduction to this feature.</p></li>
<li><p>Convenience/internal libraries are now supported (<a href="https://github.com/haskell/cabal/issues/269">#269</a>). An internal library is declared using the stanza <code>library 'libname'</code> and can be only used by other components inside a package.</p></li>
<li><p>Package components can be now built and installed in parallel. This is especially handy when compiling packages with large numbers of independent components (usually those are executables). As a consequence, the <code>Setup.hs</code> command-line interface <a href="https://github.com/ghc-proposals/ghc-proposals/pull/4">now allows to specify the component to be configured</a>.</p></li>
<li><p><a href="https://www.haskell.org/cabal/users-guide/nix-integration.html">Nix package manager integration</a> (<a href="https://github.com/haskell/cabal/issues/3651">#3651</a>).</p></li>
<li><p><a href="https://www.haskell.org/cabal/users-guide/developing-packages.html?highlight=outdated#listing-outdated-dependency-version-bounds">New <code>cabal-install</code> command: <code>outdated</code></a>, for listing outdated version bounds in a <code>.cabal</code> file or a freeze file (<a href="https://github.com/haskell/cabal/issues/4207">#4201</a>). Work on this feature was sponsored by <a href="https://scrive.com/">Scrive AB</a>.</p></li>
<li><p><a href="https://www.haskell.org/cabal/users-guide/installing-packages.html?highlight=reconfigure">New <code>cabal-install</code> command <code>reconfigure</code></a>, which re-runs <code>configure</code> with the most recently used flags (<a href="https://github.com/haskell/cabal/issues/2214">#2214</a>).</p></li>
<li><p>Package repos are now assumed to be <code>hackage-security</code>-enabled by default. If a <code>remote-repo</code> section in <code>~/.cabal/config</code> doesn’t have an explicit <code>secure</code> field, it now defaults to <code>secure: True</code>, unlike in <code>cabal-install</code> 1.24. See <a href="https://www.well-typed.com/blog/2015/04/improving-hackage-security/">this post on the Well-Typed blog</a> for an introduction to <code>hackage-security</code> and what benefits it brings.</p></li>
<li><p>New caret-style version range operator <code>^&gt;=</code> (<a href="https://github.com/haskell/cabal/issues/3705">#3705</a>) that is equivalent to <code>&gt;=</code> intersected with an automatically inferred major upper bound. For example, <code>foo ^&gt;= 1.3.1</code> is equivalent to <code>foo &gt;=   1.3.1 &amp;&amp; &lt; 1.4</code>. Besides being a convenient syntax sugar, <code>^&gt;=</code> allows to distinguish “strong” and “weak” upper bounds: <code>foo &gt;=   1.3.1 &amp;&amp; &lt; 1.4</code> means “I know for sure that my package doesn’t work with <code>foo-1.4</code>”, while <code>foo ^&gt;= 1.3.1</code> means “I don’t know whether <code>foo-1.4</code>, which is not out yet, will break my package, but I want to be cautious and follow <a href="https://pvp.haskell.org/">PVP</a>”. In the future, this feature will allow to implement automatic version bounds relaxation in a formally sound way (work on this front is progressing on <a href="https://matrix.hackage.haskell.org/"><code>matrix.hackage.haskell.org</code></a>). See <a href="https://www.haskell.org/cabal/users-guide/developing-packages.html?highlight=caret#pkg-field-build-depends">this section of the manual</a> for more information.</p></li>
<li><p>Changed <code>cabal upload</code> to upload a package candidate by default (<a href="https://github.com/haskell/cabal/issues/3419">#3419</a>). Same applies to uploading documentation. Also added a new <code>cabal upload</code> flag <code>--publish</code> for publishing a package on Hackage instead of uploading a candidate (<a href="https://github.com/haskell/cabal/issues/3419">#3419</a>).</p></li>
<li><p><a href="https://www.haskell.org/cabal/users-guide/nix-local-build.html?highlight=allow%20older#cfg-flag---allow-older">Support for <code>--allow-older</code></a> (dual to <code>--allow-newer</code>) (<a href="https://github.com/haskell/cabal/issues/3466">#3466</a>).</p></li>
<li><p><a href="https://www.haskell.org/cabal/users-guide/developing-packages.html?highlight=build%20tool%20depends#pkg-field-build-tool-depends">New <code>build-tool-depends</code> field</a> that replaces <code>build-tools</code> and has a better defined semantics (<a href="https://github.com/haskell/cabal/issues/3708">#3708</a>, <a href="https://github.com/haskell/cabal/issues/1541">#1541</a>). <code>cabal-install</code> will now install required build tools and add them to PATH automatically.</p></li>
<li><p><a href="https://www.haskell.org/cabal/users-guide/developing-packages.html?highlight=autogen%20modules#pkg-field-custom-setup-autogen-modules">New <code>autogen-modules</code> field</a> for automatically generated modules (like <code>Paths_PACKAGENAME</code>) that are not distributed inside the package tarball (<a href="https://github.com/haskell/cabal/issues/3656">#3656</a>).</p></li>
<li><p><a href="https://www.haskell.org/cabal/users-guide/developing-packages.html?highlight=scope#pkg-field-executable-scope">Added a new <code>scope</code> field</a> to the <code>executable</code> stanza (<a href="https://github.com/haskell/cabal/issues/3461">#3461</a>). Executable scope can be either <code>public</code> or <code>private</code>; private executables are those that are expected to be run by other programs rather than users and get installed into <code>$libexecdir/$libexecsubdir</code>. Additionally, <code>$libexecdir</code> now has a subdir structure similar to <code>$lib(sub)dir</code> to allow installing private executables of different packages and package versions alongside one another.</p></li>
<li><p>New <code>--index-state</code> flag for requesting a specific version of the package index (<a href="https://github.com/haskell/cabal/issues/3893">#3893</a>, <a href="https://github.com/haskell/cabal/issues/4115">#4115</a>).</p></li>
<li><p>Added <code>CURRENT_PACKAGE_VERSION</code> CPP constant to <code>cabal_macros.h</code> (<a href="https://github.com/haskell/cabal/issues/4319">#4319</a>).</p></li>
</ul>
<h2 id="minor-improvements-and-bug-fixes">Minor improvements and bug fixes</h2>
<ul>
<li><p>Dropped support for versions of GHC earlier than 6.12 (<a href="https://github.com/haskell/cabal/issues/3111">#3111</a>). Also, GHC compatibility window for the Cabal library has been extended to five years (<a href="https://github.com/haskell/cabal/issues/3838">#3838</a>).</p></li>
<li><p>Added a technical preview version of the ‘cabal doctest’ command (<a href="https://github.com/haskell/cabal/issues/4480">#4480</a>).</p></li>
<li><p>Cabal now invokes GHC with <code>-Wmissing-home-modules</code>, if that flag is supported (added in version 8.2). This means that you’ll get a warning if you forget to list a module in <code>other-modules</code> or <code>exposed-modules</code> (<a href="https://github.com/haskell/cabal/pull/4254">#4254</a>).</p></li>
<li><p>Verbosity <code>-v</code> now takes an extended format which allows specifying exactly what you want to be logged. The format is <code>[silent|normal|verbose|debug] flags</code>, where <code>flags</code> is a space separated list of flags. At the moment, only the flags <code>+callsite</code> and <code>+callstack</code> are supported; these report the call site/stack of a logging output respectively (these are only supported if Cabal is built with GHC 8.0/7.10.2 or greater, respectively).</p></li>
<li><p>The <code>-v/--verbosity</code> option no longer affects GHC verbosity (except in the case of <code>-v0</code>). Use <code>--ghc-options=-v</code> to enable verbose GHC output (<a href="https://github.com/haskell/cabal/issues/3540">#3540</a>, <a href="https://github.com/haskell/cabal/issues/3671">#3671</a>).</p></li>
<li><p>Packages which use internal libraries can result in multiple registrations; thus <code>--gen-pkg-config</code> can now output a directory of registration scripts rather than a single file.</p></li>
<li><p>Changed the default logfile template from <code>.../$pkgid.log</code> to <code>.../$compiler/$libname.log</code> (<a href="https://github.com/haskell/cabal/issues/3807">#3807</a>).</p></li>
<li><p>Macros in ‘cabal_macros.h’ are now <code>#ifndef</code>’d, so that they don’t cause an error if the macro is already defined (<a href="https://github.com/haskell/cabal/issues/3041">#3041</a>).</p></li>
<li><p>Added qualified constraints for setup dependencies. For example, <code>--constraint=&quot;setup.bar == 1.0&quot;</code> constrains all setup dependencies on bar, and <code>--constraint=&quot;foo:setup.bar == 1.0&quot;</code> constrains foo’s setup dependency on bar (part of <a href="https://github.com/haskell/cabal/issues/3502">#3502</a>).</p></li>
<li><p>Non-qualified constraints, such as –constraint=“bar == 1.0”, now only apply to top-level dependencies. They don’t constrain setup or build-tool dependencies. The new syntax <code>--constraint=&quot;any.bar   ==1.0&quot;</code> constrains all uses of bar.</p></li>
<li><p>Added a new solver flag, <code>--allow-boot-library-installs</code>, that allows normally non-upgradeable packages like <code>base</code> to be installed or upgraded (<a href="https://github.com/haskell/cabal/issues/4209">#4209</a>). Made the ‘template-haskell’ package non-upgradable again (<a href="https://github.com/haskell/cabal/issues/4185">#4185</a>).</p></li>
<li><p>Fixed password echoing on MinTTY (<a href="https://github.com/haskell/cabal/issues/4128">#4128</a>).</p></li>
<li><p>Added optional solver output visualisation support via the <code>tracetree</code> package (<a href="https://github.com/haskell/cabal/issues/3410">#3410</a>). Mainly intended for debugging.</p></li>
<li><p>New <code>./Setup configure</code> flag <code>--cabal-file</code>, allowing multiple .cabal files in a single directory (<a href="https://github.com/haskell/cabal/issues/3553">#3553</a>). Primarily intended for internal use.</p></li>
<li><p>Removed the <code>--check</code> option from <code>cabal upload</code> (<a href="https://github.com/haskell/cabal/issues/1823">#1823</a>). It was replaced by <a href="https://hackage.haskell.org/upload#candidates">Hackage package candidates</a>.</p></li>
<li><p>Removed the <code>--root-cmd</code> parameter of the ‘install’ command and deprecated <code>cabal install --global</code> (<a href="https://github.com/haskell/cabal/issues/3356">#3356</a>).</p></li>
<li><p>Removed the top-down solver (<a href="https://github.com/haskell/cabal/issues/3598">#3598</a>).</p></li>
<li><p>Cabal no longer supports using a version bound to disambiguate between an internal and external package (<a href="https://github.com/haskell/cabal/issues/4020">#4020</a>). This should not affect many people, as this mode of use already did not work with the dependency solver.</p></li>
<li><p>Miscellaneous minor and/or internal bug fixes and improvements.</p></li>
</ul>
<p>See the full <a href="https://github.com/haskell/cabal/blob/2.0/Cabal/changelog">Cabal 2.0</a> and <a href="https://github.com/haskell/cabal/blob/2.0/cabal-install/changelog"><code>cabal-install</code> 2.0</a> changelogs for the complete list of changes in the 2.0 release.</p>
<h2 id="acknowledgements">Acknowledgements</h2>
<p>Thanks to everyone who contributed code and bug reports. Full list of people who contributed patches to Cabal/<code>cabal-install</code> 2.0 is available <a href="https://gist.github.com/23Skidoo/7109479c43a8de44f8e29fa335e9645c">here</a>.</p>
<h2 id="looking-forward">Looking forward</h2>
<p>We plan to make a new release of Cabal/<code>cabal-install</code> before the end of the year – that is, around December 2017. We want to decouple the Cabal release cycle from the GHC one; that’ll allow us to release a new version of Cabal/<code>cabal-install</code> approximately every six months in the future. Main features that are currently targeted at the 2.2 milestone are:</p>
<ul>
<li><p>Further improvements in <code>new-build</code>, incorporating <a href="https://github.com/haskell/cabal/projects/4">work done by Francesco Gazzetta during HSOC 2017</a>. Currently we are planning to make <code>new-build</code> the default in the 3.0 release (tentative release date: Autumn 2018).</p></li>
<li><p>New Parsec-based parser for <code>.cabal</code> files, joint work by Oleg Grenrus and Duncan Coutts. Faster, less memory hungry, and easier to extend.</p></li>
<li><p><a href="https://github.com/haskell/cabal/issues/4013">A revamped homepage for Cabal</a>, <a href="https://github.com/haskell/cabal/labels/documentation">rewritten user manual</a>, and <a href="https://github.com/haskell/cabal/issues/4637">automated build bots for binary releases</a>. Help in this area would be appreciated!</p></li>
</ul>
<p>We would like to encourage people considering contributing to take a look at <a href="https://github.com/haskell/cabal/issues/">the bug tracker on GitHub</a>, take part in discussions on tickets and pull requests, or submit their own. The bug tracker is reasonably well maintained and it should be relatively clear to new contributors what is in need of attention and which tasks are considered relatively easy. Additionally, <a href="https://github.com/haskell/cabal/wiki/ZuriHac-2017">the list of potential projects from the latest hackathon</a> and the tickets marked <a href="https://github.com/haskell/cabal/issues?q=is%3Aopen+is%3Aissue+label%3A%22meta%3A+easy%22">“easy”</a> and <a href="https://github.com/haskell/cabal/issues?q=is%3Aopen+is%3Aissue+label%3Anewcomer">“newcomer”</a> can be used as a source of ideas for what to work on.</p>
<p>For more in-depth discussion there is also the <a href="https://mail.haskell.org/mailman/listinfo/cabal-devel"><code>cabal-devel</code> mailing list</a> and the <a href="https://wiki.haskell.org/IRC_channel"><code>#hackage</code> IRC channel</a> on FreeNode.</p>]]></summary>
</entry>
<entry>
    <title>What's new in Cabal 1.24 — Nix-style local builds, setup dependencies, HTTPS and more!</title>
    <link href="http://coldwa.st/e/blog/2016-05-04-Cabal-1-24.html" />
    <id>http://coldwa.st/e/blog/2016-05-04-Cabal-1-24.html</id>
    <published>2016-05-04T00:00:00Z</published>
    <updated>2016-05-04T00:00:00Z</updated>
    <summary type="html"><![CDATA[<p>We’ve just released versions 1.24 of both Cabal and <code>cabal-install</code>. The 1.24 release incorporates more than a thousand commits by <a href="https://gist.github.com/23Skidoo/62544d7e0352037749eec7344788831c">89 different contributors</a>. This post describes what’s new and improved in this version.</p>
<h2 id="user-visible-features">User-visible features</h2>
<ul>
<li><p>Nix-style local builds in <code>cabal-install</code> (so far only a technical preview). See <a href="http://blog.ezyang.com/2016/05/announcing-cabal-new-build-nix-style-local-builds/">this post</a> by Edward Z. Yang for more details.</p></li>
<li><p>Integration of a new security scheme for Hackage based on <a href="https://theupdateframework.github.io/">The Update Framework</a>. So far this is not enabled by default, pending some changes on the Hackage side. See <a href="http://www.well-typed.com/blog/2015/08/hackage-security-beta/">these</a> <a href="http://www.well-typed.com/blog/2015/07/hackage-security-alpha/">three</a> <a href="http://www.well-typed.com/blog/2015/04/improving-hackage-security/">posts</a> by Edsko de Vries and Duncan Coutts for more information.</p></li>
<li><p>Support for specifying setup script dependencies in <code>.cabal</code> files. Setup scripts are also now built with the <code>cabal_macros.h</code>-style macros for conditional compilation. See <a href="http://www.well-typed.com/blog/2015/07/cabal-setup-deps/">this post by Duncan Coutts</a> for more information.</p></li>
<li><p>Support for HTTPS downloads in <code>cabal-install</code>. HTTPS is now used by default for downloads from Hackage. This uses either <code>curl</code> or <code>wget</code> or, on Windows, PowerShell, under the hood. Install target URLs can now also use HTTPS, e.g. <code>cabal install https://example.com/foo-1.0.tar.gz</code>.</p></li>
<li><p><code>cabal upload</code> learned how to upload documentation to Hackage (<code>cabal upload --doc</code>) (<a href="https://github.com/haskell/cabal/pull/2890">#2890</a>).</p></li>
<li><p>In related news, <code>cabal haddock</code> now can generate documentation intended for uploading to Hackage (<code>cabal haddock --for-hackage</code>, <a href="https://github.com/haskell/cabal/pull/2852">#2852</a>). <code>cabal upload --doc</code> runs this command automatically if the documentation for current package hasn’t been generated yet.</p></li>
<li><p>New <code>cabal-install</code> command: <code>gen-bounds</code> for easy generation of version bounds. See <a href="http://softwaresimply.blogspot.se/2015/08/cabal-gen-bounds-easy-generation-of.html">this post by Doug Beardsley</a> for more information.</p></li>
<li><p>It’s now possible to limit the scope of <code>--allow-newer</code> to single packages in the install plan, both on the command line and in the config file. See <a href="https://github.com/haskell/cabal/issues/2756">here</a> for an example.</p></li>
<li><p>The <code>--allow-newer</code> option can be now used with <code>./Setup configure</code> (<a href="https://github.com/haskell/cabal/issues/3163">#3163</a>).</p></li>
<li><p>New <code>cabal user-config</code> subcommand: <code>init</code>, which creates a default config file in either the default location (<code>~/.cabal/config</code>) or as specified by <code>--config-file</code> (<a href="https://github.com/haskell/cabal/issues/2553">#2553</a>).</p></li>
<li><p>New config file field <code>extra-framework-dirs</code> for specifying extra locations to find OS X frameworks in (<a href="https://github.com/haskell/cabal/pull/3158">#3158</a>). Can be also specified as an argument for <code>install</code> and <code>configure</code> commands.</p></li>
<li><p><code>cabal-install</code> solver now takes information about extensions and language flavours into account (<a href="https://github.com/haskell/cabal/pull/2873">#2873</a>). The solver is now also aware of <code>pkg-config</code> constraints (<a href="https://github.com/haskell/cabal/pull/3023">#3023</a>).</p></li>
<li><p>New <code>cabal-install</code> option: <a href="https://github.com/haskell/cabal/pull/2578"><code>--offline</code></a>, which prevents <code>cabal-install</code> from downloading anything from the Internet.</p></li>
<li><p>New <code>cabal upload</code> option <a href="https://github.com/haskell/cabal/pull/2506"><code>-P</code>/<code>--password-command</code></a> for reading Hackage password from arbitrary program output.</p></li>
<li><p>New <code>--profiling-detail=$level</code> flag with a default for libraries and executables of ‘exported-functions’ and ‘toplevel-functions’ respectively (GHC’s <code>-fprof-auto-{exported,top}</code> flags) (<a href="https://github.com/haskell/cabal/issues/193">#193</a>).</p></li>
<li><p>New <code>--show-detail</code> mode: <code>--show-detail=direct</code>; like <code>streaming</code>, but allows the test program to detect that is connected to a terminal, and works reliable with a non-threaded runtime (<a href="https://github.com/haskell/cabal/issues/2911">#2911</a>, and serves as a work-around for <a href="https://github.com/haskell/cabal/issues/2398">#2398</a>)</p></li>
<li><p>Macros <code>VERSION_$pkgname</code> and <code>MIN_VERSION_$pkgname</code> are now also generated for the current package (<a href="https://github.com/haskell/cabal/pull/3235">#3235</a>).</p></li>
<li><p>The <code>builddir</code> option can now be specified via the <code>CABAL_BUILDDIR</code> environment variable and in <code>cabal.config</code> (<a href="https://github.com/haskell/cabal/issues/2484">#2484</a>).</p></li>
<li><p>Added a log file message similar to one printed by <code>make</code> when building in another directory (<a href="https://github.com/haskell/cabal/pull/2642">#2642</a>).</p></li>
</ul>
<h2 id="bug-fixes-and-minor-improvements">Bug fixes and minor improvements</h2>
<ul>
<li><p>Support for GHC 8. NB: pre-1.24 versions of Cabal won’t work with GHC 8.</p></li>
<li><p>Cabal is now aware of extra C sources generated by preprocessors (e.g. <code>c2hs</code> and <code>hsc2hs</code>) (<a href="https://github.com/haskell/cabal/pull/2467">#2467</a>).</p></li>
<li><p>Cabal now includes <code>cabal_macros.h</code> when running <code>c2hs</code> (<a href="https://github.com/haskell/cabal/pull/2600">#2600</a>).</p></li>
<li><p>C sources are now recompiled only when needed (<a href="https://github.com/haskell/cabal/pull/2601">#2601</a>).</p></li>
<li><p>Support Haddock response files to work around command-line length restrictions on Windows (<a href="https://github.com/haskell/cabal/pull/2746">#2746</a>).</p></li>
<li><p>Library support for multi-instance package DBs (<a href="https://github.com/haskell/cabal/pull/2948">#2948</a>).</p></li>
<li><p>Improvements in the <code>./Setup configure</code> solver (<a href="https://github.com/haskell/cabal/pull/3082">#3082</a>, <a href="https://github.com/haskell/cabal/pull/3076">#3076</a>).</p></li>
<li><p>If there are multiple remote repos, <code>cabal update</code> now updates them in parallel (<a href="https://github.com/haskell/cabal/pull/2503">#2503</a>).</p></li>
<li><p><code>cabal</code> program itself now can be used as an external setup method. This fixes an issue when Cabal version mismatch caused unnecessary reconfigures (<a href="https://github.com/haskell/cabal/pull/2633">#2633</a>).</p></li>
<li><p>Fixed space leaks in <code>cabal update</code> (<a href="https://github.com/haskell/cabal/pull/2826">#2826</a>) and in the solver (<a href="https://github.com/haskell/cabal/pull/2916">#2916</a>, <a href="https://github.com/haskell/cabal/pull/2914">#2914</a>). Improved performance of <code>--reorder-goals</code> (<a href="https://github.com/haskell/cabal/pull/3208">#3208</a>).</p></li>
<li><p><code>cabal exec</code> and <code>sandbox hc-pkg</code> now use the configured compiler (<a href="https://github.com/haskell/cabal/pull/2859">#2859</a>).</p></li>
<li><p>The man page for <code>cabal-install</code> is now automatically generated (<a href="https://github.com/haskell/cabal/pull/2877">#2877</a>).</p></li>
<li><p>Miscellaneous minor and/or internal bug fixes and improvements.</p></li>
</ul>
<h2 id="acknowledgements">Acknowledgements</h2>
<p>Thanks to everyone who contributed code and bug reports, and to Ryan Thomas for helping with release management. Full list of people who contributed patches to Cabal/<code>cabal-install</code> 1.24 is available <a href="https://gist.github.com/23Skidoo/62544d7e0352037749eec7344788831c">here</a>.</p>
<h2 id="looking-forward">Looking forward</h2>
<p>We plan to make a new release of Cabal/<code>cabal-install</code> approximately 6 months after 1.24 — that is, in late October or early November 2016. Main features that are currently targeted at 1.26 are:</p>
<ul>
<li><p>Further work on nix-style local builds, perhaps making that code path the default.</p></li>
<li><p>Enabling Hackage Security by default.</p></li>
<li><p>Native suport for <a href="https://github.com/haskell/cabal/pull/2540">foreign libraries</a>: Haskell libraries that are intended to be used by non-Haskell code.</p></li>
<li><p>New Parsec-based parser for <code>.cabal</code> files.</p></li>
<li><p>A revamped homepage for Cabal, rewritten user manual, and automated build bots for binary releases.</p></li>
</ul>
<p>We would like to encourage people considering contributing to take a look at <a href="https://github.com/haskell/cabal/issues/">the bug tracker on GitHub</a>, take part in discussions on tickets and pull requests, or submit their own. The bug tracker is reasonably well maintained and it should be relatively clear to new contributors what is in need of attention and which tasks are considered relatively easy. For more in-depth discussion there is also the <a href="https://mail.haskell.org/mailman/listinfo/cabal-devel"><code>cabal-devel</code> mailing list</a>.</p>]]></summary>
</entry>
<entry>
    <title>What's new in Cabal 1.18 — sandboxes, REPL, cross-compilation and more!</title>
    <link href="http://coldwa.st/e/blog/2013-08-21-Cabal-1-18.html" />
    <id>http://coldwa.st/e/blog/2013-08-21-Cabal-1-18.html</id>
    <published>2013-08-21T00:00:00Z</published>
    <updated>2013-08-21T00:00:00Z</updated>
    <summary type="html"><![CDATA[<p>The 1.18 release of Cabal is almost ready. This post describes what’s new and improved in this version.</p>
<h2 id="user-visible-features">User-visible features</h2>
<ul>
<li><p>Sandboxes - isolated environments for building packages, similar to (and inspired by) what the popular <code>cabal-dev</code> tool provides. See <a href="/blog/2013-08-20-Cabal-sandbox.html">this article</a> for a more detailed introduction.</p></li>
<li><p><code>cabal repl</code> - New command that opens an interpreter session for the given target (executable or library). Code based on patches developed during GSoC 2011 by Sam Anklesaria.</p></li>
<li><p><code>cabal get</code> - New command that replaces <code>cabal unpack</code>. When given the <code>--source-repository</code> argument (short form: <code>-s</code>) <code>cabal get</code> checks out a working copy of a given package’s source code using the appropriate revision control system.</p></li>
<li><p><code>cabal run</code> - New command that compiles and runs the given executable. Instead of <code>cabal build &amp;&amp; ./dist/build/prog/prog --args</code>, you can now use <code>cabal run prog -- --args</code>.</p></li>
<li><p>Better support for cross-compilation: target platform is now inferred by parsing compiler’s output (i.e., <code>ghc --info</code>). Packages are now installed to <code>$arch-$os-$compiler/$pkgid</code> instead of <code>$pkgid/$compiler</code> by default. (<a href="https://github.com/haskell/cabal/issues/1214">#1214</a>)</p></li>
<li><p>It’s now possible to specify a target for the <code>build</code> and <code>repl</code> commands. For example, if your package includes executables <code>foo</code> and <code>bar</code>, you can run <code>cabal build foo</code> to build only <code>foo</code> (and its dependencies). If there’s also a library or test-suite named <code>foo</code>, <code>cabal build exe:foo</code> can be used for disambiguation.</p></li>
<li><p>New <code>cabal configure</code> and config file option: <code>extra-prog-path</code>. Allows to specify a list of directories to be searched for required programs. In newly-created config files it is initialised to <code>~/.cabal/bin</code>, which should solve the common problem when <code>cabal</code> couldn’t find programs that the user have just installed (usually <code>alex</code>/<code>happy</code>/<code>c2hs</code>) because they were in a location not on <code>$PATH</code> (<a href="https://github.com/haskell/cabal/pull/1415">#1415</a>).</p></li>
<li><p>Two new config file sections: <code>program-locations</code> and <code>program-default-options</code>. This allows to specify custom paths and options for the required programs (<a href="https://github.com/haskell/cabal/issues/1328">#1328</a>).</p></li>
<li><p><code>extra-doc-files</code>: new package property for installing extra files referenced from the Haddock documentation, e.g. images (the <a href="http://hackage.haskell.org/package/lens"><code>lens</code> package</a> is a good example). (<a href="https://github.com/haskell/cabal/issues/1182">#1182</a>).</p></li>
<li><p>Support for executables with C/C++/Obj-C main functions (<a href="https://github.com/haskell/cabal/issues/1080">#1080</a>).</p></li>
<li><p><code>c-sources</code> can now depend on headers generated for Haskell FFI exports (<code>*_stub.h</code>) (<a href="https://github.com/haskell/cabal/issues/1080">#1080</a>).</p></li>
<li><p>Support for test and benchmark documentation with Haddock (<a href="https://github.com/haskell/cabal/issues/1374">#1374</a>).</p></li>
<li><p>Support for GNU AGPLv3 license (<a href="https://github.com/haskell/cabal/issues/1361">#1361</a>).</p></li>
<li><p><code>cabal test</code> and <code>cabal bench</code> now imply <code>cabal build</code>.</p></li>
<li><p>The <code>jobs</code> field in the config file is now initialised with <code>$ncpus</code>.</p></li>
<li><p><code>install --dependencies-only</code> is now a synonym for <code>install   --only-dependencies</code>.</p></li>
</ul>
<h2 id="bug-fixes-and-minor-improvements">Bug fixes and minor improvements</h2>
<ul>
<li><p>GHC 7.8 support (<a href="https://github.com/haskell/cabal/issues/1252">#1252</a>, <a href="https://github.com/haskell/cabal/issues/1384">#1384</a>).</p></li>
<li><p><code>cabal update</code> now downloads package metadata only if the server has a newer version (<a href="https://github.com/haskell/cabal/issues/799">#799</a>, <a href="https://github.com/haskell/cabal/issues/1341">#1341</a>).</p></li>
<li><p><code>cabal init</code> now generates less restrictive version bounds (<a href="https://github.com/haskell/cabal/issues/1329">#1329</a>).</p></li>
<li><p><code>cabal init</code> now can guess common types of extra-source-files (<a href="https://github.com/haskell/cabal/issues/1157">#1157</a>).</p></li>
<li><p>Absoulute paths are now passed to Haddock as proper URLs (<a href="https://github.com/haskell/cabal/issues/1064">#1064</a>, <a href="https://github.com/haskell/cabal/issues/1406">#1406</a>).</p></li>
<li><p><code>dist/build/autogen</code> dir is now included in the <code>-I</code> search list for c-sources (<a href="https://github.com/haskell/cabal/issues/1351">#1351</a>).</p></li>
<li><p>When building libraries, <code>c-sources</code> are now built separately for profiling (<a href="https://github.com/haskell/cabal/issues/1286">#1286</a>).</p></li>
<li><p>The <code>--package-db</code> flag now correctly handles relative paths (<a href="https://github.com/haskell/cabal/commit/234417c2a603d4d23222048e09cb2caa254ac755">234417c2</a>).</p></li>
<li><p>Annoying missing haddock warning for the rts package is now suppressed (<a href="https://github.com/haskell/cabal/issues/1231">#1231</a>).</p></li>
<li><p>Improved warning for old versions of HPC (<a href="https://github.com/haskell/cabal/issues/1155">#1155</a>).</p></li>
<li><p>Miscellaneous minor and/or internal bug fixes and improvements.</p></li>
</ul>
<h2 id="acknowledgements">Acknowledgements</h2>
<p>Thanks to everyone who contributed code to this release and to Johan Tibell for being the release manager.</p>]]></summary>
</entry>
<entry>
    <title>An Introduction to Cabal sandboxes</title>
    <link href="http://coldwa.st/e/blog/2013-08-20-Cabal-sandbox.html" />
    <id>http://coldwa.st/e/blog/2013-08-20-Cabal-sandbox.html</id>
    <published>2013-08-20T00:00:00Z</published>
    <updated>2013-08-20T00:00:00Z</updated>
    <summary type="html"><![CDATA[<p>This post describes sandboxes, a new feature of <code>cabal</code> that will be present in the 1.18 release. Sandboxes allow to build packages in isolation by creating a private package environment for each package. If you are familiar with Python’s virtualenv or Ruby’s RVM, this is a Haskell analogue. Though 1.18 is still not out yet, you can already experiment with the new features by building <code>cabal</code> from Git. This post is mainly aimed at people new to sandboxes – if you have already used <code>cabal-dev</code>, feel free to <a href="#for-the-users-of-cabal-dev">skip the introductory sections</a>.</p>
<h2 id="building-cabal-from-git">Building Cabal from git</h2>
<p>Assuming you already have a previous version of <code>cabal</code> installed:</p>
<pre><code>$ git clone git://github.com/haskell/cabal.git /path/to/cabal
$ cd /path/to/cabal
$ cabal install Cabal/ cabal-install/</code></pre>
<p>That’s all! Now you have the latest version of the <code>cabal</code> tool installed under <code>~/.cabal/bin</code>.</p>
<p>Alternatively, if you have only GHC (but not <code>cabal</code>) installed:</p>
<pre><code>$ git clone git://github.com/haskell/cabal.git /path/to/cabal
$ cd /path/to/cabal/Cabal
$ runhaskell Setup.hs configure
$ runhaskell Setup.hs build
$ runhaskell Setup.hs install
$ cd ../cabal-install
$ sh bootstrap.sh</code></pre>
<h2 id="what-are-sandboxes-and-why-are-they-needed">What are sandboxes and why are they needed?</h2>
<p>If you have used Haskell for some time, you’ve probably heard the expression “Cabal hell”. It refers to the fact that installing a new package with <code>cabal install</code> can break existing packages on your system.</p>
<p>The reason for this behaviour is <em>destructive reinstalls</em>. As of this writing, Cabal doesn’t support having <em>multiple instances</em> of the same version of a single package installed simultaneously (but note that installing <em>multiple versions</em> of the same package is completely fine). So how does this affect you, the user?</p>
<p>Imagine that you have installed the library <code>foo</code>, which depends on <code>bar-1.0</code>, which in turn depends on <code>baz</code> (any version):</p>
<figure>
<img src="/e/img/sandboxes-pic-0.png" title="foo-1.0 -&gt; bar-1.0 -&gt; baz-1.0;" />
</figure>
<p>After some time you then decide to install <code>quux</code>, which depends on <code>bar-1.0</code> and <code>baz-2.0</code>. Since you have only <code>baz-1.0</code> installed, you need to install <code>baz-2.0</code> and recompile <code>bar-1.0</code> against it:</p>
<figure>
<img src="/e/img/sandboxes-pic-1.png" title="quux-1.0 -&gt; bar-1.0; quux-1.0 -&gt; baz-2.0; bar -&gt; baz-2.0;" />
</figure>
<p>But since Cabal allows you to have only a single instance of <code>bar-1.0</code> installed, the package <code>foo-1.0</code> is now broken since it depends on an instance of package <code>bar-1.0</code> that was removed! Cue much weeping and gnashing of teeth:</p>
<figure>
<img src="/e/img/sandboxes-pic-2.png" title="foo-1.0 -&gt; ???; baz-1.0;" />
</figure>
<p>While we know what is the right way to fix this issue (see the <a href="#future-work">“future work”</a> section below), getting there will take time, and sandboxes present a relatively low-cost interim solution. The idea is to build each package in an isolated environment (“sandbox”) with a sandbox-local package database. Because sandboxes are per-project, we can constrain them to be internally consistent and simply prohibit such conflicts as described above.</p>
<p>Besides alleviating the “Cabal hell” problem, sandboxes are also useful when your package depends on patched or unreleased libraries.</p>
<h2 id="usage">Usage</h2>
<p>Using sandboxes is simple: if you already know how to use the <code>cabal</code> tool to build your packages, you only need to learn a few additional commands. To initialise a fresh sandbox in the current directory, run <code>cabal sandbox init</code>. All subsequent commands (such as <code>build</code> and <code>install</code>) from this point will use the sandbox.</p>
<pre><code>$ cd /path/to/my/haskell/library
$ cabal sandbox init                   # Initialise the sandbox
$ cabal install --only-dependencies    # Install dependencies into the sandbox
$ cabal build                          # Build your package inside the sandbox</code></pre>
<p>It can be useful to make a source package available for installation in the sandbox - for example, if your package depends on a patched or an unreleased version of a library. This can be done with the <code>cabal sandbox add-source</code> command - think of it as “local Hackage”. If an add-source dependency is later modified, it is reinstalled automatically.</p>
<pre><code>$ cabal sandbox add-source /my/patched/library # Add a new add-source dependency
$ cabal install --dependencies-only            # Install it into the sandbox
$ cabal build                                  # Build the local package
$ $EDITOR /my/patched/library/Source.hs        # Modify the add-source dependency
$ cabal build                                  # Modified dependency is automatically reinstalled</code></pre>
<p>Normally, the sandbox settings (such as optimisation level) are inherited from the main Cabal config file (<code>$HOME/.cabal/config</code>). Sometimes, though, you need to change some settings specifically for a single sandbox. You can do this by creating a <code>cabal.config</code> file in the same directory with your <code>cabal.sandbox.config</code> (which was created by <code>sandbox init</code>). This file has the same syntax as the main Cabal config file.</p>
<pre><code>$ cat cabal.config
documentation: True
constraints: foo == 1.0, bar &gt;= 2.0, baz
$ cabal build                                  # Uses settings from the cabal.config file</code></pre>
<p>When you have decided that you no longer want to build your package inside a sandbox, just delete it:</p>
<pre><code>$ cabal sandbox delete                       # Built-in command
$ rm -rf .cabal-sandbox cabal.sandbox.config # Alternative manual method</code></pre>
<h2 id="advanced-usage">Advanced usage</h2>
<p>The default behaviour of the <code>add-source</code> command is to track modifications done to the added dependency and reinstall the sandbox copy of the package when needed. Sometimes this is not desirable: in these cases you can use <code>add-source --snapshot</code>, which disables the change tracking. In addition to <code>add-source</code>, there are also <code>list-sources</code> and <code>delete-source</code> commands.</p>
<p>Sometimes one wants to share a single sandbox between multiple packages. This can be easily done with the <code>--sandbox</code> option:</p>
<pre><code>$ cd /path/to/shared-sandbox
$ cabal sandbox init --sandbox .
$ cd /path/to/package-a
$ cabal sandbox init --sandbox /path/to/shared-sandbox
$ cd /path/to/package-b
$ cabal sandbox init --sandbox /path/to/shared-sandbox</code></pre>
<p>Using multiple different versions of GHC simultaneously is also supported, via the <code>-w</code> option:</p>
<pre><code>$ cabal sandbox init
$ cabal install --only-dependencies -w /path/to/ghc-1 # Install dependencies for both compilers
$ cabal install --only-dependencies -w /path/to/ghc-2
$ cabal configure -w /path/to/ghc-1                   # Build with the first compiler
$ cabal build
$ cabal configure -w /path/to/ghc-2                   # Build with the second compiler
$ cabal build</code></pre>
<p>It can be occasionally useful to run the <code>ghc-pkg</code> tool on the sandbox package DB directly (for example, you may need to unregister some packages). The command <code>cabal sandbox hc-pkg</code> is a convenient wrapper for <code>ghc-pkg</code> that runs it with the appropriate <code>--package-conf</code> argument:</p>
<pre><code>$ cabal -v sandbox hc-pkg list
Using a sandbox located at /path/to/.cabal-sandbox
&#39;ghc-pkg&#39; &#39;--global&#39; &#39;--no-user-package-conf&#39;
    &#39;--package-conf=/path/to/.cabal-sandbox/i386-linux-ghc-7.4.2-packages.conf.d&#39;
    &#39;list&#39;
[...]</code></pre>
<h2 id="for-the-users-of-cabal-dev">For the users of cabal-dev</h2>
<p>The sandbox feature gives you basically the same functionality as <code>cabal-dev</code>, but integrated with the <code>cabal</code> tool itself. Here’s a handy cheatsheet for the users of <code>cabal-dev</code>:</p>
<table>
<colgroup>
<col style="width: 38%" />
<col style="width: 26%" />
<col style="width: 35%" />
</colgroup>
<thead>
<tr class="header">
<th>Action</th>
<th><code>cabal-dev</code></th>
<th><code>cabal sandbox</code></th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Initialise a sandbox</td>
<td><code>cabal-dev $ANY_COMMAND</code></td>
<td><code>cabal sandbox init</code></td>
</tr>
<tr class="even">
<td>Delete the sandbox</td>
<td><code>rm -rf ./cabal-dev</code></td>
<td><code>cabal sandbox delete</code></td>
</tr>
<tr class="odd">
<td>Link a source directory from the sandbox</td>
<td><code>N/A</code></td>
<td><code>cabal sandbox add-source</code></td>
</tr>
<tr class="even">
<td>Make a package available in the sandbox</td>
<td><code>cabal-dev add-source</code></td>
<td><code>cabal sandbox add-source --snapshot</code></td>
</tr>
<tr class="odd">
<td>Build the current package</td>
<td><code>cabal-dev build</code></td>
<td><code>cabal build</code></td>
</tr>
<tr class="even">
<td>Install a package into the sandbox</td>
<td><code>cabal-dev install $PKGNAME</code></td>
<td><code>cabal install $PKGNAME</code></td>
</tr>
<tr class="odd">
<td>Any other standard <code>cabal</code> command</td>
<td><code>cabal-dev $COMMAND</code></td>
<td><code>cabal $COMMAND</code></td>
</tr>
<tr class="even">
<td>Install dependencies of a package</td>
<td><code>cabal-dev install-deps</code></td>
<td><code>cabal install --only-dependencies</code></td>
</tr>
<tr class="odd">
<td>Run sandbox-local ghci</td>
<td><code>cabal-dev ghci</code></td>
<td><code>cabal repl</code></td>
</tr>
<tr class="even">
<td>Sandbox-restricted <code>ghc-pkg</code></td>
<td><code>cabal-dev ghc-pkg</code></td>
<td><code>cabal sandbox hc-pkg</code></td>
</tr>
<tr class="odd">
<td>Path to the sandbox directory</td>
<td><code>./cabal-dev</code></td>
<td><code>./.cabal-sandbox</code></td>
</tr>
</tbody>
</table>
<p>One important difference is that <code>add-source</code> adds a link to a source directory instead of making a source snapshot available for install. The add-source packages are reinstalled each time the sandboxed package is built. To get <code>cabal-dev</code>’s behaviour, use <code>cabal add-source --snapshot</code>.</p>
<p>Another difference is that sandboxes are constrained to be consistent - that is, destructively reinstalling a package (like in the introduction example) is not allowed. Installing multiple versions of a package is still fine.</p>
<h2 id="future-work">Future work</h2>
<p>In the future, we want to <a href="http://blog.johantibell.com/2012/03/cabal-of-my-dreams.html">make hermetic builds the default</a> - that is, the build system should work as if all build artifacts were rebuilt anew each time. Ideally, this feature would be built on top of a purely functional <a href="http://nixos.org/nixos/">Nix</a>-like package DB, which would allow to share build artifacts between different builds without worrying about the destructive update problem outlined in the introduction. Unfortunately, this is a large and a non-trivial project, although some work <a href="http://www.youtube.com/watch?v=h4QmkyN28Qs">has already been done in this direction</a>. A possible interim solution is to run each build in its own sandbox.</p>
<p>There is also a number of relatively minor UI issues with sandboxes which were postponed until the next release (1.20). For more details on this, see the <a href="https://github.com/haskell/cabal/issues?labels=&amp;milestone=21&amp;page=1&amp;state=open">Cabal bug tracker</a>.</p>
<p>Last but not least, we’re really interested in your feedback on this feature, especially in how well it works on large-scale projects.</p>
<h2 id="acknowledgements">Acknowledgements</h2>
<p>Thanks to Johan Tibell, Duncan Coutts and Andres Löh for code reviews and guidance, and to Google for paying me for working on this project during last summer. Thanks to Rogan Creswick for writing the original <code>cabal-dev</code> tool, which this work builds upon.</p>]]></summary>
</entry>
<entry>
    <title>Parallelising cabal-install: Results</title>
    <link href="http://coldwa.st/e/blog/2011-08-22-GSoC-Final.html" />
    <id>http://coldwa.st/e/blog/2011-08-22-GSoC-Final.html</id>
    <published>2011-08-22T00:00:00Z</published>
    <updated>2011-08-22T00:00:00Z</updated>
    <summary type="html"><![CDATA[<p>The <a href="http://www.google-melange.com/gsoc/project/google/gsoc2011/refold/31001">parallel cabal-install</a> GSoC project has reached the stage where it can be useful to a wider audience. This post describes the current state of the code, provides a guide to installing &amp; using it, and outlines the roadmap for the near future.</p>
<h2 id="building">Building</h2>
<p>The parallel version of <code>cabal-install</code> is available from <a href="http://darcsden.com/23Skidoo/Cabal">this Darcsden repository</a>. Since this branch contains changes to both cabal-install and the Cabal library itself, you are advised to use <a href="http://hackage.haskell.org/package/cabal-dev">cabal-dev</a> for building:</p>
<pre><code>$ darcs get http://darcsden.com/23Skidoo/Cabal
$ cd Cabal
$ cabal-dev install cabal/ cabal-install/</code></pre>
<p>This will install the new <code>cabal</code> executable to <code>./cabal-dev/bin/cabal</code>. You can then move it to the location of your choosing - for example, replacing the <code>cabal</code> executable you have in <code>$PATH</code> (don’t forget to do a backup!).</p>
<h2 id="running">Running</h2>
<p>To install packages from Hackage in parallel, just run <code>cabal install -jN</code>, where <code>N</code> is the number of “jobs”, or worker threads. You will see something like the following:</p>
<pre><code>$ cabal install -j2 transformers quickcheck
Resolving dependencies...
[1] Downloading QuickCheck-2.4.1.1...
[2] Downloading transformers-0.2.2.0...
[2] Configuring transformers-0.2.2.0...
[1] Configuring QuickCheck-2.4.1.1...
[2] Building transformers-0.2.2.0...
[2] Preprocessing library transformers-0.2.2.0...
[1] Building QuickCheck-2.4.1.1...
[1] Preprocessing library QuickCheck-2.4.1.1...
[2] [ 1 of 21] Compiling Data.Functor.Product ( Data/Functor/Product.hs,
dist/build/Data/Functor/Product.o )

...

[2] [21 of 21] Compiling Control.Monad.Trans.Writer.Strict (
Control/Monad/Trans/Writer/Strict.hs,
dist/build/Control/Monad/Trans/Writer/Strict.o )
[install] Installing library in
/home/cabal-test/.cabal/lib/transformers-0.2.2.0/ghc-7.0.4
[install] Registering transformers-0.2.2.0...

...

[1] [13 of 13] Compiling Test.QuickCheck.All ( Test/QuickCheck/All.hs,
dist/build/Test/QuickCheck/All.o )
[install] Installing library in
/home/cabal-test/.cabal/lib/QuickCheck-2.4.1.1/ghc-7.0.4
[install] Registering QuickCheck-2.4.1.1...</code></pre>
<p>Here, all output prefixed with <code>[1]</code> and <code>[2]</code> comes from the worker threads, and everything prefixed with <code>[install]</code> comes from the install thread (installation step is serialised to avoid races).</p>
<p>Additionally, you can play with the <a href="http://www.haskell.org/ghc/docs/7.0.3/html/users_guide/using-smp.html#parallel-options"><code>+RTS -N</code> option</a>, though it shouldn’t produce a noticeable speed difference.</p>
<p>A good way to stress the parallel install code is to back up your <code>~/.ghc</code> and <code>~/.cabal</code> directories and then run <code>cabal install world</code>:</p>
<pre><code># Backing up old data:
$ mv ~/.ghc ~/.ghc.bak
$ mv ~/.cabal ~/.cabal.bak

# Recreating the ~.cabal directory:
$ cabal update
$ cp ~/.cabal.bak/world ~/.cabal/

# Rebuilding the world (N = number of concurrent jobs):
$ cabal install -jN world</code></pre>
<p>If you encounter any bugs, please drop me a line in the comments or submit a bug report at the <a href="http://hackage.haskell.org/trac/hackage/newticket">Cabal bug tracker</a>.</p>
<h2 id="future-work">Future work</h2>
<p>First of all, the parallel patches need to be merged into the mainline repository, which may take some time.</p>
<p>Next, there are possibilities for improvement. Current version of the code works at the package granularity (a package is always built by a single thread), which doesn’t work so well for giant packages like <a href="http://hackage.haskell.org/package/Agda">Agda</a> and <a href="http://hackage.haskell.org/package/darcs">Darcs</a>. We can get better speedup by ditching <code>ghc --make</code> and instead compiling each module separately with <code>ghc -c</code>; the dependency graph can be extracted with <code>ghc -M</code>. This should be also integrated with the <code>build</code> command.</p>
<p>Third, there is the question of other compilers (e.g. Hugs). At the moment, only GHC is supported by the parallel install code, but it should be possible to adapt it to work with other compilers. This is not considered a top priority, though.</p>
<h2 id="acknowledgements">Acknowledgements</h2>
<p>Thanks to my mentor, <a href="http://blog.johantibell.com">Johan Tibell</a>, for code reviews and helpful comments; and to Google for sponsoring my work during the summer.</p>]]></summary>
</entry>
<entry>
    <title>GSoC 2011: Parallelising cabal-install</title>
    <link href="http://coldwa.st/e/blog/2011-06-03-GSocIntroduction.html" />
    <id>http://coldwa.st/e/blog/2011-06-03-GSocIntroduction.html</id>
    <published>2011-06-03T00:00:00Z</published>
    <updated>2011-06-03T00:00:00Z</updated>
    <summary type="html"><![CDATA[<p>This summer, I will be working on parallelising <a href="http://www.haskell.org/cabal/">cabal-install</a> under the aegis of the Google Summer of Code program. The aim of the <a href="http://socghop.appspot.com/gsoc/project/google/gsoc2011/refold/31001">project</a> is to make Cabal utilise multiple threads for running the build process (a-la <code>make -j</code>). This means that Cabal will be able to make use of those shiny multi-core processors many developers now own. While initially the unit of granularity will be the package, in the second phase of the project I plan to add support for building even single modules in parallel (which will require interaction with <code>ghc --make</code>). Until my patches are accepted into the main repo, they’ll live <a href="http://darcsden.com/23Skidoo">on Darcden</a> (not much there yet!).</p>
<figure>
<img src="/e/img/GSoC2011-Design.png" title="Thread communication in the prototype" />
</figure>
<p>While I haven’t yet done much work on modifying the cabal-install proper, I’ve produced a small <a href="https://gist.github.com/982483">prototype</a> that illustrates my approach to the problem. The prototype program consists of several threads which communicate via <a href="http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-Concurrent-Chan.html#t:Chan">Chans</a>. There are several worker threads, which compile the packages (<a href="http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-Concurrent.html#v:threadDelay">threadDelay</a> is used to simulate actual operations). A single control thread maintains the package graph and assigns tasks to the worker threads. A single logger thread prints out messages received from the worker threads. A single install thread installs the packages into the target directory (this is done serially, but can also be parallelized if deemed safe).</p>
<p>After the install thread installs a package, it notifies the controller thread, which then updates the package graph and adds new tasks for the worker threads (if possible). The control thread terminates when the last package has been installed (which leads to the termination of all other threads).</p>
<p>I still have exams until the 7th of June, but I’ve already posted <a href="http://hackage.haskell.org/trac/hackage/ticket/849">my first patch</a>. Though not directly related to the project, it helped me to smooth out some wrinkles in the workflow and get accustomed to the Darcs way of doing things.</p>]]></summary>
</entry>

</feed>
