<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"
    xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel>
        <title>GHC Developer blog</title>
        <link>http://haskell.org/ghc</link>
        <description><![CDATA[]]></description>
        <atom:link href="http://haskell.org/ghc/rss.xml" rel="self"
                   type="application/rss+xml" />
        <lastBuildDate>Fri, 23 Feb 2024 00:00:00 UT</lastBuildDate>
        <item>
    <title>GHC 9.8.2 is now available</title>
    <link>http://haskell.org/ghc/blog/20240223-ghc-9.8.2-released.html</link>
    <description><![CDATA[<h1>GHC 9.8.2 is now available</h1>
<h4 class="text-muted">Zubin Duggal - 2024-02-23</h4>

<p>The GHC developers are happy to announce the availability of GHC 9.8.2. Binary
distributions, source distributions, and documentation are available on the
<a href="/download_ghc_9_8_2.html">release page</a>.</p>
<p>This release is primarily a bugfix release addressing many issues
found in the 9.8 series. These include:</p>
<ul>
<li>A fix for a bug where certain warnings flags were not recognised (<a href="https://gitlab.haskell.org/ghc/ghc/issues/24071">#24071</a>)</li>
<li>Fixes for bugs in the renamer and typechecker (<a href="https://gitlab.haskell.org/ghc/ghc/issues/24084">#24084</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/24134">#24134</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/24279">#24279</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/24083">#24083</a>)</li>
<li>Fixes for bugs in the simplifier and code generator (<a href="https://gitlab.haskell.org/ghc/ghc/issues/24160">#24160</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/24242">#24242</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/23628">#23628</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/23659">#23659</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/24160">#24160</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/23862">#23862</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/24295">#24295</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/24370">#24370</a>)</li>
<li>Fixes for some memory leaks in GHCi (<a href="https://gitlab.haskell.org/ghc/ghc/issues/24107">#24107</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/24118">#24118</a>)</li>
<li>Improvements to error messages (<a href="https://gitlab.haskell.org/ghc/ghc/issues/21097">#21097</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/16996">#16996</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/11050">#11050</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/24196">#24196</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/24275">#24275</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/23768">#23768</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/23784">#23784</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/23778">#23778</a>)</li>
<li>A fix for a recompilation checking bug where GHC may miss changes in
transitive dependencies when deciding to relink a program (<a href="https://gitlab.haskell.org/ghc/ghc/issues/23724">#23724</a>).</li>
<li>And many more fixes</li>
</ul>
<p>A full accounting of changes can be found in the <a href="https://downloads.haskell.org/~ghc/9.8.2/docs/users_guide/9.8.2-notes.html">release notes</a>. As
some of the fixed issues do affect correctness users are encouraged to
upgrade promptly.</p>
<p>We would like to thank Microsoft Azure, GitHub, IOG, the Zw3rk stake pool,
Well-Typed, Tweag I/O, Serokell, Equinix, SimSpace, Haskell Foundation, and
other anonymous contributors whose on-going financial and in-kind support has
facilitated GHC maintenance and release management over the years. Finally,
this release would not have been possible without the hundreds of open-source
contributors whose work comprise this release.</p>
<p>As always, do give this release a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see
anything amiss.</p>
<p>Enjoy!</p>
<p>-Zubin</p>
]]></description>
    <pubDate>Fri, 23 Feb 2024 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20240223-ghc-9.8.2-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.6.4 is now available</title>
    <link>http://haskell.org/ghc/blog/20240109-ghc-9.6.4-released.html</link>
    <description><![CDATA[<h1>GHC 9.6.4 is now available</h1>
<h4 class="text-muted">Zubin Duggal - 2024-01-09</h4>

<p>The GHC developers are happy to announce the availability of GHC 9.6.4. Binary
distributions, source distributions, and documentation are available on the
<a href="/download_ghc_9_6_4.html">release page</a>.</p>
<p>This release is primarily a bugfix release addressing a few issues
found in the 9.6 series. These include:</p>
<ul>
<li>A fix for a bug where certain warnings flags were not recognised (<a href="https://gitlab.haskell.org/ghc/ghc/issues/24071">#24071</a>)</li>
<li>Fixes for a number of simplifier bugs (<a href="https://gitlab.haskell.org/ghc/ghc/issues/23952">#23952</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/23862">#23862</a>).</li>
<li>Fixes for compiler panics with certain package databases involving unusable
units and module reexports (<a href="https://gitlab.haskell.org/ghc/ghc/issues/21097">#21097</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/16996">#16996</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/11050">#11050</a>).</li>
<li>A fix for a typechecker crash (<a href="https://gitlab.haskell.org/ghc/ghc/issues/24083">#24083</a>).</li>
<li>A fix for a code generator bug on AArch64 platforms resulting in invalid
conditional jumps (<a href="https://gitlab.haskell.org/ghc/ghc/issues/23746">#23746</a>).</li>
<li>Fixes for some memory leaks in GHCi (<a href="https://gitlab.haskell.org/ghc/ghc/issues/24107">#24107</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/24118">#24118</a>)</li>
<li>And a few other fixes</li>
</ul>
<p>A full accounting of changes can be found in the <a href="https://downloads.haskell.org/~ghc/9.6.4/docs/users_guide/9.6.4-notes.html">release notes</a>. As
some of the fixed issues do affect correctness users are encouraged to
upgrade promptly.</p>
<p>We would like to thank Microsoft Azure, GitHub, IOG, the Zw3rk stake pool,
Well-Typed, Tweag I/O, Serokell, Equinix, SimSpace, Haskell Foundation, and
other anonymous contributors whose on-going financial and in-kind support has
facilitated GHC maintenance and release management over the years. Finally,
this release would not have been possible without the hundreds of open-source
contributors whose work comprise this release.</p>
<p>As always, do give this release a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see
anything amiss.</p>
<p>Enjoy!</p>
<p>-Zubin</p>
]]></description>
    <pubDate>Tue, 09 Jan 2024 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20240109-ghc-9.6.4-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.4.8 is now available</title>
    <link>http://haskell.org/ghc/blog/20231110-ghc-9.4.8-released.html</link>
    <description><![CDATA[<h1>GHC 9.4.8 is now available</h1>
<h4 class="text-muted">Zubin Duggal - 2023-11-10</h4>

<p>The GHC developers are happy to announce the availability of GHC 9.4.8. Binary
distributions, source distributions, and documentation are available on the
<a href="/download_ghc_9_4_8.html">release page</a>.</p>
<p>This release is primarily a bugfix release addressing a few issues
found in the 9.4 series. These include:</p>
<ul>
<li>A fix for a recompilation checking bug where GHC may miss changes in
transitive dependencies when deciding to relink a program (<a href="https://gitlab.haskell.org/ghc/ghc/issues/23724">#23724</a>).</li>
<li>A fix for a code generator bug on AArch64 platforms resulting in invalid
conditional jumps (<a href="https://gitlab.haskell.org/ghc/ghc/issues/23746">#23746</a>).</li>
<li>Support for <code>-split-sections</code> on Windows.</li>
<li>Enabling <code>-split-sections</code> for various Linux and Windows binary distributions,
enabling GHC to produce smaller binaries on these platforms.</li>
<li>And a few other fixes</li>
</ul>
<p>A full accounting of changes can be found in the <a href="https://downloads.haskell.org/~ghc/9.4.8/docs/users_guide/9.4.8-notes.html">release notes</a>. As
some of the fixed issues do affect correctness users are encouraged to
upgrade promptly.</p>
<p>We would like to thank Microsoft Azure, GitHub, IOG, the Zw3rk stake pool,
Well-Typed, Tweag I/O, Serokell, Equinix, SimSpace, Haskell Foundation, and
other anonymous contributors whose on-going financial and in-kind support has
facilitated GHC maintenance and release management over the years. Finally,
this release would not have been possible without the hundreds of open-source
contributors whose work comprise this release.</p>
<p>As always, do give this release a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see
anything amiss.</p>
<p>Enjoy!</p>
<p>-Bryan</p>
]]></description>
    <pubDate>Fri, 10 Nov 2023 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20231110-ghc-9.4.8-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.8.1 is now available</title>
    <link>http://haskell.org/ghc/blog/20231009-ghc-9.8.1-released.html</link>
    <description><![CDATA[<h1>GHC 9.8.1 is now available</h1>
<h4 class="text-muted">bgamari - 2023-10-09</h4>

<p>The GHC developers are very pleased to announce the availability of the
final release of GHC 9.8.1. Binary distributions, source
distributions, and documentation are available at
<a href="https://downloads.haskell.org/ghc/9.8.1">downloads.haskell.org</a>.</p>
<p>GHC 9.8 brings a number of new features and improvements, including:</p>
<ul>
<li><p>Preliminary support the <code>TypeAbstractions</code> language extension,
allowing types to be bound in type declarations <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0425-decl-invis-binders.rst">TypeAbstractions</a>.</p></li>
<li><p>Support for the <code>ExtendedLiterals</code> extension, providing syntax for
non-word-sized numeric literals in the surface language
<a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0451-sized-literals.rst">extended-literals</a></p></li>
<li><p>Improved rewrite rule matching behavior, allowing limited matching of
higher-order patterns</p></li>
<li><p>Better support for user-defined warnings by way of the <code>WARNING</code>
pragma <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0541-warning-pragmas-with-categories.rst">warnings</a></p></li>
<li><p>The introduction of the new <code>GHC.TypeError.Unsatisfiable</code>
constraint, allowing more predictable user-defined type errors
<a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0433-unsatisfiable.rst">unsatisfiable</a></p></li>
<li><p>Implementation of the export deprecation proposal, allowing module
exports to be marked with <code>DEPRECATE</code> pragmas <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0134-deprecating-exports-proposal.rst">deprecated-exports</a></p></li>
<li><p>The addition of build semaphore support for parallel compilation;
with coming support in <code>cabal-install</code> this will allow better use of
parallelism in multi-package builds <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0540-jsem.rst">jsem</a></p></li>
<li><p>More efficient representation of info table provenance information,
reducing binary sizes by over 50% in some cases when
<code>-finfo-table-map</code> is in use</p></li>
</ul>
<p>A full accounting of changes can be found in the <a href="https://downloads.haskell.org/ghc/9.8.1/docs/users_guide/9.8.1-notes.html">release notes</a>.
Plans for GHC’s future releases can be found on the <a href="https://gitlab.haskell.org/ghc/ghc/-/wikis/GHC-status">GHC Wiki</a>.</p>
<p>We would like to thank GitHub, IOG, the Zw3rk stake pool,
Well-Typed, Tweag I/O, Serokell, Equinix, SimSpace, the Haskell
Foundation, and other anonymous contributors whose on-going financial
and in-kind support has facilitated GHC maintenance and release
management over the years. Finally, this release would not have been
possible without the hundreds of open-source contributors whose work
comprise this release.</p>
<dl>
<dt>Happy compiling,</dt>
<dd>
<p>Ben</p>
</dd>
</dl>
]]></description>
    <pubDate>Mon, 09 Oct 2023 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20231009-ghc-9.8.1-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.8.1-rc1 is now available</title>
    <link>http://haskell.org/ghc/blog/20230929-ghc-9.8.1-rc1-released.html</link>
    <description><![CDATA[<h1>GHC 9.8.1-rc1 is now available</h1>
<h4 class="text-muted">bgamari - 2023-09-29</h4>

<p>The GHC developers are very pleased to announce the availability of the
release candidate of GHC 9.8.1. Binary distributions, source
distributions, and documentation are available at <a href="https://downloads.haskell.org/ghc/9.8.1-rc1">downloads.haskell.org</a>.</p>
<p>GHC 9.8 will bring a number of new features and improvements, including:</p>
<ul>
<li><p>Preliminary support the <code>TypeAbstractions</code> language extension,
allowing types to be bound in type declarations <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0425-decl-invis-binders.rst">TypeAbstractions</a>.</p></li>
<li><p>Support for the <code>ExtendedLiterals</code> extension, providing syntax for
non-word-sized numeric literals in the surface language
<a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0451-sized-literals.rst">extended-literals</a></p></li>
<li><p>Improved rewrite rule matching behavior, allowing limited matching of
higher-order patterns</p></li>
<li><p>Better support for user-defined warnings by way of the <code>WARNING</code>
pragma <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0541-warning-pragmas-with-categories.rst">warnings</a></p></li>
<li><p>The introduction of the new <code>GHC.TypeError.Unsatisfiable</code>
constraint, allowing more predictable user-defined type errors
<a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0433-unsatisfiable.rst">unsatisfiable</a></p></li>
<li><p>Implementation of the export deprecation proposal, allowing module
exports to be marked with <code>DEPRECATE</code> pragmas <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0134-deprecating-exports-proposal.rst">deprecated-exports</a></p></li>
<li><p>The addition of build semaphore support for parallel compilation;
with coming support in <code>cabal-install</code> this will allow better use of
parallelism in multi-package builds <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0540-jsem.rst">jsem</a></p></li>
<li><p>More efficient representation of info table provenance information,
reducing binary sizes by over 50% in some cases when
<code>-finfo-table-map</code> is in use</p></li>
</ul>
<p>A full accounting of changes can be found in the <a href="https://downloads.haskell.org/ghc/9.8.1-alpha4/docs/users_guide/9.8.1-notes.html">release notes</a>.
This candidate includes roughly 20 new commits relative to alpha 4,
including what we believe should be nearly the last changes to GHC’s
boot libraries. As always, GHC’s release status can be found on the GHC
Wiki <a href="https://gitlab.haskell.org/ghc/ghc/-/wikis/GHC-status">status</a>.</p>
<p>We would like to thank GitHub, IOG, the Zw3rk stake pool,
Well-Typed, Tweag I/O, Serokell, Equinix, SimSpace, the Haskell
Foundation, and other anonymous contributors whose on-going financial
and in-kind support has facilitated GHC maintenance and release
management over the years. Finally, this release would not have been
possible without the hundreds of open-source contributors whose work
comprise this release.</p>
<p>As always, do give this release a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see
anything amiss.</p>
<dl>
<dt>Happy compiling,</dt>
<dd>
<p>Ben</p>
</dd>
</dl>
]]></description>
    <pubDate>Fri, 29 Sep 2023 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20230929-ghc-9.8.1-rc1-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.6.3 is now available</title>
    <link>http://haskell.org/ghc/blog/20230925-ghc-9.6.3-released.html</link>
    <description><![CDATA[<h1>GHC 9.6.3 is now available</h1>
<h4 class="text-muted">Bryan Richter - 2023-09-25</h4>

<p>The GHC developers are happy to announce the availability of GHC 9.6.3. Binary
distributions, source distributions, and documentation are available on the
<a href="/download_ghc_9_6_3.html">release page</a>.</p>
<p>This release is primarily a bugfix release addressing a few issues
found in the 9.6 series. These include:</p>
<ul>
<li><p>Disable Polymorphic Specialisation (a performance optimisation) by default. It
was discovered that Polymorphic Specialisation as currently implemented in GHC
can lead to hard to diagnose bugs resulting in incorrect runtime results.
Users wishing to use this optimisation despite the caveats will now have to
explicitly enable the new <code>-fpolymorphic-specialisation</code> flag. For more details
see <a href="https://gitlab.haskell.org/ghc/ghc/issues/23469">#23469</a> as well as <a href="https://gitlab.haskell.org/ghc/ghc/issues/23109">#23109</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/21229">#21229</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/23445">#23445</a>.</p></li>
<li><p>Improve compile time and code generation performance when <code>-finfo-table-map</code> is
enabled (<a href="https://gitlab.haskell.org/ghc/ghc/issues/23103">#23103</a>).</p></li>
<li><p>Make the recompilation check more robust when code generation flags are
changed (<a href="https://gitlab.haskell.org/ghc/ghc/issues/23369">#23369</a>).</p></li>
<li><p>Addition of memory barriers that improve soundness on platforms with weak
memory ordering.</p></li>
<li><p>And dozens of other fixes.</p></li>
</ul>
<p>A full accounting of changes can be found in the <a href="https://downloads.haskell.org/~ghc/9.6.3/docs/users_guide/9.6.3-notes.html">release notes</a>. As
some of the fixed issues do affect correctness users are encouraged to
upgrade promptly.</p>
<p>We would like to thank Microsoft Azure, GitHub, IOG, the Zw3rk stake pool,
Well-Typed, Tweag I/O, Serokell, Equinix, SimSpace, Haskell Foundation, and
other anonymous contributors whose on-going financial and in-kind support has
facilitated GHC maintenance and release management over the years. Finally,
this release would not have been possible without the hundreds of open-source
contributors whose work comprise this release.</p>
<p>As always, do give this release a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see
anything amiss.</p>
<p>Enjoy!</p>
<p>-Bryan</p>
]]></description>
    <pubDate>Mon, 25 Sep 2023 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20230925-ghc-9.6.3-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.8.1-alpha4 is now available</title>
    <link>http://haskell.org/ghc/blog/20230919-ghc-9.8.1-alpha4-released.html</link>
    <description><![CDATA[<h1>GHC 9.8.1-alpha4 is now available</h1>
<h4 class="text-muted">bgamari - 2023-09-19</h4>

<p>The GHC developers are very pleased to announce the availability of the
fourth alpha prerelease of GHC 9.8.1. Binary distributions, source
distributions, and documentation are available at <a href="https://downloads.haskell.org/ghc/9.8.1-alpha4">downloads.haskell.org</a>.</p>
<p>GHC 9.8 will bring a number of new features and improvements, including:</p>
<ul>
<li><p>Preliminary support the <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0425-decl-invis-binders.rst"><code>TypeAbstractions</code> language extension</a>,
allowing types to be bound in type declarations.</p></li>
<li><p>Support for the <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0451-sized-literals.rst"><code>ExtendedLiterals</code> extension</a>, providing
more consistent support for non-word-sized numeric literals in the surface
language</p></li>
<li><p>Improved rewrite rule matching behavior, allowing limited matching of
higher-order patterns</p></li>
<li><p>Better support for user-defined warnings by way of the <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0541-warning-pragmas-with-categories.rst"><code>WARNING</code>
pragma</a></p></li>
<li><p>The introduction of the new <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0433-unsatisfiable.rst"><code>GHC.TypeError.Unsatisfiable</code></a>
constraint, allowing more predictable user-defined type errors</p></li>
<li><p>Implementation of the <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0134-deprecating-exports-proposal.rst">export deprecation proposal</a>,
allowing module exports to be marked with <code>DEPRECATE</code> pragmas</p></li>
<li><p>The addition of <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0540-jsem.rst">build semaphore support</a> for parallel compilation,
allowing better use of parallelism across GHC builds</p></li>
<li><p>More efficient representation of info table provenance information,
reducing binary sizes by nearly 80% in some cases when
<code>-finfo-table-map</code> is in use</p></li>
</ul>
<p>A full accounting of changes can be found in the <a href="https://downloads.haskell.org/ghc/9.8.1-alpha4/docs/users_guide/9.8.1-notes.html">release notes</a>. This alpha
includes roughly 40 new commits relative to alpha 3, including what we believe
should be nearly the last changes to GHC’s boot libraries.</p>
<p>We would like to thank GitHub, IOG, the Zw3rk stake pool,
Well-Typed, Tweag I/O, Serokell, Equinix, SimSpace, the Haskell
Foundation, and other anonymous contributors whose on-going financial
and in-kind support has facilitated GHC maintenance and release
management over the years. Finally, this release would not have been
possible without the hundreds of open-source contributors whose work
comprise this release.</p>
<p>As always, do give this release a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see
anything amiss.</p>
]]></description>
    <pubDate>Tue, 19 Sep 2023 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20230919-ghc-9.8.1-alpha4-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.4.7 is now available</title>
    <link>http://haskell.org/ghc/blog/20230825-ghc-9.4.7-released.html</link>
    <description><![CDATA[<h1>GHC 9.4.7 is now available</h1>
<h4 class="text-muted">Zubin Duggal - 2023-08-25</h4>

<p>The GHC developers are happy to announce the availability of GHC 9.4.7. Binary
distributions, source distributions, and documentation are available at
<a href="https://downloads.haskell.org/ghc/9.4.7">downloads.haskell.org</a>.</p>
<p>This release is primarily a bugfix release addressing some issues
found in 9.4.7. These include:</p>
<ul>
<li>A bump to bytestring-0.11.5.2 allowing GHC to be bootstrapped on
systems where the bootstrap compiler is built with the <code>pthread_condattr_setclock</code>
symbol available (<a href="https://gitlab.haskell.org/ghc/ghc/issues/23789">#23789</a>).</li>
<li>A number of bug fixes for scoping bugs in the specialiser, preventing
simplifier panics (<a href="https://gitlab.haskell.org/ghc/ghc/issues/21391">#21391</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/21689">#21689</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/21828">#21828</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/23762">#23762</a>).</li>
<li>Distributing dynamically linked alpine bindists (<a href="https://gitlab.haskell.org/ghc/ghc/issues/23349">#23349</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/23828">#23828</a>).</li>
<li>A bug fix for the release notes syntax, allowing them to built on
systems with older python and sphinx versions (<a href="https://gitlab.haskell.org/ghc/ghc/issues/23807">#23807</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/23818">#23818</a>).</li>
<li>… and a few more. See the <a href="https://downloads.haskell.org/~ghc/9.4.7/docs/users_guide/9.4.7-notes.html">release notes</a> for a full accounting.</li>
</ul>
<p>We would like to thank Microsoft Azure, GitHub, IOG, the Zw3rk stake pool,
Well-Typed, Tweag I/O, Serokell, Equinix, SimSpace, Haskell Foundation, and
other anonymous contributors whose on-going financial and in-kind support has
facilitated GHC maintenance and release management over the years. Finally,
this release would not have been possible without the hundreds of open-source
contributors whose work comprise this release.</p>
<p>As always, do give this release a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see
anything amiss.</p>
<p>Happy compiling,</p>
<ul>
<li>Zubin</li>
</ul>
]]></description>
    <pubDate>Fri, 25 Aug 2023 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20230825-ghc-9.4.7-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.8.1-alpha3 is now available</title>
    <link>http://haskell.org/ghc/blog/20230823-ghc-9.8.1-alpha3-released.html</link>
    <description><![CDATA[<h1>GHC 9.8.1-alpha3 is now available</h1>
<h4 class="text-muted">bgamari - 2023-08-23</h4>

<p>The GHC developers are very pleased to announce the availability of the
third alpha prerelease of GHC 9.8.1. Binary distributions, source
distributions, and documentation are available at <a href="https://downloads.haskell.org/ghc/9.8.1-alpha3">downloads.haskell.org</a>.</p>
<p>GHC 9.8 will bring a number of new features and improvements, including:</p>
<ul>
<li><p>Preliminary support the <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0425-decl-invis-binders.rst"><code>TypeAbstractions</code> language extension</a>,
allowing types to be bound in type declarations.</p></li>
<li><p>Support for the <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0451-sized-literals.rst"><code>ExtendedLiterals</code> extension</a>, providing
more consistent support for non-word-sized numeric literals in the surface
language</p></li>
<li><p>Improved rewrite rule matching behavior, allowing limited matching of
higher-order patterns</p></li>
<li><p>Better support for user-defined warnings by way of the <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0541-warning-pragmas-with-categories.rst"><code>WARNING</code>
pragma</a></p></li>
<li><p>The introduction of the new <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0433-unsatisfiable.rst"><code>GHC.TypeError.Unsatisfiable</code></a>
constraint, allowing more predictable user-defined type errors</p></li>
<li><p>Implementation of the <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0134-deprecating-exports-proposal.rst">export deprecation proposal</a>,
allowing module exports to be marked with <code>DEPRECATE</code> pragmas</p></li>
<li><p>The addition of <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0540-jsem.rst">build semaphore support</a> for parallel compilation,
allowing better use of parallelism across GHC builds</p></li>
<li><p>More efficient representation of info table provenance information,
reducing binary sizes by nearly 80% in some cases when
<code>-finfo-table-map</code> is in use</p></li>
</ul>
<p>A full accounting of changes can be found in the <a href="https://downloads.haskell.org/ghc/9.8.1-alpha3/docs/users_guide/9.8.1-notes.html">release notes</a>. This alpha
includes roughly a dozen changes relative to alpha 2, including what we believe
should be nearly the last changes to GHC’s boot libraries.</p>
<p>We would like to thank GitHub, IOG, the Zw3rk stake pool,
Well-Typed, Tweag I/O, Serokell, Equinix, SimSpace, the Haskell
Foundation, and other anonymous contributors whose on-going financial
and in-kind support has facilitated GHC maintenance and release
management over the years. Finally, this release would not have been
possible without the hundreds of open-source contributors whose work
comprise this release.</p>
<p>As always, do give this release a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see
anything amiss.</p>
]]></description>
    <pubDate>Wed, 23 Aug 2023 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20230823-ghc-9.8.1-alpha3-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.8.1-alpha2 is now available</title>
    <link>http://haskell.org/ghc/blog/20230809-ghc-9.8.1-alpha2-released.html</link>
    <description><![CDATA[<h1>GHC 9.8.1-alpha2 is now available</h1>
<h4 class="text-muted">bgamari - 2023-08-09</h4>

<p>The GHC developers are very pleased to announce the availability of the
second alpha prerelease of GHC 9.8.1. Binary distributions, source
distributions, and documentation are available at <a href="https://downloads.haskell.org/ghc/9.8.1-alpha2">downloads.haskell.org</a>.</p>
<p>GHC 9.8 will bring a number of new features and improvements, including:</p>
<ul>
<li><p>Preliminary support the <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0425-decl-invis-binders.rst"><code>TypeApplications</code> language extension</a>,
allowing types to be bound in type declarations.</p></li>
<li><p>Support for the <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0451-sized-literals.rst"><code>ExtendedLiterals</code> extension</a>, providing
more consistent support for non-word-sized numeric literals in the surface
language</p></li>
<li><p>Improved rewrite rule matching behavior, allowing limited matching of
higher-order patterns</p></li>
<li><p>Better support for user-defined warnings by way of the <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0541-warning-pragmas-with-categories.rst"><code>WARNING</code>
pragma</a></p></li>
<li><p>The introduction of the new <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0433-unsatisfiable.rst"><code>GHC.TypeError.Unsatisfiable</code></a>
constraint, allowing more predictable user-defined type errors</p></li>
<li><p>Implementation of the <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0134-deprecating-exports-proposal.rst">export deprecation proposal</a>,
allowing module exports to be marked with <code>DEPRECATE</code> pragmas</p></li>
<li><p>The addition of <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0540-jsem.rst">build semaphore support</a> for parallel compilation,
allowing better use of parallelism across GHC builds</p></li>
<li><p>More efficient representation of info table provenance information,
reducing binary sizes by nearly 80% in some cases when
<code>-finfo-table-map</code> is in use</p></li>
</ul>
<p>A full accounting of changes can be found in the <a href="https://downloads.haskell.org/ghc/9.8.1-alpha2/docs/users_guide/9.8.1-notes.html">release notes</a>.
This alpha includes roughly two dozen bug-fixes relative to alpha 1.</p>
<p>We would like to thank GitHub, IOG, the Zw3rk stake pool,
Well-Typed, Tweag I/O, Serokell, Equinix, SimSpace, the Haskell
Foundation, and other anonymous contributors whose on-going financial
and in-kind support has facilitated GHC maintenance and release
management over the years. Finally, this release would not have been
possible without the hundreds of open-source contributors whose work
comprise this release.</p>
<p>As always, do give this release a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see
anything amiss.</p>
]]></description>
    <pubDate>Wed, 09 Aug 2023 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20230809-ghc-9.8.1-alpha2-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.4.6 is now available</title>
    <link>http://haskell.org/ghc/blog/20230807-ghc-9.4.6-released.html</link>
    <description><![CDATA[<h1>GHC 9.4.6 is now available</h1>
<h4 class="text-muted">Zubin Duggal - 2023-08-07</h4>

<p>The GHC developers are happy to announce the availability of GHC 9.4.6. Binary
distributions, source distributions, and documentation are available at
<a href="https://downloads.haskell.org/ghc/9.4.6">downloads.haskell.org</a>.</p>
<p>This release is primarily a bugfix release addressing some issues
found in 9.4.6. These include:</p>
<ul>
<li>Many bug fixes for the simplifier, preventing compiler panics, loops and
incorrect code generation (<a href="https://gitlab.haskell.org/ghc/ghc/issues/22761">#22761</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22549">#22549</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/23208">#23208</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22761">#22761</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22272">#22272</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/23146">#23146</a>,
<a href="https://gitlab.haskell.org/ghc/ghc/issues/23012">#23012</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22547">#22547</a>).</li>
<li>Bug fixes for the typechecker involving newtype family instances, making
type equalities more robust and bugs having to do with defaulting representation
polymorphic type variables (<a href="https://gitlab.haskell.org/ghc/ghc/issues/23329">#23329</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/23333">#23333</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/23143">#23143</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/23154">#23154</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/23176">#23176</a>).</li>
<li>Some bug fixes for code generation, particularly on the aarch64 backend,
including adding more memory barriers for array read operations (<a href="https://gitlab.haskell.org/ghc/ghc/issues/23541">#23541</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/23749">#23749</a>).</li>
<li>Some bug fixes for windows builds, ensuring the reliablility of IO manager shutdown
and a bug fix for the RTS linker on windows (<a href="https://gitlab.haskell.org/ghc/ghc/issues/23691">#23691</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22941">#22941</a>).</li>
<li>A bug fix for the non-moving GC ensuring mutator allocations are properly
accounted for (<a href="https://gitlab.haskell.org/ghc/ghc/issues/23312">#23312</a>).</li>
<li>A bug fix preventing some segfaults by ensuring that pinned allocations respect
block size (<a href="https://gitlab.haskell.org/ghc/ghc/issues/23400">#23400</a>).</li>
<li>Many bug fixes for the bytecode interpreter, allowing a greater subset
of the language to be interpreted (<a href="https://gitlab.haskell.org/ghc/ghc/issues/22376">#22376</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22840">#22840</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22051">#22051</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/21945">#21945</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/23068">#23068</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22958">#22958</a>).</li>
<li>… and a few more. See the <a href="https://downloads.haskell.org/~ghc/9.4.6/docs/users_guide/9.4.6-notes.html">release notes</a> for a full accounting.</li>
</ul>
<p>As some of the fixed issues do affect correctness users are encouraged to
upgrade promptly.</p>
<p>We would like to thank Microsoft Azure, GitHub, IOG, the Zw3rk stake pool,
Well-Typed, Tweag I/O, Serokell, Equinix, SimSpace, Haskell Foundation, and
other anonymous contributors whose on-going financial and in-kind support has
facilitated GHC maintenance and release management over the years. Finally,
this release would not have been possible without the hundreds of open-source
contributors whose work comprise this release.</p>
<p>As always, do give this release a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see
anything amiss.</p>
<p>Happy compiling,</p>
<ul>
<li>Zubin</li>
</ul>
]]></description>
    <pubDate>Mon, 07 Aug 2023 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20230807-ghc-9.4.6-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.8.1-alpha1 is now available</title>
    <link>http://haskell.org/ghc/blog/20230727-ghc-9.8.1-alpha1-released.html</link>
    <description><![CDATA[<h1>GHC 9.8.1-alpha1 is now available</h1>
<h4 class="text-muted">bgamari - 2023-07-27</h4>

<p>The GHC developers are very pleased to announce the availability of the
first alpha prerelease of GHC 9.8.1. Binary distributions, source
distributions, and documentation are available at <a href="https://downloads.haskell.org/ghc/9.8.1-alpha1">downloads.haskell.org</a>.</p>
<p>GHC 9.8 will bring a number of new features and improvements, including:</p>
<ul>
<li><p>Preliminary support the <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0425-decl-invis-binders.rst"><code>TypeAbstractions</code> language extension</a>,
allowing types to be bound in type declarations.</p></li>
<li><p>Support for the <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0451-sized-literals.rst"><code>ExtendedLiterals</code></a> extension, providing syntax for
non-word-sized numeric literals in the surface language</p></li>
<li><p>Improved rewrite rule matching behavior, allowing limited matching of
higher-order patterns</p></li>
<li><p>Better support for user-defined warnings by way of the <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0541-warning-pragmas-with-categories.rst"><code>WARNING</code> pragma</a></p></li>
<li><p>The introduction of the new <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0433-unsatisfiable.rst"><code>GHC.TypeError.Unsatisfiable</code></a>
constraint, allowing more predictable user-defined type errors</p></li>
<li><p>Implementation of the <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0134-deprecating-exports-proposal.rst">export deprecation proposal</a>, allowing module
exports to be marked with <code>DEPRECATE</code> pragmas</p></li>
<li><p>The addition of <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0540-jsem.rst">build semaphore support</a> for parallel compilation;
with coming support in <code>cabal-install</code> this will allow better use of
parallelism in multi-package builds</p></li>
<li><p>More efficient representation of info table provenance information,
reducing binary sizes by over 50% in some cases when
<code>-finfo-table-map</code> is in use</p></li>
</ul>
<p>A full accounting of changes can be found in the <a href="https://downloads.haskell.org/ghc/9.8.1-alpha1/docs/users_guide/9.8.1-notes.html">release notes</a>.</p>
<p>We would like to thank GitHub, IOG, the Zw3rk stake pool,
Well-Typed, Tweag I/O, Serokell, Equinix, SimSpace, the Haskell
Foundation, and other anonymous contributors whose on-going financial
and in-kind support has facilitated GHC maintenance and release
management over the years. Finally, this release would not have been
possible without the hundreds of open-source contributors whose work
comprise this release.</p>
<p>As always, do give this release a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see
anything amiss.</p>
]]></description>
    <pubDate>Thu, 27 Jul 2023 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20230727-ghc-9.8.1-alpha1-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.2.8 is now available</title>
    <link>http://haskell.org/ghc/blog/20230526-ghc-9.2.8-released.html</link>
    <description><![CDATA[<h1>GHC 9.2.8 is now available</h1>
<h4 class="text-muted">Zubin Duggal - 2023-05-26</h4>

<p>The GHC developers are happy to announce the availability of GHC 9.2.8. Binary
distributions, source distributions, and documentation are available at
<a href="https://downloads.haskell.org/ghc/9.2.8">downloads.haskell.org</a>.</p>
<p>This release is primarily a bugfix release addressing one issue
found in 9.2.7:</p>
<ul>
<li>Fix a bug with RTS linker failing with ‘internal error: m32_allocator_init:
Failed to map’ on newer Linux kernels (<a href="https://gitlab.haskell.org/ghc/ghc/issues/19421">#19421</a>).</li>
</ul>
<p>We would like to thank Microsoft Azure, GitHub, IOG, the Zw3rk stake pool,
Well-Typed, Tweag I/O, Serokell, Equinix, SimSpace, Haskell Foundation, and
other anonymous contributors whose on-going financial and in-kind support has
facilitated GHC maintenance and release management over the years. Finally,
this release would not have been possible without the hundreds of open-source
contributors whose work comprise this release.</p>
<p>As always, do give this release a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see
anything amiss.</p>
<p>Happy compiling,</p>
<ul>
<li>Zubin</li>
</ul>
]]></description>
    <pubDate>Fri, 26 May 2023 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20230526-ghc-9.2.8-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.6.2 is now available</title>
    <link>http://haskell.org/ghc/blog/20230523-ghc-9.6.2-released.html</link>
    <description><![CDATA[<h1>GHC 9.6.2 is now available</h1>
<h4 class="text-muted">Ben Gamari - 2023-05-23</h4>

<p>The GHC developers are happy to announce the availability of GHC 9.6.2. Binary
distributions, source distributions, and documentation are available at
<a href="https://downloads.haskell.org/ghc/9.6.2">downloads.haskell.org</a>.</p>
<p>This release is primarily a bugfix release addressing a few issues
found in 9.6.2. These include:</p>
<ul>
<li><p>a number of simplifier and specialisation issues (<a href="https://gitlab.haskell.org/ghc/ghc/issues/22761">#22761</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22549">#22549</a>)</p></li>
<li><p>A bug resulting in crashes of programs using the new <code>listThreads#</code> primop
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/23071">#23071</a>).</p></li>
<li><p>A compiler crash triggered by certain uses of quantified constraints
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/23171">#23171</a>)</p></li>
<li><p>Various bugs in the Javascript backend have been fixed (<a href="https://gitlab.haskell.org/ghc/ghc/issues/23399">#23399</a>,
<a href="https://gitlab.haskell.org/ghc/ghc/issues/23360">#23360</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/23346">#23346</a>)</p></li>
<li><p>A missing write barrier in the non-moving collector’s handling of selector
thunks, resulting in undefined behavior (<a href="https://gitlab.haskell.org/ghc/ghc/issues/22930">#22930</a>).</p></li>
<li><p>The non-moving garbage collector’s treatment of weak pointers has been
revamped which should allow more reliable finalization of <code>Weak#</code>
closures (<a href="https://gitlab.haskell.org/ghc/ghc/issues/22327">#22327</a>)</p></li>
<li><p>The non-moving garbage collector now bounds the amount of marking it will
do during the post-marking stop-the-world phase, greatly reducing tail
latencies in some programs (<a href="https://gitlab.haskell.org/ghc/ghc/issues/22929">#22929</a>)</p></li>
</ul>
<p>A full accounting of changes can be found in the <a href="https://downloads.haskell.org/~ghc/9.6.2/docs/users_guide/9.6.2-notes.html">release notes</a>. As
some of the fixed issues do affect correctness users are encouraged to
upgrade promptly.</p>
<p>We would like to thank Microsoft Azure, GitHub, IOG, the Zw3rk stake pool,
Well-Typed, Tweag I/O, Serokell, Equinix, SimSpace, Haskell Foundation, and
other anonymous contributors whose on-going financial and in-kind support has
facilitated GHC maintenance and release management over the years. Finally,
this release would not have been possible without the hundreds of open-source
contributors whose work comprise this release.</p>
<p>As always, do give this release a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see
anything amiss.</p>
<p>Happy compiling,</p>
<ul>
<li>Ben</li>
</ul>
]]></description>
    <pubDate>Tue, 23 May 2023 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20230523-ghc-9.6.2-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.4.5 is now available</title>
    <link>http://haskell.org/ghc/blog/20230418-ghc-9.4.5-released.html</link>
    <description><![CDATA[<h1>GHC 9.4.5 is now available</h1>
<h4 class="text-muted">Zubin Duggal - 2023-04-18</h4>

<p>The GHC developers are happy to announce the availability of GHC 9.4.5. Binary
distributions, source distributions, and documentation are available at
<a href="https://downloads.haskell.org/ghc/9.4.5">downloads.haskell.org</a>.</p>
<p>This release is primarily a bugfix release addressing a few issues
found in 9.4.4. These include:</p>
<ul>
<li>Fixes for a number of bug fixes in the simplifier (<a href="https://gitlab.haskell.org/ghc/ghc/issues/22623">#22623</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22718">#22718</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22913">#22913</a>, 22695,
<a href="https://gitlab.haskell.org/ghc/ghc/issues/23184">#23184</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22998">#22998</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22662">#22662</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22725">#22725</a>).</li>
<li>Many bug fixes to the non-moving and parallel GCs (<a href="https://gitlab.haskell.org/ghc/ghc/issues/22264">#22264</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22327">#22327</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22926">#22926</a>,
<a href="https://gitlab.haskell.org/ghc/ghc/issues/22927">#22927</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22929">#22929</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22930">#22930</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/17574">#17574</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/21840">#21840</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22528">#22528</a>)</li>
<li>A fix a bug with the alignment of RTS data structures that could result in
segfaults when compiled with high optimisation settings on certain platforms
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/22975">#22975</a> , <a href="https://gitlab.haskell.org/ghc/ghc/issues/22965">#22965</a>).</li>
<li>Bumping <code>gmp-tarballs</code> to a version which doesn’t use the reserved <code>x18</code>
register on AArch64/Darwin systems, and also has fixes for CVE-2021-43618
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/22497">#22497</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22789">#22789</a>).</li>
<li>A number of improvements to recompilation avoidance with multiple home units
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/22675">#22675</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22677">#22677</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22669">#22669</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22678">#22678</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22679">#22679</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22680">#22680</a>)</li>
<li>Fixes for regressions in the typechecker and constraint solver (<a href="https://gitlab.haskell.org/ghc/ghc/issues/22647">#22647</a>,
<a href="https://gitlab.haskell.org/ghc/ghc/issues/23134">#23134</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22516">#22516</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22743">#22743</a>)</li>
<li>Easier installation of binary distribution on MacOS platforms by changing the
installation Makefile to remove the quarantine attribute when installing.</li>
<li>… and many more. See the <a href="https://downloads.haskell.org/~ghc/9.4.5/docs/users_guide/9.4.5-notes.html">release notes</a> for a full accounting.</li>
</ul>
<p>As some of the fixed issues do affect correctness users are encouraged to
upgrade promptly.</p>
<p>We would like to thank Microsoft Azure, GitHub, IOG, the Zw3rk stake pool,
Well-Typed, Tweag I/O, Serokell, Equinix, SimSpace, Haskell Foundation, and
other anonymous contributors whose on-going financial and in-kind support has
facilitated GHC maintenance and release management over the years. Finally,
this release would not have been possible without the hundreds of open-source
contributors whose work comprise this release.</p>
<p>As always, do give this release a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see
anything amiss.</p>
<p>Happy compiling,</p>
<ul>
<li>Zubin</li>
</ul>
]]></description>
    <pubDate>Tue, 18 Apr 2023 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20230418-ghc-9.4.5-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.6.1 is now available</title>
    <link>http://haskell.org/ghc/blog/20230310-ghc-9.6.1-released.html</link>
    <description><![CDATA[<h1>GHC 9.6.1 is now available</h1>
<h4 class="text-muted">bgamari - 2023-03-10</h4>

<p>The GHC team is very pleased to announce the availability of GHC 9.6.1.
As usual, binaries and source distributions are available at
<a href="https://downloads.haskell.org/ghc/9.6.1/">downloads.haskell.org</a>.</p>
<p>Beginning with GHC 9.6.1, GHC can be built as a cross-compiler to
WebAssembly and JavaScript. This is an important step towards robust
support for compiling Haskell to the Web, but there are a few caveats to be
aware of in the 9.6 series:</p>
<ul>
<li><p>Both the Javascript and WebAssembly backends are still at an early
stage of development and are present in this release as a technology preview</p></li>
<li><p>Using GHC as a cross-compiler is not as easy as we would like it to
be; in particular, there are challenges related to Template Haskell</p></li>
<li><p>GHC is not yet run-time retargetable; a given GHC binary targets
exactly one platform, and both WebAssembly and JavaScript are considered
platforms for this purpose. Cross-compilers must be built from source by
their users</p></li>
</ul>
<p>We hope to lift all of these limitations in future releases.</p>
<p>Additionally, 9.6.1 includes:</p>
<ul>
<li><p>Significant latency improvements in the non-moving garbage collector</p></li>
<li><p>Efficient runtime support for delimited continuations</p></li>
<li><p>Improvements in compiler error messages</p></li>
<li><p>Numerous improvements in the compiler’s memory usage</p></li>
</ul>
<p>See the <a href="https://downloads.haskell.org/ghc/9.6.1/docs/users_guide/9.6.1-notes.html">release notes</a> for a comprehensive accounting of changes in this
release.</p>
<p>As always, one can find a migration guide to aid in transitioning from older
releases on the <a href="https://gitlab.haskell.org/ghc/ghc/-/wikis/migration/9.6">GHC Wiki</a>. We have also recently started
extending our release process to cover a wider set of Linux distributions. In
particular, we now offer Rocky 8 and Ubuntu 20.04 binary distributions which
cover RedHat-derivative and distributions using older <code>glibc</code> releases (namely
2.27), respectively.</p>
<p>Thanks to everyone who has contributed code, documentation, testing, and
tickets to this release process. As this release represents upstream GHC’s
first step towards supporting web targets, we are very excited to have this
release out the door!</p>
<p>Cheers,</p>
<ul>
<li>Ben</li>
</ul>
]]></description>
    <pubDate>Fri, 10 Mar 2023 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20230310-ghc-9.6.1-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.6.1-rc1 is now available</title>
    <link>http://haskell.org/ghc/blog/20230303-ghc-9.6.1-rc1-released.html</link>
    <description><![CDATA[<h1>GHC 9.6.1-rc1 is now available</h1>
<h4 class="text-muted">bgamari - 2023-03-03</h4>

<p>The GHC team is very pleased to announce the availability of the first (and
likely final) release candidate of GHC 9.6.1.
As usual, binaries and source distributions are available at
<a href="https://downloads.haskell.org/ghc/9.6.1-rc1/">downloads.haskell.org</a>.</p>
<p>Beginning with GHC 9.6.1, GHC can be built as a cross-compiler to
WebAssembly and JavaScript. This is an important step towards robust
support for compiling Haskell to the Web, but there are a few caveats to be
aware of in the 9.6 series:</p>
<ul>
<li><p>Both the Javascript and WebAssembly backends are still at an early
stage of development and are present in this release as a technology preview</p></li>
<li><p>Using GHC as a cross-compiler is not as easy as we would like it to
be; in particular, there are challenges related to Template Haskell</p></li>
<li><p>GHC is not yet run-time retargetable; a given GHC binary targets
exactly one platform, and both WebAssembly and JavaScript are considered
platforms for this purpose. Cross-compilers must be built from source by
their users</p></li>
</ul>
<p>We hope to lift all of these limitations in future releases.</p>
<p>Additionally, 9.6.1 will include:</p>
<ul>
<li><p>Significant latency improvements in the non-moving garbage collector</p></li>
<li><p>Efficient runtime support for delimited continuations</p></li>
<li><p>Improvements in compiler error messages</p></li>
<li><p>Numerous improvements in the compiler’s memory usage</p></li>
</ul>
<p>See the <a href="https://downloads.haskell.org/ghc/9.6.1-rc1/docs/users_guide/9.6.1-notes.html">release notes</a> for a comprehensive accounting of changes in this
release.</p>
<p>As always, one can find a migration guide to aid in transitioning from older
releases on the <a href="https://gitlab.haskell.org/ghc/ghc/-/wikis/migration/9.6">GHC Wiki</a>. We have also recently started
extending our release process to cover a wider set of Linux distributions. In
particular, we now offer Rocky 8 and Ubuntu 20.04 binary distributions which
cover RedHat-derivative and distributions using older <code>glibc</code> releases (namely
2.27), respectively.</p>
<p>Please do give this release a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/issues/">ticket</a> if you see anything
amiss. If all goes well we expect the final release should be available by late
next week.</p>
<p>Cheers,</p>
<ul>
<li>Ben</li>
</ul>
]]></description>
    <pubDate>Fri, 03 Mar 2023 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20230303-ghc-9.6.1-rc1-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.2.7 is now available</title>
    <link>http://haskell.org/ghc/blog/20230227-ghc-9.2.7-released.html</link>
    <description><![CDATA[<h1>GHC 9.2.7 is now available</h1>
<h4 class="text-muted">Zubin Duggal - 2023-02-27</h4>

<p>The GHC developers are happy to announce the availability of GHC 9.2.7. Binary
distributions, source distributions, and documentation are available at
<a href="https://downloads.haskell.org/ghc/9.2.7">downloads.haskell.org</a>.</p>
<p>This release is primarily a bugfix release addressing a few issues
found in 9.2.6. These include:</p>
<ul>
<li>A fix for a bug with the RTS linker being unable to resolve the <code>setKeepCafs</code>
symbol which started being used by the GHC library in 9.2.6, resulting in
code depending on this symbol failing to load in GHCi or via a compile time
splice when using a statically linked GHC, such as on Windows (<a href="https://gitlab.haskell.org/ghc/ghc/issues/22961">#22961</a>).</li>
<li>A fix a bug with the alignment of RTS data structures that could result in
segfaults when compiled with high optimisation settings on certain platforms
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/22975">#22975</a> , <a href="https://gitlab.haskell.org/ghc/ghc/issues/22965">#22965</a>).</li>
<li>A fix for a bug in the simplifier related to placeholder values (rubbish
literals) emitted by the worker/wrapper optimisation leading to -dcore-lint
errors and compiler panics in certain cases (<a href="https://gitlab.haskell.org/ghc/ghc/issues/19882">#19882</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22914">#22914</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/23000">#23000</a>).</li>
<li>Easier installation of binary distribution on MacOS platforms by changing the
installation Makefile to remove the quarantine attribute when installing.</li>
<li>… and a few more. See the <a href="https://downloads.haskell.org/~ghc/9.2.7/docs/html/users_guide/9.2.7-notes.html">release notes</a> for a full accounting.</li>
</ul>
<p>As some of the fixed issues do affect correctness users are encouraged to
upgrade promptly.</p>
<p>We would like to thank Microsoft Azure, GitHub, IOG, the Zw3rk stake pool,
Well-Typed, Tweag I/O, Serokell, Equinix, SimSpace, Haskell Foundation, and
other anonymous contributors whose on-going financial and in-kind support has
facilitated GHC maintenance and release management over the years. Finally,
this release would not have been possible without the hundreds of open-source
contributors whose work comprise this release.</p>
<p>As always, do give this release a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see
anything amiss.</p>
<p>Happy compiling,</p>
<ul>
<li>Zubin</li>
</ul>
]]></description>
    <pubDate>Mon, 27 Feb 2023 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20230227-ghc-9.2.7-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.6.1-alpha3 is now available</title>
    <link>http://haskell.org/ghc/blog/20230213-ghc-9.6.1-alpha3-released.html</link>
    <description><![CDATA[<h1>GHC 9.6.1-alpha3 is now available</h1>
<h4 class="text-muted">bgamari - 2023-02-13</h4>

<p>The GHC team is very pleased to announce the availability of GHC 9.6.1-alpha3.
As usual, binaries and source distributions are available at
<a href="https://downloads.haskell.org/ghc/9.6.1-alpha3/">downloads.haskell.org</a>.</p>
<p>Beginning with GHC 9.6.1, GHC can be built as a cross-compiler to
WebAssembly and JavaScript. This is an important step towards robust
support for compiling Haskell to the Web, but there are a few caveats to be
aware of in the 9.6 series:</p>
<ul>
<li><p>Both the Javascript and WebAssembly backends are still at an early
stage of development and are present in this release as a technology preview</p></li>
<li><p>Using GHC as a cross-compiler is not as easy as we would like it to
be; in particular, there are challenges related to Template Haskell</p></li>
<li><p>GHC is not yet run-time retargetable; a given GHC binary targets
exactly one platform, and both WebAssembly and JavaScript are considered
platforms for this purpose. Cross-compilers must be built from source by
their users</p></li>
</ul>
<p>We hope to lift all of these limitations in future releases.</p>
<p>Additionally, 9.6.1 will include:</p>
<ul>
<li><p>Significant latency improvements in the non-moving garbage collector</p></li>
<li><p>Efficient runtime support for delimited continuations</p></li>
<li><p>Improvements in compiler error messages</p></li>
<li><p>Numerous improvements in the compiler’s memory usage</p></li>
</ul>
<p>See the <a href="https://downloads.haskell.org/ghc/9.6.1-alpha3/docs/users_guide/9.6.1-notes.html">release notes</a> for a comprehensive accounting of changes in this
release.</p>
<p>As always, one can find a migration guide to aid in transitioning from older
releases on the <a href="https://gitlab.haskell.org/ghc/ghc/-/wikis/migration/9.6">GHC Wiki</a>. We have also recently started
extending our release process to cover a wider set of Linux distributions. In
particular, we now offer Rocky 8 and Ubuntu 20.04 binary distributions which
cover RedHat-derivative and distributions using older <code>glibc</code> releases (namely
2.27), respectively.</p>
<p>Please do give this release a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/issues/">ticket</a> if you see anything
amiss.</p>
<p>Cheers,</p>
<ul>
<li>Ben</li>
</ul>
]]></description>
    <pubDate>Mon, 13 Feb 2023 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20230213-ghc-9.6.1-alpha3-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.2.6 is now available</title>
    <link>http://haskell.org/ghc/blog/20230210-ghc-9.2.6-released.html</link>
    <description><![CDATA[<h1>GHC 9.2.6 is now available</h1>
<h4 class="text-muted">Zubin Duggal - 2023-02-10</h4>

<p>The GHC developers are happy to announce the availability of GHC 9.2.6. Binary
distributions, source distributions, and documentation are available at
<a href="https://downloads.haskell.org/ghc/9.2.6">downloads.haskell.org</a>.</p>
<p>This release is primarily a bugfix release addressing a few issues
found in 9.2.5. These include:</p>
<ul>
<li>Fixes for a number of simplifier issues typically resulting in compiler panics
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/22491">#22491</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22482">#22482</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/19824">#19824</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22718">#22718</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22662">#22662</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22039">#22039</a>).</li>
<li>Fix for a simplifier regression in 9.2.5 that could impact runtime performance
when compiling with optimisations due to duplication of expensive work (<a href="https://gitlab.haskell.org/ghc/ghc/issues/22425">#22425</a>).</li>
<li>Various stability improvments and bug fixes for the non moving and parallel GCs
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/22528">#22528</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/20221">#20221</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22264">#22264</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22327">#22327</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22929">#22929</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22927">#22927</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22929">#22929</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22930">#22930</a>).</li>
<li>Allow certain keywords which can be used as variable names with
<code>-XOverloadedRecordDot</code> (<a href="https://gitlab.haskell.org/ghc/ghc/issues/20723">#20723</a>).</li>
<li>Improvements to typechecker performance for modules with holes in type
signatures (<a href="https://gitlab.haskell.org/ghc/ghc/issues/14766">#14766</a>)</li>
<li>Bump <code>gmp-tarballs</code> to a version which doesn’t use the reserved <code>x18</code>
register on AArch64/Darwin systems, and also has fixes for CVE-2021-43618
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/22497">#22497</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22789">#22789</a>).</li>
<li>… and a few more. See the <a href="https://downloads.haskell.org/~ghc/9.2.6/docs/html/users_guide/9.2.6-notes.html">release notes</a> for a full accounting.</li>
</ul>
<p>As some of the fixed issues do affect correctness users are encouraged to
upgrade promptly.</p>
<p>We would like to thank Microsoft Azure, GitHub, IOG, the Zw3rk stake pool,
Well-Typed, Tweag I/O, Serokell, Equinix, SimSpace, Haskell Foundation, and
other anonymous contributors whose on-going financial and in-kind support has
facilitated GHC maintenance and release management over the years. Finally,
this release would not have been possible without the hundreds of open-source
contributors whose work comprise this release.</p>
<p>As always, do give this release a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see
anything amiss.</p>
<p>Happy compiling,</p>
<ul>
<li>Zubin</li>
</ul>
]]></description>
    <pubDate>Fri, 10 Feb 2023 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20230210-ghc-9.2.6-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.6.1-alpha2 is now available</title>
    <link>http://haskell.org/ghc/blog/20230130-ghc-9.6.1-alpha2-released.html</link>
    <description><![CDATA[<h1>GHC 9.6.1-alpha2 is now available</h1>
<h4 class="text-muted">bgamari - 2023-01-30</h4>

<p>The GHC team is very pleased to announce the availability of GHC 9.6.1-alpha2.
As usual, binaries and source distributions are available at
<a href="https://downloads.haskell.org/ghc/9.6.1-alpha2/">downloads.haskell.org</a>.</p>
<p>Beginning with GHC 9.6.1, GHC can be built as a cross-compiler to
WebAssembly and JavaScript. This is an important step towards robust
support for compiling Haskell to the Web, but there are a few caveats to be
aware of in the 9.6 series:</p>
<ul>
<li><p>Both the Javascript and WebAssembly backends are still at an early
stage of development and are present in this release as a technology preview</p></li>
<li><p>Using GHC as a cross-compiler is not as easy as we would like it to
be; in particular, there are challenges related to Template Haskell</p></li>
<li><p>GHC is not yet run-time retargetable; a given GHC binary targets
exactly one platform, and both WebAssembly and JavaScript are considered
platforms for this purpose. Cross-compilers must be built from source by
their users</p></li>
</ul>
<p>We hope to lift all of these limitations in future releases.</p>
<p>Additionally, 9.6.1 will include:</p>
<ul>
<li><p>Significant latency improvements in the non-moving garbage collector</p></li>
<li><p>Efficient runtime support for delimited continuations</p></li>
<li><p>Improvements in compiler error messages</p></li>
<li><p>Numerous improvements in the compiler’s memory usage</p></li>
</ul>
<p>See the <a href="https://downloads.haskell.org/ghc/9.6.1-alpha2/docs/users_guide/9.6.1-notes.html">release notes</a> for a comprehensive accounting of changes in this
release.</p>
<p>As always, one can find a migration guide to aid in transitioning from older
releases on the <a href="https://gitlab.haskell.org/ghc/ghc/-/wikis/migration/9.6">GHC Wiki</a>. We have also recently started
extending our release process to cover a wider set of Linux distributions. In
particular, we now offer Rocky 8 and Ubuntu 20.04 binary distributions which
cover RedHat-derivative and distributions using older <code>glibc</code> releases (namely
2.27), respectively.</p>
<p>Please do give this release a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/issues/">ticket</a> if you see anything
amiss.</p>
<p>Cheers,</p>
<ul>
<li>Ben</li>
</ul>
]]></description>
    <pubDate>Mon, 30 Jan 2023 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20230130-ghc-9.6.1-alpha2-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.6.1-alpha1 is now available</title>
    <link>http://haskell.org/ghc/blog/20230113-ghc-9.6.1-alpha1-released.html</link>
    <description><![CDATA[<h1>GHC 9.6.1-alpha1 is now available</h1>
<h4 class="text-muted">bgamari - 2023-01-13</h4>

<p>The GHC team is very pleased to announce the availability of GHC 9.6.1-alpha1.
As usual, binaries and source distributions are available at
<a href="https://downloads.haskell.org/ghc/9.6.1-alpha1/">downloads.haskell.org</a>.
This is the first alpha release in the 9.6 series which will bring a number of
exciting features:</p>
<ul>
<li><p>A new Javascript code generation backend</p></li>
<li><p>A new WebAssembly code generation backend,</p></li>
<li><p>Significant latency improvements in the non-moving garbage collector</p></li>
<li><p>Support for loading of multiple components in GHCi</p></li>
<li><p>Efficient support for delimited continuations</p></li>
<li><p>Improvements in error messages</p></li>
<li><p>Numerous improvements in compiler-residency</p></li>
</ul>
<p>Note that both the Javascript and WebAssembly backends are still in a state of
infancy and are present in this release as a technology preview; we hope that
they will mature considerably before the final 9.6.1 release.</p>
<p>Please give this release a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/issues/">ticket</a> if you see anything
amiss.</p>
<p>Cheers,</p>
<ul>
<li>Ben</li>
</ul>
]]></description>
    <pubDate>Fri, 13 Jan 2023 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20230113-ghc-9.6.1-alpha1-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.4.4 released</title>
    <link>http://haskell.org/ghc/blog/20221224-ghc-9.4.4-released.html</link>
    <description><![CDATA[<h1>GHC 9.4.4 released</h1>
<h4 class="text-muted">bgamari - 2022-12-24</h4>

<p>The GHC developers are happy to announce the availability of GHC 9.4.4. Binary
distributions, source distributions, and documentation are available at
<a href="https://downloads.haskell.org/ghc/9.4.4">downloads.haskell.org</a>.</p>
<p>This release is primarily a bugfix release. Bugs fixed include:</p>
<ul>
<li>An issue where the wrong labels were used in the eventlog for events emitted
when using info table profiling which was broken in 9.4.3 (<a href="https://gitlab.haskell.org/ghc/ghc/issues/22452">#22452</a>)</li>
<li>Fix a long standing bug where invalid eventlogs would be produced with long
command-lines (<a href="https://gitlab.haskell.org/ghc/ghc/issues/20221">#20221</a>)</li>
<li>Fix a regression in eta-expansion which resulted in serious performance
regressions in 9.4.3 (<a href="https://gitlab.haskell.org/ghc/ghc/issues/22424">#22424</a>)</li>
<li>Fix the <code>-fdefer-diagnostics</code> flag (<a href="https://gitlab.haskell.org/ghc/ghc/issues/22391">#22391</a>)</li>
<li>Fixes to several subtle compiler panics. (<a href="https://gitlab.haskell.org/ghc/ghc/issues/22491">#22491</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22416">#22416</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22549">#22549</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22475">#22475</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22039">#22039</a>)</li>
<li>Add necessary write barriers to <code>IORef</code> operations, avoiding potential
soundness issues on architectures with weakly-ordered memory models
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/22468">#22468</a>)</li>
</ul>
<p>Note that, as GHC 9.4 is the first release series where the release artifacts
are all generated by our new Hadrian build system, it is possible that there
will be packaging issues. If you enounter trouble while using a binary
distribution, please open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a>. Likewise, if you are a downstream
packager, do consider migrating to <a href="https://gitlab.haskell.org/ghc/ghc/-/blob/e2520df3fffa0cf22fb19c5fb872832d11c07d35/hadrian">Hadrian</a> to run your build; the Hadrian
build system can be built using <code>cabal-install</code>, <code>stack</code>, or the in-tree
<a href="https://gitlab.haskell.org/ghc/ghc/-/blob/e2520df3fffa0cf22fb19c5fb872832d11c07d35/hadrian/bootstrap/README.md">bootstrap script</a>. See the accompanying <a href="https://www.haskell.org/ghc/blog/20220805-make-to-hadrian.html">blog post</a> for details on
migrating packaging to Hadrian.</p>
<p>We would also like to emphasize that GHC 9.4 must be used in conjunction with
<code>Cabal-3.8</code> or later. This is particularly important for Windows users due to
changes in GHC’s Windows toolchain.</p>
<p>We would like to thank Microsoft Azure, GitHub, IOG, the Zw3rk stake pool,
Well-Typed, Tweag I/O, Serokell, Equinix, SimSpace, Haskell Foundation, and
other anonymous contributors whose on-going financial and in-kind support has
facilitated GHC maintenance and release management over the years. Finally,
this release would not have been possible without the hundreds of open-source
contributors whose work comprise this release.</p>
<p>As always, do give this release a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see
anything amiss.</p>
<p>Happy Haskelling,</p>
<ul>
<li>Ben</li>
</ul>
]]></description>
    <pubDate>Sat, 24 Dec 2022 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20221224-ghc-9.4.4-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.2.5 is now available</title>
    <link>http://haskell.org/ghc/blog/20221107-ghc-9.2.5-released.html</link>
    <description><![CDATA[<h1>GHC 9.2.5 is now available</h1>
<h4 class="text-muted">Zubin Duggal - 2022-11-07</h4>

<p>The GHC developers are happy to announce the availability of GHC 9.2.5. Binary
distributions, source distributions, and documentation are available at
<a href="https://downloads.haskell.org/ghc/9.2.5">downloads.haskell.org</a>.</p>
<p>This release is primarily a bugfix release addressing a few issues
found in 9.2.4. These include:</p>
<ul>
<li>Code generation issues in the AArch64 native code generator backend
resulting in incorrect runtime results in some circumstances (<a href="https://gitlab.haskell.org/ghc/ghc/issues/22282">#22282</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/21964">#21964</a>)</li>
<li>Fixes for a number of issues with the simplifier leading to core lint
errors and suboptimal performance (<a href="https://gitlab.haskell.org/ghc/ghc/issues/21694">#21694</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/21755">#21755</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/22114">#22114</a>)</li>
<li>A long-standing interface-file determinism issue where full paths would leak
into the interface file (<a href="https://gitlab.haskell.org/ghc/ghc/issues/22162">#22162</a>)</li>
<li>A runtime system bug where creating empty mutable arrays resulted in a crash
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/21962">#21962</a>)</li>
<li>… and a few more. See the <a href="https://downloads.haskell.org/~ghc/9.2.5/docs/html/users_guide/9.2.5-notes.html">release notes</a> for a full accounting.</li>
</ul>
<p>As some of the fixed issues do affect correctness users are encouraged to
upgrade promptly.</p>
<p>We would like to thank Microsoft Azure, GitHub, IOG, the Zw3rk stake pool,
Well-Typed, Tweag I/O, Serokell, Equinix, SimSpace, Haskell Foundation, and
other anonymous contributors whose on-going financial and in-kind support has
facilitated GHC maintenance and release management over the years. Finally,
this release would not have been possible without the hundreds of open-source
contributors whose work comprise this release.</p>
<p>As always, do give this release a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see
anything amiss.</p>
<p>Happy compiling,</p>
<ul>
<li>Zubin</li>
</ul>
]]></description>
    <pubDate>Mon, 07 Nov 2022 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20221107-ghc-9.2.5-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.4.3 released</title>
    <link>http://haskell.org/ghc/blog/20221103-ghc-9.4.3-released.html</link>
    <description><![CDATA[<h1>GHC 9.4.3 released</h1>
<h4 class="text-muted">bgamari - 2022-11-03</h4>

<p>The GHC developers are happy to announce the availability of GHC 9.4.3. Binary
distributions, source distributions, and documentation are available at
<a href="https://downloads.haskell.org/ghc/9.4.3">downloads.haskell.org</a>.</p>
<p>This release is primarily a bugfix release addressing a few issues
found in 9.4.2. These include:</p>
<ul>
<li>An issue where recursively calls could be speculatively evaluated, resulting
in non-termination (<a href="https://gitlab.haskell.org/ghc/ghc/issues/20836">#20836</a>)</li>
<li>A code generation issue in the AArch64 native code generator backend
resulting in incorrect runtime results in some circumstances (<a href="https://gitlab.haskell.org/ghc/ghc/issues/22282">#22282</a>)</li>
<li>A crash on Darwin when running executables compiled with IPE support (<a href="https://gitlab.haskell.org/ghc/ghc/issues/22080">#22080</a>)</li>
<li>A long-standing interface-file determinism issue where full paths would leak
into the interface file (<a href="https://gitlab.haskell.org/ghc/ghc/issues/22162">#22162</a>)</li>
<li>A bug in the <code>process</code> library where file handles specified as <code>NoStream</code> would
still be usable in the child (<a href="https://github.com/haskell/process/issues/251">process<a href="https://gitlab.haskell.org/ghc/ghc/issues/251">#251</a></a>)</li>
</ul>
<p>Note that, as GHC 9.4 is the first release series where the release artifacts
are all generated by our new Hadrian build system, it is possible that there
will be packaging issues. If you enounter trouble while using a binary
distribution, please open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a>. Likewise, if you are a downstream
packager, do consider migrating to <a href="https://gitlab.haskell.org/ghc/ghc/-/blob/e2520df3fffa0cf22fb19c5fb872832d11c07d35/hadrian">Hadrian</a> to run your build; the Hadrian
build system can be built using <code>cabal-install</code>, <code>stack</code>, or the in-tree
<a href="https://gitlab.haskell.org/ghc/ghc/-/blob/e2520df3fffa0cf22fb19c5fb872832d11c07d35/hadrian/bootstrap/README.md">bootstrap script</a>. See the accompanying <a href="https://www.haskell.org/ghc/blog/20220805-make-to-hadrian.html">blog post</a> for details on
migrating packaging to Hadrian.</p>
<p>We would also like to emphasize that GHC 9.4 must be used in conjunction with
Cabal-3.8 or later. This is particularly important for Windows users due to
changes in GHC’s Windows toolchain.</p>
<p>We would like to thank Microsoft Azure, GitHub, IOG, the Zw3rk stake pool,
Well-Typed, Tweag I/O, Serokell, Equinix, SimSpace, Haskell Foundation, and
other anonymous contributors whose on-going financial and in-kind support has
facilitated GHC maintenance and release management over the years. Finally,
this release would not have been possible without the hundreds of open-source
contributors whose work comprise this release.</p>
<p>As always, do give this release a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see
anything amiss.</p>
<p>Happy Haskelling,</p>
<ul>
<li>Ben</li>
</ul>
]]></description>
    <pubDate>Thu, 03 Nov 2022 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20221103-ghc-9.4.3-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.4.2 released</title>
    <link>http://haskell.org/ghc/blog/20220822-ghc-9.4.2-released.html</link>
    <description><![CDATA[<h1>GHC 9.4.2 released</h1>
<h4 class="text-muted">bgamari - 2022-08-22</h4>

<p>The GHC developers are happy to announce the availability of GHC 9.4.2. Binary
distributions, source distributions, and documentation are available at
<a href="https://downloads.haskell.org/ghc/9.4.2">downloads.haskell.org</a>.</p>
<p>This release is primarily a bugfix release addressing a few packaging issues
found in 9.4.1. See the <a href="https://downloads.haskell.org/~ghc/9.4.2/docs/users_guide/9.4.2-notes.html">release notes</a> for a full accounting.</p>
<p>Note that, as GHC 9.4 is the first release series where the release artifacts
are all generated by our new Hadrian build system, it is possible that there
will be packaging issues. If you enounter trouble while using a binary
distribution, please open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a>. Likewise, if you are a downstream
packager, do consider migrating to <a href="https://gitlab.haskell.org/ghc/ghc/-/blob/e2520df3fffa0cf22fb19c5fb872832d11c07d35/hadrian">Hadrian</a> to run your build; the Hadrian
build system can be built using <code>cabal-install</code>, <code>stack</code>, or the in-tree
<a href="https://gitlab.haskell.org/ghc/ghc/-/blob/e2520df3fffa0cf22fb19c5fb872832d11c07d35/hadrian/bootstrap/README.md">bootstrap script</a>. See the accompanying <a href="https://www.haskell.org/ghc/blog/20220805-make-to-hadrian.html">blog post</a> for details on
migrating packaging to Hadrian.</p>
<p>We would also like to emphasize that GHC 9.4 must be used in conjunction with
Cabal-3.8 or later. This is particularly important for Windows users due to
changes in GHC’s Windows toolchain.</p>
<p>We would like to thank Microsoft Azure, GitHub, IOG, the Zw3rk stake pool,
Well-Typed, Tweag I/O, Serokell, Equinix, SimSpace, Haskell Foundation, and
other anonymous contributors whose on-going financial and in-kind support has
facilitated GHC maintenance and release management over the years. Finally,
this release would not have been possible without the hundreds of open-source
contributors whose work comprise this release.</p>
<p>As always, do give this release a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see
anything amiss.</p>
<p>Happy Haskelling,</p>
<ul>
<li>Ben</li>
</ul>
]]></description>
    <pubDate>Mon, 22 Aug 2022 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20220822-ghc-9.4.2-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.4.1 released</title>
    <link>http://haskell.org/ghc/blog/20220807-ghc-9.4.1-released.html</link>
    <description><![CDATA[<h1>GHC 9.4.1 released</h1>
<h4 class="text-muted">bgamari - 2022-08-07</h4>

<p>The GHC developers are happy to announce the availability of GHC 9.4.1. Binary
distributions, source distributions, and documentation are available at
<a href="https://downloads.haskell.org/ghc/9.4.1">downloads.haskell.org</a>.</p>
<p>This release includes:</p>
<ul>
<li><p>A new profiling mode, <code>-fprof-late</code>, which adds automatic cost-center
annotations to all top-level functions <em>after</em> Core optimisation has
run. This provides informative profiles while interfering
significantly less with GHC’s aggressive optimisations, making it
easier to understand the performance of programs which depend upon
simplification..</p></li>
<li><p>A variety of plugin improvements including the introduction of a new
plugin type, <em>defaulting plugins</em>, and the ability for typechecking
plugins to rewrite type-families.</p></li>
<li><p>An improved constructed product result analysis, allowing unboxing of
nested structures, and a new boxity analysis, leading to less reboxing.</p></li>
<li><p>Introduction of a tag-check elision optimisation, bringing
significant performance improvements in strict programs.</p></li>
<li><p>Generalisation of a variety of primitive types to be levity
polymorphic. Consequently, the <code>ArrayArray#</code> type can at long last be
retired, replaced by standard <code>Array#</code>.</p></li>
<li><p>Introduction of the <code>\cases</code> syntax from <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0302-cases.rst">GHC proposal 0302</a>.</p></li>
<li><p>A complete overhaul of GHC’s Windows support. This includes a
migration to a fully Clang-based C toolchain, a deep refactoring of
the linker, and many fixes in WinIO.</p></li>
<li><p>Support for multiple home packages, significantly improving support
in IDEs and other tools for multi-package projects.</p></li>
<li><p>A refactoring of GHC’s error message infrastructure, allowing GHC to
provide diagnostic information to downstream consumers as structured
data, greatly easing IDE support.</p></li>
<li><p>Significant compile-time improvements to runtime and memory consumption.</p></li>
<li><p>On overhaul of our packaging infrastructure, allowing full
traceability of release artifacts and more reliable binary
distributions.</p></li>
<li><p>Reintroduction of deep subsumption (which was previously dropped with the
<em>simplified subsumption</em> change) as a language extension.</p></li>
<li><p>… and much more. See the <a href="https://downloads.haskell.org/~ghc/9.4.1/docs/users_guide/9.4.1-notes.html">release notes</a> for a full accounting.</p></li>
</ul>
<p>Note that, as 9.4.1 is the first release for which the released artifacts will
all be generated by our Hadrian build system, it is possible that there will be
packaging issues. If you enounter trouble while using a binary distribution,
please open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a>. Likewise, if you are a downstream packager, do consider
migrating to <a href="https://gitlab.haskell.org/ghc/ghc/-/blob/e2520df3fffa0cf22fb19c5fb872832d11c07d35/hadrian">Hadrian</a> to run your build; the Hadrian build system can be built
using <code>cabal-install</code>, <code>stack</code>, or the in-tree <a href="https://gitlab.haskell.org/ghc/ghc/-/blob/e2520df3fffa0cf22fb19c5fb872832d11c07d35/hadrian/bootstrap/README.md">bootstrap script</a>. See the accompanying
<a href="https://www.haskell.org/ghc/blog/20220805-make-to-hadrian.html">blog post</a> for details on migrating packaging to Hadrian.</p>
<p>We would like to thank Microsoft Azure, GitHub, IOG, the Zw3rk stake pool,
Well-Typed, Tweag I/O, Serokell, Equinix, SimSpace, Haskell Foundation, and
other anonymous contributors whose on-going financial and in-kind support has
facilitated GHC maintenance and release management over the years. Finally,
this release would not have been possible without the hundreds of open-source
contributors whose work comprise this release.</p>
<p>As always, do give this release a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see
anything amiss.</p>
<p>Happy testing,</p>
<ul>
<li>Ben</li>
</ul>
]]></description>
    <pubDate>Sun, 07 Aug 2022 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20220807-ghc-9.4.1-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>Migrating from Make to Hadrian (for packagers)</title>
    <link>http://haskell.org/ghc/blog/20220805-make-to-hadrian.html</link>
    <description><![CDATA[<h1>Migrating from Make to Hadrian (for packagers)</h1>
<h4 class="text-muted">Sam Derbyshire - 2022-08-05</h4>

<p>As the <a href="https://gitlab.haskell.org/ghc/ghc/blob/master/hadrian/README.md">Hadrian build system for
GHC</a> has
reached maturity and the old Make-based build system is becoming increasingly
costly to maintain, the GHC maintenance team has decided that it is finally
time to remove GHC’s Make-based build system. GHC 9.4 will be the last release
series compatible with Make, which will be limited to booting with GHC 9.0.
From 9.6 onwards, the only supported way to build GHC will be to use Hadrian.</p>
<p>This blog post will give an overview of using Hadrian, which should help
packagers migrate from the old Make-based build system.</p>
<!-- more -->
<h2 id="the-hadrian-build-system">The Hadrian build system</h2>
<p>Hadrian is a modular, statically-typed, extensible build system for GHC, introduced in the paper <a href="https://www.microsoft.com/en-us/research/wp-content/uploads/2016/03/hadrian.pdf">Non-recursive Make Considered Harmful</a>. It consists of a Haskell executable implemented using the <a href="https://hackage.haskell.org/package/shake">shake</a> library, and is used to configure and build GHC.</p>
<h2 id="building-hadrian">Building Hadrian</h2>
<p>Contributors to GHC will be accustomed to running the <code>./hadrian/build</code> script,
which builds and runs Hadrian. This script calls out to <code>cabal</code>, which fetches
the dependencies of the Hadrian package from Hackage before building the
resulting Haskell executable. While this is convenient for developers, it isn’t
appropriate for build environments in which one doesn’t have access to the
network (e.g. in order to enforce a hermetic build environment). For that
reason, Hadrian provides a set of scripts for bootstrapping the build system
from source tarballs. These can be found in the <code>hadrian/bootstrap</code> directory.</p>
<h3 id="bootstrapping-hadrian">Bootstrapping Hadrian</h3>
<p>The Hadrian bootstrap scripts are driven by a set of precomputed build plans;
these depend on the version of the bootstrap GHC being used. A typical workflow
might look like the following:</p>
<ul>
<li>Locally:
<ul>
<li>Choose a build plan appropriate for the bootstrap GHC version, such as <code>hadrian/bootstrap/plan-bootstrap-8.10.7.json</code>.
(These build plans can also be generated manually from a <code>cabal-install</code> build plan; see <code>generate_bootstrap_plans</code>)</li>
<li>Fetch the sources needed by the build plan:
<code>bootstrap.py fetch -w &lt;path_to_ghc&gt; --deps plan-bootstrap-8.10.7.json -o 8_10_7_bootstrap_sources.tar.gz</code></li>
</ul></li>
<li>In the build environment:
<ul>
<li>Provision the <code>bootstrap-sources</code> tarball generated above.</li>
</ul></li>
<li>In your GHC build script:
<ul>
<li>Build Hadrian using the bootstrap script:
<code>bootstrap.py -w &lt;path_to_ghc&gt; --bootstrap-sources 8_10_7_bootstrap_sources.tar.gz</code></li>
<li>Build GHC using the resulting Hadrian executable, located by default in <code>bin/hadrian</code>, e.g.
<code>bin/hadrian -j --flavour=perf+debug_info -w &lt;path_to_ghc&gt;</code></li>
</ul></li>
</ul>
<p>An example of how to use these bootstrap scripts can be seen in the <a href="https://gitlab.haskell.org/bgamari/ghcs-nix/-/blob/master/hadrian-bootstrap.nix"><code>ghcs-nix</code>
repository</a>.
This repository contains Nix expressions specifying how to build many GHC
versions, with both Make and Hadrian.</p>
<p>From now on, we will assume that you have built Hadrian (either via
<code>./hadrian/build</code> or via bootstrapping), referring to the <code>hadrian</code> executable
agnostically.</p>
<h2 id="using-hadrian">Using Hadrian</h2>
<h3 id="how-does-hadrian-replace-make">How does Hadrian replace make?</h3>
<p>To build GHC, we begin as before by running <code>./boot</code> (if necessary, i.e. a
<code>configure</code> file doesn’t already exist) and then <code>./configure &lt;args&gt;</code>. As with
Make, the build environment is determined by the configure script, which will
read provided arguments as well as environment variables. For example, the
selection of the bootstrap compiler is done via the <code>GHC</code> environment variable,
and the selection of the C compiler uses the <code>CC</code> environment variable. This is
unchanged, and details can be found on the <a href="https://gitlab.haskell.org/ghc/ghc/-/wikis/building/using#run-the-configure-script">GHC
wiki</a>.</p>
<p>Once the configure script is run, we replace <code>make</code> commands with <code>hadrian</code>
commands. The fundamental command to build GHC with Hadrian is</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="ex">hadrian</span> <span class="op">&lt;</span>args<span class="op">&gt;</span></span></code></pre></div>
<h3 id="hadrian-stages">Hadrian stages</h3>
<p>GHC is a self-hosted compiler. This means that we need to provide a GHC
executable in order to compile GHC. In Hadrian, this is done in <strong>stages</strong>:</p>
<ul>
<li>The <code>stage0</code> compiler is the bootstrap compiler: a user-provided executable
which will be used to compile GHC. The bootstrap compiler is chosen via the
<code>GHC</code> variable passed to the <code>configure</code> script.</li>
<li>The <code>stage1</code> compiler is the compiler built using the <code>stage0</code> compiler; it
runs on the build platform and produces code for the target platform. The
stage1 compiler is limited in that it does not support dynamic code loading
via the internal bytecode interpreter.</li>
<li>The <code>stage2</code> compiler is the compiler built using the <code>stage1</code> compiler; it
runs on the target platform. The <code>stage2</code> compiler is necessary for the
implementation of Template Haskell and GHC plugins.</li>
</ul>
<p>In Hadrian, build artifacts are put in a subdirectory of the build folder (by
default, <code>_build</code>) corresponding to the stage of the compiler <strong>used to perform
the build</strong>. This means that the <code>stage2</code> compiler will be found (if using the
default build directory, <code>_build</code>) at <code>_build/stage1/bin/ghc</code>.</p>
<p>Hadrian provides meta-targets which can be used to build particular subsets of
the compiler. A typical Hadrian command, which builds a library or executable
for a given stage, looks like</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">hadrian</span> <span class="op">&lt;</span>stage<span class="op">&gt;</span>:<span class="dt">{lib</span><span class="op">,</span><span class="dt">exe}</span>:<span class="op">&lt;</span>package name<span class="op">&gt;</span></span></code></pre></div>
<p>For example, <code>hadrian stage2:lib:base</code> will build the <code>stage2</code> <code>base</code> library,
and put it into the <code>_build/stage1</code> subdirectory.</p>
<h3 id="flavours-and-flavour-transformers">Flavours and flavour transformers</h3>
<p>A Hadrian <strong>build flavour</strong> is a pre-defined collection of build settings that
fully define a GHC build. These are described
<a href="https://gitlab.haskell.org/ghc/ghc/blob/master/hadrian/doc/flavours.md">here</a>.
The flavour being used determines the ways in which GHC and its libraries will
be built, as described in the <a href="https://gitlab.haskell.org/ghc/ghc/blob/master/hadrian/doc/flavours.md#ways">Hadrian documentation</a>.
This replaces the variables of the <code>make</code> build system such as <code>GhcLibWays</code>,
<code>DYNAMIC_GHC_PROGRAMS</code>, <code>DYNAMIC_BY_DEFAULT</code>.</p>
<p>A flavour is set using the <code>--flavour</code> command-line argument, e.g.
<code>hadrian/build --flavour=perf</code>. As a packager you probably want to use either
the <code>release</code> or <code>perf</code> flavour:</p>
<div class="table">
<table>
<colgroup>
<col style="width: 43%" />
<col style="width: 56%" />
</colgroup>
<thead>
<tr class="header">
<th>flavour name</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><code>perf</code></td>
<td>A fully optimised bindist</td>
</tr>
<tr class="even">
<td><code>release</code></td>
<td>The same configuration as <code>perf</code>, but with additional build products such as interface files containing Haddock docs</td>
</tr>
</tbody>
</table>
</div>
<p>Flavours can be modified using <em>flavour transformers</em>. For example, the
<code>profiled_ghc</code> flavour transformer compiles the GHC library and executable with
cost-centre profiling enabled. One can, e.g., apply the <code>profiled_ghc</code>
transformer to the <code>perf</code> flavour with <code>hadrian --flavour=perf+profiled_ghc</code>.</p>
<div class="table">
<table>
<thead>
<tr class="header">
<th>Make variable</th>
<th>Hadrian flavour transformer</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><code>GhcProfiled</code></td>
<td><code>profiled_ghc</code></td>
</tr>
<tr class="even">
<td><code>GhcDebugged</code></td>
<td><code>debug_ghc</code></td>
</tr>
<tr class="odd">
<td><code>SplitObjs</code></td>
<td><code>split_sections</code></td>
</tr>
</tbody>
</table>
</div>
<p>The full list of supported flavour transformers is available
<a href="https://gitlab.haskell.org/ghc/ghc/blob/master/hadrian/doc/flavours.md">here</a>.</p>
<h3 id="building-ghc-for-distribution">Building GHC for distribution</h3>
<p>Packagers will be interested in the <code>binary-dist</code> and <code>binary-dist-dir</code> Hadrian
targets. For example, the command</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">hadrian/build</span> <span class="at">--flavour</span><span class="op">=</span>release binary-dist</span></code></pre></div>
<p>will produce a complete release binary distribution tarball, while the
<code>binary-dist-dir</code> target produces the directory only (not the tarball). The
resulting bindist will be placed in <code>_build/bindist</code>.</p>
<p>When building the <code>binary-dist</code> target, documentation (namely, Haddock
documentation and GHC’s <a href="https://www.sphinx-doc.org/">Sphinx</a>-built user’s
guide) will be built by default. Building of documentation can be disabled
using Hadrian’s <code>--docs=...</code> command-line flag. If you don’t want to build
documentation, there are options to disable building various parts of the
documentation.
For example, if you don’t have Sphinx available, you can disable the parts of the documentation which require it:</p>
<pre><code># Build only the documentation for the base package, without using sphinx
hadrian {..} docs:base --docs=no-sphinx</code></pre>
<p>Further information about configuring the documentation built by Hadrian can be
found in the <a href="https://gitlab.haskell.org/ghc/ghc/blob/master/hadrian/README.md#documentation">Hadrian readme</a>.</p>
<h3 id="large-integer-implementation">Large-integer implementation</h3>
<p>GHC supports several implementations of the <code>Integer</code>/<code>Natural</code> types and
operations on them. The selection of the implementation is done using the
<code>--bignum</code> Hadrian argument, e.g. <code>--bignum=gmp</code> to use the <a href="https://gmplib.org/">GMP
library</a>, or <code>--bignum=native</code> to use a pure-Haskell
implementation.</p>
<h3 id="key-value-settings">Key-value settings</h3>
<p>While we expect that the mechanisms described above will suffice for most
builds, Hadrian also provides a fine-grained key-value configuration mechanism
for modifying the command-lines passed to each of the tools run by Hadrian. For
instance, one can pass an additional argument to all GHC invocations via:</p>
<pre><code>hadrian {..} &quot;*.*.ghc.*.opts += -my-ghc-option&quot;</code></pre>
<p>Passing an additional option when compiling the <code>ghc</code> library only:</p>
<pre><code>hadrian {..} &quot;*.ghc.ghc.*.opts += -my-ghc-option&quot;</code></pre>
<p>These settings can also be placed in a <code>hadrian.settings</code> file in the build
root (by default <code>_build</code>), instead of passing them in the command line.</p>
<p>Hadrian currently supports the <a href="https://gitlab.haskell.org/ghc/ghc/-/blob/a9fc15b1228d557c2241a28ac702d4a6e140d975/hadrian/doc/user-settings.md#key-value-and-key-value-style-settings">following key-value settings</a></p>
<ul>
<li><code>(&lt;stage&gt; or *).(&lt;package name&gt; or *).ghc.{hs, c, cpp, link, deps, *}.opts</code><br />
Arguments passed to GHC invocations.
<ul>
<li><code>hs</code> for arguments passed to GHC when compiling Haskell modules</li>
<li><code>c</code> for arguments passed to the C compiler</li>
<li><code>cpp</code> for arguments passed to the C++ compiler</li>
<li><code>link</code> for arguments passed during linking</li>
<li><code>deps</code> for arguments to a <code>ghc -M</code> command, which outputs
dependency information between Haskell modules</li>
</ul></li>
<li><code>(&lt;stage&gt; or *).(&lt;package name&gt; or *).cc.{c, deps, *}.opts</code><br />
Arguments passed directly to the C compiler.</li>
<li><code>(&lt;stage&gt; or *).(&lt;package name&gt; or *).cabal.configure.opts</code><br />
Arguments passed to the cabal configure step.</li>
<li><code>(&lt;stage&gt; or *).(&lt;package name&gt; or *).hsc2hs.run.opts</code><br />
Arguments passed when running Hsc2Hs.</li>
</ul>
<p>These Hadrian key-value settings are useful to replace the assignment of Make variables,
even though Hadrian is not intended to be a one-to-one replacement of Make;
recovering the behaviour with Hadrian might require a few tweaks.</p>
<p>Consider for example the way that Make passes flags to GHC when compiling
source Haskell files. Make has several different variables, such as
<code>SRC_HC_OPTS</code>, <code>WAY_&lt;way&gt;_&lt;pkg&gt;_OPTS</code>, <code>EXTRA_HC_OPTS</code>. These are passed in
order, with later flags overriding previous ones. With Hadrian, things are much
simpler, and one can usually achieve the same goal by simply setting the
<code>*.*.ghc.hs.opts</code> Hadrian key-value setting.</p>
<p>The following table serves as a general guideline in migrating the use of Make variables (bearing the above caveats in mind):</p>
<div class="table">
<table>
<colgroup>
<col style="width: 49%" />
<col style="width: 50%" />
</colgroup>
<thead>
<tr class="header">
<th>Make variable</th>
<th>Hadrian key-value setting</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><code>GhcLibOpts</code></td>
<td><code>*.*.ghc.*.opts</code></td>
</tr>
<tr class="even">
<td><code>GhcRtsHcOpts</code></td>
<td><code>*.*.rts.*.opts</code></td>
</tr>
<tr class="odd">
<td><code>SRC_HC_OPTS</code>, <code>EXTRA_HC_OPTS</code></td>
<td><code>*.*.ghc.hs.opts</code></td>
</tr>
<tr class="even">
<td><code>SRC_CC_OPTS</code>, <code>EXTRA_CC_OPTS</code></td>
<td><code>*.*.ghc.c.opts</code> with <code>-optc</code> prefix</td>
</tr>
<tr class="odd">
<td><code>SRC_CPP_OPTS</code>, <code>EXTRA_CPP_OPTS</code></td>
<td>a combination of <code>*.*.ghc.c.opts</code> with <code>-optc</code> prefix and <code>*.*.cc.c.opts</code></td>
</tr>
<tr class="even">
<td><code>SRC_LD_OPTS</code>, <code>EXTRA_LD_OPTS</code></td>
<td><code>*.*.ghc.link.opts</code> with <code>-optl</code> prefix</td>
</tr>
<tr class="odd">
<td><code>&lt;pkg&gt;_EXTRA_LD_OPTS</code></td>
<td><code>*.&lt;pkg&gt;.ghc.link.opts</code> with <code>-optl</code> prefix</td>
</tr>
<tr class="even">
<td><code>&lt;pkg&gt;_CONFIGURE_OPTS</code></td>
<td><code>*.&lt;pkg&gt;.cabal.configure.opts</code></td>
</tr>
<tr class="odd">
<td><code>utils/hsc2hs_dist-install_EXTRA_LD_OPTS</code></td>
<td><code>*.*.hsc2hs.run.opt</code> with <code>-L</code> prefix</td>
</tr>
</tbody>
</table>
</div>
<p>To pass module-specific or way-specific options, e.g. passing a C pre-processor
option when compiling specific modules in a certain <code>way</code> (as when using a
<code>Way_&lt;way&gt;_&lt;pkg&gt;_OPTS</code> Make variable), please use the programmatic interface
described <a href="#programmatic-configuration">below</a>.</p>
<h3 id="programmatic-configuration">Programmatic configuration</h3>
<p>If the above configuration mechanisms aren’t sufficient, it is also possible to
directly add new configurations to Hadrian. This allows finer-grained changes,
such as changing the options when compiling a specific module or set of
modules. If you really need to do this, you can read about it in the <a href="https://gitlab.haskell.org/ghc/ghc/-/blob/master/hadrian/doc/user-settings.md#directly-modifying-hadrian-configuration">Hadrian
manual</a>.
A good starting place to look for inspiration is <a href="https://gitlab.haskell.org/ghc/ghc/-/blob/a9fc15b1228d557c2241a28ac702d4a6e140d975/hadrian/src/Settings/Packages.hs">Settings.Packages</a>, which contains the
arguments used to build GHC and the libraries it depends upon. The
<a href="https://hackage.haskell.org/package/shake">documentation for Shake</a> is also a
helpful resource, as Hadrian uses the Shake EDSL to implement its build rules.</p>
<h2 id="further-support">Further support</h2>
<p>If you are having any issues with packaging GHC after these changes, or find
yourself needing to use the programmatic
interface, please open an issue on the issue
tracker, so that we can work together to modify Hadrian for your needs.</p>
]]></description>
    <pubDate>Fri, 05 Aug 2022 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20220805-make-to-hadrian.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.2.4 is now available</title>
    <link>http://haskell.org/ghc/blog/20220728-ghc-9.2.4-released.html</link>
    <description><![CDATA[<h1>GHC 9.2.4 is now available</h1>
<h4 class="text-muted">Zubin Duggal - 2022-07-28</h4>

<p>The GHC developers are very happy to at announce the availability of GHC
9.2.4. Binary distributions, source distributions, and documentation are
available at <a href="https://downloads.haskell.org/ghc/9.2.4"><code>downloads.haskell.org</code></a>.</p>
<p>This release will include:</p>
<ul>
<li><p>The new <code>DeepSubsumption</code> language extension which reverses the
effects of the <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0287-simplify-subsumption.rst">Simplified Subsumption Proposal</a> introduced in GHC 9.0. This
is an attempt to make GHC 9.2.4 more backwards compatible with GHC 8.10 and
eases migration for users who depended on this feature.</p>
<p>This extension is enabled by default with the <code>Haskell2010</code>
and <code>Haskell98</code> languages but disabled with the <code>GHC2021</code>
language originally introduced in GHC 9.2.1.</p>
<p>See the <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0511-deep-subsumption.rst">Deep Subsumption Proposal</a> for more details.</p></li>
<li><p>Fixes for segfaults that may arise due to a bug in the implementation of the
<code>keepAlive#</code> primop. This may regress performance for certain programs which
use this primop or functions which use the primop, such as <code>withForeignPtr</code>.
These regressions are mostly small, but can be larger in certain edge cases.
Judicious use of <code>unsafeWithForeignPtr</code> when its argument is known not to
statically diverge can mitigate these in many cases. It is our judgment that
the critical correctness issues justify the regression in performance and that
it is important to get a release out with the fix while we work on a better
approach which will improve performance for future releases (<a href="https://gitlab.haskell.org/ghc/ghc/issues/21708">#21708</a>).</p>
<p>We have a <a href="https://gitlab.haskell.org/ghc/ghc/-/wikis/proposal/with-combinator">wiki page</a>
that tracks possible solutions to this problem, and Ben wrote a
<a href="https://www.haskell.org/ghc/blog/20210607-the-keepAlive-story.html">blog post</a>
detailing the introduction of the <code>keepAlive#</code> primop and its history.</p></li>
<li><p>Fixes for a number of miscompilations on AArch64 and other platforms (<a href="https://gitlab.haskell.org/ghc/ghc/issues/21624">#21624</a>,
<a href="https://gitlab.haskell.org/ghc/ghc/issues/21773">#21773</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/20735">#20735</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/21685">#21685</a>).</p></li>
<li><p>Fixes for segfaults due to bugs in the RTS and GC (<a href="https://gitlab.haskell.org/ghc/ghc/issues/21708">#21708</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/21880">#21880</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/21885">#21885</a>).</p></li>
<li><p>Fixing the behaviour of Ctrl-C with GHCi on Windows (<a href="https://gitlab.haskell.org/ghc/ghc/issues/21889">#21889</a>).</p></li>
<li><p>… and much more. See the <a href="https://downloads.haskell.org/~ghc/9.2.4/docs/html/users_guide/9.2.4-notes.html">release notes</a> for a full accounting.</p></li>
</ul>
<p>As some of the fixed issues do affect correctness users are encouraged to
upgrade promptly.</p>
<p>We would like to thank Microsoft Azure, GitHub, IOG, the Zw3rk
stake pool, Tweag I/O, Serokell, Equinix, SimSpace, Haskell Foundation, and other anonymous
contributors whose on-going financial and in-kind support has
facilitated GHC maintenance and release management over the years.
Finally, this release would not have been possible without the hundreds
of open-source contributors whose work comprise this release.</p>
<p>As always, do give this release a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see
anything amiss.</p>
<p>Happy compiling,</p>
<ul>
<li>Zubin</li>
</ul>
]]></description>
    <pubDate>Thu, 28 Jul 2022 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20220728-ghc-9.2.4-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.4.1-rc1 released</title>
    <link>http://haskell.org/ghc/blog/20220721-ghc-9.4.1-rc1-released.html</link>
    <description><![CDATA[<h1>GHC 9.4.1-rc1 released</h1>
<h4 class="text-muted">bgamari - 2022-07-21</h4>

<p>The GHC developers are happy to announce the availability of the first
(and likely last) release candidate of GHC 9.4.1. Binary distributions, source
distributions, and documentation are available at
<a href="https://downloads.haskell.org/ghc/9.4.1-rc1">downloads.haskell.org</a>.</p>
<p>This release will include:</p>
<ul>
<li><p>A new profiling mode, <code>-fprof-late</code>, which adds automatic cost-center
annotations to all top-level functions <em>after</em> Core optimisation has
run. This provides informative profiles while interfering
significantly less with GHC’s aggressive optimisations, making it
easier to understand the performance of programs which depend upon
simplification..</p></li>
<li><p>A variety of plugin improvements including the introduction of a new
plugin type, <em>defaulting plugins</em>, and the ability for typechecking
plugins to rewrite type-families.</p></li>
<li><p>An improved constructed product result analysis, allowing unboxing of
nested structures, and a new boxity analysis, leading to less reboxing.</p></li>
<li><p>Introduction of a tag-check elision optimisation, bringing
significant performance improvements in strict programs.</p></li>
<li><p>Generalisation of a variety of primitive types to be levity
polymorphic. Consequently, the <code>ArrayArray#</code> type can at long last be
retired, replaced by standard <code>Array#</code>.</p></li>
<li><p>Introduction of the <code>\cases</code> syntax from <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0302-cases.rst">GHC proposal 0302</a>.</p></li>
<li><p>A complete overhaul of GHC’s Windows support. This includes a
migration to a fully Clang-based C toolchain, a deep refactoring of
the linker, and many fixes in WinIO.</p></li>
<li><p>Support for multiple home packages, significantly improving support
in IDEs and other tools for multi-package projects.</p></li>
<li><p>A refactoring of GHC’s error message infrastructure, allowing GHC to
provide diagnostic information to downstream consumers as structured
data, greatly easing IDE support.</p></li>
<li><p>Significant compile-time improvements to runtime and memory consumption.</p></li>
<li><p>On overhaul of our packaging infrastructure, allowing full
traceability of release artifacts and more reliable binary
distributions.</p></li>
<li><p>Reintroduction of deep subsumption (which was previously dropped with the
<em>simplified subsumption</em> change) as a language extension.</p></li>
<li><p>… and much more. See the <a href="https://downloads.haskell.org/~ghc/9.4.1-rc1/docs/users_guide/9.4.1-notes.html">release notes</a> for a full accounting.</p></li>
</ul>
<p>Note that, as 9.4.1 is the first release for which the released artifacts will
all be generated by our Hadrian build system, it is possible that there will be
packaging issues. If you enounter trouble while using a binary distribution,
please open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a>. Likewise, if you are a downstream packager, do consider
migrating to <a href="https://gitlab.haskell.org/ghc/ghc/-/blob/e2520df3fffa0cf22fb19c5fb872832d11c07d35/hadrian">Hadrian</a> to run your build; the Hadrian build system can be built
using <code>cabal-install</code>, <code>stack</code>, or the in-tree <a href="https://gitlab.haskell.org/ghc/ghc/-/blob/e2520df3fffa0cf22fb19c5fb872832d11c07d35/hadrian/bootstrap/README.md">bootstrap script</a>. We will be
publishing a blog post describing the migration process to Hadrian in the
coming weeks.</p>
<p>We would like to thank Microsoft Azure, GitHub, IOG, the Zw3rk
stake pool, Tweag I/O, Serokell, Equinix, SimSpace, Haskell Foundation, and other anonymous
contributors whose on-going financial and in-kind support has
facilitated GHC maintenance and release management over the years.
Finally, this release would not have been possible without the hundreds
of open-source contributors whose work comprise this release.</p>
<p>As always, do give this release a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see
anything amiss.</p>
<p>Happy testing,</p>
<ul>
<li>Ben</li>
</ul>
]]></description>
    <pubDate>Thu, 21 Jul 2022 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20220721-ghc-9.4.1-rc1-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.4.1-alpha3 released</title>
    <link>http://haskell.org/ghc/blog/20220624-ghc-9.4.1-alpha3-released.html</link>
    <description><![CDATA[<h1>GHC 9.4.1-alpha3 released</h1>
<h4 class="text-muted">bgamari - 2022-06-24</h4>

<p>The GHC developers are happy to announce the availability of the third
alpha release of the GHC 9.4 series. Binary distributions, source
distributions, and documentation are available at
<a href="https://downloads.haskell.org/ghc/9.4.1-alpha3">downloads.haskell.org</a>.</p>
<p>This major release will include:</p>
<ul>
<li><p>A new profiling mode, <code>-fprof-late</code>, which adds automatic cost-center
annotations to all top-level functions <em>after</em> Core optimisation has
run. This incurs significantly less performance cost while still
providing informative profiles.</p></li>
<li><p>A variety of plugin improvements including the introduction of a new
plugin type, <em>defaulting plugins</em>, and the ability for typechecking
plugins to rewrite type-families.</p></li>
<li><p>An improved constructed product result analysis, allowing unboxing of
nested structures, and a new boxity analysis, leading to less reboxing.</p></li>
<li><p>Introduction of a tag-check elision optimisation, bringing
significant performance improvements in strict programs.</p></li>
<li><p>Generalisation of a variety of primitive types to be levity
polymorphic. Consequently, the <code>ArrayArray#</code> type can at long last be
retired, replaced by standard <code>Array#</code>.</p></li>
<li><p>Introduction of the <code>\cases</code> syntax from <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0302-cases.rst">GHC proposal 0302</a></p></li>
<li><p>A complete overhaul of GHC’s Windows support. This includes a
migration to a fully Clang-based C toolchain, a deep refactoring of
the linker, and many fixes in WinIO.</p></li>
<li><p>Support for multiple home packages, significantly improving support
in IDEs and other tools for multi-package projects.</p></li>
<li><p>A refactoring of GHC’s error message infrastructure, allowing GHC to
provide diagnostic information to downstream consumers as structured
data, greatly easing IDE support.</p></li>
<li><p>Significant compile-time improvements to runtime and memory consumption.</p></li>
<li><p>On overhaul of our packaging infrastructure, allowing full
traceability of release artifacts and more reliable binary
distributions.</p></li>
<li><p>… and much more. See the <a href="https://downloads.haskell.org/~ghc/9.4.1-alpha3/docs/users_guide/9.4.1-notes.html">release notes</a> for a full accounting.</p></li>
</ul>
<p>Note that, as 9.4.1 is the first release for which the released
artifacts will all be generated by our Hadrian build system, it’s possible that there
will be packaging issues. If you enounter trouble while using a binary
distribution, please open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a>. Likewise, if you are a downstream
packager, do consider migrating to <a href="https://gitlab.haskell.org/ghc/ghc/-/blob/e2520df3fffa0cf22fb19c5fb872832d11c07d35/hadrian">Hadrian</a> to run your build; the
Hadrian build system can be built using <code>cabal-install</code>, <code>stack</code>, or the
in-tree <a href="https://gitlab.haskell.org/ghc/ghc/-/blob/e2520df3fffa0cf22fb19c5fb872832d11c07d35/hadrian/bootstrap/README.md">bootstrap script</a>.</p>
<p>We would like to thank Microsoft Azure, GitHub, IOG, the Zw3rk
stake pool, Tweag I/O, Serokell, Equinix, SimSpace, and other anonymous
contributors whose on-going financial and in-kind support has
facilitated GHC maintenance and release management over the years.
Finally, this release would not have been possible without the hundreds
of open-source contributors whose work comprise this release.</p>
<p>As always, do give this release a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see
anything amiss.</p>
<p>Happy testing,</p>
<ul>
<li>Ben</li>
</ul>
]]></description>
    <pubDate>Fri, 24 Jun 2022 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20220624-ghc-9.4.1-alpha3-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.2.3 is now available</title>
    <link>http://haskell.org/ghc/blog/20220527-ghc-9.2.3-released.html</link>
    <description><![CDATA[<h1>GHC 9.2.3 is now available</h1>
<h4 class="text-muted">Zubin Duggal - 2022-05-27</h4>

<p>The GHC developers are very happy to at announce the availability of GHC
9.2.3. Binary distributions, source distributions, and documentation are
available at <a href="https://downloads.haskell.org/ghc/9.2.3"><code>downloads.haskell.org</code></a>.</p>
<p>This release includes many bug-fixes and other improvements to 9.2.2 including:</p>
<ul>
<li><p>A fix to a critical linking bug on Windows causing the 9.2.2 release to be unusable (<a href="https://gitlab.haskell.org/ghc/ghc/issues/21196">#21196</a>).</p></li>
<li><p>Numerous bug fixes for regressions and other issues in the typechecker (<a href="https://gitlab.haskell.org/ghc/ghc/issues/2147">#2147</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/21515">#21515</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/20582">#20582</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/20820">#20820</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/21130">#21130</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/21479">#21479</a>).</p></li>
<li><p>Correctness bugs in the code generator and compiler backends (<a href="https://gitlab.haskell.org/ghc/ghc/issues/21396">#21396</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/20959">#20959</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/21465">#21465</a>).</p></li>
<li><p>Packaging fixes on many platforms (<a href="https://gitlab.haskell.org/ghc/ghc/issues/20760">#20760</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/21487">#21487</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/21402">#21402</a>).</p></li>
<li><p>Many others. See the <a href="https://downloads.haskell.org/ghc/9.2.3/docs/html/users_guide/9.2.3-notes.html">release notes</a> for a full list.</p></li>
</ul>
<p>As some of the fixed issues do affect correctness users are encouraged to
upgrade promptly.</p>
<p>We would like to thank Microsoft Azure, GitHub, IOG, the Zw3rk
stake pool, Tweag I/O, Serokell, Equinix, SimSpace, and other anonymous
contributors whose on-going financial and in-kind support has
facilitated GHC maintenance and release management over the years.
Finally, this release would not have been possible without the hundreds
of open-source contributors whose work comprise this release.</p>
<p>As always, do give this release a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see
anything amiss.</p>
<p>Happy compiling,</p>
<ul>
<li>Zubin</li>
</ul>
]]></description>
    <pubDate>Fri, 27 May 2022 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20220527-ghc-9.2.3-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.4.1-alpha2 released</title>
    <link>http://haskell.org/ghc/blog/20220524-ghc-9.4.1-alpha2-released.html</link>
    <description><![CDATA[<h1>GHC 9.4.1-alpha2 released</h1>
<h4 class="text-muted">bgamari - 2022-05-24</h4>

<p>The GHC developers are happy to announce the availability of the second
alpha release of the GHC 9.4 series. Binary distributions, source
distributions, and documentation are available at
<a href="https://downloads.haskell.org/ghc/9.4.1-alpha2">downloads.haskell.org</a>.</p>
<p>This major release will include:</p>
<ul>
<li><p>A new profiling mode, <code>-fprof-late</code>, which adds automatic cost-center
annotations to all top-level functions <em>after</em> Core optimisation has
run. This incurs significantly less performance cost while still
providing informative profiles.</p></li>
<li><p>A variety of plugin improvements including the introduction of a new
plugin type, <em>defaulting plugins</em>, and the ability for typechecking
plugins to rewrite type-families.</p></li>
<li><p>An improved constructed product result analysis, allowing unboxing of
nested structures, and a new boxity analysis, leading to less reboxing.</p></li>
<li><p>Introduction of a tag-check elision optimisation, bringing
significant performance improvements in strict programs.</p></li>
<li><p>Generalisation of a variety of primitive types to be levity
polymorphic. Consequently, the <code>ArrayArray#</code> type can at long last be
retired, replaced by standard <code>Array#</code>.</p></li>
<li><p>Introduction of the <code>\cases</code> syntax from <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0302-cases.rst">GHC proposal 0302</a></p></li>
<li><p>A complete overhaul of GHC’s Windows support. This includes a
migration to a fully Clang-based C toolchain, a deep refactoring of
the linker, and many fixes in WinIO.</p></li>
<li><p>Support for multiple home packages, significantly improving support
in IDEs and other tools for multi-package projects.</p></li>
<li><p>A refactoring of GHC’s error message infrastructure, allowing GHC to
provide diagnostic information to downstream consumers as structured
data, greatly easing IDE support.</p></li>
<li><p>Significant compile-time improvements to runtime and memory consumption.</p></li>
<li><p>On overhaul of our packaging infrastructure, allowing full
traceability of release artifacts and more reliable binary
distributions.</p></li>
<li><p>… and much more. See the <a href="https://downloads.haskell.org/~ghc/9.4.1-alpha2/docs/users_guide/9.4.1-notes.html">release notes</a> for a full accounting.</p></li>
</ul>
<p>Note that, as 9.4.1 is the first release for which the released
artifacts will all be generated by our Hadrian build system, it’s possible that there
will be packaging issues. If you enounter trouble while using a binary
distribution, please open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a>. Likewise, if you are a downstream
packager, do consider migrating to <a href="https://gitlab.haskell.org/ghc/ghc/-/blob/e2520df3fffa0cf22fb19c5fb872832d11c07d35/hadrian">Hadrian</a> to run your build; the
Hadrian build system can be built using <code>cabal-install</code>, <code>stack</code>, or the
in-tree <a href="https://gitlab.haskell.org/ghc/ghc/-/blob/e2520df3fffa0cf22fb19c5fb872832d11c07d35/hadrian/bootstrap/README.md">bootstrap script</a>.</p>
<p>We would like to thank Microsoft Azure, GitHub, IOG, the Zw3rk
stake pool, Tweag I/O, Serokell, Equinix, SimSpace, and other anonymous
contributors whose on-going financial and in-kind support has
facilitated GHC maintenance and release management over the years.
Finally, this release would not have been possible without the hundreds
of open-source contributors whose work comprise this release.</p>
<p>As always, do give this release a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see
anything amiss.</p>
<p>Happy testing,</p>
<ul>
<li>Ben</li>
</ul>
]]></description>
    <pubDate>Tue, 24 May 2022 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20220524-ghc-9.4.1-alpha2-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>Mid 2022 Release Plans</title>
    <link>http://haskell.org/ghc/blog/20220523-release-status.html</link>
    <description><![CDATA[<h1>Mid 2022 Release Plans</h1>
<h4 class="text-muted">Matthew Pickering - 2022-05-23</h4>

<p>This post sets out our current plans for the upcoming
releases in the next few months.</p>
<h2 id="section">9.4.1</h2>
<p>The next stage of the 9.4.1 release series (alpha2) will be released within the next few days.
The main changes in alpha2 relative to alpha1 are improvements to the packaging and
release process which have fixed a number of packaging bugs present in alpha1 due
to moving to bindists built by hadrian.</p>
<p>The final 9.4.1 release is scheduled for late July.</p>
<p>The release manager for this release is Ben Gamari.</p>
<h2 id="section-1">9.2.3</h2>
<p>The 9.2.3 release is scheduled to immediately follow the 9.4.1-alpha1. This
release fixes some packaging issues on Windows and a few bugs, notably:</p>
<ul>
<li>a panic involving unbound cycle-breaker variables that prevented several
libraries from compiling, such as <code>massiv-io</code> (<a href="https://gitlab.haskell.org/ghc/ghc/issues/20231">#20231</a>),</li>
<li>a typechecker regression in which GHC refused to use recursive equalities
involving type families (<a href="https://gitlab.haskell.org/ghc/ghc/issues/21473">#21473</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/21515">#21515</a>).</li>
</ul>
<p>The release manager for this release is Zubin Duggal.</p>
<h2 id="series">9.0.* series</h2>
<p>We do not intend to produce any more releases in the 9.0.* series.
From our perspective there are no serious bugs affecting the 9.0.2 release.
It is advised that users start using the 9.2 series, which we intend to stabilise
in the same manner as the 8.10 series. We have made this decision for the following
reasons:</p>
<ul>
<li>The 9.2 series does not contain significant breakage (when upgrading from 9.0)</li>
<li>Anecdotal evidence suggests that many companies are upgrading straight from 8.10.7
to 9.2.2 and skipping the 9.0.* releases.</li>
<li>We do not currently have capacity to manage 4 active branches.</li>
</ul>
<h2 id="conclusion">Conclusion</h2>
<p>This post summarises the latest state of the release cycles and our intent within
the next few months. If you have any questions or comments then please post
the next few months. If you have any questions or comments then please be in touch
via <a href="mailto:ghc-devs@haskell.org" class="uri">mailto:ghc-devs@haskell.org</a>.</p>
]]></description>
    <pubDate>Mon, 23 May 2022 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20220523-release-status.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.4.1-alpha1 released</title>
    <link>http://haskell.org/ghc/blog/20220501-ghc-9.4.1-alpha1-released.html</link>
    <description><![CDATA[<h1>GHC 9.4.1-alpha1 released</h1>
<h4 class="text-muted">bgamari - 2022-05-01</h4>

<p>The GHC developers are happy to announce the availability of the first
alpha release of the GHC 9.4 series. Binary distributions, source
distributions, and documentation are available at
<a href="https://downloads.haskell.org/ghc/9.4.1-alpha1">downloads.haskell.org</a>.</p>
<p>This major release will include:</p>
<ul>
<li><p>A new profiling mode, <code>-fprof-late</code>, which adds automatic cost-center
annotations to all top-level functions <em>after</em> Core optimisation has
run. This incurs significantly less performance cost while still
providing informative profiles.</p></li>
<li><p>A variety of plugin improvements including the introduction of a new
plugin type, <em>defaulting plugins</em>, and the ability for typechecking
plugins to rewrite type-families.</p></li>
<li><p>An improved constructed product result analysis, allowing unboxing of
nested structures, and a new boxity analysis, leading to less reboxing.</p></li>
<li><p>Introduction of a tag-check elision optimisation, bringing
significant performance improvements in strict programs.</p></li>
<li><p>Generalisation of a variety of primitive types to be levity
polymorphic. Consequently, the <code>ArrayArray#</code> type can at long last be
retired, replaced by standard <code>Array#</code>.</p></li>
<li><p>Introduction of the <code>\cases</code> syntax from <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0302-cases.rst">GHC proposal 0302</a></p></li>
<li><p>A complete overhaul of GHC’s Windows support. This includes a
migration to a fully Clang-based C toolchain, a deep refactoring of
the linker, and many fixes in WinIO.</p></li>
<li><p>Support for multiple home packages, significantly improving support
in IDEs and other tools for multi-package projects.</p></li>
<li><p>A refactoring of GHC’s error message infrastructure, allowing GHC to
provide diagnostic information to downstream consumers as structured
data, greatly easing IDE support.</p></li>
<li><p>Significant compile-time improvements to runtime and memory consumption.</p></li>
<li><p>… and much more</p></li>
</ul>
<p>We would like to thank Microsoft Azure, GitHub, IOG, the Zw3rk
stake pool, Tweag I/O, Serokell, Equinix, SimSpace, and other anonymous
contributors whose on-going financial and in-kind support has
facilitated GHC maintenance and release management over the years.
Finally, this release would not have been possible without the hundreds
of open-source contributors whose work comprise this release.</p>
<p>As always, do give this release a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see
anything amiss.</p>
<p>Happy testing,</p>
<ul>
<li>Ben</li>
</ul>
]]></description>
    <pubDate>Sun, 01 May 2022 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20220501-ghc-9.4.1-alpha1-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.2.2 is now available</title>
    <link>http://haskell.org/ghc/blog/20220305-ghc-9.2.2-released.html</link>
    <description><![CDATA[<h1>GHC 9.2.2 is now available</h1>
<h4 class="text-muted">bgamari - 2022-03-06</h4>

<p>The GHC developers are very happy to at announce the availability of GHC
9.2.2. Binary distributions, source distributions, and documentation are
available at <a href="https://downloads.haskell.org/ghc/9.2.2"><code>downloads.haskell.org</code></a>.</p>
<p>This release includes many bug-fixes and other improvements to 9.2.1 including:</p>
<ul>
<li><p>A number of bug-fixes in the new AArch64 native code generator</p></li>
<li><p>Fixes ensuring that the <code>indexWord8ArrayAs*#</code> family of primops is handled
correctly on platforms lacking support for unaligned memory accesses
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/21015">#21015</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/20987">#20987</a>).</p></li>
<li><p>Improvements to the compatibility story in GHC’s migration to the
XDG Base Directory Specification (<a href="https://gitlab.haskell.org/ghc/ghc/issues/20684">#20684</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/20669">#20669</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/20660">#20660</a>)</p></li>
<li><p>Restored compatibility with Windows 7</p></li>
<li><p>A new <code>-fcompact-unwind</code> flag, improving compatibility with C++ libraries on
Apple Darwin (<a href="https://gitlab.haskell.org/ghc/ghc/issues/11829">#11829</a>)</p></li>
<li><p>Introduction of a new flag, <code>-fcheck-prim-bounds</code>, enabling runtime bounds
checking of array primops (<a href="https://gitlab.haskell.org/ghc/ghc/issues/20769">#20769</a>)</p></li>
<li><p>Unboxing of unlifted types (<a href="https://gitlab.haskell.org/ghc/ghc/issues/20663">#20663</a>)</p></li>
<li><p>Numerous improvements in compiler performance.</p></li>
<li><p>Many, many others. See the <a href="https://downloads.haskell.org/ghc/9.2.2/docs/html/users_guide/9.2.2-notes.html">release notes</a> for a full list.</p></li>
</ul>
<p>As some of the fixed issues do affect correctness users are encouraged to
upgrade promptly.</p>
<p>Finally, thank you to Microsoft Research, GitHub, IOHK, the Zw3rk stake
pool, Tweag I/O, Serokell, Equinix, SimSpace, and other anonymous
contributors whose on-going financial and in-kind support has
facilitated GHC maintenance and release management over the years.
Moreover, this release would not have been possible without the hundreds
of open-source contributors whose work comprise this release.</p>
<p>As always, do open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see anything amiss.</p>
<p>Happy compiling,</p>
<ul>
<li>Ben</li>
</ul>
]]></description>
    <pubDate>Sun, 06 Mar 2022 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20220305-ghc-9.2.2-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.0.2 is now available</title>
    <link>http://haskell.org/ghc/blog/20211225-ghc-9.0.2-released.html</link>
    <description><![CDATA[<h1>GHC 9.0.2 is now available</h1>
<h4 class="text-muted">Zubin Duggal - 2021-12-25</h4>

<p>The GHC developers are very happy to at long last announce the availability of GHC
9.0.2. Binary distributions, source distributions, and documentation are
available at <a href="https://downloads.haskell.org/ghc/9.0.2"><code>downloads.haskell.org</code></a>.</p>
<p>GHC 9.0.2 adds first class AArch64/Darwin support using the LLVM backend, as
well as fixing a number of critical correctness bugs with the 9.0.1 release,
along with numerous improvements to compiler performance and memory usage:</p>
<ul>
<li><p>First-class support for Apple M1 hardware using GHC’s LLVM ARM backend.</p></li>
<li><p>Fix a number of incorrect rewrite rules for <code>fromInteger</code> (<a href="https://gitlab.haskell.org/ghc/ghc/issues/19345">#19345</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/20066">#20066</a>).</p></li>
<li><p>Fix a number of runtime system and GC bugs which typically manifested in
crashes (<a href="https://gitlab.haskell.org/ghc/ghc/issues/19417">#19417</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/19297">#19297</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/19645">#19645</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/19667">#19667</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/18033">#18033</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/20132">#20132</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/19715">#19715</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/20399">#20399</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/20414">#20414</a>,
<a href="https://gitlab.haskell.org/ghc/ghc/issues/20649">#20649</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/19147">#19147</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/20051">#20051</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/20093">#20093</a>)</p></li>
<li><p>Fixes for various compiler performance and memory usage issues (<a href="https://gitlab.haskell.org/ghc/ghc/issues/20134">#20134</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/13586">#13586</a>,
<a href="https://gitlab.haskell.org/ghc/ghc/issues/20509">#20509</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/19668">#19668</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/19996">#19996</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/19471">#19471</a>)</p></li>
<li><p>Improvements and bug fixes for the code generator and optimiser (<a href="https://gitlab.haskell.org/ghc/ghc/issues/18638">#18638</a>,
<a href="https://gitlab.haskell.org/ghc/ghc/issues/19581">#19581</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/19700">#19700</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/19996">#19996</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/19181">#19181</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/19822">#19822</a>)</p></li>
<li><p>Fixes for typechecker bugs (<a href="https://gitlab.haskell.org/ghc/ghc/issues/19410">#19410</a> , <a href="https://gitlab.haskell.org/ghc/ghc/issues/19191">#19191</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/19522">#19522</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/19400">#19400</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/19849">#19849</a>)</p></li>
<li><p>Bug fixes for the frontend and parser (<a href="https://gitlab.haskell.org/ghc/ghc/issues/19397">#19397</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/19838">#19838</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/19518">#19518</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/19777">#19777</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/20242">#20242</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/19786">#19786</a>)</p></li>
<li><p>Emit warnings if Unicode Bidirectional Formatting characters are found in the source,
possibly misleading code reviewers (<a href="https://gitlab.haskell.org/ghc/ghc/issues/20263">#20263</a>, <a href="https://trojansource.codes/">vulnerability website</a>).</p></li>
<li><p>Many packaging related fixes, including versioned <code>ghc-pkg</code> executables
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/20087">#20087</a>), and actually distributing GHC versions linked against the
<code>native</code> big integer backend (<a href="https://gitlab.haskell.org/ghc/ghc/issues/18967">#18967</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/19953">#19953</a>) on both Windows and Alpine
Linux. Some previous releases were still linked against the <code>GMP</code> library due to a
misconfiguration of the builders.</p></li>
<li><p>A significant refactoring of <code>process</code> fixing numerous bugs mostly on
Apple platforms (<a href="https://gitlab.haskell.org/ghc/ghc/issues/19994">#19994</a>, <a href="https://github.com/haskell/process/pull/208">process refactoring</a>).</p></li>
<li><p>Bug fixes for the linker on Darwin platforms (<a href="https://gitlab.haskell.org/ghc/ghc/issues/20004">#20004</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/19968">#19968</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/19950">#19950</a>).</p></li>
</ul>
<p>A complete list of bug fixes and improvements can be found in the <a href="https://downloads.haskell.org/ghc/9.0.2/docs/html/users_guide/9.0.2-notes.html">release
notes</a>.</p>
<p>Finally, thank you to Microsoft Research, GitHub, IOHK, the Zw3rk stake
pool, Tweag I/O, Serokell, Equinix, SimSpace, and other anonymous
contributors whose on-going financial and in-kind support has
facilitated GHC maintenance and release management over the years.
Moreover, this release would not have been possible without the hundreds
of open-source contributors whose work comprise this release.</p>
<p>As always, do open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see anything amiss.</p>
]]></description>
    <pubDate>Sat, 25 Dec 2021 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20211225-ghc-9.0.2-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.2.1 is now available</title>
    <link>http://haskell.org/ghc/blog/20211029-ghc-9.2.1-released.html</link>
    <description><![CDATA[<h1>GHC 9.2.1 is now available</h1>
<h4 class="text-muted">bgamari - 2021-10-29</h4>

<p>The GHC developers are very happy to at long last announce the availability of GHC
9.2.1. Binary distributions, source distributions, and documentation are
available at <a href="https://downloads.haskell.org/ghc/9.2.1"><code>downloads.haskell.org</code></a>.</p>
<p>GHC 9.2 brings a number of exciting features including:</p>
<ul>
<li><p>A native code generation backend for AArch64, significantly speeding
compilation time on ARM platforms like the Apple M1.</p></li>
<li><p>Many changes in the area of records, including the new
<code>RecordDotSyntax</code> and <code>NoFieldSelectors</code> language extensions, as well
as Support for <code>DuplicateRecordFields</code> with <code>PatternSynonyms</code>.</p></li>
<li><p>Introduction of the new <code>GHC2021</code> language extension set, giving
users convenient access to a larger set of language extensions which
have been long considered stable.</p></li>
<li><p>Merging of <code>ghc-exactprint</code> into the GHC tree, providing
infrastructure for source-to-source program rewriting out-of-the-box.</p></li>
<li><p>Introduction of a <code>BoxedRep</code> <code>RuntimeRep</code>, allowing for polymorphism
over levity of boxed objects (<a href="https://gitlab.haskell.org/ghc/ghc/issues/17526">#17526</a>)</p></li>
<li><p>Implementation of the <code>UnliftedDataTypes</code> extension, allowing users
to define types which do not admit lazy evaluation (<a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0265-unlifted-datatypes.rst">proposal</a>)</p></li>
<li><p>The new [<code>-hi</code> profiling][] mechanism which provides significantly
improved insight into thunk leaks.</p></li>
<li><p>Support for the <code>ghc-debug</code> out-of-process heap inspection library
<a href="http://ghc.gitlab.haskell.org/ghc-debug/">ghc-debug</a></p></li>
<li><p>Significant improvements in the bytecode interpreter, allowing more
programs to be efficently run in GHCi and Template Haskell splices.</p></li>
<li><p>Support for profiling of pinned objects with the cost-centre profiler
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/7275">#7275</a>)</p></li>
<li><p>Faster compilation and a smaller memory footprint</p></li>
<li><p>Introduction of Haddock documentation support in TemplateHaskell (<a href="https://gitlab.haskell.org/ghc/ghc/issues/5467">#5467</a>)</p></li>
</ul>
<p>Finally, thank you to Microsoft Research, GitHub, IOHK, the Zw3rk stake
pool, Tweag I/O, Serokell, Equinix, SimSpace, and other anonymous
contributors whose on-going financial and in-kind support has
facilitated GHC maintenance and release management over the years.
Moreover, this release would not have been possible without the hundreds
of open-source contributors whose work comprise this release.</p>
<p>As always, do open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see anything amiss.</p>
<p>Happy testing,</p>
<ul>
<li>Ben</li>
</ul>
]]></description>
    <pubDate>Fri, 29 Oct 2021 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20211029-ghc-9.2.1-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 8.10.7 is now available</title>
    <link>http://haskell.org/ghc/blog/20210827-ghc-8.10.7-released.html</link>
    <description><![CDATA[<h1>GHC 8.10.7 is now available</h1>
<h4 class="text-muted">Zubin Duggal - 2021-08-27</h4>

<p>The GHC team is very pleased to announce the availability of GHC
8.10.7. Source and binary distributions are available at the <a href="https://downloads.haskell.org/ghc/8.10.7/">usual
place</a>.</p>
<p>This is a small bugfix release, fixing one linking portability issue (<a href="https://gitlab.haskell.org/ghc/ghc/issues/19950">#19950</a>)
present in GHC 8.10.5 and GHC 8.10.6 on some x86_64 macOS toolchains, which
resulted in undefined symbol errors for <code>___darwin_check_fd_set_overflow</code>.</p>
<p>Issue <a href="https://gitlab.haskell.org/ghc/ghc/issues/19950">#19950</a> is caused by a bug in newer Apple toolchains (specifically XCode
12) where programs compiled with affected versions of XCode are not backwards
compatible with configurations running older version of XCode (certain versions
of XCode 11).</p>
<p>We claimed to have fixed this in GHC 8.10.6, but alas this wasn’t the case. The
fix was originally tested on the master branch, which uses a different build
configuration from the 8.10 branch. We have now tested the fix on the GHC 8.10
branch and finally squashed the bug.</p>
<p>We would like to thank Microsoft Research, GitHub, IOHK, the Zw3rk stake pool,
Tweag I/O, Serokell, Equinix, SimSpace, and other anonymous contributors whose
on-going financial and in-kind support has facilitated GHC maintenance and
release management over the years. We would also like to thank the hundreds of
open-source contributors whose work makes GHC possible.</p>
<p>A complete list of bug fixes and improvements can be found in the <a href="https://downloads.haskell.org/ghc/8.10.7/docs/html/users_guide/8.10.7-notes.html">release
notes</a>.</p>
<p>As always, feel free to report any issues you encounter via
<a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">gitlab.haskell.org</a>.</p>
]]></description>
    <pubDate>Fri, 27 Aug 2021 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20210827-ghc-8.10.7-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 8.10.6 is now available</title>
    <link>http://haskell.org/ghc/blog/20210814-ghc-8.10.6-released.html</link>
    <description><![CDATA[<h1>GHC 8.10.6 is now available</h1>
<h4 class="text-muted">Zubin Duggal - 2021-08-14</h4>

<p>The GHC team is very pleased to announce the availability of GHC 8.10.6.
Source and binary distributions are available at the <a href="https://downloads.haskell.org/ghc/8.10.6/">usual
place</a>.</p>
<p>This is a bugfix release, fixing many issues present in GHC 8.10.5, including:</p>
<ul>
<li><p>A fix for segmentation faults in GHCi on <code>aarch64-darwin</code> due to
an incorrect foreign import in <code>haskeline</code>. See <a href="https://www.haskell.org/ghc/blog/20210709-capi-usage.html">this blog
post</a> by Ben Gamari
for more details on how your library could be affected.</p></li>
<li><p>A fix for a critical bug affecting Haskell Language Server (HLS) among other
applications caused by missing RTS symbols required for statically linked
builds of the GHC library (<a href="https://gitlab.haskell.org/ghc/ghc/issues/19763">#19763</a>).</p></li>
<li><p>No longer emitting spurious warnings for LLVM versions (LLVM 9-12) that were
actually supported (<a href="https://gitlab.haskell.org/ghc/ghc/issues/19973">#19973</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/19829">#19829</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/19959">#19959</a>).</p></li>
<li><p>Numerous bug fixes for the new LLVM based <code>aarch64-darwin</code> backend (<a href="https://gitlab.haskell.org/ghc/ghc/issues/20132">#20132</a>).</p></li>
<li><p>Fixes and stability improvements for the non-moving GC (<a href="https://gitlab.haskell.org/ghc/ghc/issues/19715">#19715</a>).</p></li>
<li><p>Many other bug fixes for the RTS (<a href="https://gitlab.haskell.org/ghc/ghc/issues/18033">#18033</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/20132">#20132</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/20093">#20093</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/19421">#19421</a>).</p></li>
<li><p>Many packaging related fixes, including versioned <code>ghc-pkg</code> executables
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/20087">#20087</a>), and actually distributing GHC versions linked against the
<code>integer-simple</code> big integer backend (<a href="https://gitlab.haskell.org/ghc/ghc/issues/18967">#18967</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/19953">#19953</a>) on both Windows and Alpine
Linux. Previous releases were still linked against the <code>GMP</code> library due to a
misconfiguration of the builders.</p></li>
<li><p>A significant refactoring of <code>process</code> fixing numerous bugs mostly on
Apple platforms (<a href="https://gitlab.haskell.org/ghc/ghc/issues/19994">#19994</a>, <a href="https://github.com/haskell/process/pull/208">process refactoring</a>).</p></li>
<li><p>A FreeBSD release after fixing issues that caused GHC 8.10.5 to be unable to build
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/19958">#19958</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/19948">#19948</a>).</p></li>
<li><p>Bug fixes for the linker on Darwin platforms (<a href="https://gitlab.haskell.org/ghc/ghc/issues/20004">#20004</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/19968">#19968</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/19950">#19950</a>).</p></li>
</ul>
<p>A complete list of bug fixes and improvements can be found in the <a href="https://downloads.haskell.org/ghc/8.10.6/docs/html/users_guide/8.10.6-notes.html">release
notes</a>.</p>
<p>As always, feel free to report any issues you encounter via
<a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">gitlab.haskell.org</a>.</p>
]]></description>
    <pubDate>Sat, 14 Aug 2021 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20210814-ghc-8.10.6-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.2.1-rc1 is now available</title>
    <link>http://haskell.org/ghc/blog/20210807-ghc-9.2.1-rc1-released.html</link>
    <description><![CDATA[<h1>GHC 9.2.1-rc1 is now available</h1>
<h4 class="text-muted">bgamari - 2021-08-07</h4>

<p>The GHC team is very happy to announce the availability of the
release cadidate of the 9.2.1 release. Binary distributions, source
distributions, and documentation are available at
<a href="https://downloads.haskell.org/ghc/9.2.1-rc1">downloads.haskell.org</a>.</p>
<p>GHC 9.2 will bring a number of exciting features including:</p>
<ul>
<li><p>A native code generation backend for AArch64, significantly reducing
compilation times on ARM platforms such as the Apple M1.</p></li>
<li><p>Many changes in the area of records, including the new
<code>RecordDotSyntax</code> and <code>NoFieldSelectors</code> language extensions, as well
as Support for <code>DuplicateRecordFields</code> with <code>PatternSynonyms</code>.</p></li>
<li><p>Introduction of the new <code>GHC2021</code> language extension set, giving
users convenient access to a larger set of language extensions which
have been long considered stable.</p></li>
<li><p>Merge of <code>ghc-exactprint</code> into the GHC tree, providing infrastructure
for source-to-source program rewriting out-of-the-box.</p></li>
<li><p>Introduction of a <code>BoxedRep</code> <code>RuntimeRep</code>, allowing for polymorphism
over levity of boxed objects (<a href="https://gitlab.haskell.org/ghc/ghc/issues/17526">#17526</a>)</p></li>
<li><p>Implementation of the <code>UnliftedDataTypes</code> extension, allowing users
to define types which do not admit lazy evaluation (<a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0265-unlifted-datatypes.rst">proposal</a>)</p></li>
<li><p>The new <a href="https://well-typed.com/blog/2021/01/first-look-at-hi-profiling-mode/">-hi profiling</a> mechanism which provides significantly
improved insight into thunk leaks.</p></li>
<li><p>Support for the <code>ghc-debug</code> out-of-process heap inspection library
<a href="http://ghc.gitlab.haskell.org/ghc-debug/">ghc-debug</a></p></li>
<li><p>Support for profiling of pinned objects with the cost-centre profiler
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/7275">#7275</a>)</p></li>
<li><p>Introduction of Haddock documentation support in TemplateHaskell (<a href="https://gitlab.haskell.org/ghc/ghc/issues/5467">#5467</a>)</p></li>
</ul>
<p>Thank you to GitHub, IOHK, the Zw3rk stake pool, Tweag I/O, Serokell,
Equinix, SimSpace, and other anonymous contributors whose on-going
financial and in-kind support has facilitated GHC maintenance and
release management over the years. Moreover, this release would not have
been possible without the hundreds of open-source contributors whose
work comprise this release.</p>
<p>As always, do give this a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see anything amiss.</p>
<p>Happy testing,</p>
<ul>
<li>Ben</li>
</ul>
]]></description>
    <pubDate>Sat, 07 Aug 2021 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20210807-ghc-9.2.1-rc1-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>Best practices for foreign imports</title>
    <link>http://haskell.org/ghc/blog/20210709-capi-usage.html</link>
    <description><![CDATA[<h1>Best practices for foreign imports</h1>
<h4 class="text-muted">bgamari - 2021-07-12</h4>

<p>tl;dr: When importing system libraries we strongly recommend that users use
GHC’s <a href="https://downloads.haskell.org/ghc/9.0.1/docs/html/users_guide/exts/ffi.html?highlight=capiffi#extension-CApiFFI"><code>capi</code> calling convention</a>. For details, see the <a href="#recommendations">recommendations
section</a> below.</p>
<p>One of Haskell’s strengths is its great foreign function interface: using
time-tested foreign libraries or raw system calls is just a <code>foreign import</code>
away. However, while syntactically simple, safely using foreign functions can be
quite tricky. A few weeks ago we saw one facet of this problem in the
<a href="https://www.haskell.org/ghc/blog/20210607-the-keepAlive-story.html"><code>keepAlive#</code> post</a>.
This week we will look at another complexity which has recently caused us
trouble: calling conventions.</p>
<h2 id="why-this-matters">Why this matters</h2>
<p>With the increasing prevalance of ARM hardware with Apple’s recent releases,
many latent bugs due to calling convention details are becoming more visible.</p>
<p>For instance, in <a href="https://gitlab.haskell.org/ghc/ghc/issues/20079">#20079</a> it was noticed that GHCi crashes on
AArch64/Darwin when the terminal window is resized. We eventually found that
this was due to a <a href="https://github.com/judah/haskeline/issues/162">bug</a> in <code>haskeline</code>: <code>ioctl</code>, a variadic
function, was <a href="https://github.com/judah/haskeline/blob/c03e7029b2d9c3d16da5480306b42b8d4ebe03cf/System/Console/Haskeline/Backend/Posix.hsc#L64">imported</a> using GHC’s <code>ccall</code> calling convention.
The <a href="https://github.com/judah/haskeline/pull/163/files">fix</a> is straightforward: use the <a href="https://downloads.haskell.org/ghc/9.0.1/docs/html/users_guide/exts/ffi.html?highlight=capiffi#extension-CApiFFI"><code>capi</code> pseudo-calling
convention</a> introduced in GHC 7.6.1.</p>
<p>It turns out that incorrect <code>ioctl</code> imports is <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/20085#note_363651">rather common
pattern</a> among
Hackage packages. Consequently, we thought it would be helpful to offer some
explicit guidance for users.</p>
<h2 id="background-foreign-calling-conventions">Background: Foreign calling conventions</h2>
<p>During a function call both the caller and the callee must agree on several
operational details:</p>
<ul>
<li>when the function is called:
<ul>
<li>which arguments can be passed in registers?</li>
<li>in what order are the remaining arguments pushed to the stack?</li>
<li>how are variadic functions handled?</li>
<li>must the stack be aligned?</li>
<li>where is the return address found?</li>
</ul></li>
<li>when the function returns:
<ul>
<li>who is responsible for popping the arguments from the stack?</li>
<li>where is the return value(s) stored?</li>
</ul></li>
</ul>
<p>Together, these details are known as a <em>calling convention</em> and are typically
implied by the operating system and target architecture. For instance, x86-64 Linux
(and most other POSIX platforms) typically uses the <a href="https://github.com/hjl-tools/x86-psABI/wiki/x86-64-psABI-1.0.pdf">System V amd64 calling
convention</a> whereas 32-bit Windows has no fewer than three commonly-used
conventions.</p>
<p>When compiling C source, the C compiler determines a function’s
calling convention using its <em>signature</em>, which typically appears in a header
file. However, when GHC imports a function with the usual <code>ccall</code> calling convention, e.g.:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a>foreign <span class="kw">import</span> ccall &quot;hello_world&quot; helloWorld :: <span class="dt">IO</span> ()</span></code></pre></div>
<p>it does not have the benefit of a signature; instead it must infer the calling
convention from the type given by the import. This can break in two ways:</p>
<ul>
<li>many calling conventions treat variadic functions (e.g. <code>printf</code>)
differently from the corresponding non-variadic signature; while it is
<a href="https://downloads.haskell.org/ghc/9.0.1/docs/html/users_guide/exts/ffi.html?highlight=capiffi#varargs-not-supported-by-ccall-calling-convention">documented</a> that <code>ccall</code> does not support variadic
functions, this fact is not well-known by users.</li>
<li>the type provided by the user may be wrong (e.g. using <code>Int</code> instead of <code>CInt</code>)</li>
</ul>
<p>Unfortunately, with the <code>foreign import ccall</code> mechanism the compiler has no
way of catching such issues, potentially leaving the user with
difficult-to-spot, platform-dependent soundness bugs.</p>
<h2 id="safe-foreign-calls-via-capiffi">Safe foreign calls via <code>CApiFFI</code></h2>
<p>To address help mitigate this class of bugs, GHC 7.10 introduced a new language
extension, <a href="https://downloads.haskell.org/ghc/9.0.1/docs/html/users_guide/exts/ffi.html?highlight=capiffi#extension-CApiFFI"><code>CApiFFI</code></a>, which offers a more robust way to import foreign
functions. Unlike <code>ccall</code>, <code>capi</code> requires that the user specify both the
foreign function’s name as well as the name of the header file where its
signature can be found. For instance, one can write:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>foreign <span class="kw">import</span> capi &quot;stdio.h puts&quot; c_puts :: <span class="dt">Ptr</span> <span class="dt">CChar</span> -&gt; <span class="dt">IO</span> <span class="dt">CInt</span></span></code></pre></div>
<p>To compile this, GHC will construct a C source file which <code>#include</code>’s
<code>stdio.h</code>. and defines a stub function which performs the call:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="pp">#include </span><span class="im">&quot;stdio.h&quot;</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a>HsInt32 ghczuwrapperZC0ZCmainZCHelloZCputs<span class="op">(</span><span class="dt">void</span><span class="op">*</span> a1<span class="op">)</span> <span class="op">{</span></span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a>    <span class="cf">return</span> puts<span class="op">(</span>a1<span class="op">);</span></span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
<p>This approach brings a few advantages:</p>
<ul>
<li><code>capi</code> imports can be used to import functions defined using CPP</li>
<li>the calling convention is decided by the C compiler using the signature
provided in the indicated header file, eliminating the potential for
inconsistency</li>
<li>variadic functions “just work”</li>
<li>it removes the need to worry about which of Windows’ zoo of supported
conventions is used (see <a href="https://gitlab.haskell.org/ghc/ghc/issues/12890">#12890</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/3052">#3052</a>)</li>
</ul>
<h2 id="recommendations">Recommendations for users</h2>
<p>As a rule, the easiest code to debug is the code that you don’t need to write.
Consequently, users are encouraged to use existing bindings libraries (e.g.
<code>unix</code>) instead of defining their own foreign imports when possible.</p>
<p>Of course, not all libraries have bindings available. In these cases we
recommend that users use <code>foreign import capi</code> for imports of libraries not under
their control (e.g. system libraries).</p>
<p>Note, however, that <code>capi</code> does incur a small (arguably negligible) runtime
cost due to the to the C stub. It is justifiable to use <code>ccall</code> to avoid this
runtime cost in cases where the foreign function is shipped with a package’s
<code>cbits</code>, where the calling convention is clear.</p>
]]></description>
    <pubDate>Mon, 12 Jul 2021 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20210709-capi-usage.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>The tale of keepAlive#</title>
    <link>http://haskell.org/ghc/blog/20210607-the-keepAlive-story.html</link>
    <description><![CDATA[<h1>The tale of keepAlive#</h1>
<h4 class="text-muted">bgamari - 2021-06-08</h4>

<p>In GHC 9.0 we have reworked the primops used for guaranteeing heap object
lifetime in the presence of off-heap references.
The result is a new primop, <code>keepAlive#</code>, which largely replaces the venerable
<code>touch#</code> operation. This post will give some background on <code>touch#</code>, describe
the rationale for this change, discuss some of the alternatives that were
evaluated on the way to this new design, and provide some guidance on how this
change affects users.</p>
<p>Users who merely want to know how to adapt their existing <code>touch#</code> uses for the
new <code>keepAlive#</code> should feel free to skip to the <a href="#keepAlive">last section</a> of
the post.</p>
<h2 id="the-challenge-of-foreign-references">The challenge of foreign references</h2>
<p>One of the joys of working in a garbage collected language
is that one is freed from the burden of thinking about object lifetime.
Instead, it is the responsibility of the runtime to retain each object
as long as it is reachable from the roots of the heap graph.</p>
<p>Moreover, one of the great joys of Haskell is its robust foreign function
interface, giving users the ability to easily weave together Haskell and
foreign code in a safe and efficient manner.</p>
<p>However, taken together these two features pose significant
challenges to language implementors; specifically, consider a program such as:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="co">-- Recall that:</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="co">--   newPinnedByteArray       :: Int -&gt; IO (MutableByteArray RealWorld)</span></span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="co">--   setByteArray             :: Prim a =&gt; MutableByteArray RealWorld -&gt; Int -&gt; Int -&gt; a -&gt; IO ()</span></span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a><span class="co">--   mutableByteArrayContents :: MutableByteArray RealWorld -&gt; Ptr a</span></span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a><span class="kw">import</span> <span class="dt">Data.Primitive.ByteArray</span></span>
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a>main <span class="ot">=</span> printDots <span class="dv">10</span></span>
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a><span class="ot">printDots ::</span> <span class="dt">Int</span> <span class="ot">-&gt;</span> <span class="dt">IO</span> ()</span>
<span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a>printDots len <span class="ot">=</span> <span class="kw">do</span></span>
<span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a>    arr <span class="ot">&lt;-</span> newPinnedByteArray len</span>
<span id="cb1-12"><a href="#cb1-12" aria-hidden="true" tabindex="-1"></a>    setByteArray arr <span class="dv">0</span> len (<span class="fu">fromIntegral</span> <span class="op">$</span> <span class="fu">ord</span> <span class="ch">&#39;.&#39;</span><span class="ot"> ::</span> <span class="dt">Word8</span>)</span>
<span id="cb1-13"><a href="#cb1-13" aria-hidden="true" tabindex="-1"></a>    <span class="kw">let</span><span class="ot"> ptr ::</span> <span class="dt">Ptr</span> <span class="dt">CChar</span></span>
<span id="cb1-14"><a href="#cb1-14" aria-hidden="true" tabindex="-1"></a>        ptr <span class="ot">=</span> byteArrayContents arr</span>
<span id="cb1-15"><a href="#cb1-15" aria-hidden="true" tabindex="-1"></a>    puts ptr</span>
<span id="cb1-16"><a href="#cb1-16" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-17"><a href="#cb1-17" aria-hidden="true" tabindex="-1"></a><span class="co">-- Recall that:</span></span>
<span id="cb1-18"><a href="#cb1-18" aria-hidden="true" tabindex="-1"></a><span class="co">--   void puts(const char *);</span></span>
<span id="cb1-19"><a href="#cb1-19" aria-hidden="true" tabindex="-1"></a>foreign <span class="kw">import</span> ccall &quot;puts&quot;</span>
<span id="cb1-20"><a href="#cb1-20" aria-hidden="true" tabindex="-1"></a><span class="ot">    puts ::</span> <span class="dt">Ptr</span> <span class="dt">CChar</span> <span class="ot">-&gt;</span> <span class="dt">IO</span> ()</span></code></pre></div>
<p>Here we have allocated an array on the Haskell heap, initialized it, and passed
it to the C <code>puts</code> function, which will print it to <code>stdout</code>. On its face, this
program looks completely innocuous: it contains no mentions of <code>unsafe</code>
functions, the array’s bounds are clearly respected, and <code>puts</code> is specified to
treat its argument as immutable. Indeed, running the program even prints the
expected result (at least most of the time).</p>
<p>However, despite its appearance, this program is fatally flawed. Specifically,
note that <code>puts</code> is (implicitly) declared to be a <code>safe</code> foreign call; this
means that GHC is free to do as it pleases (e.g. continue running another
Haskell thread or, perhaps, initiate a GC) while the C call executes in another
operating system thread. This is problematic since upon entering <code>puts</code> there
are no references to <code>arr</code> remaining on the Haskell heap, leading the collector
to conclude that the array can be safely reclaimed. However, <code>arr</code> is <em>not</em>
dead: it is still in use via the <em>off-heap</em> reference passed to <code>puts</code>.
However, this reference is not visible to the garbage collector.</p>
<p>Premature collection of live heap objects may result in arbitrary heap
corruption, which may cause a program crash at best and incorrect runtime
result at worst. Also note that while FFI is the most common reason for off-heap
references, it is certainly not the only reason. In particular, any use of
<code>byteArrayContents</code> is potentially problematic in this way.</p>
<p>To make such off-heap references visible to the runtime, GHC has long provided the
<code>touch</code> operation (embodied by the <code>GHC.Exts.touch#</code> primop):</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ot">touch ::</span> <span class="kw">forall</span> a<span class="op">.</span> a <span class="ot">-&gt;</span> <span class="dt">IO</span> ()</span></code></pre></div>
<p>Semantically (and, mostly, operationally) the action <code>touch x</code> is a no-op; it
merely instructs GHC to ensure that the given value is alive at the point when the
action is executed. Using this operation we can fix <code>printDots</code> as follows:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a>printDots len <span class="ot">=</span> </span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a>    arr <span class="ot">&lt;-</span> newPinnedByteArray len</span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a>    setByteArray arr <span class="dv">0</span> len (<span class="fu">fromIntegral</span> <span class="op">$</span> <span class="fu">ord</span> <span class="ch">&#39;.&#39;</span><span class="ot"> ::</span> <span class="dt">Word8</span>)</span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a>    puts (byteArrayContents arr)</span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a>    touch arr</span></code></pre></div>
<p>Here we have added a <code>touch</code> after the <code>puts</code>, ensuring that <code>arr</code> is retained
<em>at least</em> until the call has returned.</p>
<p>To a functional programmer, <code>touch</code> may smell a bit odd, merely serving to
introduce a side-effect. By contrast, most idiomatic Haskell libraries rather
express resource lifetimes using the “with” pattern. That is, rather than
write:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a>hdl <span class="ot">&lt;-</span> openFile <span class="st">&quot;hello.txt&quot;</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a>hPutStrLn hdl <span class="st">&quot;hello world!&quot;</span></span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a>hClose hdl</span></code></pre></div>
<p>We prefer to write:
<code>withFile</code>:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a>withFile <span class="st">&quot;hello.txt&quot;</span> <span class="op">$</span> \hdl <span class="ot">-&gt;</span></span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a>    hPutStrLn hdl <span class="st">&quot;hello world!&quot;</span></span></code></pre></div>
<p>as the latter makes the lifetime of the resource apparent from the program’s
syntactic structure alone. In the same way, users have historically been advised
to stay away from using <code>touch</code> and its variants directly. For instance, while
<code>Foreign.ForeignPtr</code> provides a <a href="https://hackage.haskell.org/package/base-4.15.0.0/docs/Foreign-ForeignPtr.html#v:touchForeignPtr"><code>touchForeignPtr</code></a> operation the documentation
strong recommends that the user rather use <a href="https://hackage.haskell.org/package/base-4.15.0.0/docs/Foreign-ForeignPtr.html#v:withForeignPtr"><code>withForeignPtr</code></a>.</p>
<p>While it is rarely seen in user code, the <code>touch#</code> primop has served
the Haskell community well for many years: a handful of occurrences in <code>base</code>,
<code>bytestring</code>, and other foundational libraries ensured that garbage colection
and foreign calls could peacefully coexist. However, as we will see, the design
of the primop is ripe for unsoundness.</p>
<h2 id="aside-a-bit-of-simplifier-background">Aside: A bit of simplifier background</h2>
<p>Over the years GHC’s simplifier (the GHC subsystem responsible for
optimising programs in its Core intermediate representation)
has consistently grown in its abilities. By GHC 8.2 we started to come to
the realization that all was not well with <code>touch#</code>. To see why, let us examine
a transform performed by GHC’s simplifier which I will call <em>dead-continuation
elimination</em> (DCE).</p>
<p>Consider that you have a program such as:</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a>doThings <span class="ot">=</span></span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a>    <span class="kw">case</span> <span class="fu">error</span> <span class="st">&quot;hello world&quot;</span><span class="ot"> ::</span> <span class="dt">Int</span> <span class="kw">of</span></span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a>      <span class="dv">0</span>  <span class="ot">-&gt;</span>  <span class="co">{- some large expression -}</span></span>
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a>      <span class="dv">1</span>  <span class="ot">-&gt;</span>  <span class="co">{- another large expression -}</span></span>
<span id="cb6-5"><a href="#cb6-5" aria-hidden="true" tabindex="-1"></a>      <span class="op">...</span></span></code></pre></div>
<p>Here we have a program with a divergent expression (namely the <code>error</code>
application) scrutinized by a <code>case</code> with a number of large alternatives.
Under Haskell’s semantics, it is impossible for program execution to reach
any of these alternatives’ right-hand-sides.</p>
<p>By the dead-continuation elimination transform, GHC’s simplifier will cull this
unreachable code, turning the program into:</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a>doThings <span class="ot">=</span></span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a>    <span class="kw">case</span> <span class="fu">error</span> <span class="st">&quot;hello world&quot;</span><span class="ot"> ::</span> <span class="dt">Int</span> <span class="kw">of</span> { }</span></code></pre></div>
<p>This optimisation can significantly reduce program sizes. Note that exceptions
are only one source of divergence: any non-terminating scrutinee can trigger this
transformation.</p>
<h2 id="the-shortcomings-of-touch">The shortcomings of <code>touch#</code></h2>
<p>With this transformation in mind, consider a trivial modification to the
original <code>printDots</code> program which loops the <code>puts</code> call infinitely:</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="ot">printManyDots ::</span> <span class="dt">Int</span> <span class="ot">-&gt;</span> <span class="dt">IO</span> ()</span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a>printManyDots len <span class="ot">=</span> <span class="kw">do</span></span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a>    arr <span class="ot">&lt;-</span> newPinnedByteArray len</span>
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a>    setByteArray arr <span class="dv">0</span> len (<span class="fu">fromIntegral</span> <span class="op">$</span> <span class="fu">ord</span> <span class="ch">&#39;.&#39;</span><span class="ot"> ::</span> <span class="dt">Word8</span>)</span>
<span id="cb8-5"><a href="#cb8-5" aria-hidden="true" tabindex="-1"></a>    forever <span class="op">$</span> puts (byteArrayContents arr)</span>
<span id="cb8-6"><a href="#cb8-6" aria-hidden="true" tabindex="-1"></a>    touch arr</span></code></pre></div>
<p>At its face, this modification looks benign enough; indeed, many server
applications take a very similar form (replacing <code>puts</code> with some request
handling logic). However in <a href="https://gitlab.haskell.org/ghc/ghc/issues/14346">#14346</a> we noticed that the simplifier could in
some cases determine that the <code>forever $ ...</code> expression would diverge and
consequently that the <code>touch arr</code> continuation was unreachable. By the DCE
transform, this continuation could be dropped. Without the <code>touch</code>
application, the garbage collector may prematurely collect <code>arr</code>, resulting in
unsoundness in an otherwise reasonable-looking program.</p>
<p>In light of this, it becomes clear that the design of <code>touch#</code> is not
compatible with DCE (which is otherwise a perfectly sound transform under
Haskell’s semantics): to faithfully serve its purpose, <code>touch#</code> must be
retained even if it could never be executed.</p>
<p>As there are relatively few uses of <code>touch#</code>, we tried for a while to paper
over this issue with the judicious use of <code>NOINLINE</code> to hide the divergence
from GHC’s sights. However, between 8.2 and 8.10 we encountered
at least six other user reports of unsoundness due to various manifestations of
this issue in various <code>base</code> interfaces
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/15260">#15260</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/14403">#14403</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/15544">#15544</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/13707">#13707</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/14329">#14329</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/18061">#18061</a>). For this reason, last year we
resolved to address the issue in the 9.0 release, marking the beginning of a
nearly year-long journey towards a possible replacement which lead us through
nearly a dozen design and implementation variants.</p>
<h2 id="finding-an-alternative-design">Finding an alternative design</h2>
<p>At first glance, the design of a safer <code>touch#</code> seems obvious by analogy to
<code>withFile</code>:</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="ot">with ::</span> a <span class="ot">-&gt;</span> (a <span class="ot">-&gt;</span> m b) <span class="ot">-&gt;</span> m b</span></code></pre></div>
<p>Under such a design <code>with x f</code> would evaluate to <code>f x</code>, ensuring that <code>x</code> is
kept alive (at least) until evaluation finishes.</p>
<p>While this interface is simple and pleasingly similar to patterns which
Haskellers expect, it does not make for a good primop design. In particular,
<code>touch#</code> incurs nearly no runtime overhead (it doesn’t even emit code of its own) and
generally occurs in performance-critical, low-level code. Consequently,
it is important to minimize the performance overhead imposed by our new
primitive. However, the type given to <code>with</code> above is <em>extremely</em> restrictive to
the optimisations available to the simplifier.</p>
<p>For instance, consider a function like,</p>
<div class="sourceCode" id="cb10"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="ot">readWord8_touch ::</span> <span class="dt">ForeignPtr</span> <span class="dt">Word8</span> <span class="ot">-&gt;</span> <span class="dt">IO</span> <span class="dt">Word8</span></span>
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a>readWord8_touch fptr <span class="ot">=</span> <span class="kw">do</span></span>
<span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a>    n <span class="ot">&lt;-</span> peek (unsafeForeignPtrToPtr fptr)</span>
<span id="cb10-4"><a href="#cb10-4" aria-hidden="true" tabindex="-1"></a>    touch fptr</span>
<span id="cb10-5"><a href="#cb10-5" aria-hidden="true" tabindex="-1"></a>    <span class="fu">return</span> n</span></code></pre></div>
<p>After a bit of simplification this will become:</p>
<div class="sourceCode" id="cb11"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="ot">readWord8_touch ::</span> <span class="dt">ForeignPtr</span> <span class="dt">Word8</span> <span class="ot">-&gt;</span> <span class="dt">IO</span> <span class="dt">Word8</span></span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a>readWord8_touch fptr <span class="ot">=</span> <span class="dt">IO</span> (\s0 <span class="ot">-&gt;</span></span>
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a>    <span class="kw">case</span> readWord8<span class="op">#</span> (unsafeForeignPtrToPtr fptr) s0 <span class="kw">of</span> (<span class="op">#</span> s1, n <span class="op">#</span>) <span class="ot">-&gt;</span></span>
<span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a>    <span class="kw">case</span> touch<span class="op">#</span> fptr s1 <span class="kw">of</span> s2 <span class="ot">-&gt;</span> </span>
<span id="cb11-5"><a href="#cb11-5" aria-hidden="true" tabindex="-1"></a>      (<span class="op">#</span> s2, <span class="dt">W8</span><span class="op">#</span> n <span class="op">#</span>)</span></code></pre></div>
<p>This function will benefit from GHC’s worker/wrapper transform, resulting in
a pair of Core bindings<a href="#fn1" class="footnote-ref" id="fnref1" role="doc-noteref"><sup>1</sup></a>:</p>
<div class="sourceCode" id="cb12"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="co">-- The worker:</span></span>
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a><span class="ot">worker_readWord8_touch ::</span> <span class="dt">ForeignPtr</span> <span class="dt">Word8</span> <span class="ot">-&gt;</span> <span class="dt">State</span><span class="op">#</span> <span class="dt">RealWorld</span> <span class="ot">-&gt;</span> (<span class="op">#</span> <span class="dt">State</span><span class="op">#</span> <span class="dt">RealWorld</span>, <span class="dt">Word8</span><span class="op">#</span> <span class="op">#</span>)</span>
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a>worker_readWord8_touch fptr s0 <span class="ot">=</span></span>
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a>    <span class="kw">case</span> peek (unsafeForeignPtrToPtr fptr) s0 <span class="kw">of</span> (<span class="op">#</span> s0, n <span class="op">#</span>) <span class="ot">-&gt;</span></span>
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a>    <span class="kw">case</span> touch<span class="op">#</span> fptr s0 <span class="kw">of</span> s1 <span class="ot">-&gt;</span></span>
<span id="cb12-6"><a href="#cb12-6" aria-hidden="true" tabindex="-1"></a>      (<span class="op">#</span> s1, n <span class="op">#</span>)</span>
<span id="cb12-7"><a href="#cb12-7" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-8"><a href="#cb12-8" aria-hidden="true" tabindex="-1"></a><span class="co">-- The wrapper:</span></span>
<span id="cb12-9"><a href="#cb12-9" aria-hidden="true" tabindex="-1"></a><span class="ot">readWord8_touch ::</span> <span class="dt">ForeignPtr</span> <span class="dt">Word8</span> <span class="ot">-&gt;</span> <span class="dt">IO</span> <span class="dt">Word8</span></span>
<span id="cb12-10"><a href="#cb12-10" aria-hidden="true" tabindex="-1"></a>readWord8_touch fptr <span class="ot">=</span> <span class="dt">IO</span> <span class="op">$</span> \s <span class="ot">-&gt;</span></span>
<span id="cb12-11"><a href="#cb12-11" aria-hidden="true" tabindex="-1"></a>    <span class="kw">case</span> worker_readWord fptr s <span class="kw">of</span> (<span class="op">#</span> s1, n <span class="op">#</span>) <span class="ot">-&gt;</span></span>
<span id="cb12-12"><a href="#cb12-12" aria-hidden="true" tabindex="-1"></a>      (<span class="op">#</span> s1, <span class="dt">W8</span><span class="op">#</span> n <span class="op">#</span>)</span>
<span id="cb12-13"><a href="#cb12-13" aria-hidden="true" tabindex="-1"></a><span class="ot">{-# INLINE readWord8_touch #-}</span></span></code></pre></div>
<p>The <code>readWord8_touch</code> wrapper can then be inlined into call sites, allowing
elimination of the <code>W8#</code> allocation (via case-of-known-constructor) at
call-sites which strictly consume the result.</p>
<p>However, if we rewrite <code>readWord8</code> using <code>with</code> we will rather get Core of the
form:</p>
<div class="sourceCode" id="cb13"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="ot">readWord8_with ::</span> <span class="dt">ForeignPtr</span> <span class="dt">Word8</span> <span class="ot">-&gt;</span> <span class="dt">IO</span> <span class="dt">Word8</span></span>
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a>readWord8_with fptr <span class="ot">=</span> with fptr <span class="op">$</span> \fptr&#39; <span class="ot">-&gt;</span> <span class="dt">IO</span> <span class="op">$</span> \s0 <span class="ot">-&gt;</span></span>
<span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a>    <span class="kw">case</span> peek (unsafeForeignPtrToPtr fptr&#39;) s0 <span class="kw">of</span> (<span class="op">#</span> s1, n <span class="op">#</span>) <span class="ot">-&gt;</span></span>
<span id="cb13-4"><a href="#cb13-4" aria-hidden="true" tabindex="-1"></a>      (<span class="op">#</span> s1, <span class="dt">W8</span><span class="op">#</span> n <span class="op">#</span>)</span></code></pre></div>
<p>Unlike <code>readWord8_touch</code>, this right-hand side does not have the
constructed-product property and therefore can not benefit from unboxing by the
worker/wrapper transform. Consequently, <code>readWord8_with</code> will allocate
a <code>W8#</code> result on every call. Empirically we found that these added
allocations significantly regress runtime performance of many, if not most,
Haskell programs. GHC in particular regressed in compile-time by nearly 10% in
some cases.</p>
<h3 id="recovering-the-cpr-property">Recovering the CPR property?</h3>
<p>At first appearance, there is no reason why GHC could not learn to transform
programs defined in terms of <code>with</code> to retain the CPR property. In particular,
this would require three changes:</p>
<ol type="1">
<li><p>since worker/wrapper may produce results of arbitrary <code>RuntimeRep</code>
we must generalize the type of <code>with</code>:</p>
<div class="sourceCode" id="cb14"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a>with<span class="op">#</span><span class="ot"> ::</span> <span class="kw">forall</span> a (<span class="ot">r ::</span> <span class="dt">RuntimeRep</span>) (<span class="ot">b ::</span> <span class="dt">TYPE</span> r)<span class="op">.</span></span>
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a>         a <span class="ot">-&gt;</span> (a <span class="ot">-&gt;</span> b) <span class="ot">-&gt;</span> b</span></code></pre></div></li>
<li><p>use <code>State#</code> tokens to enforce execution ordering:</p>
<div class="sourceCode" id="cb15"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a>with<span class="op">#</span><span class="ot"> ::</span> <span class="kw">forall</span> a (<span class="ot">r ::</span> <span class="dt">RuntimeRep</span>) (<span class="ot">b ::</span> <span class="dt">TYPE</span> r)<span class="op">.</span></span>
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a>         a <span class="ot">-&gt;</span> <span class="dt">State</span><span class="op">#</span> s <span class="ot">-&gt;</span> (<span class="dt">State</span><span class="op">#</span> s <span class="ot">-&gt;</span> b) <span class="ot">-&gt;</span> b</span></code></pre></div></li>
<li><p>teaching the simplifier to “push” strict contexts (e.g. <code>case</code>) into
<code>with#</code> applications. For instance, transform</p>
<div class="sourceCode" id="cb16"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a><span class="kw">case</span> (with<span class="op">#</span> x s (\s&#39; <span class="ot">-&gt;</span> k)) <span class="kw">of</span> alt <span class="ot">-&gt;</span> rhs</span></code></pre></div>
<p>into</p>
<div class="sourceCode" id="cb17"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a>with<span class="op">#</span> x s (\s&#39; <span class="ot">-&gt;</span> <span class="kw">case</span> k <span class="kw">of</span> alt <span class="ot">-&gt;</span> rhs)</span></code></pre></div>
<p>This transformation, which we call “strict context pushing” (SCP), is
similar to a transform already performed on <code>runRW#</code> applications (<a href="https://gitlab.haskell.org/ghc/ghc/issues/15127">#15127</a>).
In this case of <code>with#</code>, it is sound as it strictly <em>grows</em> the scope of the
continuation and therefore <em>lengthens</em> the lifetime of the kept-alive value.</p></li>
</ol>
<p>This SCP transformation allows us to eliminate the allocation incurred in the
case of <code>readWord8</code> by way of inlining and simplification. That is, consider a
strict call-site of <code>readWord8</code>:</p>
<div class="sourceCode" id="cb18"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a><span class="dt">IO</span> <span class="op">$</span> \s0 <span class="ot">-&gt;</span></span>
<span id="cb18-2"><a href="#cb18-2" aria-hidden="true" tabindex="-1"></a>  <span class="kw">case</span> readWord8 fptr s0 <span class="kw">of</span> (<span class="op">#</span> s1, n <span class="op">#</span>) <span class="ot">-&gt;</span></span>
<span id="cb18-3"><a href="#cb18-3" aria-hidden="true" tabindex="-1"></a>  <span class="kw">case</span> n <span class="kw">of</span> <span class="dt">W8</span><span class="op">#</span> n<span class="op">#</span> <span class="ot">-&gt;</span></span>
<span id="cb18-4"><a href="#cb18-4" aria-hidden="true" tabindex="-1"></a>    doSomething n<span class="op">#</span></span></code></pre></div>
<p>First, we inline <code>readWord8</code>, resulting in:</p>
<div class="sourceCode" id="cb19"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a><span class="dt">IO</span> <span class="op">$</span> \s0 <span class="ot">-&gt;</span></span>
<span id="cb19-2"><a href="#cb19-2" aria-hidden="true" tabindex="-1"></a>  <span class="kw">case</span> (</span>
<span id="cb19-3"><a href="#cb19-3" aria-hidden="true" tabindex="-1"></a>    with<span class="op">#</span> fptr s0 (\s1 <span class="ot">-&gt;</span></span>
<span id="cb19-4"><a href="#cb19-4" aria-hidden="true" tabindex="-1"></a>      <span class="kw">case</span> peek (unsafeForeignPtrToPtr fptr&#39;) s1 <span class="kw">of</span> (<span class="op">#</span> s2, n<span class="op">#</span> <span class="op">#</span>) <span class="ot">-&gt;</span></span>
<span id="cb19-5"><a href="#cb19-5" aria-hidden="true" tabindex="-1"></a>        (<span class="op">#</span> s2, <span class="dt">W8</span><span class="op">#</span> n<span class="op">#</span> <span class="op">#</span>)</span>
<span id="cb19-6"><a href="#cb19-6" aria-hidden="true" tabindex="-1"></a>    )</span>
<span id="cb19-7"><a href="#cb19-7" aria-hidden="true" tabindex="-1"></a>  ) <span class="kw">of</span> (<span class="op">#</span> s3, n <span class="op">#</span>) <span class="ot">-&gt;</span></span>
<span id="cb19-8"><a href="#cb19-8" aria-hidden="true" tabindex="-1"></a>  <span class="kw">case</span> n <span class="kw">of</span> <span class="dt">W8</span><span class="op">#</span> n<span class="op">#</span> <span class="ot">-&gt;</span></span>
<span id="cb19-9"><a href="#cb19-9" aria-hidden="true" tabindex="-1"></a>    doSomething n<span class="op">#</span></span></code></pre></div>
<p>Now, by the SCP transform above, the outer <code>case</code> can be pushed inside of the
<code>with#</code>:</p>
<div class="sourceCode" id="cb20"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a><span class="dt">IO</span> <span class="op">$</span> \s0 <span class="ot">-&gt;</span></span>
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a>  with<span class="op">#</span> fptr s0 (\s1 <span class="ot">-&gt;</span></span>
<span id="cb20-3"><a href="#cb20-3" aria-hidden="true" tabindex="-1"></a>    <span class="kw">case</span> (</span>
<span id="cb20-4"><a href="#cb20-4" aria-hidden="true" tabindex="-1"></a>      <span class="kw">case</span> peek (unsafeForeignPtrToPtr fptr&#39;) s1 <span class="kw">of</span> (<span class="op">#</span> s2, n<span class="op">#</span> <span class="op">#</span>) <span class="ot">-&gt;</span></span>
<span id="cb20-5"><a href="#cb20-5" aria-hidden="true" tabindex="-1"></a>        (<span class="op">#</span> s2, <span class="dt">W8</span><span class="op">#</span> n<span class="op">#</span> <span class="op">#</span>)</span>
<span id="cb20-6"><a href="#cb20-6" aria-hidden="true" tabindex="-1"></a>    ) <span class="kw">of</span> (<span class="op">#</span> s3, n <span class="op">#</span>) <span class="ot">-&gt;</span></span>
<span id="cb20-7"><a href="#cb20-7" aria-hidden="true" tabindex="-1"></a>    <span class="kw">case</span> n <span class="kw">of</span> <span class="dt">W8</span><span class="op">#</span> n<span class="op">#</span> <span class="ot">-&gt;</span></span>
<span id="cb20-8"><a href="#cb20-8" aria-hidden="true" tabindex="-1"></a>      doSomething n<span class="op">#</span></span>
<span id="cb20-9"><a href="#cb20-9" aria-hidden="true" tabindex="-1"></a>  )</span></code></pre></div>
<p>Finally, case-of-known constructor can be applied twice, eliminating the <code>W8#</code>
allocation:</p>
<div class="sourceCode" id="cb21"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true" tabindex="-1"></a><span class="dt">IO</span> <span class="op">$</span> \s0 <span class="ot">-&gt;</span></span>
<span id="cb21-2"><a href="#cb21-2" aria-hidden="true" tabindex="-1"></a>  with<span class="op">#</span> fptr s0 (\s1 <span class="ot">-&gt;</span></span>
<span id="cb21-3"><a href="#cb21-3" aria-hidden="true" tabindex="-1"></a>    <span class="kw">case</span> peek (unsafeForeignPtrToPtr fptr&#39;) s1 <span class="kw">of</span> (<span class="op">#</span> s2, n<span class="op">#</span> <span class="op">#</span>) <span class="ot">-&gt;</span></span>
<span id="cb21-4"><a href="#cb21-4" aria-hidden="true" tabindex="-1"></a>      doSomething n<span class="op">#</span></span>
<span id="cb21-5"><a href="#cb21-5" aria-hidden="true" tabindex="-1"></a>  )</span></code></pre></div>
<p>Hooray!</p>
<h3 id="the-trouble-with-scp">The trouble with SCP</h3>
<p>At first glance, this SCP transform looks like a promising way to eliminate a
major source of overhead imposed by <code>with#</code>. Unfortunately, testing quickly
revealed that matters are not so simple. For instance, consider a loop which
uses <code>readWord8</code> to sum the elements of an array:</p>
<div class="sourceCode" id="cb22"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb22-1"><a href="#cb22-1" aria-hidden="true" tabindex="-1"></a><span class="ot">sumArray ::</span> <span class="dt">ForeignPtr</span> <span class="dt">Word8</span>    <span class="co">-- ^ an array of Word8s</span></span>
<span id="cb22-2"><a href="#cb22-2" aria-hidden="true" tabindex="-1"></a>         <span class="ot">-&gt;</span> <span class="dt">Int</span>                 <span class="co">-- ^ array length</span></span>
<span id="cb22-3"><a href="#cb22-3" aria-hidden="true" tabindex="-1"></a>         <span class="ot">-&gt;</span> <span class="dt">IO</span> <span class="dt">Word8</span></span>
<span id="cb22-4"><a href="#cb22-4" aria-hidden="true" tabindex="-1"></a>sumArray fptr n <span class="ot">=</span> <span class="dt">IO</span> (go <span class="dv">0</span><span class="op">#</span> n)</span>
<span id="cb22-5"><a href="#cb22-5" aria-hidden="true" tabindex="-1"></a>  <span class="kw">where</span></span>
<span id="cb22-6"><a href="#cb22-6" aria-hidden="true" tabindex="-1"></a><span class="ot">    go ::</span> <span class="dt">Word8</span><span class="op">#</span> <span class="ot">-&gt;</span> <span class="dt">Int</span> <span class="ot">-&gt;</span> <span class="dt">State</span><span class="op">#</span> <span class="dt">RealWorld</span> <span class="ot">-&gt;</span> (<span class="op">#</span> <span class="dt">State</span><span class="op">#</span> <span class="dt">RealWorld</span>, <span class="dt">Word8</span> <span class="op">#</span>)</span>
<span id="cb22-7"><a href="#cb22-7" aria-hidden="true" tabindex="-1"></a>    go accum <span class="dv">0</span> s0 <span class="ot">=</span> (<span class="op">#</span> s0, <span class="dt">W8</span><span class="op">#</span> accum <span class="op">#</span>)</span>
<span id="cb22-8"><a href="#cb22-8" aria-hidden="true" tabindex="-1"></a>    go accum i s0 <span class="ot">=</span></span>
<span id="cb22-9"><a href="#cb22-9" aria-hidden="true" tabindex="-1"></a>      <span class="kw">case</span> readWord8 (fptr <span class="ot">`plusForeignPtr`</span> i) s0 <span class="kw">of</span> (<span class="op">#</span> s1, n <span class="op">#</span>) <span class="ot">-&gt;</span></span>
<span id="cb22-10"><a href="#cb22-10" aria-hidden="true" tabindex="-1"></a>      <span class="kw">case</span> n <span class="kw">of</span> <span class="dt">W8</span><span class="op">#</span> n<span class="op">#</span> <span class="ot">-&gt;</span></span>
<span id="cb22-11"><a href="#cb22-11" aria-hidden="true" tabindex="-1"></a>        go (accum <span class="op">+#</span> n<span class="op">#</span>) (i<span class="op">-</span><span class="dv">1</span>) s1</span></code></pre></div>
<p>As written, this program will run in constant space (modulo short-lived garbage
<code>W8#</code> constructors). However, consider what happens if we inline <code>readWord8#</code>,
apply the SCP transform, and simplify in the second equation of <code>go</code>:</p>
<div class="sourceCode" id="cb23"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb23-1"><a href="#cb23-1" aria-hidden="true" tabindex="-1"></a>    go accum i s0 <span class="ot">=</span></span>
<span id="cb23-2"><a href="#cb23-2" aria-hidden="true" tabindex="-1"></a>      with<span class="op">#</span> (fptr <span class="ot">`plusForeignPtr`</span> i) s0 (\s1 <span class="ot">-&gt;</span></span>
<span id="cb23-3"><a href="#cb23-3" aria-hidden="true" tabindex="-1"></a>        <span class="kw">case</span> peek (unsafeForeignPtrToPtr (fptr <span class="ot">`plusForeignPtr`</span> i)) s1 <span class="kw">of</span> (<span class="op">#</span> s2, n<span class="op">#</span> <span class="op">#</span>) <span class="ot">-&gt;</span></span>
<span id="cb23-4"><a href="#cb23-4" aria-hidden="true" tabindex="-1"></a>          go (accum <span class="op">+#</span> n<span class="op">#</span>) (i<span class="op">-</span><span class="dv">1</span>) s1</span></code></pre></div>
<p>While we have successfully eliminated the garbage <code>W8#</code> allocations,
the recursive <code>go</code> call (previously a tail-call) is now beneath a <code>with#</code>
application. Since most implementations of <code>with#</code> will have the operational
effect of pushing a frame to the evaluation stack, this transforms the
otherwise constant-space <code>sumArray</code> into an O(n) program. This is clearly not
acceptable.</p>
<p>Unfortunately, this problem is quite difficult to avoid. While one can think of
placing various heuristic restrictions on the contexts where SCP is applied,
there is no obviously-correct, local criterion which robostly preserves
CPR while avoiding stack blow-up.</p>
<p>While we found no way to make SCP work, the modifications we made to <code>with#</code>’s
type at the beginning of this section are desireable regardless. That is:</p>
<ul>
<li><code>with#</code> must be polymorphic in the <code>RuntimeRep</code> of its result lest the user is
unable to use it to compute unboxed results.</li>
<li>the use of <code>State#</code> tokens is a good hint to the user that they must take
care to control execution ordering to safely use the operation</li>
</ul>
<p>Consequently, we will adopt the following type for <code>with#</code>:</p>
<div class="sourceCode" id="cb24"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a>with<span class="op">#</span><span class="ot"> ::</span> <span class="kw">forall</span> a (<span class="ot">r ::</span> <span class="dt">RuntimeRep</span>) (<span class="ot">b ::</span> <span class="dt">TYPE</span> r)<span class="op">.</span></span>
<span id="cb24-2"><a href="#cb24-2" aria-hidden="true" tabindex="-1"></a>        a <span class="ot">-&gt;</span> <span class="dt">State</span><span class="op">#</span> s <span class="ot">-&gt;</span> (<span class="dt">State</span><span class="op">#</span> s <span class="ot">-&gt;</span> b) <span class="ot">-&gt;</span> b</span></code></pre></div>
<h2 id="generating-code-for-with">Generating code for <code>with#</code></h2>
<p>Above we considered some of the design decisions surrounding the user-facing
interface of <code>with#</code>. However, the interface is only half of the story: the
compiler must also know how to generate code for <code>with#</code>.</p>
<p>Thankfully, doing so is (currently) reasonably straightforward as GHC’s DCE
optimisation strictly occurs on Core. For this reason, we can safely desugar
<code>with#</code> into <code>touch#</code> by inlining after the Core-to-Core optimisation pipeline
has run (namely in the <code>CorePrep</code> stage of compilation). Specifically, an
application:</p>
<div class="sourceCode" id="cb25"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb25-1"><a href="#cb25-1" aria-hidden="true" tabindex="-1"></a><span class="co">-- Recall that</span></span>
<span id="cb25-2"><a href="#cb25-2" aria-hidden="true" tabindex="-1"></a><span class="co">--   with# :: forall a (r :: RuntimeRep) (b :: TYPE r).</span></span>
<span id="cb25-3"><a href="#cb25-3" aria-hidden="true" tabindex="-1"></a><span class="co">--            a -&gt; State# s -&gt; (State# s -&gt; b) -&gt; b</span></span>
<span id="cb25-4"><a href="#cb25-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb25-5"><a href="#cb25-5" aria-hidden="true" tabindex="-1"></a>with<span class="op">#</span> x s0 (\s0 <span class="ot">-&gt;</span> k)</span></code></pre></div>
<p>can be rewritten to</p>
<div class="sourceCode" id="cb26"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb26-1"><a href="#cb26-1" aria-hidden="true" tabindex="-1"></a><span class="kw">case</span> k s0 <span class="kw">of</span> r <span class="ot">-&gt;</span></span>
<span id="cb26-2"><a href="#cb26-2" aria-hidden="true" tabindex="-1"></a><span class="kw">case</span> touch<span class="op">#</span> x s0 <span class="kw">of</span> s1 <span class="ot">-&gt;</span></span>
<span id="cb26-3"><a href="#cb26-3" aria-hidden="true" tabindex="-1"></a>  r</span></code></pre></div>
<p>Admittedly, this rewrite is a bit suspicious as we there is nothing
ensuring the ordering between the <code>case k s</code> and the <code>touch#</code> (since they are
both applied to the <code>State#</code> token <code>s</code>). However, this is a pragmatic choice:
GHC’s STG pipeline currently performs no optimisation which could reorder
these expressions and forcing <code>with#</code> to return a <code>(# State# s, b #)</code> would
preclude its use in some pure contexts.</p>
<p>On the bright side, the fact that we can reuse <code>touch#</code> means that we can
provide <code>with#</code> with minimal overhead and no further changes to the backend.</p>
<h2 id="keepAlive"><code>keepAlive#</code> in GHC 9.0</h2>
<p>While we originally set out to supercede (and ultimately remove) <code>touch#</code>, the
issues described above (and others described in the <a href="https://gitlab.haskell.org/ghc/ghc/-/wikis/proposal/with-combinator">Wiki</a>) made it clear
that this plan was not feasible: what <code>touch#</code> lacks in robustness and
aesthetics, it makes up for in efficiency and ease-of-optimisation. Moreover,
there are occassionally cases which do not fit with the lexically-scoped
semantics of <code>with#</code>.</p>
<p>Consequently, in GHC 9.0 we opted for a pragmatic solution: continue to allow
use of <code>touch#</code> where necessary but prefer to use the safer <code>with</code>-style where
possible. GHC 9.0.1 exposes this operation as <code>keepAlive#</code> (the kinds in the
type below are slightly different than those present in 9.0, referring to
<code>BoxedRep</code> <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0203-pointer-rep.rst">introduced</a> in 9.2 for added precision):</p>
<div class="sourceCode" id="cb27"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb27-1"><a href="#cb27-1" aria-hidden="true" tabindex="-1"></a>keepAlive<span class="op">#</span><span class="ot"> ::</span> <span class="kw">forall</span> (<span class="ot">lev ::</span> <span class="dt">Levity</span>) (<span class="ot">a ::</span> <span class="dt">TYPE</span> (<span class="dt">BoxedRep</span> lev))</span>
<span id="cb27-2"><a href="#cb27-2" aria-hidden="true" tabindex="-1"></a>                     (<span class="ot">rep ::</span> <span class="dt">RuntimeRep</span>) (<span class="ot">b ::</span> <span class="dt">TYPE</span> rep) s<span class="op">.</span></span>
<span id="cb27-3"><a href="#cb27-3" aria-hidden="true" tabindex="-1"></a>              a</span>
<span id="cb27-4"><a href="#cb27-4" aria-hidden="true" tabindex="-1"></a>           <span class="ot">-&gt;</span> <span class="dt">State</span><span class="op">#</span> s</span>
<span id="cb27-5"><a href="#cb27-5" aria-hidden="true" tabindex="-1"></a>           <span class="ot">-&gt;</span> (<span class="dt">State</span><span class="op">#</span> s <span class="ot">-&gt;</span> b)</span>
<span id="cb27-6"><a href="#cb27-6" aria-hidden="true" tabindex="-1"></a>           <span class="ot">-&gt;</span> b</span></code></pre></div>
<p>What implications does this have on user code? For most users, none: nearly all
uses of <code>touch#</code> are buried in low-level libraries which have already been
adapted by the GHC maintainers.</p>
<p>If you <em>do</em> for some reason use <code>touch#</code>, we advise that you first consider
whether it is possible to replace the usage with a higher-level, less fragile
abstraction: in our experience, there are few cases where <code>touch#</code> is necessary
which would not be equally-well served by, e.g., <code>ForeignPtr</code> or a higher-level
scoped allocation primitive.</p>
<p>If you have determined that the low-level primitive is indeed unavoidable then
the next question is whether <code>touch#</code> should be replaced with <code>keepAlive#</code>. In the
general case this unfortunately comes down to a safety/performance tradeoff.
Specifically, let us consider the example of the <code>withForeignPtr</code> operation
exposed by <code>base</code>. When written in terms of <code>touch</code> this operation is defined
as:</p>
<div class="sourceCode" id="cb28"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb28-1"><a href="#cb28-1" aria-hidden="true" tabindex="-1"></a><span class="ot">withForeignPtr ::</span> <span class="dt">ForeignPtr</span> a <span class="ot">-&gt;</span> (<span class="dt">Ptr</span> a <span class="ot">-&gt;</span> <span class="dt">IO</span> b) <span class="ot">-&gt;</span> <span class="dt">IO</span> b</span>
<span id="cb28-2"><a href="#cb28-2" aria-hidden="true" tabindex="-1"></a>withForeignPtr fptr k <span class="ot">=</span> <span class="kw">do</span></span>
<span id="cb28-3"><a href="#cb28-3" aria-hidden="true" tabindex="-1"></a>    k (unsafeForeignPtrToPtr fptr)</span>
<span id="cb28-4"><a href="#cb28-4" aria-hidden="true" tabindex="-1"></a>    touch fptr</span></code></pre></div>
<p>While this can produce very efficient code, it is also deeply unsafe as the
user may provide a divergent continuation (e.g. <code>withForeignPtr fptr (forever ...)</code>). For the reasons described above, this can result in the dropping of the
<code>touch#</code>, resulting in unsoundness.</p>
<p>To avoid this, we should rather express <code>withForeignPtr</code> in terms of
<code>keepAlive#</code>:</p>
<div class="sourceCode" id="cb29"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb29-1"><a href="#cb29-1" aria-hidden="true" tabindex="-1"></a><span class="ot">withForeignPtr ::</span> <span class="dt">ForeignPtr</span> a <span class="ot">-&gt;</span> (<span class="dt">Ptr</span> a <span class="ot">-&gt;</span> <span class="dt">IO</span> b) <span class="ot">-&gt;</span> <span class="dt">IO</span> b</span>
<span id="cb29-2"><a href="#cb29-2" aria-hidden="true" tabindex="-1"></a>withForeignPtr fptr k <span class="ot">=</span> <span class="dt">IO</span> <span class="op">$</span> \s0 <span class="ot">-&gt;</span> </span>
<span id="cb29-3"><a href="#cb29-3" aria-hidden="true" tabindex="-1"></a>    keepAlive<span class="op">#</span> fptr s0 (unIO <span class="op">$</span> k (unsafeForeignPtrToPtr fptr))</span></code></pre></div>
<p>This avoids unsoundness at the expense of needing to allocate the <code>b</code> result of
the continuation. This is the implementation provided with <code>base-4.15</code>.</p>
<h3 id="introducing-unsafewithforeignptr">Introducing <code>unsafeWithForeignPtr</code></h3>
<p>While the introduction of <code>keepAlive#</code> affects relatively little user-code, the
added cost of <code>withForeignPtr</code> has the potential to be more impactful. In
particular, it is not uncommon to find code such as:</p>
<div class="sourceCode" id="cb30"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb30-1"><a href="#cb30-1" aria-hidden="true" tabindex="-1"></a>withForeignPtr fptr (peek <span class="op">@</span><span class="dt">Word8</span>)</span></code></pre></div>
<p>in tight inner-loops. Adding an allocation in such a context would be
catestrophic for performance and consequently <code>GHC.ForeignPtr</code> exports the old,
<code>touch#</code>-based implementation of <code>withForeignPtr</code> as <code>unsafeWithForeignPtr</code>.
This allows performance sensitive code to avoid boxing when it is known that the
continuation is not certain to diverge. Since this operation is unsafe in the
presence of known-divergent continuations, users are strong encouraged to
use this operation sparingly and only in cases where the continuation is
obviously not divergent.</p>
<h3 id="guidance-for-earlier-ghc-releases">Guidance for earlier GHC releases</h3>
<p>As noted, use of <code>touch#</code> in previous GHC versions is a bit perilous unless due
care is taken. Let’s consider an example:</p>
<div class="sourceCode" id="cb31"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb31-1"><a href="#cb31-1" aria-hidden="true" tabindex="-1"></a><span class="ot">foo ::</span> <span class="dt">ByteArray</span> <span class="ot">-&gt;</span> <span class="dt">IO</span> ()</span>
<span id="cb31-2"><a href="#cb31-2" aria-hidden="true" tabindex="-1"></a>foo x <span class="ot">=</span> <span class="kw">do</span></span>
<span id="cb31-3"><a href="#cb31-3" aria-hidden="true" tabindex="-1"></a>    doSomething x                        <span class="co">-- (a)</span></span>
<span id="cb31-4"><a href="#cb31-4" aria-hidden="true" tabindex="-1"></a>    <span class="op">...</span></span>
<span id="cb31-5"><a href="#cb31-5" aria-hidden="true" tabindex="-1"></a>    doForeignCall (byteArrayContents x)  <span class="co">-- (b)</span></span>
<span id="cb31-6"><a href="#cb31-6" aria-hidden="true" tabindex="-1"></a>    <span class="op">...</span></span>
<span id="cb31-7"><a href="#cb31-7" aria-hidden="true" tabindex="-1"></a>    touch x                              <span class="co">-- (c)</span></span></code></pre></div>
<p>For this program to be safe, the user must guarantee that no subexpression in
the body of <code>foo</code> between (a) (the point that <code>x</code> potentially becomes
unreachable) and (c) (the <code>touch</code>, which we must ensure DCE does not drop)
is provably divergent. In the case that all of the <code>...</code>s are statically known
it is possible to determine this by inspection.</p>
<p>However, things are harder if the function takes a user-provided continuation a
la <code>withForeignPtr</code>:</p>
<div class="sourceCode" id="cb32"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb32-1"><a href="#cb32-1" aria-hidden="true" tabindex="-1"></a><span class="ot">withForeignPtr ::</span> <span class="dt">ForeignPtr</span> a <span class="ot">-&gt;</span> (<span class="dt">Ptr</span> a <span class="ot">-&gt;</span> <span class="dt">IO</span> b) <span class="ot">-&gt;</span> <span class="dt">IO</span> b</span>
<span id="cb32-2"><a href="#cb32-2" aria-hidden="true" tabindex="-1"></a>withForeignPtr fptr k <span class="ot">=</span> <span class="kw">do</span></span>
<span id="cb32-3"><a href="#cb32-3" aria-hidden="true" tabindex="-1"></a>    k (unsafeForeignPtrToPtr fptr)</span>
<span id="cb32-4"><a href="#cb32-4" aria-hidden="true" tabindex="-1"></a>    touch fptr</span></code></pre></div>
<p>In this case the only reliable way to avoid unsoundness is to place a <code>NOINLINE</code>
on <code>withForeignPtr</code>. This deprives the simplifier of knowledge of <code>k</code>, ensuring
that it cannot conclude that <code>touch</code> is unreachable.</p>
<h2 id="conclusion">Conclusion</h2>
<p>Here we have described a bit of the story that lead to <code>keepAlive#</code>. While the
full story is significantly longer (and ultimately lead to the three-month deferral
of the 9.0.1 release), the result is a primop which avoids a class of
pernicious soundness issues which had lurked in previous releases.</p>
<p>If you have any questions regarding <code>touch#</code> and <code>keepAlive#</code>, do be in touch
on the <a href="https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs"><code>ghc-devs</code> mailing list</a>.</p>
<section class="footnotes footnotes-end-of-document" role="doc-endnotes">
<hr />
<ol>
<li id="fn1" role="doc-endnote"><p>To avoid cluttering the code too much, we are playing a bit
fast-and-loose with the <code>IO</code> newtype here. For instance, we treat <code>peek</code> as a
function of type <code>State# RealWorld -&gt; (# State# RealWorld, a #)</code> (i.e. the
representation of <code>IO a)</code>) instead of <code>IO a</code>. We will continue this
pragmatic abuse of notation below.<a href="#fnref1" class="footnote-back" role="doc-backlink">↩︎</a></p></li>
</ol>
</section>
]]></description>
    <pubDate>Tue, 08 Jun 2021 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20210607-the-keepAlive-story.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 8.10.5 is now available</title>
    <link>http://haskell.org/ghc/blog/20210605-ghc-8.10.5-released.html</link>
    <description><![CDATA[<h1>GHC 8.10.5 is now available</h1>
<h4 class="text-muted">Zubin Duggal - 2021-06-05</h4>

<p>The GHC team is very pleased to announce the availability of GHC 8.10.5.
Source and binary distributions are available at the <a href="https://downloads.haskell.org/ghc/8.10.5/">usual
place</a>.</p>
<p>This release adds native ARM/Darwin support, as well as bringing performance
improvements and fixing numerous bugs of varying severity present in the 8.10
series:</p>
<ul>
<li><p>First-class support for Apple M1 hardware using GHC’s LLVM ARM backend</p></li>
<li><p>Fix a bug resulting in segmentation faults where code may be unloaded
prematurely when using the parallel garbage collector (<a href="https://gitlab.haskell.org/ghc/ghc/issues/19417">#19417</a>) along
with other bugs in the GC and linker (<a href="https://gitlab.haskell.org/ghc/ghc/issues/19147">#19147</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/19287">#19287</a>)</p></li>
<li><p>Improve code layout fixing certain performance regressions (<a href="https://gitlab.haskell.org/ghc/ghc/issues/18053">#18053</a>)
and other code generation bug fixes (<a href="https://gitlab.haskell.org/ghc/ghc/issues/19645">#19645</a>)</p></li>
<li><p>Bug fixes for signal handling when using the pthread itimer implementation.</p></li>
<li><p>Improvements to the specializer and simplifier reducing code size and
and memory usage (<a href="https://gitlab.haskell.org/ghc/ghc/issues/17151">#17151</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/18923">#18923</a>,<a href="https://gitlab.haskell.org/ghc/ghc/issues/18140">#18140</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10421">#10421</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/18282">#18282</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/13253">#13253</a>).</p></li>
<li><p>Fix a bug where typechecker plugins could be run with an inconsistent
typechecker environment (<a href="https://gitlab.haskell.org/ghc/ghc/issues/19191">#19191</a>).</p></li>
<li><p>Fix a simplifier bug which lead to an exponential blow up and excessive
memory usage in certain cases</p></li>
</ul>
<p>A complete list of bug fixes and improvements can be found in the release notes: <a href="https://downloads.haskell.org/ghc/8.10.5/docs/html/users_guide/8.10.5-notes.html">release
notes</a>,</p>
<p>As always, feel free to report any issues you encounter via
<a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">gitlab.haskell.org</a>.</p>
]]></description>
    <pubDate>Sat, 05 Jun 2021 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20210605-ghc-8.10.5-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.2.1-alpha2 now available</title>
    <link>http://haskell.org/ghc/blog/20210422-ghc-9.2.1-alpha2-relased.html</link>
    <description><![CDATA[<h1>GHC 9.2.1-alpha2 now available</h1>
<h4 class="text-muted">Ben Gamari - 2021-04-22</h4>

<p>The GHC developers are very happy to announce the availability of the second
alpha release in the 9.2.1 series. Binary distributions, source distributions,
and documentation are available from
<a href="https://downloads.haskell.org/ghc/9.2.1-alpha2">downloads.haskell.org</a>.</p>
<p>GHC 9.2 will bring a number of exciting features including:</p>
<ul>
<li><p>Many changes in the area of records, including the new
<code>RecordDotSyntax</code> and <code>NoFieldSelectors</code> language extensions, as well
as Support for <code>DuplicateRecordFields</code> with <code>PatternSynonyms</code>.</p></li>
<li><p>Introduction of the new <code>GHC2021</code> language extension set, giving
users convenient access to a larger set of language extensions which
have been long considered stable.</p></li>
<li><p>Merge of <code>ghc-exactprint</code> into the GHC tree, providing infrastructure
for source-to-source program rewriting out-of-the-box.</p></li>
<li><p>Introduction of a <code>BoxedRep</code> <code>RuntimeRep</code>, allowing for polymorphism
over levity of boxed objects (<a href="https://gitlab.haskell.org/ghc/ghc/issues/17526">#17526</a>)</p></li>
<li><p>Implementation of the <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0265-unlifted-datatypes.rst"><code>UnliftedDataTypes</code> extension</a>, allowing
users to define types which do not admit lazy evaluation</p></li>
<li><p>The new <a href="https://well-typed.com/blog/2021/01/first-look-at-hi-profiling-mode/">-hi profiling</a> mechanism which provides significantly
improved insight into thunk leaks.</p></li>
<li><p>Support for the <a href="http://ghc.gitlab.haskell.org/ghc-debug/"><code>ghc-debug</code></a> out-of-process heap inspection
library</p></li>
<li><p>Support for profiling of pinned objects with the cost-centre profiler
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/7275">#7275</a>)</p></li>
<li><p>Introduction of Haddock documentation support in TemplateHaskell (<a href="https://gitlab.haskell.org/ghc/ghc/issues/5467">#5467</a>)</p></li>
<li><p>Proper support for impredicative types in the form of Quick-Look
impredicativity.</p></li>
<li><p>A native code generator backend for AArch64.</p></li>
</ul>
<p>This pre-release brings nearly 50 fixes relative to the first alpha,
although the long-awaited ARM NCG backend hasn’t quite landed yet.</p>
<p>As always, do give this a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see anything amiss.</p>
<p>Happy testing!</p>
]]></description>
    <pubDate>Thu, 22 Apr 2021 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20210422-ghc-9.2.1-alpha2-relased.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.2.1-alpha1 now available</title>
    <link>http://haskell.org/ghc/blog/20210401-ghc-9.2.1-alpha1-released.html</link>
    <description><![CDATA[<h1>GHC 9.2.1-alpha1 now available</h1>
<h4 class="text-muted">Ben Gamari - 2021-04-01</h4>

<p>The GHC developers are very happy to announce the availability of the first
alpha release in the 9.2.1 series. Binary distributions, source distributions,
and documentation are available from
<a href="https://downloads.haskell.org/ghc/9.2.1-alpha1">downloads.haskell.org</a>.</p>
<p>GHC 9.2 will bring a number of exciting features including:</p>
<ul>
<li><p>Many changes in the area of records, including the new
<code>RecordDotSyntax</code> and <code>NoFieldSelectors</code> language extensions, as well
as Support for <code>DuplicateRecordFields</code> with <code>PatternSynonyms</code>.</p></li>
<li><p>Introduction of the new <code>GHC2021</code> language extension set, giving
users convenient access to a larger set of language extensions which
have been long considered stable.</p></li>
<li><p>Merge of <code>ghc-exactprint</code> into the GHC tree, providing infrastructure
for source-to-source program rewriting out-of-the-box.</p></li>
<li><p>Introduction of a <code>BoxedRep</code> <code>RuntimeRep</code>, allowing for polymorphism
over levity of boxed objects (<a href="https://gitlab.haskell.org/ghc/ghc/issues/17526">#17526</a>)</p></li>
<li><p>Implementation of the <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0265-unlifted-datatypes.rst"><code>UnliftedDataTypes</code> extension</a>, allowing
users to define types which do not admit lazy evaluation</p></li>
<li><p>The new <a href="https://well-typed.com/blog/2021/01/first-look-at-hi-profiling-mode/">-hi profiling</a> mechanism which provides significantly
improved insight into thunk leaks.</p></li>
<li><p>Support for the <a href="http://ghc.gitlab.haskell.org/ghc-debug/"><code>ghc-debug</code></a> out-of-process heap inspection
library</p></li>
<li><p>Support for profiling of pinned objects with the cost-centre profiler
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/7275">#7275</a>)</p></li>
<li><p>Introduction of Haddock documentation support in TemplateHaskell (<a href="https://gitlab.haskell.org/ghc/ghc/issues/5467">#5467</a>)</p></li>
</ul>
<p>In addition, the final 9.2.1 release will bring a new native code
generator for ARM, providing fast, first-class for Haskell on <a href="https://www.haskell.org/ghc/blog/20210309-apple-m1-story.html">Apple
ARM hardware</a>, although this functionality is not yet
present in this alpha.</p>
<p>As always, do give this a try and open a <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">ticket</a> if you see anything amiss.</p>
<p>Happy testing!</p>
]]></description>
    <pubDate>Thu, 01 Apr 2021 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20210401-ghc-9.2.1-alpha1-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>Status update: GHC on Apple M1 hardware</title>
    <link>http://haskell.org/ghc/blog/20210309-apple-m1-story.html</link>
    <description><![CDATA[<h1>Status update: GHC on Apple M1 hardware</h1>
<h4 class="text-muted">bgamari - 2021-03-09</h4>

<p>A few months ago, Apple released the latest round of Apple hardware built upon
their M1 ARM implementation. Today, existing x86-64 GHC releases can be used on
M1 hardware using Rosetta emulation. In this post I will describe recent work
in GHC to enable native use of the compiler on M1 hardware, as well as some welcome
improvements to GHC’s general ARM support coming in GHC 9.2.</p>
<p>To run natively on Apple M1 hardware running macOS, GHC needs three
things:</p>
<ol type="1">
<li>the ability to generate code in the ARM instruction set</li>
<li>support for Darwin’s ARM application binary interface (ABI)</li>
<li>various build system changes to accomodate the new platform</li>
</ol>
<p>GHC has had (1) for many years now through the LLVM code generation backend.
By far the largest chunk of work necessary for minimal M1 support has been (2)
and (3).</p>
<p>Below I will discuss efforts that have gone into each of these aspects.
However, readers with less interest in compiler development may skip to the
final section for a brief overview of the state of play.</p>
<h2 id="the-memory-ordering-problem">The memory ordering problem</h2>
<p>While GHC has long had ARM support, it has until recently been something of a
second-class citizen and exhibited some degree of instability. One major cause
of this was runtime’s ad-hoc treatment of memory consistency. GHC’s runtime was
written well-before memory consistency models were widely understood, and nearly
two decades before the standardization of C11 atomics.</p>
<p>Consequently, until recently GHC’s runtime relied on a mix of <code>volatile</code>
variables and explicit memory barriers to enforce memory consistency. However,
ensuring correctness in a large concurrent system like GHC’s runtime is
extraordinarily difficult. As a result, numerous bugs lurked. To make matter
worse, bugs generally did not affect platforms with strong memory models (e.g.
x86) and only manifested on platforms like ARM where they are considerably
harder to debug.</p>
<p>To address this, I merged a large refactoring of GHC’s lock-free memory paths
in GHC 9.0. This patch moved the runtime to use standard acquire-release
orderings in place of our previous explicit barriers. In addition to being
easier to audit, this change enabled the use of
<a href="https://research.google.com/pubs/archive/35604.pdf">ThreadSanitizer</a> to
idenitfy data-races within the runtime system. Using ThreadSanitizer, I was
able to identify and fix over a dozen distinct data races within the runtime.
As a result, we can now have considerably greater confidence in the correctness
of GHC on today’s increasingly wide, out-of-order ARM implementations.</p>
<h2 id="the-abi-problem">The ABI problem</h2>
<p>Point (2) above has been particularly thorny due to the interaction
between Darwin’s ABI and GHC’s historically-simplistic way of representing
sub-word size integer types (e.g. <code>Word8</code>). The problem arises from the
definition of sub-word size types in <code>base</code>. For instance, <code>Word8</code> is defined
as</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="kw">data</span> <span class="dt">Word8</span> <span class="ot">=</span> <span class="dt">W8</span><span class="op">#</span> <span class="dt">Word</span><span class="op">#</span></span></code></pre></div>
<p>This means that, from the perspective of the compiler, <code>Word8</code> is simply a
word-sized (e.g. 64-bit) value; the fact that only the bottom 8-bits contains
useful information has no representation in the type system. Until now this
scheme has served us fine. However, this changes with Darwin/ARM,
which defines a <a href="https://developer.apple.com/documentation/xcode/writing_arm64_code_for_apple_platforms">calling convention</a> which is sensitive to argument width.
This means that foreign calls like,</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>foreign <span class="kw">import</span> ccall &quot;f&quot; f :: <span class="dt">Word8</span> -&gt; <span class="dt">IO</span> ()</span></code></pre></div>
<p>are treated incorrectly under this scheme on ARM/Darwin.</p>
<h2 id="the-long-term-plan">The long-term plan</h2>
<p>Fixing the above issue correctly requires teaching GHC about the representation
of sub-word size types. Thankfully, the first step in this direction was
already taken several releases ago with the introduction of unlifted
sub-word-size integer types (as described in
<a href="https://github.com/ghc-proposals/ghc-proposals/pull/74">GHC Proposal 74</a>).
However, there is still a fair amount of work that remains. First, we must
rework the lifted types defined by <code>base</code> to take advantage of these
sub-word-size types:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="co">-- today we have:</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="kw">data</span> <span class="dt">Word8</span> <span class="ot">=</span> <span class="dt">W8</span><span class="op">#</span> <span class="dt">Word</span><span class="op">#</span></span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a><span class="co">-- in the glorious future we will have:</span></span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a><span class="kw">data</span> <span class="dt">Word8</span> <span class="ot">=</span> <span class="dt">W8</span><span class="op">#</span> <span class="dt">Word8</span><span class="op">#</span></span></code></pre></div>
<p>However, this change in isolation ends breaking quite a bit of code since many
of GHC’s primops <em>primops</em> are still defined in terms of <code>Word#</code>. For instance,
in GHC 9.0 the primop for reading a <code>Word8</code> from a <code>ByteArray</code> has the type:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a>indexWord8Array<span class="op">#</span><span class="ot"> ::</span> <span class="dt">ByteArray</span><span class="op">#</span> <span class="ot">-&gt;</span> <span class="dt">Int</span><span class="op">#</span> <span class="ot">-&gt;</span> <span class="dt">Word</span><span class="op">#</span></span></code></pre></div>
<p>Consequently, a common idiom like <code>W8# (indexWord8Array# byteArray n)</code>
will break if we were to merely make above change to <code>Word8</code>. It turns out that we
can mitigate most of this by changing the primop definitions as well. That is,</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="co">-- today:</span></span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a>indexWord8Array<span class="op">#</span><span class="ot"> ::</span> <span class="dt">ByteArray</span><span class="op">#</span> <span class="ot">-&gt;</span> <span class="dt">Int</span><span class="op">#</span> <span class="ot">-&gt;</span> <span class="dt">Word</span><span class="op">#</span></span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a><span class="co">-- the glorious future:</span></span>
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a>indexWord8Array<span class="op">#</span><span class="ot"> ::</span> <span class="dt">ByteArray</span><span class="op">#</span> <span class="ot">-&gt;</span> <span class="dt">Int</span><span class="op">#</span> <span class="ot">-&gt;</span> <span class="dt">Word8</span><span class="op">#</span></span></code></pre></div>
<p>Note only does this type better reflect the operation’s meaning, but it also
eliminates a significant fraction of the churn required by the lifted-type
change. The return type can help here because most code doesn’t actually care
what the type being returned is, so long as it can be boxed right away by the
corresponding constructor (<code>W8#</code> in this case). We just need the constructor
and primops to agree to preserve that level of compatibility.</p>
<h2 id="improving-consistency-of-word-sized-integer-types">Improving consistency of word-sized integer types</h2>
<p>Darwin/ARM’s size-sensitive ABI also provides considerable incentive to fix a
long-standing wart in our treatment of <code>Word32#</code> and <code>Word64</code>: <code>Word64#</code> (resp.
<code>Word32#</code>) are only available on 32-bit (resp. 64-bit) platforms (<a href="https://gitlab.haskell.org/ghc/ghc/issues/11953">#11953</a>).
This requires the user to awkwardly rely on CPP to select between <code>Word64#</code>
(resp. <code>Word32#</code>) and <code>Word#</code> for 64-bit (resp. 32-bit) wide integers,
depending upon the host platform.</p>
<p>Making all sized integer types always available on all architectures allows
considerable simplification of many bits of <code>base</code> and other core libraries.
However, it also also reveals an awkward property of our existing primop naming.
Specifically to convert between the fixed-width integer types and <code>Word#</code> GHC 8.10
provided the following family of primops:</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a>GHC.Exts.narrowWord8<span class="op">#</span><span class="ot">  ::</span> <span class="dt">GHC.Prim.Word</span><span class="op">#</span>    <span class="ot">-&gt;</span> <span class="dt">GHC.Prim.Word8</span><span class="op">#</span></span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a>GHC.Exts.extendWord8<span class="op">#</span><span class="ot">  ::</span> <span class="dt">GHC.Prim.Word8</span><span class="op">#</span>   <span class="ot">-&gt;</span> <span class="dt">GHC.Prim.Word</span><span class="op">#</span></span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a>GHC.Exts.narrowWord16<span class="op">#</span><span class="ot"> ::</span> <span class="dt">GHC.Prim.Word</span><span class="op">#</span>    <span class="ot">-&gt;</span> <span class="dt">GHC.Prim.Word16</span><span class="op">#</span></span>
<span id="cb6-5"><a href="#cb6-5" aria-hidden="true" tabindex="-1"></a>GHC.Exts.extendWord16<span class="op">#</span><span class="ot"> ::</span> <span class="dt">GHC.Prim.Word16</span><span class="op">#</span>  <span class="ot">-&gt;</span> <span class="dt">GHC.Prim.Word</span><span class="op">#</span></span>
<span id="cb6-6"><a href="#cb6-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb6-7"><a href="#cb6-7" aria-hidden="true" tabindex="-1"></a>GHC.Exts.narrowInt8<span class="op">#</span><span class="ot">   ::</span> <span class="dt">GHC.Prim.Int</span><span class="op">#</span>     <span class="ot">-&gt;</span> <span class="dt">GHC.Prim.Int8</span><span class="op">#</span></span>
<span id="cb6-8"><a href="#cb6-8" aria-hidden="true" tabindex="-1"></a>GHC.Exts.extendInt8<span class="op">#</span><span class="ot">   ::</span> <span class="dt">GHC.Prim.Int8</span><span class="op">#</span>    <span class="ot">-&gt;</span> <span class="dt">GHC.Prim.Int</span><span class="op">#</span></span>
<span id="cb6-9"><a href="#cb6-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb6-10"><a href="#cb6-10" aria-hidden="true" tabindex="-1"></a>GHC.Exts.narrowInt16<span class="op">#</span><span class="ot">  ::</span> <span class="dt">GHC.Prim.Int</span><span class="op">#</span>     <span class="ot">-&gt;</span> <span class="dt">GHC.Prim.Int16</span><span class="op">#</span></span>
<span id="cb6-11"><a href="#cb6-11" aria-hidden="true" tabindex="-1"></a>GHC.Exts.extendInt16<span class="op">#</span><span class="ot">  ::</span> <span class="dt">GHC.Prim.Int16</span><span class="op">#</span>   <span class="ot">-&gt;</span> <span class="dt">GHC.Prim.Int</span><span class="op">#</span></span></code></pre></div>
<p>However, if we were to add such operations for, e.g., <code>Word64#</code>
we would end up with:</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a>GHC.Exts.narrowWord64<span class="op">#</span><span class="ot">  ::</span> <span class="dt">GHC.Prim.Word</span><span class="op">#</span>   <span class="ot">-&gt;</span> <span class="dt">GHC.Prim.Word64</span><span class="op">#</span></span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a>GHC.Exts.extendWord64<span class="op">#</span><span class="ot">  ::</span> <span class="dt">GHC.Prim.Word64</span><span class="op">#</span> <span class="ot">-&gt;</span> <span class="dt">GHC.Prim.Word</span><span class="op">#</span></span></code></pre></div>
<p>Consider the case of <code>narrowWord64#</code> on a 32-bit platform (where <code>Word#</code> is 32-bits wide):
the operation’s semantics make its argument <em>wider</em>, yet its name suggests it
makes the value <em>narrower</em> (N.B. on a 64-bit platform this operation is a no-op).
We felt that this is too confusing to be allowed to stand. Consequently the
<code>narrow</code> and <code>extend</code> primops will be deprecated in 9.2 and eventually removed in GHC
9.8. They will be replaced by a set of more clearly named operations:</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a>GHC.Exts.wordToWord64<span class="op">#</span><span class="ot">  ::</span> <span class="dt">GHC.Prim.Word</span><span class="op">#</span>   <span class="ot">-&gt;</span> <span class="dt">GHC.Prim.Word64</span><span class="op">#</span></span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a>GHC.Exts.word64ToWord<span class="op">#</span><span class="ot">  ::</span> <span class="dt">GHC.Prim.Word64</span><span class="op">#</span> <span class="ot">-&gt;</span> <span class="dt">GHC.Prim.Word</span><span class="op">#</span></span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a>GHC.Exts.wordToWord32<span class="op">#</span><span class="ot">  ::</span> <span class="dt">GHC.Prim.Word</span><span class="op">#</span>   <span class="ot">-&gt;</span> <span class="dt">GHC.Prim.Word32</span><span class="op">#</span></span>
<span id="cb8-5"><a href="#cb8-5" aria-hidden="true" tabindex="-1"></a>GHC.Exts.word32ToWord<span class="op">#</span><span class="ot">  ::</span> <span class="dt">GHC.Prim.Word32</span><span class="op">#</span> <span class="ot">-&gt;</span> <span class="dt">GHC.Prim.Word</span><span class="op">#</span></span>
<span id="cb8-6"><a href="#cb8-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb8-7"><a href="#cb8-7" aria-hidden="true" tabindex="-1"></a><span class="co">-- et cetera</span></span></code></pre></div>
<p>The above changes are documented in the
<a href="https://gitlab.haskell.org/ghc/ghc/-/wikis/Unboxed-Numerics">Wiki</a> and will
ship in GHC 9.2.1. While we would generally prefer to make these changes
through the usual GHC proposals process, we deemed that due to the urgency of
M1 support and relatively confined impact of the changes, users would be better
served by quickly moving ahead (since otherwise proper M1 support likely would
not have happened until 9.4). On the whole, this new story will be considerably
more pleasant for all and fixes a number of related issues (<a href="https://gitlab.haskell.org/ghc/ghc/issues/17375">#17375</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/17377">#17377</a>).</p>
<h2 id="the-short-term-plan">The short-term plan</h2>
<p>Of course, the changes described above would be inappropriate to include in a
minor GHC release. However, we feel that it is important that M1
support is shipped well before the release of GHC 9.2.1. For this reason,
Moritz Angerman, has been
working tirelessly over the past several months to backport the M1
changes to the GHC 8.10 branch, using a less principled approach for
working around the calling convention issue.</p>
<p>This work will be released shortly in the form of a GHC 8.10.5 release.
We also expect that this work will also make it into GHC 9.0.2 or 9.0.3.</p>
<h2 id="a-cherry-on-top-a-new-ncg-for-arm">A cherry on top: A new NCG for ARM</h2>
<p>While LLVM has served us well on ARM, it is not known for its speed. For
instance, on x86-64 a GHC bootstrap build using the LLVM takes roughly twice as
long as a similar build using the native code generator. As Apple’s new hardware
will mean that ARM will gain considerable adoption by developers, we thought
such a sizeable compile-time tax was unacceptable.</p>
<p>To address this, Moritz Angerman picked up the
long-standing (and quite large) task of implementing a native ARM backend for
GHC (as enjoyed by x86-64 and PowerPC). Early indications suggest that this
backend will considerably reduce compilation time on ARM platforms, bringing
times in line with what we see on x86-64. This work will ship in GHC 9.2.1.</p>
<h2 id="summary">Summary</h2>
<p>To summarize, over two years of work to improve the state of GHC on ARM will be
culminating in the coming months. Specifically:</p>
<ul>
<li><p>GHC 8.10.4 solidified ARM support by revamping the runtime’s treatment of
memory consistency.</p></li>
<li><p>GHC 8.10.5 will be out in the coming weeks with initial Darwin/ARM support</p></li>
<li><p>GHC 9.0.2 will be out a few weeks later, also with Darwin/ARM support</p></li>
<li><p>GHC 9.2.1 will be released in June 2021 sporting Darwin/ARM support,
revamped sized-integer types in <code>base</code>, and considerably faster compilation
thanks to Moritz’s ARM NCG backend.</p></li>
</ul>
<p>On the whole, this has been a very long road but we are quickly approach its
end. This is almost entirely due to a few people who deserve recognition here:
First, Moritz Angerman not just for his incredible
work on the NCG and Darwin support, but also for his help wrangling CI and
tireless work on the thankless task of backporting. Second, thanks to John
Ericson for his work in pushing through the various primop cleanups (and
knock-on changes in downstream libraries) necessitated by the M1 ABI issue.</p>
<p>Lastly, thanks to Davean Scies and <a href="https://simspace.com/">Simspace</a> for their
help and support in hosting a set of M1 CI runners.</p>
]]></description>
    <pubDate>Tue, 09 Mar 2021 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20210309-apple-m1-story.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 8.10.4 is now available</title>
    <link>http://haskell.org/ghc/blog/20210204-ghc-8.10.4-released.html</link>
    <description><![CDATA[<h1>GHC 8.10.4 is now available</h1>
<h4 class="text-muted">bgamari - 2021-02-05</h4>

<p>The GHC team is very pleased to announce the availability of GHC 8.10.4.
Source and binary distributions are available at the <a href="https://downloads.haskell.org/ghc/8.10.4/">usual
place</a>.</p>
<p>This is a small bug-fix release, fixing two bugs present in 8.10.3:</p>
<ul>
<li><p>Fix a linker hang triggered by dynamic code loading on Windows
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/19155">#19155</a>)</p></li>
<li><p>Fix a crash caused by inappropriate garbage of heap-allocated data reachable
from foreign exports (<a href="https://gitlab.haskell.org/ghc/ghc/issues/19149">#19149</a>)</p></li>
</ul>
<p>As always, feel free to report any issues you encounter via
<a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">gitlab.haskell.org</a>.</p>
]]></description>
    <pubDate>Fri, 05 Feb 2021 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20210204-ghc-8.10.4-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.0.1 is now available</title>
    <link>http://haskell.org/ghc/blog/20210204-ghc-9.0.1-released.html</link>
    <description><![CDATA[<h1>GHC 9.0.1 is now available</h1>
<h4 class="text-muted">bgamari - 2021-02-04</h4>

<p>The GHC team is very pleased to announce the availability of GHC 9.0.1.
Source and binary distributions are available at the <a href="https://downloads.haskell.org/ghc/9.0.1/">usual
place</a>.</p>
<p>In addition to numerous bug fixes, GHC 9.0.1 brings a number of new
features:</p>
<ul>
<li><p>A first cut of the new <code>LinearTypes</code> <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0111-linear-types.rst">language extension</a>, allowing use
of linear function syntax and linear record fields.</p></li>
<li><p>A new bignum library, <code>ghc-bignum</code>, improving portability and allowing GHC
to be more easily used with integer libraries other than GMP.</p></li>
<li><p>Improvements in code generation, resulting in considerable
runtime performance improvements in some programs.</p></li>
<li><p>Improvements in pattern-match checking, allowing more precise
detection of redundant cases and reduced compilation time.</p></li>
<li><p>Implementation of the “simplified subsumption” <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0287-simplify-subsumption.rst">proposal</a>
simplifying the type system and paving the way for QuickLook
impredicativity in GHC 9.2.</p></li>
<li><p>Implementation of the <code>QualifiedDo</code> <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst">extension</a>, allowing more
convenient overloading of <code>do</code> syntax.</p></li>
<li><p>An experimental new IO manager implementation for Windows platforms, both
improving performance and fixing many of the quirks with the old manager built
on POSIX-emulation.</p></li>
<li><p>Improvements in compilation time.</p></li>
</ul>
<p>And many more. See the <a href="https://downloads.haskell.org/ghc/9.0.1/docs/html/users_guide/9.0.1-notes.html">release notes</a> for a full accounting of the
changes in this release.</p>
<p>As always, feel free to report any issues you encounter via
<a href="https://gitlab.haskell.org/ghc/ghc/-/issues/new">gitlab.haskell.org</a>.</p>
]]></description>
    <pubDate>Thu, 04 Feb 2021 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20210204-ghc-9.0.1-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 9.0.1 release candidate 1 now available</title>
    <link>http://haskell.org/ghc/blog/20201229-ghc-9.0.1-rc1-released.html</link>
    <description><![CDATA[<h1>GHC 9.0.1 release candidate 1 now available</h1>
<h4 class="text-muted">bgamari - 2020-12-29</h4>

<p>The GHC team is very pleased to announce the availability of the first
release candidate of GHC 9.0.1 series. Source and binary distributions are
available at the <a href="https://downloads.haskell.org/ghc/9.0.1-rc1/">usual place</a>.</p>
<p>This release candidate comes quite a bit later than expected after
difficulty finding a performance neutral fix for a critical soundness
bug, <a href="https://gitlab.haskell.org/ghc/ghc/issues/17760">#17760</a>. See the <a href="https://gitlab.haskell.org/ghc/ghc/-/wikis/migration/9.0#ghc-prim-07">migration page</a> for details on the solution, particularly
if you are a library maintainer currently using the <code>touch#</code> primop or
<code>Foreign.ForeignPtr.withForeignPtr</code>.</p>
<p>Nevertheless, this release has nevertheless seen a considerable amount of
testing and consequently we hope that this should be the last
pre-release before the final release.</p>
<p>In addition to numerous bug fixes, GHC 9.0.1 will bring a number of new
features:</p>
<ul>
<li><p>A first cut of the new <code>LinearTypes</code> <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0111-linear-types.rst">language extension</a>, allowing use
of linear function syntax and linear record fields.</p></li>
<li><p>A new bignum library (<code>ghc-bignum</code>), allowing GHC to be more easily
used with integer libraries other than GMP.</p></li>
<li><p>Improvements in code generation, resulting in considerable
performance improvements in some programs.</p></li>
<li><p>Improvements in pattern-match checking, allowing more precise
detection of redundant cases and reduced compilation time.</p></li>
<li><p>Implementation of the “simplified subsumption” <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0287-simplify-subsumption.rst">proposal</a>
simplifying the type system and paving the way for QuickLook
impredicativity in GHC 9.2.</p></li>
<li><p>Implementation of the <code>QualifiedDo</code> <a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst">extension</a>, allowing more
convenient overloading of <code>do</code> syntax.</p></li>
<li><p>Improvements in compilation time.</p></li>
</ul>
<p>And many more. See the <a href="https://downloads.haskell.org/ghc/9.0.1-rc1/docs/html/users_guide/9.0.1-notes.html">release notes</a> for a full accounting of the
changes in this release.</p>
<p>As always, do test this release and open tickets for whatever issues you
encounter.</p>
]]></description>
    <pubDate>Tue, 29 Dec 2020 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20201229-ghc-9.0.1-rc1-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 8.10.3 released</title>
    <link>http://haskell.org/ghc/blog/20201219-ghc-8.10.3-released.html</link>
    <description><![CDATA[<h1>GHC 8.10.3 released</h1>
<h4 class="text-muted">bgamari - 2020-12-19</h4>

<p>The GHC team is happy to announce the release of GHC 8.10.3. Source
and binary distributions are available at the <a href="https://downloads.haskell.org/ghc/8.10.3/">usual place</a>.</p>
<p>GHC 8.10.3 fixes a number of issues in present in GHC 8.10.2 including:</p>
<ul>
<li><p>Numerous stability improves on Windows</p></li>
<li><p>More robust support for architectures with weak memory ordering
guarantees (e.g. modern ARM hardware).</p></li>
<li><p>GHC can now split dynamic objects to accomodate macOS’ RPATH size
limitation when building large projects (<a href="https://gitlab.haskell.org/ghc/ghc/issues/14444">#14444</a>)</p></li>
<li><p>Several correctness bugs in the new low-latency garbage collector</p></li>
</ul>
<p>Note that at the moment we still require that macOS Catalina users
exempt the binary distribution from the notarization requirement by
running <code>xattr -cr .</code> on the unpacked tree before running <code>make install</code>.
This situation will hopefully be improved for GHC 9.0.1 with the
resolution of <a href="https://gitlab.haskell.org/ghc/ghc/issues/17418">#17418</a>.</p>
]]></description>
    <pubDate>Sat, 19 Dec 2020 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20201219-ghc-8.10.3-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 8.10.2 released</title>
    <link>http://haskell.org/ghc/blog/20200808-ghc-8.10.2-released.html</link>
    <description><![CDATA[<h1>GHC 8.10.2 released</h1>
<h4 class="text-muted">bgamari - 2020-08-08</h4>

<p>The GHC team is happy to announce the availability of GHC 8.10.2. Source
and binary distributions are available at the <a href="https://downloads.haskell.org/ghc/8.10.2/">usual
place</a>.</p>
<p>GHC 8.10.2 fixes a number of issues in present in GHC 8.10.1 including:</p>
<ul>
<li><p>Fixes a bug in process creation on Windows (<a href="https://gitlab.haskell.org/ghc/ghc/issues/17926">#17926</a>).</p></li>
<li><p>Fixes a code generation bug resulting in incorrect code
generation for foreign calls with complex arguments (<a href="https://gitlab.haskell.org/ghc/ghc/issues/18527">#18527</a>)</p></li>
<li><p>Fixes a bug causing object merging to fail when the lld linker is in
use (<a href="https://gitlab.haskell.org/ghc/ghc/issues/17962">#17962</a>)</p></li>
<li><p>Introduces a workaround for a Linux kernel bug in the implementation
of the timerfd mechanism (<a href="https://gitlab.haskell.org/ghc/ghc/issues/18033">#18033</a>).</p></li>
<li><p>Fixes a few specialiser regressions (<a href="https://gitlab.haskell.org/ghc/ghc/issues/17810">#17810</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/18120">#18120</a>) as well
introduces a variety of miscellaneous specialiser improvements
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/16473">#16473</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/17930">#17930</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/17966">#17966</a>)</p></li>
<li><p>Fixes a potential loss of sharing due to left operator sections (<a href="https://gitlab.haskell.org/ghc/ghc/issues/18151">#18151</a>).</p></li>
<li><p>Fix bootstrapping of GHC with the LLVM backend on x86-64 (<a href="https://gitlab.haskell.org/ghc/ghc/issues/17920">#17920</a>).</p></li>
<li><p>A few important correctness fixes for the low-latency garbage
collector. Users of <code>--nonmoving-gc</code> are strongly encouraged to upgrade
promptly.</p></li>
</ul>
<p>Note that at the moment we still require that macOS Catalina users
exempt the binary distribution from the notarization requirement by
running <code>xattr -cr .</code> on the unpacked tree before running <code>make install</code>.
This situation will hopefully be improved for GHC 9.0.1 with the
resolution of <a href="https://gitlab.haskell.org/ghc/ghc/issues/17418">#17418</a>.</p>
]]></description>
    <pubDate>Sat, 08 Aug 2020 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20200808-ghc-8.10.2-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 8.8.4 released</title>
    <link>http://haskell.org/ghc/blog/20200715-ghc-8.8.4-released.html</link>
    <description><![CDATA[<h1>GHC 8.8.4 released</h1>
<h4 class="text-muted">bgamari - 2020-07-15</h4>

<p>The GHC team is proud to announce the release of GHC 8.8.4. The source
distribution, binary distributions, and documentation are available at
<a href="https://downloads.haskell.org/~ghc/8.8.4">downloads.haskell.org</a>.</p>
<p>Release notes are also <a href="https://downloads.haskell.org/ghc/8.8.4/docs/html/users_guide/8.8.4-notes.html">available</a>.</p>
<p>This release fixes a handful of issues affecting 8.8.3:</p>
<ul>
<li><p>Fixes a bug in process creation on Windows (<a href="https://gitlab.haskell.org/ghc/ghc/issues/17926">#17926</a>). Due to this fix
we strongly encourage all Windows users to upgrade immediately.</p></li>
<li><p>Works around a Linux kernel bug in the implementation of timerfd
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/18033">#18033</a>)</p></li>
<li><p>Fixes a few linking issues affecting ARM</p></li>
<li><p>Fixes “missing interface file” error triggered by some uses of
<code>Data.Ord.Ordering</code> (<a href="https://gitlab.haskell.org/ghc/ghc/issues/18185">#18185</a>)</p></li>
<li><p>Fixes an integer overflow in the compact-normal-form import
implementation (<a href="https://gitlab.haskell.org/ghc/ghc/issues/16992">#16992</a>)</p></li>
<li><p><code>configure</code> now accepts a <code>--enable-numa</code> flag to enable/disable
<code>numactl</code> support on Linux.</p></li>
<li><p>Fixes potentially lost sharing due to the desugaring of left operator
sections (<a href="https://gitlab.haskell.org/ghc/ghc/issues/18151">#18151</a>).</p></li>
<li><p>Fixes a build-system bug resulting in potential miscompilation by
unregisteised compilers (<a href="https://gitlab.haskell.org/ghc/ghc/issues/18024">#18024</a>)</p></li>
</ul>
<p>As always, if anything looks amiss do let us know.</p>
]]></description>
    <pubDate>Wed, 15 Jul 2020 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20200715-ghc-8.8.4-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>Integrating head.hackage with GHC's CI infrastructure</title>
    <link>http://haskell.org/ghc/blog/20200611-head-hackage.html</link>
    <description><![CDATA[<h1>Integrating head.hackage with GHC's CI infrastructure</h1>
<h4 class="text-muted">Ben Gamari - 2020-06-11</h4>

<p>Hello everyone,</p>
<p>As I mentioned a last year in my <a href="20190403-infra-status.html">infrastructure
update</a>, one of the many features that we have
gained as a result of our migration to GitLab is the ability to incorporate
testing against user code (e.g. from Hackage) into our routine CI testing.
In the past year we have been hard at work to make this infrastructure a reality.</p>
<p>In this post we will describe the current state of that infrastructure as well
as what you (yes, you!) can do to help us make the most of this infrastructure;
no GHC hacking experience is required!</p>
<h2 id="the-goal">The goal</h2>
<p>For a long time we have discussed using our large package repositories (Hackage
and Stackage) for testing of GHC snapshots and pre-releases. Specifically,
there are three ends which such testing might serve:</p>
<ul>
<li><p><em>correctness testing</em>: By confirming that user code compiles we have better
assurance that we understand the full implications of changes made in GHC on
our users and that those changes are implemented correctly.</p></li>
<li><p><em>compiler performance testing</em>: By measuring the performance of the compiler
as it compilers user code we learn more about the <em>typical</em> cost centers
within GHC. While we have dedicated performance testsuites (e.g. <code>nofib</code>)
that also serve this purpose, there is plenty of evidence that suggests that
the programs in these testsuites are qualitatively different from modern
Haskell programs.</p></li>
<li><p><em>runtime performance testing</em>: As with (2), but measuring the performance of
the compiled program itself rather than that of GHC.</p></li>
</ul>
<p>While these potential benefits are significant, so are the challenges:</p>
<ol type="1">
<li><em>changes in GHC and core libraries</em>: Due to the tight coupling between GHC
and its core libraries (e.g. <code>base</code>, <code>template-haskell</code>), GHC releases are
typically accompanied by library changes which often break user programs.
These need to be patched but in a way that allows package authors to respect
the <a href="https://www.haskell.org/ghc/blog/20190722-ghc-8.8.1-rc1-released.html">PVP</a>.</li>
<li><em>persistent breakage</em>: Because of the expected breakage mentioned in (1) any
package set of non-trivial size will contain at least a few broken packages
at any given time. For this reason, in contrast to typical CI pipelines, we
want to be notified only when packages’ build state <em>changes</em>: e.g. when a
package breakage <em>starts</em> (e.g. due to a breaking change being merged to GHC) but
not every subsequent breakage.</li>
<li><em>changes in user programs</em>: Particularly when tracking performance changes we
must take care when updating the tested set of packages: A we are fooled into
thinking that a change in a user program is a regression in GHC.</li>
</ol>
<p>While (2) and (3) are both non-trivial problems, a solution to (1) is close at
hand in the form of the
<a href="https://gitlab.haskell.org/ghc/head.hackage">head.hackage</a> patch-set.</p>
<h2 id="patching-hackage-for-pre-releases">Patching Hackage for pre-releases</h2>
<p>The <code>head.hackage</code> project is a set of patches and associated tools for
patching released Hackage packages to build with GHC pre-releases. While
<code>head.hackage</code> has been a tool in GHC developers’ toolbox for over a year now,
a few considerations has kept it from reaching its potential:</p>
<ol type="1">
<li>a lack of documentation and a few usability papercuts have limited adoption
to a small set of developers.</li>
<li>the lack of integration with GHC’s own continuous integration infrastructure
meant that testing of GHC snapshots had to be performed manually</li>
<li>the lack of automated testing of the patchset has precluded scaling the
approach to a larger set of packages.</li>
</ol>
<p>The remainder of this post will discuss our recent work in implementing
continuous integration infrastructure to address points (2) and (3). In a
future post we will discuss work done to address (1) and walk the user through
use of <code>head.hackage</code> to build a real-world package.</p>
<h2 id="testing-infrastructure">Testing infrastructure</h2>
<p>Of course, the patch-set is of little value if it is not tested. For this
reason we introduced continuous integration infrastructure, allowing us to
build the patch-set with both released and pre-released compilers. These two
build configurations test somewhat orthogonal notions of correctness:</p>
<ol type="1">
<li><p>Testing against GHC releases tests the patch-set, giving us (some)
assurance that the patches themselves are correct.</p></li>
<li><p>Testing against <code>master</code> (or pre-releases) provides assurance that
GHC itself hasn’t regressed.</p></li>
</ol>
<p>Happily, this effort has now converged on a usable result, embodied in
three merge requests:</p>
<p><a href="https://gitlab.haskell.org/ghc/head.hackage/merge_requests/2">ghc/head.hackage<a href="https://gitlab.haskell.org/ghc/ghc/merge_requests/2">!2</a></a>
adds CI support to <code>head.hackage</code>. In addition to a pass/fail status for the
overall build, this job produces (e.g. as seen in <a href="https://gitlab.haskell.org/ghc/head.hackage/-/jobs/361579">this
run</a>) a variety of
additional products:</p>
<ul>
<li><p>a JSON summary of the run, describing the dependency graph and
pass/fail state of each package. We can feed this to an external service to
track newly-failing packages.</p></li>
<li><p>a tarball of build logs, each including statistics from GHC’s
<code>-ddump-timings</code> flag. Not only do these logs capture the reason for failure
in the case of erroring builds, but they can be scraped for compiler
performance metrics, allowing us to track compiler performance on a diverse
set of real-world code.</p></li>
</ul>
<p>These can be fed to downstream tools, allowing us to better understand and
record the evolution of GHC’s performance and correctness.</p>
<h2 id="making-patched-packages-accessible-to-users">Making patched packages accessible to users</h2>
<p>Our final goal in this effort was to make the patched packages themselves
readily accessible to users, allowing users to be easily use GHC’s pre-releases
to build larger projects. <code>head.hackage</code>’s continuous integration now
produces a <a href="http://ghc.gitlab.haskell.org/head.hackage/">Hackage repository</a>,
which can be easily used to build existing projects using <code>cabal v2-build</code>’s
remote repository support. Use of this repository will be the focus of a future
blog post.</p>
<h2 id="future-work">Future work</h2>
<p>There are a few things that remain to be done:</p>
<ul>
<li><p>Work out how to handle tracking of persistent breakage; for instance, we want
a responsible party to be notified when a package initially breaks (e.g.
when a breaking change is merged to GHC) but not in every subsequent build.</p></li>
<li><p>Determine a sustainable means to keep this patch-set up-to-date. Thusfar
this has fallen on the shoulders of a few dedicated contributors (thanks
Ryan Scott!), but to make this work in the long term we need a more
diverse group of maintainers. If this sort of work sounds like something you
would be interested in contributing to, please do be in touch!</p>
<p>Furthermore, we might consider making authors of GHC patches which break
<code>head.hackage</code> responsible for updating the broken packages, further
spreading the maintenance load.</p></li>
<li><p>Currently our testing is limited to testing that compilation of the packages
does not fail. However, we might also consider extending this to running
package testsuites in select cases. This would give us further assurance of
correctness, although would likely significantly increase maintenance
and computational cost.</p></li>
</ul>
<p>Finally, I would like to acknowledge Herbert Valerio Riedel whose vision for
the <code>head.hackage</code> patch-set evolved into the infrastructure described above.</p>
<p>Cheers,</p>
<ul>
<li>Ben</li>
</ul>
]]></description>
    <pubDate>Thu, 11 Jun 2020 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20200611-head-hackage.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>Profiling Template Haskell splices</title>
    <link>http://haskell.org/ghc/blog/20200524-profiling-template-haskell.html</link>
    <description><![CDATA[<h1>Profiling Template Haskell splices</h1>
<h4 class="text-muted">Ben Gamari - 2020-05-25</h4>

<p>This weekend a user came into <code>#ghc</code> asking how to profile their Template
Haskell splices using GHC’s <a href="https://downloads.haskell.org/~ghc/8.10.1/docs/html/users_guide/profiling.html">cost-center profiler</a>. While this is
<a href="https://downloads.haskell.org/~ghc/8.10.1/docs/html/users_guide/glasgow_exts.html#using-template-haskell-with-profiling">not so hard</a> in the simple case where you have no dependencies, doing so
with a real package took a surprisingly long time and
was non-obvious to even GHC developers. Consequently, I felt this might be
helpful to write down the prescription.</p>
<p>In short, the method we arrived at takes advantage of GHC’s <a href="https://downloads.haskell.org/~ghc/8.10.1/docs/html/users_guide/ghci.html#ghc-flag--fexternal-interpreter">external
interpreter</a> coupled with <code>cabal-install</code>’s support for
producing <a href="https://downloads.haskell.org/~ghc/8.10.1/docs/html/users_guide/packages.html">package environment files</a>. To demonstrate the
approach, we will profile the Template Haskell-based lens derivation logic of
the <code>optics-th</code> package, using the <code>T799</code> module as our source of splices.</p>
<p>We first start by setting up a working directory of the project:</p>
<pre><code>$ cabal unpack optics-th
$ cd optics-th-0.3</code></pre>
<p>Now we will build the package with <code>cabal v2-build</code>, taking care to instruct
cabal to enable profiling and create a GHC environment file (which will be
necessary shortly):</p>
<pre><code>$ cabal v2-build lib:optics-th \
    --enable-profiling --write-ghc-environment-files=always</code></pre>
<p>Finally, we can invoke <code>ghc</code> on the module containing our splices, instructing
GHC to evaluate splices using the external interpreter with profiling enabled:</p>
<pre><code>$ ghc -prof -fexternal-interpreter -opti+RTS -opti-p tests/Optics/TH/Tests/T799.hs </code></pre>
<p>Now we have our profile:</p>
<pre><code>$ cat ghc-iserv-prof.prof 
	Sun May 24 17:20 2020 Time and Allocation Profiling Report  (Final)

	   ghc-iserv-prof +RTS -p -RTS 12 13

	total time  =        0.25 secs   (253 ticks @ 1000 us, 1 processor)
	total alloc =   4,607,184 bytes  (excludes profiling overheads)

COST CENTRE         MODULE                       SRC                                                     %time %alloc

MAIN                MAIN                         &lt;built-in&gt;                                               96.8   82.0
reifyDatatype       Language.Haskell.TH.Datatype src/Language/Haskell/TH/Datatype.hs:353:1-70              1.2    1.9
makeFieldOptics     Optics.TH.Internal.Product   src/Optics/TH/Internal/Product.hs:63:1-101                0.8    7.6
resolveTypeSynonyms Language.Haskell.TH.Datatype src/Language/Haskell/TH/Datatype.hs:(1257,1)-(1303,28)    0.4    5.7

...</code></pre>
<p>Of course, we can also pass any of the usual heap profiling flags to the interpreter
by adding additional <code>-opti</code> flags. For instance,</p>
<pre><code>$ ghc -prof -fexternal-interpreter -opti+RTS -opti-p -opti-hy tests/Optics/TH/Tests/T799.hs </code></pre>
<p>would produce a heap profile by type, in addition to the usual <code>.prof</code> file.</p>
<h2 id="how-does-it-work">How does it work?</h2>
<p>The challenge in profiling Template Haskell is that we must arrange that splices
run under a profiling-enabled runtime system. In GHC’s default internal
interpreter mode of operation, splices (and, e.g., GHCi evaluations) are evaluated
in the same process as the compiler. However, the <code>ghc</code> executable provided in
GHC binary distributions is not built with profiling enabled.</p>
<p>For this reason we must instruct GHC to rather run splices in another process
via the <code>-fexternal-interpreter</code> flag. This process is provided by the
<code>ghc-iserv</code> executable; your GHC binary distribution ships with several variants
of this executable, including one with profiling enabled. The easiest way to
enable use of profiling and the external interpreter do this is by invoking
GHC manually (all of my attempts at achieving this via <code>cabal-install</code>
came up short).</p>
<p>However, if we invoke GHC manually we must somehow tell it where to find the
dependencies that <code>cabal-install</code> built. For this we tell <code>cabal-install</code>
to save this information as a GHC package environment with the
<code>--write-ghc-environment-files</code> flag. GHC will look for this file (which is
named, e.g., <code>.ghc.environment.x86_64-linux-8.10.1</code>) when invoked.</p>
<p>Finally, invoking <code>ghc</code> with <code>-prof</code> not only tells the compiler to produce
profiled code, but also forces the compiler to build dependencies with
profiling support. This includes both runtime dependencies, as well as the
dependencies which provide splice expressions.</p>
]]></description>
    <pubDate>Mon, 25 May 2020 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20200524-profiling-template-haskell.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>The state of GHC on ARM</title>
    <link>http://haskell.org/ghc/blog/20200515-ghc-on-arm.html</link>
    <description><![CDATA[<h1>The state of GHC on ARM</h1>
<h4 class="text-muted">bgamari - 2020-05-15</h4>

<p>The ARM architecture represents an overwhelming majority of CPUs on this planet.
Furthermore, there are now GHC users (myself included) who stake their
livelihood on being able to deploy their Haskell applications on ARM-based
platforms. As such, the task of making GHC run well on ARM has never been more
important.</p>
<p>This task has a long history, being the project that brought me to GHC
development <a href="http://www.smart-cactus.org/~ben/posts/2013-01-04-ghc-arm-update.html">many years
ago</a>, and
reliability of support has varied greatly from release-to-release.
As I’ve had a few people ask about the state of GHC-on-ARM over the past few
months, I thought now might be a good time to write some words on
the state of things.</p>
<p>In short, things are in significantly better shape today than they were back
in 2012. There are a few reasons for this:</p>
<ul>
<li><p>LLVM and <code>binutils</code> have stabilized significantly on ARM (this <a href="http://www.smart-cactus.org/~ben/posts/2014-11-28-state-of-llvm-backend.html">wasn’t
always</a>
the case)</p></li>
<li><p>ARM support in GHC’s linker is now mostly complete</p></li>
<li><p>(since GHC 8.10) GHC’s runtime system is much more careful about ensuring
memory ordering (see <a href="https://gitlab.haskell.org/ghc/ghc/merge_requests/1128">!1128</a>)</p></li>
</ul>
<p>Consequently, it now fairly easy to bring up GHC on ARMv7 and ARMv8 machines.</p>
<h3 id="getting-started-on-a-raspberry-pi">Getting started on a Raspberry Pi</h3>
<p>By far, the most readily-available ARM hardware running a standard Linux
distribution is the Raspberry Pi. Moreover, with more recent hardware
iterations (e.g. Raspberry Pi 4) the hardware is capable enough to run GHC
itself without incurring too much of a pain due to long compile times.</p>
<p>Most Raspberry Pi users will be using the Raspbian Debian variant. Unfortunately,
due to some <a href="https://gitlab.haskell.org/ghc/ghc/issues/17856#note_256497">creative packaging
decisions</a> on the
part of the Raspbian maintainers, installing GHC under Raspbian requires a bit
of manual intervention.</p>
<p>First, we need to install LLVM 9 (which GHC uses for code generation on ARM):</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> sudo apt-get install llvm-9</span></code></pre></div>
<p>Next we can fetch and install the GHC 8.10.1 ARMv7 binary distribution
for Debian 9:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> wget http://downloads.haskell.org/~ghc/8.10.1/ghc-8.10.1-armv7-deb9-linux.tar.xz</span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> tar <span class="at">-xf</span> ghc-8.10.1-armv7-deb9-linux.tar.gz</span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> cd ghc-8.10.1</span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./configure CONF_CC_OPTS_STAGE2=<span class="st">&quot;-marm -march=armv7-a&quot;</span> CFLAGS=<span class="st">&quot;-marm -march=armv7-a&quot;</span></span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> sudo make install</span></code></pre></div>
<p>Depending upon the speed of your storage medium this may take a while.
Here we have had to override the C flags inferred by <code>autoconf</code> since otherwise
<code>gcc</code> will produce invalid assembler (see <a href="https://gitlab.haskell.org/ghc/ghc/issues/17856">#17856</a>).</p>
<p>Finally, we can test our handiwork:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ghc <span class="at">--version</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> cat <span class="op">&gt;</span> Hello.hs <span class="op">&lt;&lt;EOF</span></span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="st">&gt; main = putStrLn &quot;hello world!&quot;</span></span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a><span class="st">&gt; EOF</span></span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a><span class="st">$ ghc Hello.hs</span></span>
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a><span class="st">$ ./Hello</span></span>
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a><span class="st">hello world!</span></span></code></pre></div>
<p>We can even use GHCi:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ghci</span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="ex">GHCi,</span> version 8.10.1: https://www.haskell.org/ghc/  :<span class="pp">?</span> for help</span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="ex">Prelude</span><span class="op">&gt;</span> putStrLn $ cycle <span class="st">&quot;turtles all the way down.\n&quot;</span></span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a><span class="ex">turtles</span> all the way down.</span>
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a><span class="ex">turtles</span> all the way down.</span>
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a><span class="ex">turtles</span> all the way down.</span>
<span id="cb4-7"><a href="#cb4-7" aria-hidden="true" tabindex="-1"></a><span class="ex">...</span></span></code></pre></div>
<p>Currently <code>Cabal</code>’s upstream doesn’t provide a <code>cabal-install</code> binary
distribution for ARM (although this will hopefully change
<a href="https://github.com/haskell/cabal/issues/6616">soon</a>). Nevertheless, I have
provided one
<a href="https://home.smart-cactus.org/~ben/ghc/cabal-install-3.4.0.0-rc4-armv7l-deb10.tar.xz">here</a>.</p>
<h3 id="future-work">Future work</h3>
<p>As always, there is plenty left to be done.</p>
<h4 id="further-memory-ordering-robustness">Further memory ordering robustness</h4>
<p>While <a href="https://gitlab.haskell.org/ghc/ghc/merge_requests/1128">!1128</a> was a significant step forward in stability on ARM (and other
weakly-ordered architectures), there is still room for improvement. GHC’s
runtime system has long been
<a href="http://isvolatileusefulwiththreads.in/C/">abusing</a> C’s <code>volatile</code> keyword to
prevent the compiler from doing unsound things with our ubiquitous reliance on
undefined behavior (in our defense, prior to the introduction on the C memory
model in C11 it was not possible to write programs like GHC’s RTS in standard C).</p>
<p>However, finding all of the data races in the RTS is no small task. I currently
have an on-going series of <a href="https://gitlab.haskell.org/ghc/ghc/-/merge_requests/2642">merge
requests</a> which
adds support for checking GHC’s runtime with the
<a href="https://github.com/google/sanitizers/wiki/ThreadSanitizerCppManual">ThreadSanitizer</a>
data-race detector. This is itself a non-trivial task as it requires that GHC
adopt C atomics in place of our previous use of explicit barriers wherever
possible. That being said, I hope to have this work done for 8.14. This will
squash a <a href="https://gitlab.haskell.org/ghc/ghc/issues/17757">few</a>
<a href="https://gitlab.haskell.org/ghc/ghc/issues/17289">more</a> bugs and should make
GHC on ARM quite solid.</p>
<p>Where ThreadSanitizer does <em>not</em> help us is in checking the lack of data races
between the mutator and the runtime system. In principle it would be possible
to emit ThreadSanitizer instrumentation, in practice we have found that
ThreadSanitizer gets quite upset at our large address-space reservations.
Nevertheless, we have found that even just checking the RTS in isolation is
very helpful, having caught several bugs that would have likely otherwise gone
unnoticed.</p>
<h4 id="a-native-code-generator">A native code generator?</h4>
<p>In my opinion, it is a shame that we do not have a dedicated native code
generator for the most populus architecture on the planet. ARM hardware is
typically fairly slow relative to x86; even under the best of conditions
compile-times will be rather long. The fact that we also rely on LLVM, which
itself isn’t the fastest compiler under the sun, exacerbates this problem.</p>
<p>However, eliminating LLVM from the equation shouldn’t be hard. ARM isn’t a
complex architecture; in particular, ARMv8 is a relatively
clean RISC ISA with little in the way of historical baggage. It would be
relatively easy for someone with a basic grasp of assembler to write a native
code generator backend for this platform in a week or two. I think this would
be a great project for someone; perhaps that person could be you!</p>
<h3 id="acknowledgments">Acknowledgments</h3>
<p>Continuous integration for ARM would not be possible without hosted hardware
contributions provided by <a href="https://www.packet.com/">Packet</a> through
the <a href="https://www.worksonarm.com/">Works on ARM</a> program.</p>
]]></description>
    <pubDate>Fri, 15 May 2020 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20200515-ghc-on-arm.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>DWARF support in GHC (part 5)</title>
    <link>http://haskell.org/ghc/blog/20200407-dwarf-5.html</link>
    <description><![CDATA[<h1>DWARF support in GHC (part 5)</h1>
<h4 class="text-muted">Ben Gamari - 2020-04-07</h4>

<p>This is the fifth and final post of a series examining GHC’s support for
DWARF debug information and the tooling that this support enables:</p>
<ul>
<li><a href="20200403-dwarf-1.html">Part 1</a> introduces DWARF debugging
information and explains how its generation can be enabled in GHC.</li>
<li><a href="20200404-dwarf-2.html">Part 2</a> looks at a DWARF-enabled program in
<code>gdb</code> and examines some of the limitations of this style of debug
information.</li>
<li><a href="20200405-dwarf-3.html">Part 3</a> looks at the backtrace support of
GHC’s runtime system and how it can be used from Haskell.</li>
<li><a href="20200406-dwarf-4.html">Part 4</a> examines how the Linux <code>perf</code>
utility can be used on GHC-compiled programs.</li>
<li><a href="20200407-dwarf-5.html">Part 5</a> concludes the series by describing
future work, related projects, and ways in which you can help.</li>
</ul>
<h2 id="future-work">Future work</h2>
<p>In the previous four posts we saw of some the functionality enabled by
DWARF debug information. As of GHC 8.10.2 everything we saw above should
be possible with the standard DWARF-enabled GHC binary distributions.</p>
<p>However, there is still a great deal of untapped potential and much
remains to be done. Here is a sampling of tasks in no particular order:</p>
<ul>
<li>Merge the fruits of my latest push on DWARF support upstream (<a href="https://gitlab.haskell.org/ghc/ghc/merge_requests/2380">!2380</a>,
<a href="https://gitlab.haskell.org/ghc/ghc/merge_requests/2373">!2373</a>, <a href="https://gitlab.haskell.org/ghc/ghc/merge_requests/2387">!2387</a>)</li>
<li>Make GHC-generated symbols (e.g. <code>59fw_info</code>) more reflective of
their origin in the source program</li>
<li>Preserve call-stacks in exceptions (as discussed in <a href="20200405-dwarf-3.html">part
3</a>)</li>
<li>Reduce the size of debug information through more concise
representation (see <a href="https://gitlab.haskell.org/ghc/ghc/issues/17609">#17609</a>)</li>
<li>Some RTS symbols (e.g. <code>stg_PAP_apply</code>) don’t have accurate unwind
information, leading to truncated backtraces in some cases (<a href="https://gitlab.haskell.org/ghc/ghc/issues/17627">#17627</a>)</li>
<li>Implement a native (e.g. non-DWARF-based) stack unwinder in the GHC
runtime system, allowing improved unwind performance in Haskell code</li>
<li>Windows PDB support (<a href="https://gitlab.haskell.org/ghc/ghc/issues/12397">#12397</a>)</li>
<li>Try moving GHC’s stack pointer to the native stack pointer register,
enabling call-graph profiling via DWARF unwinding (as discussed in
<a href="20200406-dwarf-4.html">part 4</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/8272">#8272</a>)</li>
<li>Build statistical profiling support into the GHC runtime system
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/10915">#10915</a>)</li>
<li>Add support for expressing local variables in C–, enabling
allocation profiling</li>
<li>Add support for tracking register value semantics in STG-to-C– and
DWARF type information, enabling local variable introspection.</li>
<li>Implement thread support in <code>GHC.ExecutionStack</code></li>
<li>Make better use of GHC-specific source-note information (mentioned
briefly in <a href="20200403-dwarf-1.html">part 1</a>)</li>
<li>Symbol demangling support in the GHC RTS, <code>perf</code>, and <code>gdb</code></li>
<li>Analysis tools</li>
</ul>
<p>As always, we are looking for people to help with this effort. If any of
the above tasks sound enticing to you, do let us know. Deep compiler
experience is quite unnecessary for many of these tasks, especially
those in the area of analysis tools.</p>
<p>Below I will describe in greater detail a few of the tasks which I think
hold the greatest potential.</p>
<h3 id="profile-analysis-tools">Profile analysis tools</h3>
<p>In his thesis, Peter Wortmann shows that the one-to-one correspondence
between instructions and line numbers required by DWARF (see <a href="20200403-dwarf-1.html">part
1</a>) can result in rather un-helpful profiles. He
shows that one can do significantly better by splitting the attribution
of an instruction across the full set of source locations that gave rise
to it. This is not something that existing tools can do. One could
implement this approach on top of the sample data produced by
<code>perf record</code> (e.g. exporting the samples via the <code>perf script</code> tool or
the <code>linux-perf</code> <a href="http://hackage.haskell.org/package/linux-perf">Haskell
library</a>) and using the
the extended DWARF annotations <a href="https://downloads.haskell.org/~ghc/8.10.1/docs/html/users_guide/debug-info.html#dw-tag-ghc-src-note">produced by
GHC</a>.</p>
<p>Peter’s Haskell Implementor’s Workshop
<a href="https://www.youtube.com/watch?v=kBm1sW3hNck">demonstration</a> showed one
possible interface for such an analysis tool, marrying Haskell source
and Core with sample data in the ThreadScope interface. It would be
great to continue exploration down this path.</p>
<h3 id="using-native-stack-pointer-register">Using native stack pointer register</h3>
<p>As noted in <a href="20200406-dwarf-4.html">part 4</a>, GHC’s current execution
model on x86 precludes use of <code>perf record</code>’s call-graph profiling
functionality. The most promising avenue to fix this would be to rework
GHC to use the native stack pointer register to track the Haskell stack
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/8272">#8272</a>). This would potentially carry a few benefits:</p>
<ul>
<li><p>it would enable use of native profiling tools</p></li>
<li><p>the native code generator could use the <code>PUSH</code> and <code>POP</code>
instructions, which may be more concise or better optimised in the
microarchitecture than our current stack manipulation strategy</p></li>
</ul>
<p>However, there are also a few tricky points:</p>
<ul>
<li><p>LLVM makes very strong assumptions about the nature of the stack;
consequently, moving the LLVM backend to this scheme may be
non-trivial.</p></li>
<li><p>the System V ABI requires that the stack always have a small
region above the stack pointer (called the “red zone”) which code
can use for temporary storage. GHC would need to ensure this
before calling into foreign code.</p></li>
</ul>
<p>There is some interesting discussion surrounding this idea in <a href="https://gitlab.haskell.org/ghc/ghc/issues/8272">#8272</a> and
<a href="https://github.com/ghc-proposals/ghc-proposals/pull/17">GHC Proposal MR
<a href="https://gitlab.haskell.org/ghc/ghc/issues/17">#17</a></a>.</p>
<h3 id="building-sampling-profiling-into-the-ghc-runtime">Building sampling profiling into the GHC runtime</h3>
<p>Without fixing the stack register issue described above, <code>perf</code>’s
call-graph profiling functionality is unusable. However, nothing is
stopping GHC from providing its own sampling infrastructure in the
runtime (<a href="https://gitlab.haskell.org/ghc/ghc/issues/10915">#10915</a>). In 2016 I started a
<a href="https://gitlab.haskell.org/ghc/ghc/tree/wip/libdw-prof">branch</a>) doing
exactly this using <code>perf_events</code>’s signal-based sampling interface,
dumping samples to GHC’s eventlog.</p>
<p>As far as I can recall the <code>wip/libdw-prof</code> branch can readily collect
samples; the work that remains primarily revolves around developing
analysis tools.</p>
<p>One approach would be to build a tool to convert the GHC-eventlog-based
output from the <code>wip/libdw-prof</code> branch into a <code>perf.data</code> file for use
with <code>perf report</code>. However, one could no doubt do much better with a
more specialised tool, as described in the “Profile analysis tools”
above.</p>
<p>While simple, this signal-based approach does imply a slightly more
overhead (in the form of context-switches) than necessary. A more
efficient approach might involve the Linux eBPF mechanism, which can be
triggered from a <code>perf_events</code> event.</p>
<h3 id="in-scope-bindings">In-scope bindings</h3>
<p>Most imperative compilers produce debug information that allow debuggers
display and modify in-scope variables and their values. In principle GHC
could also provide such support. However, doing so in a way that will be
useful in simplified programs would be quite non-trivial. For instance,
consider the program:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="ot">f ::</span> (<span class="dt">Int</span>, <span class="dt">String</span>) <span class="ot">-&gt;</span> <span class="dt">Int</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a>f (x, _) <span class="ot">=</span> x <span class="op">+</span> <span class="dv">4</span></span></code></pre></div>
<p>GHC’s worker-wrapper transformation would likely transform this to,</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ot">f ::</span> (<span class="dt">Int</span>, <span class="dt">String</span>) <span class="ot">-&gt;</span> <span class="dt">Int</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a>f pair <span class="ot">=</span></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a>  <span class="kw">case</span> pair <span class="kw">of</span> (x, _) <span class="ot">-&gt;</span> </span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a>  <span class="kw">case</span> x <span class="kw">of</span> <span class="dt">I</span><span class="op">#</span> x<span class="op">#</span> <span class="ot">-&gt;</span></span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a>  <span class="kw">case</span> <span class="op">$</span>wf x<span class="op">#</span> <span class="kw">of</span> result <span class="ot">-&gt;</span></span>
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a>    <span class="dt">I</span><span class="op">#</span> result</span>
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a><span class="op">$</span><span class="ot">wf ::</span> <span class="dt">Int</span><span class="op">#</span> <span class="ot">-&gt;</span> <span class="dt">Int</span><span class="op">#</span></span>
<span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a><span class="op">$</span>wf x<span class="op">#</span> <span class="ot">=</span> x<span class="op">#</span> <span class="op">+</span> <span class="dv">4</span></span></code></pre></div>
<p>This sort of transformation is ubiquitous and critical to the quality of
GHC’s produced code. Naturally, we would want to ensure that the debug
information of <code>$wf</code> can represent the fact that <code>x#</code> is the unboxed
first element of the argument of <code>f</code>. I suspect that the best way to
accomplish this would be to propagate value provenance information
through binders’ (e.g. in this case <code>x#</code>) <code>IdInfo</code> metadata.</p>
<p>This would involve:</p>
<ol type="1">
<li>Adding syntax in C– to encode local variable information</li>
<li>Producing such syntax in the STG-to-C– code generator</li>
<li>Adding information in Core to propagate value provenance, as
discussed above</li>
<li>Populate this information in worker-wrapper</li>
</ol>
<p>While being able to poke around at Haskell values in <code>gdb</code> is perhaps a
tempting proposition, all-in-all I suspect that the costs (both in
implementation time and complexity) of would likely outweigh the
benefits it would bring. This is especially true given that GHC already
has the GHCi debugger for cases where such interactive debugging is
necessary.</p>
<h3 id="aside-event-tracing">Aside: Event tracing</h3>
<p>Some users have related to me that they have sometimes wished that GHC
programs were as “traceable” as other programming language. In
particular, tools like <code>perf</code>, <code>bcc</code>, <code>bpftrace</code>, and <code>dtrace</code> provide
robust, minimal-overhead, language-agonstic tracing infrastructure which
can be invaluable in production settings. It would be great if Haskell
programs could benefit from these same tools.</p>
<p>The easiest on-ramp to tracing support is via the <a href="http://dtrace.org/guide/chp-usdt.html">User-space
Statically-Defined Tracepoint</a>
(USDT) mechanism supported by all of the aforementioned tools. Under
this scheme, the traced program embeds a bit of metadata describing the
available tracepoints, the information they provide, and how they are
enabled.</p>
<p>It turns out that GHC’s runtime system already defines a number of USDT
tracepoints (although they need to be enabled when configuring GHC with
the <code>--enable-dtrace</code> <code>configure</code> flag). However, it is possible that
this support may have bit-rotted (<a href="https://gitlab.haskell.org/ghc/ghc/issues/15543">#15543</a>).</p>
<p>However, it may also be useful to be able to define USDT tracepoints in
Haskell programs. A simple implementation of this would simply be a
Template Haskell splice which would generate the necessary C stubs and
splice in a foreign function import and call into the program.</p>
<h3 id="aside-llvm-and-x-ray">Aside: LLVM and X-Ray</h3>
<p>It should also be noted that LLVM provides another, much different
approach to the tracing/profiling problem with its <a href="https://www.llvm.org/docs/XRay.html">XRay instrumentation
infrastructure</a>. This approach
seeks to introduce low-cost tracing instrumentation in generated code,
allowing precise and highly detailed accounting of runtime costs.</p>
<p>Matthew Pickering tried (<a href="https://gitlab.haskell.org/ghc/ghc/issues/15929">#15929</a>) adding XRay support to GHC’s LLVM
backend. Unfortunately, this effort ended up being rather stunted, in
part due to limitations of LLVM itself (specifically difficulties with
tail-calls) and in part due to limitations of GHC’s LLVM backend
(namely, we rely on the LLVM IR <code>alias</code> mechanism to convince LLVM that
our type annotations are correct; this confuses the XRay logic).</p>
<h2 id="acknowledgments">Acknowledgments</h2>
<p>This work has been a multi-year (off-and-on) effort for me, but it would
not have been possible without a number of others.</p>
<p>In particular, this work would never have even started without the
efforts of Peter Wortmann. Not only does the causality formalism he
described in his <a href="http://etheses.whiterose.ac.uk/8321/">dissertation</a>
provide the theoretical foundation for all of this functionality, but
his initial implmentation kick-started the effort and the promising
results he <a href="https://www.youtube.com/watch?v=kBm1sW3hNck">demonstrated</a>
at the Haskell Implementors’ Workshop provided me with the motivation to
keep picking away at the seemingly endless stream of details which arose
as I refined the feature over the years.</p>
<p>In general, Well-Typed’s work on GHC (and, therefore, my own work) would
not have been possible without the support of Microsoft Research, IOHK and
others who have supported the position which allows me to work on GHC for many
years. In addition, some of my early work in 2015 to clean up the original
DWARF implementation was supported directly by funding from Microsoft Research.</p>
]]></description>
    <pubDate>Tue, 07 Apr 2020 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20200407-dwarf-5.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>DWARF support in GHC (part 4)</title>
    <link>http://haskell.org/ghc/blog/20200406-dwarf-4.html</link>
    <description><![CDATA[<h1>DWARF support in GHC (part 4)</h1>
<h4 class="text-muted">Ben Gamari - 2020-04-06</h4>

<p>This post is the fourth of a series examining GHC’s support for DWARF
debug information and the tooling that this support enables:</p>
<ul>
<li><a href="20200403-dwarf-1.html">Part 1</a> introduces DWARF debugging
information and explains how its generation can be enabled in GHC.</li>
<li><a href="20200404-dwarf-2.html">Part 2</a> looks at a DWARF-enabled program in
<code>gdb</code> and examines some of the limitations of this style of debug
information.</li>
<li><a href="20200405-dwarf-3.html">Part 3</a> looks at the backtrace support of
GHC’s runtime system and how it can be used from Haskell.</li>
<li><a href="20200406-dwarf-4.html">Part 4</a> examines how the Linux <code>perf</code>
utility can be used on GHC-compiled programs.</li>
<li><a href="20200407-dwarf-5.html">Part 5</a> concludes the series by describing
future work, related projects, and ways in which you can help.</li>
</ul>
<h2 id="profiling-with-perf">Profiling with <code>perf</code></h2>
<p>The final application of debug information that we will examine is
performance analysis, specifically profiling with the Linux <code>perf</code>
<a href="https://perf.wiki.kernel.org/index.php/Main_Page">tool</a>.</p>
<p><code>perf</code> is a statistical profiling tool relying on, among other things,
the underlying machine’s performance monitoring hardware. It can be used
not only to profile time, but also details of the microarchitecture such
as cache-misses, front-end stalls, etc. With a bit of cleverness, one
can even use <code>perf</code> to profile allocations of a Haskell program.</p>
<p>Moreover, all of this profiling functionality comes with a negligible
impact on the throughput of the profiled profiling. Of course, for all
of these benefits one trades off precision and ease of interpretation of
the resulting profile.</p>
<div class="table">
<table style="width:89%;">
<caption>Summary of the trade-offs made by cost-center profiler and
statistical profiling with <code>perf</code>.</caption>
<colgroup>
<col style="width: 22%" />
<col style="width: 30%" />
<col style="width: 36%" />
</colgroup>
<thead>
<tr class="header">
<th style="text-align: center;">Attribute</th>
<th style="text-align: center;"><code>perf</code></th>
<th style="text-align: center;">cost-center profiler</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: center;">Runtime impact</td>
<td style="text-align: center;">negligible</td>
<td style="text-align: center;">anywhere from moderate to
high</td>
</tr>
<tr class="even">
<td style="text-align: center;">Relatability to
source program</td>
<td style="text-align: center;">often hard to relate
back to source program</td>
<td style="text-align: center;">profile structure directly
reflects cost centers
declared in source program</td>
</tr>
<tr class="odd">
<td style="text-align: center;">Provides call
graphs</td>
<td style="text-align: center;">yes, with limited depth</td>
<td style="text-align: center;">yes</td>
</tr>
<tr class="even">
<td style="text-align: center;">Provides call
graphs on Haskell
programs</td>
<td style="text-align: center;">not currently</td>
<td style="text-align: center;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: center;">Profiled
variables</td>
<td style="text-align: center;">time, allocations,
micro-architectural
counters, system calls,
user- and kernel-space
probe points</td>
<td style="text-align: center;">time, allocations</td>
</tr>
<tr class="even">
<td style="text-align: center;">Determinism</td>
<td style="text-align: center;">profile is statistical
and will likely vary
from run to run</td>
<td style="text-align: center;">deterministic</td>
</tr>
</tbody>
</table>
</div>
<p>To see this trade-off in action, let’s return to our <code>vector-tests-O0</code>
example. We can acquire a simple time profile by simply running the
executable under <code>perf record</code>:</p>
<pre><code>$ perf record vector-tests-O0</code></pre>
<p>The resulting profile can be examined via <code>perf report</code>. This will show
you a TUI interface along the lines of</p>
<pre><code>Samples: 145K of event &#39;cycles:ppp&#39;, Event count (approx.): 98781024840
Overhead  Command          Shared Object       Symbol
  10.19%  vector-tests-O0  vector-tests-O0     [.] integerzmwiredzmin_GHCziIntegerziType_quotInteger_info
   5.02%  vector-tests-O0  vector-tests-O0     [.] evacuate
   3.58%  vector-tests-O0  vector-tests-O0     [.] stg_upd_frame_info+0xffffffffffc00000
   3.28%  vector-tests-O0  vector-tests-O0     [.] QuickCheckzm2zi13zi2zmac90a2a0d9e0dd2c227d795a9d4d9de22a119c3781b679f3b245300e1b658c43_TestziQuickCheckziGen_zdwzdsgamma_info
   2.96%  vector-tests-O0  vector-tests-O0     [.] integerzmwiredzmin_GHCziIntegerziType_timesInteger_info
   2.93%  vector-tests-O0  vector-tests-O0     [.] integerzmwiredzmin_GHCziIntegerziType_minusInteger_info
   2.67%  vector-tests-O0  vector-tests-O0     [.] integerzmwiredzmin_GHCziIntegerziType_testBitInteger_info
   2.34%  vector-tests-O0  vector-tests-O0     [.] integerzmwiredzmin_GHCziIntegerziType_eqIntegerzh_info
   2.30%  vector-tests-O0  vector-tests-O0     [.] randomzm1zi1zmc60864d5616c60090371cdf8e600240f388e8a9bd87aa769d8045bda89826ee2_SystemziRandom_zdwrandomIvalInteger_info
   2.18%  vector-tests-O0  vector-tests-O0     [.] integerzmwiredzmin_GHCziIntegerziType_plusInteger_info
   2.16%  vector-tests-O0  vector-tests-O0     [.] integerzmwiredzmin_GHCziIntegerziType_divInteger_info
   1.71%  vector-tests-O0  vector-tests-O0     [.] QuickCheckzm2zi13zi2zmac90a2a0d9e0dd2c227d795a9d4d9de22a119c3781b679f3b245300e1b658c43_TestziQuickCheckziGen_zdwilog2_info
   1.63%  vector-tests-O0  vector-tests-O0     [.] stg_ap_p_info+0xffffffffffc00010
   1.52%  vector-tests-O0  vector-tests-O0     [.] integerzmwiredzmin_GHCziIntegerziType_remInteger_info
   1.36%  vector-tests-O0  vector-tests-O0     [.] hs_popcnt64
   1.34%  vector-tests-O0  vector-tests-O0     [.] stg_PAP_apply
   1.23%  vector-tests-O0  vector-tests-O0     [.] stg_ap_0_fast
   1.22%  vector-tests-O0  vector-tests-O0     [.] stg_gc_noregs
   1.20%  vector-tests-O0  vector-tests-O0     [.] stg_newByteArrayzh
   1.15%  vector-tests-O0  vector-tests-O0     [.] stg_ap_pp_info+0xffffffffffc00000
   1.11%  vector-tests-O0  vector-tests-O0     [.] _randomzm1zi1zmc60864d5616c60090371cdf8e600240f388e8a9bd87aa769d8045bda89826ee2_SystemziRandom_b1_siHV_entry
   0.98%  vector-tests-O0  vector-tests-O0     [.] integerzmwiredzmin_GHCziIntegerziType_geIntegerzh_info
   0.98%  vector-tests-O0  vector-tests-O0     [.] stg_BLACKHOLE_info+0xffffffffffc00069
   0.92%  vector-tests-O0  vector-tests-O0     [.] scavenge_block
...</code></pre>
<p>This profile shows costs from both the runtime system and compiled
Haskell. If one selects an entry from this list with the arrow keys and
presses enter <code>perf</code> will show the annotated assembler of this function,
along with the associated Haskell source.</p>
<p>In principle, <code>perf record</code> can also give us call-graph information. We
will examine this in depth in the next section.</p>
<h3 id="paths-to-call-stack-profiling">Paths to call-stack profiling</h3>
<p>In addition to the flat profiles we saw earlier, <code>perf</code> can also produce
call-graph profiles which sample not only the current location of
execution but also callers to the enclosing function. Such call-graph
profiles are produced with the <code>perf record -g</code> command.</p>
<p>Unlike flat profiles, call-graph capture tends to be quite language- and
hardware-dependent. Consequently, <code>perf record</code> currently provides three
mechanisms for collecting call-stacks:</p>
<ul>
<li><p>via the <a href="https://en.wikipedia.org/wiki/Call_stack#FRAME-POINTER">frame pointer
register</a>:
GHC doesn’t track the frame-pointer like many imperative languages
do, so this is unusable on Haskell programs.</p></li>
<li><p>via the <a href="https://lwn.net/Articles/680985/">last branch record</a>
(LBR): This takes advantage of the LBR, a hardware feature of Intel
CPUs, and is only really usable on modern (e.g. Skylake and later)
hardware. However, even on Skylake it provides only a very limited
stack depth (32 branches on Skylake, of which many will be
uninteresting).</p></li>
<li><p>via DWARF unwinding: This uses DWARF unwinding information to decode
the state of the stack, which is captured at sampling-time. This
capture can result in non-trivial runtime overhead.</p></li>
</ul>
<p>Recent Intel hardware also includes another, more expensive hardware
mechanism, the Branch Trace Store, which could be useful for deeper
call-graph acquisition but <code>perf record</code> support currently does not
support using it for call-graph capture.</p>
<div class="table">
<table style="width:88%;">
<caption>Summary of trade-offs made by various call-stack collection
mechanisms supported by <code>perf record</code>.</caption>
<colgroup>
<col style="width: 25%" />
<col style="width: 20%" />
<col style="width: 21%" />
<col style="width: 21%" />
</colgroup>
<thead>
<tr class="header">
<th style="text-align: center;">attribute</th>
<th style="text-align: center;">frame pointer</th>
<th style="text-align: center;">LBR</th>
<th style="text-align: center;">DWARF</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: center;">maximum depth</td>
<td style="text-align: center;">unlimited</td>
<td style="text-align: center;">32 on Skylake</td>
<td style="text-align: center;">unlimited</td>
</tr>
<tr class="even">
<td style="text-align: center;">runtime overhead</td>
<td style="text-align: center;">negligible</td>
<td style="text-align: center;">negligible</td>
<td style="text-align: center;">small</td>
</tr>
<tr class="odd">
<td style="text-align: center;">compatible with GHC
execution model</td>
<td style="text-align: center;">no</td>
<td style="text-align: center;">yes?</td>
<td style="text-align: center;">not currently</td>
</tr>
</tbody>
</table>
</div>
<p>Unfortunately, call-stack profiling support for Haskell is complicated
by the fact that currently GHC uses machine registers in a rather
non-standard way: rather than use the machine’s stack pointer register
(e.g. <code>%rsp</code> on x86-64) to store the Haskell stack pointer GHC rather
reserves another register (<code>%rbp</code> on x86-64). This choice simplifies
interaction with foreign code at the expense of one usable register.
While DWARF’s representation of unwinding information is sufficiently
flexible to encode GHC’s non-standard stack register, the unwinding
logic in the Linux kernel used by <code>perf record</code> sadly is not. For this
reason, the unwind information produced by <code>ghc -g</code> is of little use
when profiling with <code>perf record -g</code>.</p>
<p>Other than DWARF unwinding, the only other viable call-graph option is
the last-branch register (LBR). Unfortunately, the rather restrictive
32-branch depth limit and the fact that GHC does not use the traditional
<code>call</code> instruction means that in practice the call-graphs produced by
this method tend not to be very useful.</p>
<p>In sum, currently I do not have a prescription for call-graph profiling
of Haskell programs with <code>perf</code>. The <a href="20200407-dwarf-5.html">next and final
post</a> will conclude this discussion of GHC’s
debug information support by looking at future directions (including
solutions to this call-graph problem) and other related projects.</p>
]]></description>
    <pubDate>Mon, 06 Apr 2020 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20200406-dwarf-4.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>DWARF support in GHC (part 3)</title>
    <link>http://haskell.org/ghc/blog/20200405-dwarf-3.html</link>
    <description><![CDATA[<h1>DWARF support in GHC (part 3)</h1>
<h4 class="text-muted">Ben Gamari - 2020-04-05</h4>

<p>This post is the third of a series examining GHC’s support for DWARF
debug information and the tooling that this support enables:</p>
<ul>
<li><a href="20200403-dwarf-1.html">Part 1</a> introduces DWARF debugging
information and explains how its generation can be enabled in GHC.</li>
<li><a href="20200404-dwarf-2.html">Part 2</a> looks at a DWARF-enabled program in
<code>gdb</code> and examines some of the limitations of this style of debug
information.</li>
<li><a href="20200405-dwarf-3.html">Part 3</a> looks at the backtrace support of
GHC’s runtime system and how it can be used from Haskell.</li>
<li><a href="20200406-dwarf-4.html">Part 4</a> examines how the Linux <code>perf</code>
utility can be used on GHC-compiled programs.</li>
<li><a href="20200407-dwarf-5.html">Part 5</a> concludes the series by describing
future work, related projects, and ways in which you can help.</li>
</ul>
<h2 id="getting-backtraces-from-the-runtime">Getting backtraces from the runtime</h2>
<p>We saw in the <a href="20200404-dwarf-2.html">last post</a> that GHC’s debug
information can be used by the <code>gdb</code> interactive debugger to provide
meaningful backtraces of running Haskell programs. However, debuggers
are not the only consumer of these backtraces. For several releases now
the GHC RTS has itself supported stack backtraces. This support can be
invoked in two ways:</p>
<ul>
<li>via the <code>SIGQUIT</code> signal</li>
<li>via the <code>GHC.ExecutionStack</code> interface in <code>base</code></li>
</ul>
<p>In the first case, programs built with debug symbols and a
<code>libdw</code>-enabled compiler can be sent the <code>SIGQUIT</code> signal <a href="#fn1" class="footnote-ref" id="fnref1" role="doc-noteref"><sup>1</sup></a>,
resulting in a stack trace being blurted to <code>stderr</code>:</p>
<pre><code>$ vector-tests-O0 &gt;/dev/null &amp; sleep 0.2; kill -QUIT %1
Caught SIGQUIT; Backtrace:
                 0x1387442    set_initial_registers (rts/Libdw.c:288.0)
            0x7feecbf2b0e0    dwfl_thread_getframes (/nix/store/35vnzk39hwsx18d1bkcd30r5xrx026mr-elfutils-0.176/lib/libdw-0.176.so)
            0x7feecbf2ab4e    get_one_thread_cb (/nix/store/35vnzk39hwsx18d1bkcd30r5xrx026mr-elfutils-0.176/lib/libdw-0.176.so)
            0x7feecbf2aea3    dwfl_getthreads (/nix/store/35vnzk39hwsx18d1bkcd30r5xrx026mr-elfutils-0.176/lib/libdw-0.176.so)
            0x7feecbf2b479    dwfl_getthread_frames (/nix/store/35vnzk39hwsx18d1bkcd30r5xrx026mr-elfutils-0.176/lib/libdw-0.176.so)
                 0x1387abd    libdwGetBacktrace (rts/Libdw.c:259.0)
                 0x1373b26    backtrace_handler (rts/posix/Signals.c:534.0)
            0x7feecbf7185f    (null) (/nix/store/g2p6fwjc995jrq3d8vph7k45l9zhdf8f-glibc-2.27/lib/libpthread-2.27.so)
                 0x137f24f    _rts_stgzuapzup_ret (_build/stage1/rts/build/cmm/AutoApply.cmm:654.18)
                 0x137de10    stg_upd_frame_info (rts/Updates.cmm:31.1)
                  0xa7cc80    _randomzm1zi1zmc60864d5616c60090371cdf8e600240f388e8a9bd87aa769d8045bda89826ee2_SystemziRandom_lvl6_siHP_entry (System/Random.hs:489.70)
                 0x12c52d8    integerzmwiredzmin_GHCziIntegerziType_minusInteger_info (libraries/integer-gmp/src/GHC/Integer/Type.hs:437.1)
                  0xa7d098    randomzm1zi1zmc60864d5616c60090371cdf8e600240f388e8a9bd87aa769d8045bda89826ee2_SystemziRandom_zdwrandomIvalInteger_info (System/Random.hs:487.20)
                  0x98da50    _QuickCheckzm2zi13zi2zmac90a2a0d9e0dd2c227d795a9d4d9de22a119c3781b679f3b245300e1b658c43_TestziQuickCheckziArbitrary_sat_sx8e_entry (Test/QuickCheck/Arbitrary.hs:988.26)
                 0x137de10    stg_upd_frame_info (rts/Updates.cmm:31.1)
...
                 0x137c810    stg_stop_thread_info (rts/StgStartup.cmm:42.1)
                 0x136571b    StgRunJmp (rts/StgCRun.c:370.0)
                 0x136241b    scheduleWaitThread (rts/Capability.h:219.0)
                 0x135f35e    hs_main (rts/RtsMain.c:73.0)
                  0x455df4    (null) (/opt/exp/ghc/ghc-8.10/vector/dist-newstyle/build/x86_64-linux/ghc-8.10.0.20191231/vector-0.13.0.1/t/vector-tests-O0/build/vector-tests-O0/vector-tests-O0)
            0x7feecbd4ab8e    __libc_start_main (/nix/store/g2p6fwjc995jrq3d8vph7k45l9zhdf8f-glibc-2.27/lib/libc-2.27.so)
                  0x40a82a    _start (../sysdeps/x86_64/start.S:122.0)</code></pre>
<p>This can be especially useful in diagnosing unexpected CPU usage or
latency in long-running tasks (e.g. a server stuck in a loop).</p>
<p>Note, however, that this currently only provides a backtrace of the
program’s main capability. Backtrace support for multiple capabilities
is an <a href="https://gitlab.haskell.org/ghc/ghc/issues/15774">outstanding
task</a>.</p>
<h3 id="getting-backtraces-from-haskell">Getting backtraces from Haskell</h3>
<p>The runtime’s unwinding support can also be invoked from Haskell
programs via the
<a href="https://hackage.haskell.org/package/base-4.12.0.0/docs/GHC-ExecutionStack.html">GHC.ExecutionStack</a>
interface. This provides:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="co">-- | A source location.</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="kw">data</span> <span class="dt">Location</span> <span class="ot">=</span> <span class="co">{- ... -}</span></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a><span class="co">-- | Returns a stack trace of the calling thread or &#39;Nothing&#39;</span></span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a><span class="co">-- if the runtime system lacks libdw support.</span></span>
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a><span class="ot">getStackTrace ::</span> <span class="dt">IO</span> (<span class="dt">Maybe</span> [<span class="dt">Location</span>])</span></code></pre></div>
<p>In the future we would also like to provide</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ot">getThreadStackTrace ::</span> <span class="dt">ThreadId</span> <span class="ot">-&gt;</span> <span class="dt">IO</span> (<span class="dt">Maybe</span> [<span class="dt">Location</span>])</span></code></pre></div>
<p>although this is an <a href="https://gitlab.haskell.org/ghc/ghc/issues/17630">outstanding
task</a>.</p>
<p>This could be used in a number of ways:</p>
<ol type="1">
<li><p>when throwing an exception, one could capture the current stack for
use in diagnostics output.</p></li>
<li><p>with <code>getThreadStackTrace</code> a monitoring library like <code>ekg</code> might
provide the ability to enumerate the program’s threads and
introspect on what they are up to.</p></li>
</ol>
<p>We’ll look at (1) in greater detail below.</p>
<h3 id="providing-backtraces-for-exceptions">Providing backtraces for exceptions</h3>
<p>Attaching backtrace information to exceptions is fairly straightforward.
For instance, one could provide</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="kw">data</span> <span class="dt">WithStack</span> e <span class="ot">=</span> <span class="dt">WithStack</span> (<span class="dt">Maybe</span> [<span class="dt">Location</span>]) e</span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="kw">instance</span> <span class="dt">Exception</span> (<span class="dt">WithStack</span> e)</span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a><span class="ot">throwIOWithStack ::</span> e <span class="ot">-&gt;</span> <span class="dt">IO</span> a</span>
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a>throwIOWithStack exc <span class="ot">=</span> <span class="kw">do</span></span>
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a> stack <span class="ot">&lt;-</span> getStackTrace</span>
<span id="cb4-7"><a href="#cb4-7" aria-hidden="true" tabindex="-1"></a> throwM <span class="op">$</span> <span class="dt">WithStack</span> stack exc</span>
<span id="cb4-8"><a href="#cb4-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-9"><a href="#cb4-9" aria-hidden="true" tabindex="-1"></a><span class="ot">throwWithStack ::</span> e <span class="ot">-&gt;</span> a</span>
<span id="cb4-10"><a href="#cb4-10" aria-hidden="true" tabindex="-1"></a>throwWithStack <span class="ot">=</span> unsafePerformIO <span class="op">.</span> throwIOWithStack</span>
<span id="cb4-11"><a href="#cb4-11" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-12"><a href="#cb4-12" aria-hidden="true" tabindex="-1"></a><span class="co">-- | Attach a stack trace to any exception thrown by the enclosed action.</span></span>
<span id="cb4-13"><a href="#cb4-13" aria-hidden="true" tabindex="-1"></a><span class="co">-- Note that this is idempotent.</span></span>
<span id="cb4-14"><a href="#cb4-14" aria-hidden="true" tabindex="-1"></a><span class="ot">addStack ::</span> <span class="dt">IO</span> a <span class="ot">-&gt;</span> <span class="dt">IO</span> a</span>
<span id="cb4-15"><a href="#cb4-15" aria-hidden="true" tabindex="-1"></a>addStack <span class="ot">=</span> handle f</span>
<span id="cb4-16"><a href="#cb4-16" aria-hidden="true" tabindex="-1"></a>  <span class="kw">where</span></span>
<span id="cb4-17"><a href="#cb4-17" aria-hidden="true" tabindex="-1"></a><span class="ot">    f ::</span> <span class="dt">SomeException</span> <span class="ot">-&gt;</span> <span class="dt">IO</span> b</span>
<span id="cb4-18"><a href="#cb4-18" aria-hidden="true" tabindex="-1"></a>    f exc <span class="op">|</span> <span class="dt">WithStack</span>{} <span class="ot">&lt;-</span> fromException exc <span class="ot">=</span></span>
<span id="cb4-19"><a href="#cb4-19" aria-hidden="true" tabindex="-1"></a>      throwIO exc  <span class="co">-- ensure idempotency</span></span>
<span id="cb4-20"><a href="#cb4-20" aria-hidden="true" tabindex="-1"></a>    f (<span class="dt">SomeException</span> exc) <span class="ot">=</span></span>
<span id="cb4-21"><a href="#cb4-21" aria-hidden="true" tabindex="-1"></a>      throwIOWithStack exc</span></code></pre></div>
<p>Keep in mind that DWARF stack unwinding can incur a significant overhead
(being linear in the depth of the stack with a significant constant
factor). Consequently, it would be unwise to use <code>throwIOWithStack</code>
indiscriminantly (e.g. when throwing an asynchronous exception to kill
another thread). However, for truly “exceptional” cases (e.g. failing
due to a non-existent file), it would offer quite some value.</p>
<p>Unfortunately, the untyped nature of Haskell exceptions complicates the
migration path for existing code. Specifically, if a library provides a
function which throws <code>MyException</code>, users catching <code>MyException</code> would
break if the library started throwing <code>WithStack MyException</code>. While
this may be manageable in the case of user libraries, for packages at
the heart of the Haskell ecosystem (e.g. <code>base</code>) this is a significant
hurdle.</p>
<p>Another design which avoids this migration problem is to incorporate
backtraces directly into the <code>base</code> <code>SomeException</code> type, which is used
to represent all thrown exceptions. Specifically, <code>Control.Exception</code>
could then expose a variety of throwing functions, reflecting the many
call stack mechanisms GHC now offers:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="kw">data</span> <span class="dt">SomeException</span> <span class="kw">where</span></span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a>    <span class="dt">SomeException</span><span class="ot"> ::</span> <span class="kw">forall</span> e<span class="op">.</span> <span class="dt">Exception</span> e</span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a>                  <span class="ot">=&gt;</span> <span class="dt">Maybe</span> [<span class="dt">Location</span>]  <span class="co">-- ^ backtrace, if available</span></span>
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a>                  <span class="ot">-&gt;</span> e                 <span class="co">-- ^ the exception</span></span>
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a>                  <span class="ot">-&gt;</span> <span class="dt">SomeException</span></span>
<span id="cb5-6"><a href="#cb5-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb5-7"><a href="#cb5-7" aria-hidden="true" tabindex="-1"></a><span class="co">-- | A representation of source locations consolidating &#39;GHC.Stack.SrcLoc&#39;,</span></span>
<span id="cb5-8"><a href="#cb5-8" aria-hidden="true" tabindex="-1"></a><span class="co">-- &#39;GHC.Stack.CostCentre&#39;, and &#39;GHC.ExecutionStack.Location&#39;.</span></span>
<span id="cb5-9"><a href="#cb5-9" aria-hidden="true" tabindex="-1"></a><span class="kw">data</span> <span class="dt">Location</span> <span class="ot">=</span> <span class="co">{- ... -}</span></span>
<span id="cb5-10"><a href="#cb5-10" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb5-11"><a href="#cb5-11" aria-hidden="true" tabindex="-1"></a><span class="co">-- | Throws an exception with no stack trace.</span></span>
<span id="cb5-12"><a href="#cb5-12" aria-hidden="true" tabindex="-1"></a><span class="ot">throwIO ::</span> e <span class="ot">-&gt;</span> <span class="dt">IO</span> a</span>
<span id="cb5-13"><a href="#cb5-13" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb5-14"><a href="#cb5-14" aria-hidden="true" tabindex="-1"></a><span class="co">-- | Throws an exception with a stack trace captured via</span></span>
<span id="cb5-15"><a href="#cb5-15" aria-hidden="true" tabindex="-1"></a><span class="co">-- &#39;GHC.Stack.getStackTrace&#39;.</span></span>
<span id="cb5-16"><a href="#cb5-16" aria-hidden="true" tabindex="-1"></a><span class="ot">throwIOWithExecutionStack ::</span> e <span class="ot">-&gt;</span> <span class="dt">IO</span> a</span>
<span id="cb5-17"><a href="#cb5-17" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb5-18"><a href="#cb5-18" aria-hidden="true" tabindex="-1"></a><span class="co">-- | Throws an exception with a `HasCallStack` stack trace.</span></span>
<span id="cb5-19"><a href="#cb5-19" aria-hidden="true" tabindex="-1"></a><span class="ot">throwIOWithCallStack ::</span> <span class="dt">HasCallStack</span> <span class="ot">=&gt;</span> e <span class="ot">-&gt;</span> <span class="dt">IO</span> a</span></code></pre></div>
<p>Of course, this raises the question of which call-stack method a
particular exception ought to use. This is often unknowable, depending
upon the user’s build configuration. Consequently, we might consider
exposing something of the form:</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="co">-- | Throws an exception with a stack trace using the most</span></span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a><span class="co">-- precise method available in the current build configuration.</span></span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a><span class="ot">throwIOWithStack ::</span> <span class="dt">HasCallStack</span> <span class="ot">=&gt;</span> e <span class="ot">-&gt;</span> <span class="dt">IO</span> a</span>
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a>throwIOWithStack</span>
<span id="cb6-5"><a href="#cb6-5" aria-hidden="true" tabindex="-1"></a>  <span class="op">|</span> profiling_enabled <span class="ot">=</span> throwIOWithCostCentreStack</span>
<span id="cb6-6"><a href="#cb6-6" aria-hidden="true" tabindex="-1"></a>  <span class="op">|</span> dwarf_enabled     <span class="ot">=</span> throwIOWithExecutionStack</span>
<span id="cb6-7"><a href="#cb6-7" aria-hidden="true" tabindex="-1"></a>  <span class="op">|</span> <span class="fu">otherwise</span>         <span class="ot">=</span> throwIOWithCallStack</span></code></pre></div>
<p>Finally, new “catch” operations could be introduced providing the
handler access to the exception’s stack:</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="ot">catchWithLocation ::</span> <span class="dt">IO</span> a <span class="ot">-&gt;</span> (e <span class="ot">-&gt;</span> <span class="dt">Maybe</span> [<span class="dt">Location</span>] <span class="ot">-&gt;</span> <span class="dt">IO</span> a) <span class="ot">-&gt;</span> <span class="dt">IO</span> a</span></code></pre></div>
<p>Above are just two possible designs; I’m sure there are other points
worthy of exploration. Do let me know if you are interesting in picking
up this line of work.</p>
<p>The <a href="20200406-dwarf-4.html">next post</a> will look at using the Linux
<code>perf</code> utility to profile Haskell executables.</p>
<section class="footnotes footnotes-end-of-document" role="doc-endnotes">
<hr />
<ol>
<li id="fn1" role="doc-endnote"><p>The unfortunate choice of the <code>SIGQUIT</code> signal to dump a backtrace
originates from the Java virtual machine implementations, where this
has been long available. GHC currently follows this precedent
although some people believe that <code>SIGQUIT</code> should be used for…
quitting. Do let us know on <a href="https://gitlab.haskell.org/ghc/ghc/issues/17451">#17451</a> if you feel should we should
reconsider the choice to follow Java on this point.<a href="#fnref1" class="footnote-back" role="doc-backlink">↩︎</a></p></li>
</ol>
</section>
]]></description>
    <pubDate>Sun, 05 Apr 2020 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20200405-dwarf-3.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>DWARF support in GHC (part 2)</title>
    <link>http://haskell.org/ghc/blog/20200404-dwarf-2.html</link>
    <description><![CDATA[<h1>DWARF support in GHC (part 2)</h1>
<h4 class="text-muted">Ben Gamari - 2020-04-04</h4>

<p>This post is the second of a series examining GHC’s support for DWARF
debug information and the tooling that this support enables:</p>
<ul>
<li><a href="20200403-dwarf-1.html">Part 1</a> introduces DWARF debugging
information and explains how its generation can be enabled in GHC.</li>
<li><a href="20200404-dwarf-2.html">Part 2</a> looks at a DWARF-enabled program in
<code>gdb</code> and examines some of the limitations of this style of debug
information.</li>
<li><a href="20200405-dwarf-3.html">Part 3</a> looks at the backtrace support of
GHC’s runtime system and how it can be used from Haskell.</li>
<li><a href="20200406-dwarf-4.html">Part 4</a> examines how the Linux <code>perf</code>
utility can be used on GHC-compiled programs.</li>
<li><a href="20200407-dwarf-5.html">Part 5</a> concludes the series by describing
future work, related projects, and ways in which you can help.</li>
</ul>
<h2 id="using-gdb-on-haskell-programs">Using <code>gdb</code> on Haskell programs</h2>
<p><code>gdb</code> is an interactive debugger ubiquitous on Unix systems. Let’s try
using it to run our executable and then break into execution with
<code>Ctrl-C</code>:</p>
<pre><code>$ gdb vector-tests-O0
GNU gdb (GDB) 8.3
...
Reading symbols from dist-newstyle/.../vector-tests-O0...
(gdb) run
Using host libthread_db library &quot;/nix/store/pnd2kl27sag76h23wa5kl95a76n3k9i3-glibc-2.27/lib/libthread_db.so.1&quot;.
Data.Vector.Fusion.Bundle:
  fromList.toList == id: [OK, passed 100 tests]
  toList.fromList == id: [OK, passed 100 tests]
...
  postscanr: [OK, passed 100 tests]
  postscanr&#39;: [OK, passed 100 tests]
^C
Program received signal SIGINT, Interrupt.
stg_ap_pp_fast () at _build/stage1/rts/build/cmm/AutoApply.cmm:3708
3708	        default: {
(gdb) bt
#0  stg_ap_pp_fast () at _build/stage1/rts/build/cmm/AutoApply.cmm:3708
#1  0x000000000137de10 in _rts_stgzuupdzuframe_ret ()
#2  0x0000000000997668 in QuickCheckzm2zi13zi2zmac90a2a0d9e0dd2c227d795a9d4d9de22a119c3781b679f3b245300e1b658c43_TestziQuickCheckziArbitrary_zdfCoArbitraryAll1_info () at Test/QuickCheck/Arbitrary.hs:1230
#3  0x000000000137de10 in _rts_stgzuupdzuframe_ret ()
...
#54 0x0000000000997668 in QuickCheckzm2zi13zi2zmac90a2a0d9e0dd2c227d795a9d4d9de22a119c3781b679f3b245300e1b658c43_TestziQuickCheckziArbitrary_zdfCoArbitraryAll1_info () at Test/QuickCheck/Arbitrary.hs:1230
#55 0x000000000137de10 in _rts_stgzuupdzuframe_ret ()
#56 0x0000000001316510 in ghczmprim_GHCziClasses_zdfEqBoolzuzdczeze_info () at libraries/ghc-prim/GHC/Classes.hs:205
#57 0x0000000000643698 in r5bd2_info () at Data/Vector.hs:289
#58 0x000000000137de10 in _rts_stgzuupdzuframe_ret ()
#59 0x00000000009bc478 in s1TRr_info () at Test/QuickCheck/Property.hs:225
#60 0x00000000009bbc88 in s1TQC_info () at Test/QuickCheck/Property.hs:190
#61 0x0000000001375f50 in _rts_stgzucatchzuframe_ret () at rts/Exception.cmm:335
#62 0x00000000009bbe08 in s1TQX_info () at Test/QuickCheck/Property.hs:252
#63 0x00000000009b7670 in s1TIa_info () at Test/QuickCheck/Property.hs:216
...
#68 0x00000000009b7670 in s1TIa_info () at Test/QuickCheck/Property.hs:216
#69 0x00000000009b7c18 in s1TIJ_info () at Test/QuickCheck/Property.hs:207
#70 0x00000000009b7670 in s1TIa_info () at Test/QuickCheck/Property.hs:216
#71 0x00000000009b7670 in s1TIa_info () at Test/QuickCheck/Property.hs:216
#72 0x00000000009bff88 in QuickCheckzm2zi13zi2zmac90a2a0d9e0dd2c227d795a9d4d9de22a119c3781b679f3b245300e1b658c43_TestziQuickCheckziProperty_reduceRose1_info () at Test/QuickCheck/Property.hs:232
#73 0x00000000009e18a8 in s2eT1_info () at Test/QuickCheck/Test.hs:331
#74 0x0000000001375f50 in _rts_stgzucatchzuframe_ret () at rts/Exception.cmm:335
#75 0x00000000009e2380 in QuickCheckzm2zi13zi2zmac90a2a0d9e0dd2c227d795a9d4d9de22a119c3781b679f3b245300e1b658c43_TestziQuickCheckziTest_quickCheck4_info () at Test/QuickCheck/Test.hs:333
#76 0x00000000007479b0 in s4py_info () at Test/Framework/Providers/QuickCheck2.hs:114
#77 0x0000000000755cf8 in s2dc_info () at Test/Framework/Improving.hs:68
#78 0x0000000000762080 in r6ny_info () at Test/Framework/Runners/ThreadPool.hs:62
#79 0x0000000001375f50 in _rts_stgzucatchzuframe_ret () at rts/Exception.cmm:335
#80 0x000000000137c810 in _rts_stgzustopzuthread_ret ()
#81 0x000000000136571b in StgRunIsImplementedInAssembler () at rts/StgCRun.c:370
#82 0x000000000136241b in schedule (task=0x175aa00, initialCapability=&lt;optimized out&gt;) at rts/Schedule.c:467
#83 scheduleWaitThread (tso=&lt;optimized out&gt;, ret=ret@entry=0x0, pcap=pcap@entry=0x7fffffff5210) at rts/Schedule.c:2600
#84 0x000000000138b204 in rts_evalLazyIO (cap=cap@entry=0x7fffffff5210, p=p@entry=0x14122d0, ret=ret@entry=0x0) at rts/RtsAPI.c:530
#85 0x000000000135f35e in hs_main (argc=&lt;optimized out&gt;, argv=&lt;optimized out&gt;, main_closure=0x14122d0, rts_config=...) at rts/RtsMain.c:72
#86 0x0000000000455df4 in main ()
(gdb) </code></pre>
<p>Here we see the state of the stack around one second into the execution.
Note that I have elided a good number (around 50) repeated
<code>CoArbitraryAll1</code> frames. There are four kinds of symbol names seen
here:</p>
<ol type="1">
<li>C functions provided by the runtime system (e.g. <code>rts_evalLazyIO</code>)</li>
<li>C– functions provided by the runtime system
(e.g. <code>_rts_stgzuupdzuframe_ret</code>)</li>
<li>Haskell functions exported by modules
(e.g. <code>ghczmprim_GHCziClasses_zdfEqBoolzuzdczeze_info</code>)</li>
<li>Haskell functions internal to modules (e.g. <code>s1TRr_info</code>)</li>
</ol>
<p>In cases (2) and (3) the names are derived from source program names via
GHC’s <a href="https://gitlab.haskell.org/ghc/ghc/wikis/commentary/compiler/symbol-names">Z
encoding</a>)
symbol name mangling scheme. For instance,</p>
<div class="table">
<table>
<tbody>
<tr class="odd">
<td style="text-align: left;">mangled</td>
<td style="text-align: left;"><code>ghczmprim_GHCziClasses_zdfEqBoolzuzdczeze_info</code></td>
</tr>
<tr class="even">
<td style="text-align: left;">demangled</td>
<td style="text-align: left;"><code>ghc-prim_GHC.Classes_$fEqBool_$c==_info</code></td>
</tr>
</tbody>
</table>
</div>
<p>In principle <code>gdb</code> could be taught to perform this demangling on our
behalf.</p>
<p>Aside from symbol names, the above backtrace also gives us (often more
informative) source locations. However, it should be noted that this
line information can be slightly misleading at times for reasons that we
will describe below.</p>
<h3 id="surprises-in-debug-information">Surprises in debug information</h3>
<p>As noted above, GHC backtraces can at times be slightly surprising. To
see why, consider the simple program,</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ot">f ::</span> [<span class="dt">Int</span>] <span class="ot">-&gt;</span> <span class="dt">Int</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a>f <span class="ot">=</span> <span class="fu">sum</span> <span class="op">.</span> <span class="fu">map</span> (<span class="op">*</span> <span class="dv">42</span>)</span></code></pre></div>
<p>The code generated for this function (when compiled with <code>-O</code>) will
inevitably contain a multiplication instruction and an addition
instruction. However, which source location should these be attributed
to <a href="#fn1" class="footnote-ref" id="fnref1" role="doc-noteref"><sup>1</sup></a>? One might say <code>f</code>, or somewhere in <code>Data.List.sum</code>, or
somewhere in <code>foldl</code> (which <code>sum</code> is defined in terms of). Moreover,
these sets of options can grow to be quite large, particularly in cases
where stream fusion is involved.</p>
<p>Unfortunately, the DWARF specification requires that GHC choose
precisely one of these locations when producing debug information. At
the moment GHC uses heuristics to choose from among the options, but
these heuristics, like all heuristics, can sometimes produce less than
helpful results. GHC can also emit an <a href="https://downloads.haskell.org/~ghc/8.10.1-alpha2/docs/html/users_guide/debug-info.html#dw-tag-ghc-src-note">extended DWARF
form</a>
which encodes the entire set of source locations. However, there is
currently widely available tooling which can consume this information.</p>
<p>In addition to the above wrinkle there is another feature of GHC’s
produced code that poses a challenge when producing debug information:
tail calls. In a language lacking tail calls, a stack frame typically
contains a pointer to the instruction following the function call that
pushed the frame. This serves as the address to which execution will
return after the callee finishes and is guaranteed to be in the same
procedure as the call itself. For this reason, stack backtraces always
reflect the history of a program’s execution. That is, a stack
containing the frames <code>f; g; h</code> means:</p>
<ul>
<li><code>f</code> called <code>g</code></li>
<li><code>g</code> called <code>h</code></li>
<li><code>h</code> is currently executing</li>
</ul>
<p>However, tail calls break this model. For instance, consider the Haskell
function:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ot">tail_caller ::</span> [<span class="dt">Int</span>] <span class="ot">-&gt;</span> <span class="dt">Int</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a>tail_caller xs <span class="ot">=</span> <span class="fu">sum</span> xs</span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a><span class="fu">sum</span><span class="ot"> ::</span> [<span class="dt">Int</span>] <span class="ot">-&gt;</span> <span class="dt">Int</span></span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a><span class="fu">sum</span> xs <span class="ot">=</span> foldl&#39; (<span class="op">+</span>) <span class="dv">0</span> xs</span></code></pre></div>
<p>Without optimisation, the code generated for <code>tail_caller</code> will simply
jump straight to the entry-point of <code>sum</code>; no stack entry will be left
to mark the fact that <code>sum</code> was called by <code>tail_caller</code>. This, coupled
with the source location ambiguity described above, can at times lead to
slightly surprising backtraces. If you find a case that you think makes
little sense, please do open a ticket. We are always looking for ways to
improve the quality of the debug information produced by GHC.</p>
<h3 id="breakpoints">Breakpoints</h3>
<p>In addition to printing backtraces, we can also set breakpoints:</p>
<pre><code>(gdb) break Test/Framework/Improving.hs:68
(gdb) cont
Continuing.

Breakpoint 1, s2dc_info () at Test/Framework/Improving.hs:68
68	Test/Framework/Improving.hs: No such file or directory.
(gdb) bt
#0  s2dc_info () at Test/Framework/Improving.hs:68
#1  0x0000000000762080 in r6ny_info () at Test/Framework/Runners/ThreadPool.hs:62
#2  0x0000000001375f50 in _rts_stgzucatchzuframe_ret () at rts/Exception.cmm:335
#3  0x000000000137c810 in _rts_stgzustopzuthread_ret ()
#4  0x000000000136571b in StgRunIsImplementedInAssembler () at rts/StgCRun.c:370
#5  0x000000000136241b in schedule (task=0x175aa00, initialCapability=&lt;optimized out&gt;) at rts/Schedule.c:467
#6  scheduleWaitThread (tso=&lt;optimized out&gt;, ret=ret@entry=0x0, pcap=pcap@entry=0x7fffffff5210) at rts/Schedule.c:2600
#7  0x000000000138b204 in rts_evalLazyIO (cap=cap@entry=0x7fffffff5210, p=p@entry=0x14122d0, ret=ret@entry=0x0) at rts/RtsAPI.c:530
#8  0x000000000135f35e in hs_main (argc=&lt;optimized out&gt;, argv=&lt;optimized out&gt;, main_closure=0x14122d0, rts_config=...) at rts/RtsMain.c:72
#9  0x0000000000455df4 in main ()</code></pre>
<p>However, at the moment this is little more than a parlor trick since our
debug information does not encode information about in-scope bindings
(fixing this is a significant project in its own right and is not
currently planned).</p>
<p>In the <a href="20200405-dwarf-3.html">next post</a> we will see how we can use
GHC’s native unwinding support to gather stack traces from within
Haskell programs.</p>
<section class="footnotes footnotes-end-of-document" role="doc-endnotes">
<hr />
<ol>
<li id="fn1" role="doc-endnote"><p>The very question of what it means to “attribute” a machine
operation to a source location is itself a tricky one to precisely
define in a lazy language like Haskell. Finding such a definition
was a central part of Peter Wortmann’s
<a href="http://etheses.whiterose.ac.uk/8321/">dissertation</a>. I would
encourage anyone interested to peruse Chapter 4 of this very
readable work.<a href="#fnref1" class="footnote-back" role="doc-backlink">↩︎</a></p></li>
</ol>
</section>
]]></description>
    <pubDate>Sat, 04 Apr 2020 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20200404-dwarf-2.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>DWARF support in GHC (part 1)</title>
    <link>http://haskell.org/ghc/blog/20200403-dwarf-1.html</link>
    <description><![CDATA[<h1>DWARF support in GHC (part 1)</h1>
<h4 class="text-muted">Ben Gamari - 2020-04-03</h4>

<p>This post is the first of a series examining GHC’s support for DWARF
debug information and the tooling that this support enables:</p>
<ul>
<li><a href="20200403-dwarf-1.html">Part 1</a> introduces DWARF debugging
information and explains how its generation can be enabled in GHC.</li>
<li><a href="20200404-dwarf-2.html">Part 2</a> looks at a DWARF-enabled program in
<code>gdb</code> and examines some of the limitations of this style of debug
information.</li>
<li><a href="20200405-dwarf-3.html">Part 3</a> looks at the backtrace support of
GHC’s runtime system and how it can be used from Haskell.</li>
<li><a href="20200406-dwarf-4.html">Part 4</a> examines how the Linux <code>perf</code>
utility can be used on GHC-compiled programs.</li>
<li><a href="20200407-dwarf-5.html">Part 5</a> concludes the series by describing
future work, related projects, and ways in which you can help.</li>
</ul>
<h2 id="dwarf-debugging-information">DWARF debugging information</h2>
<p>For several years now GHC has had support for producing DWARF debugging
information. DWARF is a widely-used format (used by Linux and several
BSDs) for representing debug information (typically embedded in an
executable) for consumption by runtime systems, profiling, and debugging
tools. It allows representation of a variety of information:</p>
<ul>
<li><p><em>line information</em> mapping instructions back to their location in
the source program (e.g. the instruction at address <code>x</code> originated
from <code>myprogram.c</code> line 42).</p></li>
<li><p><em>unwind information</em> allowing call chains to be reconstructed from
the runtime state of the execution stack (e.g. the program is
currently executing <code>f</code>, which was called from <code>g</code>, which was called
from <code>h</code>, …)</p></li>
<li><p><em>type information</em>, allowing debugging tools to reconstruct the
structure and identity of values from the runtime state of the
program (e.g. when the program is executing the instruction at
address <code>x</code>, the value sitting in the <code>$rax</code> register is a pointer
to a <code>Foobar</code> object.</p></li>
</ul>
<p>Collectively, this information is what allows debuggers (e.g. <code>gdb</code>) and
profiling tools (e.g. <code>perf</code>) to do what they do.</p>
<p>The effort to add DWARF support to GHC started with Peter Wortmann’s
<a href="http://etheses.whiterose.ac.uk/8321/">dissertation work</a> which
introduced the ability for GHC to emit basic line and unwind information
in its executables. This support has matured considerably over the past
few years and should finally be ready for use with GHC 8.10.</p>
<p>There are a few potential use-cases for DWARF information:</p>
<ol type="1">
<li><p>Use in native debugging tools (e.g. <code>gdb</code>)</p></li>
<li><p>Dumping runtime call stacks to the console using the <code>SIGQUIT</code>
<a href="https://ghc.gitlab.haskell.org/ghc/doc/users_guide/debug-info.html?highlight=sigquit#requesting-a-stack-trace-with-sigquit">signal</a>;
this is particularly useful in production</p></li>
<li><p>Computing runtime call stacks from within the program (using the
<code>GHC.ExecutionStack</code>
<a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/GHC-ExecutionStack.html">interface</a>
in <code>base</code>)</p></li>
<li><p>Statistical profiling using tools like perf.</p></li>
<li><p>Capturing call-stacks in exceptions for reporting to the user</p></li>
</ol>
<p>We will discuss all of these in this series of blog posts. The rest of
this first post will examine how to compile a DWARF-enabled binary.</p>
<h2 id="first-steps">First steps</h2>
<p>As of GHC 8.10.2, GHC HQ will provide DWARF-enabled binary distributions
for Debian 9, Debian 10, and Fedora 27 (as of 8.10.1 only Debian 9 is
provided). These binary distributions differ in two respects from the
non-DWARF distributions:</p>
<ul>
<li>all provided libraries (e.g. <code>base</code>, <code>filepath</code>, <code>unix</code>, etc.) are
built with debug information.</li>
<li>the runtime system is built with a dependency on the <code>libdw</code> library
(provided by the <code>elfutils</code> package).</li>
</ul>
<p>Like other compilers, debug information support under GHC is enabled
with the <code>-g</code> flag. This flag can be passed a numeric “debug level”,
which determines the detail (and, consequently, size) of the debug
information that is produced. These levels are described in the <a href="https://downloads.haskell.org/~ghc/8.10.1/docs/html/users_guide/debug-info.html#ghc-flag--g">GHC
user
guide</a>.</p>
<p>When using native debug information we must keep in mind that all code
linked into an executable (e.g. native libraries, Haskell libraries, and
the code of the executable itself) must be built with debug information.
Failure to ensure this will result in truncated backtraces.</p>
<p>To build a package with native debug information we can use
<code>cabal-install</code>’s <code>--enable-debug-info</code> flag (or, below, its equivalent
key in <code>cabal.project</code>). Here, we will use the <code>vector</code> testsuite as a
non-trivial example:</p>
<pre><code>$ git clone https://github.com/haskell/vector
$ cd vector
$ cat &gt;&gt;cabal.project.local &lt;&lt;EOF
allow-newer: base

package vector
  tests: True

package *
  debug-info: 2
EOF
$ cabal new-build vector-tests-O0</code></pre>
<p>For the sake of demonstration we built the <code>vector-tests-O0</code> testsuite
(which builds <code>vector</code>’s tests without optimisation) since this provides
slightly more interesting stacktraces. We chose debug level 2 as we will
not be using the GHC-specific debug information emitted by debug level
3.</p>
<p>At this point we have a DWARF-annotated binary. This binary is
functionally identical to a non-annotated build (apart from containing
quite a few more bits, weighing in at over 150 megabytes). Most
importantly, no optimizations were inhibited by enabling debug
information.</p>
<p>In the <a href="20200404-dwarf-2.html">next post</a> we will begin to see what this
extra 100 megabytes of debug information gives us.</p>
]]></description>
    <pubDate>Fri, 03 Apr 2020 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20200403-dwarf-1.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 8.10.1 released</title>
    <link>http://haskell.org/ghc/blog/20200324-ghc-8.10.1-released.html</link>
    <description><![CDATA[<h1>GHC 8.10.1 released</h1>
<h4 class="text-muted">bgamari - 2020-03-24</h4>

<p>The GHC team is happy to announce the availability of GHC 8.10.1. Source
and binary distributions are available at the <a href="https://downloads.haskell.org/ghc/8.10.1/">usual
place</a>.</p>
<p>GHC 8.10.1 brings a number of new features including:</p>
<ul>
<li><p>The new <code>UnliftedNewtypes</code> extension allowing newtypes around unlifted
types.</p></li>
<li><p>The new <code>StandaloneKindSignatures</code> extension allows users to give
top-level kind signatures to type, type family, and class
declarations.</p></li>
<li><p>A new warning, <code>-Wderiving-defaults</code>, to draw attention to ambiguous
deriving clauses</p></li>
<li><p>A number of improvements in code generation, including a new loop analyzer, optimisation of <code>memset</code>, <code>memcpy</code> and array allocation, more aggressive specialisation, and pointer tagging for larger data types.</p></li>
<li><p>A new GHCi command, <code>:instances</code>, for listing the class instances
available for a type.</p></li>
<li><p>An upgraded Windows toolchain lifting the <code>MAX_PATH</code> limitation</p></li>
<li><p>A new, low-latency garbage collector.</p></li>
<li><p>Improved support profiling, including support for sending profiler
samples to the eventlog, allowing correlation between the profile and
other program events</p></li>
</ul>
<p>A full accounting of the changes of this release can be found in the <a href="https://downloads.haskell.org/ghc/8.10.1/docs/html/users_guide/8.10.1-notes.html">release notes</a>.
A guide for migrating existing code to GHC 8.10 can be found in the <a href="https://gitlab.haskell.org/ghc/ghc/-/wikis/migration/8.10">release migration notes</a>.</p>
<p>Note that at the moment we still require that macOS Catalina users
exempt the binary distribution from the notarization requirement by
running <code>xattr -cr .</code> on the unpacked tree before running <code>make install</code>.
This situation will hopefully be improved for GHC 8.10.2 with the
resolution of <a href="https://gitlab.haskell.org/ghc/ghc/issues/17418">#17418</a>.</p>
<p>Cheers,</p>
<ul>
<li>Ben</li>
</ul>
]]></description>
    <pubDate>Tue, 24 Mar 2020 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20200324-ghc-8.10.1-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 8.8.3 released</title>
    <link>http://haskell.org/ghc/blog/20200224-ghc-8.8.3-released.html</link>
    <description><![CDATA[<h1>GHC 8.8.3 released</h1>
<h4 class="text-muted">bgamari - 2020-02-24</h4>

<p>The GHC team is proud to announce the release of GHC 8.8.3. The source
distribution, binary distributions, and documentation are available at
<a href="https://downloads.haskell.org/~ghc/8.8.3">downloads.haskell.org</a></p>
<p>Release notes are also <a href="https://downloads.haskell.org/ghc/8.8.3/docs/html/users_guide/8.8.3-notes.html">available</a>.</p>
<p>This release fixes a handful of issues affecting 8.8.2:</p>
<ul>
<li><p>a compiler panic (<a href="https://gitlab.haskell.org/ghc/ghc/issues/17429">#17429</a>) due to over-zealous eta reduction</p></li>
<li><p>a linker crash on Windows (<a href="https://gitlab.haskell.org/ghc/ghc/issues/17575">#17575</a>)</p></li>
<li><p>the ability to bootstrap with earlier 8.8 releases has been restored
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/17146">#17146</a>)</p></li>
<li><p>the <code>directory</code> submodule has been updated, fixing <a href="https://gitlab.haskell.org/ghc/ghc/issues/17598">#17598</a></p></li>
</ul>
<p>As always, if anything looks amiss do let us know.</p>
]]></description>
    <pubDate>Mon, 24 Feb 2020 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20200224-ghc-8.8.3-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 8.10.1-rc1 now available</title>
    <link>http://haskell.org/ghc/blog/20200124-ghc-8.10.1-rc1-released.html</link>
    <description><![CDATA[<h1>GHC 8.10.1-rc1 now available</h1>
<h4 class="text-muted">bgamari - 2020-01-24</h4>

<p>The GHC team is happy to announce the availability of the first release
candidate of GHC 8.10.1. Source and binary distributions are
available at the <a href="https://downloads.haskell.org/ghc/8.10.1-rc1/">usual place</a>.</p>
<p>GHC 8.10.1 will bring a number of new features including:</p>
<ul>
<li><p>The new <code>UnliftedNewtypes</code> extension allowing newtypes around unlifted
types.</p></li>
<li><p>The new <code>StandaloneKindSignatures</code> extension allows users to give
top-level kind signatures to type, type family, and class
declarations.</p></li>
<li><p>A new warning, <code>-Wderiving-defaults</code>, to draw attention to ambiguous
deriving clauses</p></li>
<li><p>A number of improvements in code generation, including changes</p></li>
<li><p>A new GHCi command, <code>:instances</code>, for listing the class instances
available for a type.</p></li>
<li><p>An upgraded Windows toolchain lifting the <code>MAX_PATH</code> limitation</p></li>
<li><p>A new, low-latency garbage collector.</p></li>
<li><p>Improved support profiling, including support for sending profiler
samples to the eventlog, allowing correlation between the profile and
other program events</p></li>
</ul>
<p>This is the first and likely final release candidate. For a variety of
reasons, it comes a few weeks later than the original schedule of
release late December. However, besides a few core libraries
book-keeping issues this candidate is believed to be in good condition
for the final release. As such, the final 8.10.1 release will likely
come in two weeks.</p>
<p>Note that at the moment we still require that macOS Catalina users
exempt the binary distribution from the notarization requirement by
running <code>xattr -cr .</code> on the unpacked tree before running <code>make install</code>.</p>
<p>In addition, we are still looking for any Alpine Linux to help diagnose
the correctness issues in the <a href="https://gitlab.haskell.org/ghc/ghc/issues/17508">Alpine binary distribution</a>. If you use
Alpine any you can offer here would be greatly appreciated.</p>
<p>Please do test this release and let us know if you encounter any other
issues.</p>
]]></description>
    <pubDate>Fri, 24 Jan 2020 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20200124-ghc-8.10.1-rc1-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 8.8.2 released</title>
    <link>http://haskell.org/ghc/blog/20200116-ghc-8.8.2-released.html</link>
    <description><![CDATA[<h1>GHC 8.8.2 released</h1>
<h4 class="text-muted">bgamari - 2020-01-16</h4>

<p>The GHC team is proud to announce the release of GHC 8.8.2. The source
distribution, binary distributions, and documentation are available at
<a href="https://downloads.haskell.org/~ghc/8.8.2">downloads.haskell.org</a>. Release
notes are also
<a href="https://downloads.haskell.org/ghc/8.8.2/docs/html/users_guide/8.8.2-notes.html">available</a></p>
<p>This release fixes a handful of issues affecting 8.8.1:</p>
<ul>
<li><p>A bug (<a href="https://gitlab.haskell.org/ghc/ghc/issues/17088">#17088</a>) in the compacting garbage collector resulting in
segmentations faults under specific circumstances. Note that this may
affect user programs even if they did not explicitly request the
compacting GC (using the -c RTS flag) since GHC may fallback to
compacting collection during times of high memory pressure.</p></li>
<li><p>A code generation bug (<a href="https://gitlab.haskell.org/ghc/ghc/issues/17334">#17334</a>) resulting in GHC panics has been
fixed.</p></li>
<li><p>A bug in the <code>process</code> library causing builds using <code>hsc2hs</code> to fail
non-deterministically on Windows has been fixed (<a href="https://gitlab.haskell.org/ghc/ghc/issues/17480">#17480</a>)</p></li>
<li><p>A typechecker bug (<a href="https://gitlab.haskell.org/ghc/ghc/issues/16288">#16288</a>) resulting in programs being unexpectedly
rejected has been fixed.</p></li>
<li><p>A bug in the implementation of compact normal forms resulting in
segmentation faults in some uses (<a href="https://gitlab.haskell.org/ghc/ghc/issues/17044">#17044</a>) has been fixed.</p></li>
<li><p>A bug causing GHC to incorrectly complain about incompatible LLVM
versions when using LLVM 7.0.1 has been fixed (<a href="https://gitlab.haskell.org/ghc/ghc/issues/16990">#16990</a>).</p></li>
</ul>
<p>As always, if anything looks amiss do let us know.</p>
<p>Happy compiling!</p>
]]></description>
    <pubDate>Thu, 16 Jan 2020 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20200116-ghc-8.8.2-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>Eventful GHC</title>
    <link>http://haskell.org/ghc/blog/20190924-eventful-ghc.html</link>
    <description><![CDATA[<h1>Eventful GHC</h1>
<h4 class="text-muted">Alp Mestanogullari - 2019-09-24</h4>

<p>What can we do when it takes GHC a lot of time to compile a given module?
Where is it spending its time? Where can we start to get a 10,000 feet view of
what GHC is doing? This blog post covers one possible answer, using the
<a href="https://downloads.haskell.org/~ghc/8.6.5/docs/html/users_guide/runtime_control.html#rts-eventlog">eventlog</a>
mechanism.</p>
<p>(This post has also been published on the
<a href="https://well-typed.com/blog/2019/09/eventful-ghc/">Well-Typed blog</a>.)</p>
<h2 id="eventlog">Eventlog ?</h2>
<p>GHC has a mechanism that allows us to record all sorts of “events” to an
eventlog (a simple binary file), during a program’s execution, attaching a
timestamp to it to later allow tools to reconstruct as much of a program’s
execution as the events allow. This includes RTS events (garbage collection,
HEC/thread activity) but also user defined events, where “user” designates the
author of a Haskell library or program;
<a href="https://hackage.haskell.org/package/base-4.12.0.0/docs/Debug-Trace.html"><code>Debug.Trace</code></a>
in <code>base</code> provides functions that anyone can use to emit events, in addition to
the ones that the RTS itself will emit.</p>
<p>Those functions are implemented in terms of primitive operations that are
backed by GHC’s runtime system. Its design and implementation is
discussed, along with other topics, in
<a href="https://www.microsoft.com/en-us/research/publication/parallel-performance-tuning-for-haskell/">Parallel Performance Tuning for Haskell</a>
by Don Jones Jr., Simon Marlow and Satnam Singh.</p>
<p>After the program’s execution, one can then use libraries like
<a href="http://hackage.haskell.org/package/ghc-events">ghc-events</a> or
tools like <a href="http://hackage.haskell.org/package/ghc-events-analyze">ghc-events-analyze</a>,
or <a href="http://hackage.haskell.org/package/threadscope">threadscope</a> to consume the
eventlog in order to gain some insights into where time was spent.</p>
<p>While profiling lets us gather more detailed information about where time is
spent and where allocations are made, it requires rebuilding our program’s code
<em>and</em> using a dedicated RTS flavour. The code generated by GHC for a profiled
program is quite different, adding lots of instrumentation to support profiling
the execution of Haskell code. The extra code generated to support profiling
can get in the way of some optimisations and can therefore drastically affect
the performance of a program. On the other hand, generating the eventlog for a
program only requires re-linking it (against a flavour of the RTS that supports
tracing) with <code>-eventlog</code> and running it with <code>+RTS -l</code>. The eventlog mechanism
also has much lower impact on runtime performance, since emitting events is
merely about putting a few values in a buffer, that the RTS will then regularly
flush to the eventlog file or whatever the destination is. The aforementionned
paper has some precise numbers on the overhead of the eventlog mechanism, but
it’s of course quite low.</p>
<p>This can therefore be an interesting solution when you want to get a big picture
without having to rebuild your whole program and some of its dependencies. All
you have to do is set up some events that cover the fragments of the program’s
execution that you’re particularly interested in.</p>
<p>Events are in general emitted using one of the following 4 functions from
<code>Debug.Trace</code>:
- <code>traceEvent :: String -&gt; a -&gt; a</code>
- <code>traceEventIO :: String -&gt; IO ()</code>
- <code>traceMarker :: String -&gt; a -&gt; a</code>
- <code>traceMarkerIO :: String -&gt; IO ()</code></p>
<p>The <code>traceEvent[IO]</code> functions should be used for all sorts of events,
particularly the ones that are likely to happen a lot during the execution of
your program, while <code>traceMarker[IO]</code> are generally used to mark certain points
or phases in the execution and see that visually in the profile. This is
particularly helpful with tools like <em>eventlog2html</em> (see the last section of
this post) that allow you to visualize heap profiles, drawing those
“marker events” on top so that users can get a sense of when some
particularly allocations or deallocations take place, with user-supplied labels
instead of trying to guess from timestamps.</p>
<p>For more about eventlogs in general, see
<a href="http://downloads.haskell.org/~ghc/8.6.5/docs/html/users_guide/runtime_control.html#tracing">GHC’s users guide</a>
or <a href="https://gitlab.haskell.org/ghc/ghc/wikis/event-log">the event-log page</a> on the GHC
wiki.</p>
<h2 id="ghc-events">GHC events</h2>
<p>Starting with <a href="https://gitlab.haskell.org/ghc/ghc/commit/ebfa35284741fca47719f531f0996261441f75b0">this commit</a>,
by Ben Gamari about 3 months ago, GHC started emitting eventlog entries for all
calls to <code>withTiming</code>, which is a function we use to measure how long various
parts of GHC take. We then started adding a few more <code>withTiming</code> calls:</p>
<ul>
<li><a href="https://gitlab.haskell.org/ghc/ghc/commit/688a1b89584327d6ba0d3ec9558a3cd8a111c655">688a1b89</a>
added tracing around calls to various external tools (C compiler, linker,
assembler, etc);</li>
<li><a href="https://gitlab.haskell.org/ghc/ghc/commit/0c5cd771a8792ca4a4a553d3d4636e32191ef936">0c5cd771</a>
added tracing around all the individual passes that make up the codegen
pipeline (we previously only tracked codegen as a whole, single event);</li>
<li><a href="https://gitlab.haskell.org/ghc/ghc/commit/e3cbe319dbe2f6a64ea3108dcd8d42e7876e5b34">e3cbe319</a>
added tracing around the package database initialization.</li>
</ul>
<p>And other similar patches later on. As a result, we can trace most of the
execution of GHC when compiling a trivial hello world module:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="co">-- hello.hs</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="ot">main ::</span> <span class="dt">IO</span> ()</span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a>main <span class="ot">=</span> <span class="fu">putStrLn</span> <span class="st">&quot;hello, world!&quot;</span></span></code></pre></div>
<p>First, you need to get a somewhat recent checkout of GHC’s <code>master</code> branch -
<a href="https://gitlab.haskell.org/ghc/ghc/commit/e3cbe319dbe2f6a64ea3108dcd8d42e7876e5b34">e3cbe319</a>
or newer. Then you need to build that source tree and make sure that the stage 2
GHC is linked with <code>-eventlog</code>:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./boot <span class="kw">&amp;&amp;</span> <span class="ex">./configure</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="co"># Build with Hadrian:</span></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> hadrian/build.sh <span class="at">-j</span> <span class="st">&quot;stage1.ghc-bin.ghc.link.opts += -eventlog&quot;</span></span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a><span class="co"># stage 2 ghc at: _build/stage1/bin/ghc</span></span>
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a><span class="co"># Build with Make:</span></span>
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> make <span class="at">-j</span> GhcStage2HcOpts+=-eventlog</span>
<span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a><span class="co"># stage 2 ghc at: inplace/bin/ghc-stage2</span></span>
<span id="cb2-10"><a href="#cb2-10" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-11"><a href="#cb2-11" aria-hidden="true" tabindex="-1"></a><span class="co"># If you have a GHC build around already, both of those commands should not</span></span>
<span id="cb2-12"><a href="#cb2-12" aria-hidden="true" tabindex="-1"></a><span class="co"># cause a lot of work to be done: just linking the GHC executable against a</span></span>
<span id="cb2-13"><a href="#cb2-13" aria-hidden="true" tabindex="-1"></a><span class="co"># slightly different RTS flavour! No recompilation needed.</span></span></code></pre></div>
<p>You can then build any module, library or program with the resulting stage 2
executable as you would normally do. Except that if you pass <code>+RTS -l</code> with one
of <code>-v2</code> or <code>-ddump-timings</code>, GHC will produce an eventlog at <code>ghc.eventlog</code>
with all the standard RTS events, but also events for each pass in GHC’s
pipeline. Let’s see this in action by compiling `hello.hs’ from earlier.</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="co"># use inplace/bin/ghc-stage2 if you built GHC with Make</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> _build/stage1/bin/ghc <span class="at">-ddump-timings</span> hello.hs <span class="at">-o</span> hello +RTS <span class="at">-l</span></span></code></pre></div>
<p>We now have an eventlog. But what can we do with it? You’ve got several options:</p>
<ul>
<li>The <a href="http://hackage.haskell.org/package/ghc-events">ghc-events</a> library and
program, used by all the other options, provide primitives for decoding the
eventlog and extracting data from it. The accompanying program provides
various commands for querying eventlog files.</li>
<li>The <a href="http://hackage.haskell.org/package/threadscope">threadscope</a> program lets
you visualize eventlogs with a GTK+ frontend.</li>
<li><a href="http://hackage.haskell.org/package/ghc-events-analyze">ghc-events-analyze</a>
produces per-label totals, SVG visualizations and per-label timing data given
an eventlog file as input.</li>
<li>… and maybe other options that I’m not remembering or aware of at all.</li>
</ul>
<p>I personally use <code>ghc-events-analyze</code> a lot, since it can produce pretty SVG
pictures that I can then embed in GitLab comments or… blog posts. :-)</p>
<p>To get the timings and SVG picture, you need to install <code>ghc-events-analyze</code>,
and then ask it to process <code>ghc.eventlog</code> with the right “markers”:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ghc-events-analyze <span class="at">--timed</span> <span class="at">--timed-txt</span> <span class="at">--totals</span> <span class="dt">\</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a>                     <span class="at">--start</span> <span class="st">&quot;GHC:started:&quot;</span> <span class="at">--stop</span> <span class="st">&quot;GHC:finished:&quot;</span> <span class="dt">\</span></span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a>		     ghc.eventlog</span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a><span class="co"># --timed:     produce SVG visualization of the eventlog, in ghc.timed.svg</span></span>
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a><span class="co"># --timed-txt: produce per-label groupings of timings that report when the events</span></span>
<span id="cb4-7"><a href="#cb4-7" aria-hidden="true" tabindex="-1"></a>               <span class="ex">were</span> emitted, in ghc.timed.txt</span>
<span id="cb4-8"><a href="#cb4-8" aria-hidden="true" tabindex="-1"></a><span class="co"># --totals:    produce per-label totals, reporting how much time was spent in</span></span>
<span id="cb4-9"><a href="#cb4-9" aria-hidden="true" tabindex="-1"></a>               <span class="ex">a</span> given label, in total</span>
<span id="cb4-10"><a href="#cb4-10" aria-hidden="true" tabindex="-1"></a><span class="co"># --start:     all events that we&#39;re interested in are wrapped in</span></span>
<span id="cb4-11"><a href="#cb4-11" aria-hidden="true" tabindex="-1"></a><span class="co"># --stop       GHC:started:... / GHC:finished:... events, so we just tell</span></span>
<span id="cb4-12"><a href="#cb4-12" aria-hidden="true" tabindex="-1"></a>               <span class="ex">ghc-events-analyze</span> that it should be looking for those markers</span>
<span id="cb4-13"><a href="#cb4-13" aria-hidden="true" tabindex="-1"></a>	       <span class="ex">and</span> report about those events.</span></code></pre></div>
<p>Here are the totals that I get for our hello world program compilation.</p>
<pre><code>GC                                389461503ns   0.389s

USER EVENTS (user events are corrected for GC)
 systool:linker                  2386891920ns   2.387s
 systool:cc                       801347228ns   0.801s
 systool:as                       145128851ns   0.145s
 Renamer/typechecker [Main]        45709853ns   0.046s
 initializing package database     20877412ns   0.021s
 CodeGen [Main]                    20754058ns   0.021s
 CoreTidy [Main]                    8262122ns   0.008s
 NCG                                7566252ns   0.008s
 Chasing dependencies               2441212ns   0.002s
 Cmm pipeline                       2040174ns   0.002s
 Desugar [Main]                     1657607ns   0.002s
 STG -&gt; Cmm                         1103737ns   0.001s
 Simplifier [Main]                  1045768ns   0.001s
 Cmm -&gt; Raw Cmm                      319442ns   0.000s
 Parser [Main]                       286350ns   0.000s
 CorePrep [Main]                      88795ns   0.000s
TOTAL                            3445520781ns   3.446s

THREAD EVENTS
1                                    460138ns   0.000s
IOManager on cap 0:2                 670044ns   0.001s
TimerManager:3                       143699ns   0.000s
4                                 153050783ns   0.153s
weak finalizer thread:5               43518ns   0.000s
weak finalizer thread:6               10677ns   0.000s
weak finalizer thread:7               33126ns   0.000s
weak finalizer thread:8               23787ns   0.000s
weak finalizer thread:9                1534ns   0.000s
weak finalizer thread:10               8142ns   0.000s
weak finalizer thread:11               1352ns   0.000s
weak finalizer thread:12              10080ns   0.000s
weak finalizer thread:13              10603ns   0.000s
weak finalizer thread:14               8767ns   0.000s
weak finalizer thread:15              10849ns   0.000s
16                                    69745ns   0.000s
17                                   307420ns   0.000s
18                                    83017ns   0.000s
19                                    76866ns   0.000s
weak finalizer thread:20              10083ns   0.000s
21                                    96582ns   0.000s
22                                   103373ns   0.000s
23                                    62562ns   0.000s
24                                    97655ns   0.000s
weak finalizer thread:25              11676ns   0.000s
26                                   238116ns   0.000s
27                                   245821ns   0.000s
weak finalizer thread:28               8268ns   0.000s
29                                    80235ns   0.000s
30                                    86759ns   0.000s
31                                    21571ns   0.000s
weak finalizer thread:32                396ns   0.000s
TOTAL                             156087244ns   0.156s</code></pre>
<p>And the SVG image:</p>
<p><img src="images/eventful-ghc/ghc-events-viz.svg" width="800" /></p>
<p>(<a href="images/eventful-ghc/ghc-events-viz.svg">click here for full size picture</a>)</p>
<p>We can see two time windows where we don’t have an “active” label:</p>
<ul>
<li>towards the beginning, where GHC likely parses settings, sets everything up
and reads the input file;</li>
<li>after code generation and before calling the assembler, where it turns out we
spend most of the time getting some information about the C compiler being
used.</li>
</ul>
<p>We otherwise have a pretty good picture of what GHC is doing the rest of the
time. It might be nice in the future to add a few more events, e.g to track when
we’re running Template Haskell code.</p>
<p>If you want GHC to only emit so-called “user events” (= non-RTS events) to the
eventlog, pass <code>+RTS -l-au</code> instead of <code>+RTS -l</code>. More options can be found
in <a href="https://downloads.haskell.org/~ghc/8.6.5/docs/html/users_guide/runtime_control.html#rts-eventlog">the relevant section of the GHC user manual</a>.</p>
<h2 id="wrapping-up">Wrapping up</h2>
<p>Of course, if you’re looking into a performance problem, once you narrow down
the part of the execution that is taking too long, you will quite likely start
using slightly fancier profiling methods, nothing new there. You can however
emit your own events when working on GHC, so as to collect some simple timing
data about those codepaths that you are working on, without affecting GHC’s
performance much. You simply have to use <code>compiler/main/ErrUtils.hs:withTiming</code>:</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a>withTiming <span class="op">&lt;</span>action to get dynflags<span class="op">&gt;</span> (text <span class="st">&quot;&lt;label&gt;&quot;</span>) <span class="op">&lt;</span>forcing function<span class="op">&gt;</span> <span class="op">$</span></span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a>  <span class="op">&lt;</span>action to time<span class="op">&gt;</span></span></code></pre></div>
<p>where the forcing function is used to force the evaluation of the action’s
result just as much as the user wants; the time it takes to perform this
evaluation is included in the timings reported by <code>withTiming</code>. Your <code>&lt;label&gt;</code>
would then show up in the eventlog reports, if the corresponding code path is
entered. See <a href="https://gitlab.haskell.org/ghc/ghc/blob/68ddb43c44065d0d3a8a6893f7f8e87f15ee9c1e/compiler/main/ErrUtils.hs#L802">Note [withTiming]</a>
for more explanations about the <code>withTiming</code> function and how to use it.</p>
<p>All the eventlog markers that <code>withTiming</code> emits can then be integrated in heap
profiles using <a href="https://mpickering.github.io/eventlog2html/">eventlog2html</a>,
written by Matthew Pickering; see
<a href="https://mpickering.github.io/eventlog2html/examples/ghc.eventlog.html">here</a>
for an example. If you put your mouse on one of the vertical lines, you will see
the label of the phase that begins or ends at that moment.</p>
<p>Before ending this post, I would like to mention that we have some
infrastructure to collect timings and allocations for various compilation
phases in GHC, over the
<a href="https://gitlab.haskell.org/ghc/head.hackage">head.hackage</a> package set.
This can be used locally or triggered manually from the CI interface of
the GHC repository, and is set up to run nightly against GHC’s <code>master</code>
branch. The resulting data can be loaded in PostgreSQL and queried at will.
We plan on collecting more data about GHC’s behaviour when compiling all
those packages and on relying more on the eventlog than GHC output parsing to do
so, with two major goals in mind:</p>
<ul>
<li>have an easy way to track GHC’s performance over time and in particular
provide some initial data about where a performance regression might be
coming from;</li>
<li>expose enough data to be able to identify “real world modules” where GHC
doesn’t perform as well as we would like it to, which could in turn lead to
an investigation and possibly a patch that improves GHC’s performance on the
said module.</li>
</ul>
<p>Happy profiling!</p>
]]></description>
    <pubDate>Tue, 24 Sep 2019 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20190924-eventful-ghc.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 8.8.1 released</title>
    <link>http://haskell.org/ghc/blog/20190825-ghc-8.8.1-released.html</link>
    <description><![CDATA[<h1>GHC 8.8.1 released</h1>
<h4 class="text-muted">bgamari - 2019-08-26</h4>

<p>The GHC team is very pleased to announce the reelease of GHC 8.8.1.
The source distribution, binary distributions, and documentation are available
at <a href="https://downloads.haskell.org/ghc/8.8.1">downloads.haskell.org</a>.</p>
<p>This release is the culmination of over 3000 commits by over one hundred
contributors and has several new features and numerous bug fixes
relative to GHC 8.6:</p>
<ul>
<li><p>Visible kind applications are now supported
(<a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0015-https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0080-type-level-type-applications.rst">GHC Proposal <a href="https://gitlab.haskell.org/ghc/ghc/issues/15">#15</a></a>)</p></li>
<li><p>Profiling now works correctly on 64-bit Windows (although still may
be problematic on 32-bit Windows due to platform limitations; see
<a href="https://gitlab.haskell.org/ghc/ghc/issues/15934">#15934</a>)</p></li>
<li><p>A new code layout algorithm for amd64’s native code generator
significantly improving the runtime performance of some kernels</p></li>
<li><p>The introduction of a late lambda-lifting pass which may reduce
allocations significantly for some programs.</p></li>
<li><p>Further work on Trees That Grow, enabling improved code re-use of the
Haskell AST in tooling</p></li>
<li><p>More locations where users can write <code>forall</code> (<a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0007-instance-foralls.rst">GHC Proposal <a href="https://gitlab.haskell.org/ghc/ghc/issues/7">#7</a></a>)</p></li>
<li><p>The pattern-match checker is now more precise in the presence of
strict fields with uninhabited types.</p></li>
<li><p>A comprehensive audit of GHC’s memory ordering barriers has been
performed, resulting in a number of fixes that should significantly
improve the reliability of programs on architectures with
weakly-ordered memory models (e.g. PowerPC, many ARM and AArch64
implementations).</p></li>
<li><p>A long-standing linker limitation rendering GHCi unusable with
projects with cyclic symbol dependencies has been fixed (<a href="https://gitlab.haskell.org/ghc/ghc/issues/13786">#13786</a>)</p></li>
<li><p>Further work on the Hadrian build system</p></li>
<li><p>Countless miscellaneous bug-fixes</p></li>
</ul>
<p>Unfortunately, due to a build issue (<a href="https://gitlab.haskell.org/ghc/ghc/issues/17108">#17108</a>) found late in the release process
i386 Windows builds are currently unavailable. These will be provided in
the coming weeks.</p>
<p><code>cabal-install</code> users should note that <code>cabal-install-3.0</code> or later is required
for use with GHC 8.8.</p>
<p>As always, if anything looks amiss do let us know.</p>
<p>Happy compiling!</p>
]]></description>
    <pubDate>Mon, 26 Aug 2019 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20190825-ghc-8.8.1-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>Exploring Cloud Builds in Hadrian</title>
    <link>http://haskell.org/ghc/blog/20190731-hadrian-cloud-builds.html</link>
    <description><![CDATA[<h1>Exploring Cloud Builds in Hadrian</h1>
<h4 class="text-muted">David Eichmann - 2019-07-31</h4>

<p>GHC’s new build system, Hadrian, now supports a cloud build option: <code>--share</code>.
With that enabled, build artifacts will be cached and shared between builds.
This can improve build times, but getting this feature to function correctly is
still a work in progress. This blog post explores the requirements for
correctness, some examples in Hadrian, the current state of the project, and how
developers can use cloud builds to improve iteration time.</p>
<h2 id="background">Background</h2>
<p>For much of its life GHC has had a build system based around Gnu Make. Though it
has served its purpose well, the <code>make</code> based build system is being replaced by
a new and improved project called Hadrian. Hadrian is a build system written in
Haskell and based on the <a href="https://shakebuild.com/">Shake</a> library. With Hadrian
comes cleaner code and better maintainability, but also some interesting
features of Shake such as cloud builds. Cloud builds are enabled with the
<code>--share</code> option. A cloud build keeps a cache of build
artifacts that can be shared between builds eliminating a lot of duplicate work that had
already been done on a previous build. This feature seems particularly useful in
the context of continuous integration (CI). Merge Requests made via
<a href="https://gitlab.haskell.org/">GitLab</a> must all pass a comprehensive set of tests
on the CI server (the CI pipeline). This involves building GHC multiple times
and running the test suite. Due to limited resources, long build times, and the
large number of tested build configurations, the CI pipeline typically takes 6 to
8 hours to complete. Keep in mind that each merge request is typically only
making a small change to the compiler. By utilizing Shake’s cloud build system
to cache build artifacts between CI runs, one would expect a large speedup.</p>
<p>After an <a href="https://gitlab.haskell.org/ghc/ghc/merge_requests/317">initial effort</a>,
Andrey Mokhov achieved a successful cloud build and rebuild of GHC with Hadrian.
After Andrey’s changes were merged I did a cloud build (using the<code>--share</code>
option) of GHC to fill up the cloud build cache, deleted the build directory,
then timed a rebuild. This resulted in a 10x speedup of the rebuild compared
to a clean non-cloud build, a very positive result. On my machine this took a
25 minute build
down to only 2.5 minutes! However, this is an overly optimistic test: no source files
have changed, so we expect full cache utilization. In practice we expect source
files to have changed and so should expect less cache utilization. Regardless,
the prospect of using cloud builds to improve CI times looked very promising.
Unfortunately, the correctness of cloud builds came into question, and the last
thing we want in CI is an incorrect build. We needed a better understanding of
the requirements for correct cloud builds.</p>
<h2 id="build-rules">Build rules</h2>
<p>To understand the problems at hand, one must understand the basics of how a
build system like Hadrian is implemented using Shake. Put simply, you must
create a set of build rules that map file name patterns to <code>Action</code>s that
perform some IO to generate the corresponding file or files i.e. the “targets” of the rule. In particular, <code>Action</code> is a
monad and the <code>need :: [FilePath] -&gt; Action ()</code> function is used to dynamically
specify the rule’s inputs (i.e. dependencies) that must be built before the action
continues. Here is an example of a typical build rule that generates a file with
the extension <code>.output</code>:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="st">&quot;*.output&quot;</span> <span class="op">%&gt;</span> \ outputFileName <span class="ot">-&gt;</span> <span class="kw">do</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a>    <span class="co">-- Input file is just the output file with &quot;.input&quot; as the extension.</span></span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a>    <span class="kw">let</span> inputFileName <span class="ot">=</span> outputFileName <span class="op">-&lt;.&gt;</span> <span class="st">&quot;input&quot;</span></span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a>    <span class="co">-- Here we declare the dependency on the input file. Shake will then</span></span>
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a>    <span class="co">-- ensure it exists and is up to date before this Action continues.</span></span>
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a>    need [inputFileName]</span>
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a>    <span class="co">-- Do some IO to generate the output file from the input file.</span></span>
<span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a>    compile inputFileName outputFileName</span>
<span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-12"><a href="#cb1-12" aria-hidden="true" tabindex="-1"></a>    <span class="co">-- In some cases we generate more files than just the target,</span></span>
<span id="cb1-13"><a href="#cb1-13" aria-hidden="true" tabindex="-1"></a>    <span class="co">-- `outputFileName`, of the rule. We still need those files to be</span></span>
<span id="cb1-14"><a href="#cb1-14" aria-hidden="true" tabindex="-1"></a>    <span class="co">-- cached for cloud builds, so they must be declared here using the</span></span>
<span id="cb1-15"><a href="#cb1-15" aria-hidden="true" tabindex="-1"></a>    <span class="co">-- `produces :: [FileName] -&gt; Action ()` function. In this case</span></span>
<span id="cb1-16"><a href="#cb1-16" aria-hidden="true" tabindex="-1"></a>    <span class="co">-- `compile` generated some other extra file.</span></span>
<span id="cb1-17"><a href="#cb1-17" aria-hidden="true" tabindex="-1"></a>    <span class="kw">let</span> extraFileName <span class="ot">=</span> outputFileName <span class="op">-&lt;.&gt;</span> <span class="st">&quot;extra&quot;</span></span>
<span id="cb1-18"><a href="#cb1-18" aria-hidden="true" tabindex="-1"></a>    produces [extraFileName]</span></code></pre></div>
<h2 id="evaluating-cloud-build-correctness">Evaluating Cloud Build Correctness</h2>
<p>Let’s consider what it means to have a correct build system. A correct build
system is one that always produces a correct set of build artifacts according to
some specification. In the
case of Hadrian, while not formally specified, this would include producing a
functioning <code>ghc</code> binary that reflects the build inputs (e.g. source files and
build flavour). We can break correctness down into three specific definitions:</p>
<ol type="1">
<li>Clean Build Correctness: Start with no existing build artifacts. Running a build
will succeed and produce correct build artifacts.</li>
<li>Incremental Build Correctness: Start with existing build artifacts (e.g. by doing
a full or partial build). Possibly change some build inputs. Running a build
will succeed and produce correct build artifacts.</li>
<li>Cloud Build Correctness: Start with an existing and populated cloud cache and
possibly existing build artifacts (e.g. by doing a cloud build then possibly deleting build
artifacts). Possibly change some build inputs. Running a cloud build will
succeed and produce correct build artifacts.</li>
</ol>
<p>For each definition above, a requirement for correctness is that the build
produces correct build artifacts. Another way of thinking about
this is that correct clean, incremental, and cloud builds should always produce an equal
set of build artifacts given the same build inputs. In practice, “equal”
ignores some insignificant differences due to nondeterminism in GHC and other
build tools.</p>
<p>A main source of incremental and cloud build correctness bugs relates to build
rules declaring an incorrect set of inputs via <code>need</code>. In an incremental build,
the rule inputs indicate when the rule needs to be rerun to produce fresh build
artifacts. If an input is undeclared and that input changes, it could result in
the rule failing to rerun and hence stale build artifacts. In cloud builds, the
rule inputs are used as keys into the cache. If an input is undeclared and that
input changes, it could result in an (incorrect) cache hit and again stale build
artifacts.</p>
<p>In this blog post we only focus on declaring the correct set of inputs. Rules
are assumed to otherwise correctly call <code>produces</code> and generate build artifacts
for that rule. Note, Andrey Mokhov’s
<a href="https://gitlab.haskell.org/ghc/ghc/merge_requests/317">initial effort</a> largely
focused on the use of <code>produces</code>.</p>
<p>Let’s take a closer look at what we mean by “input”. The natural definition of
inputs, which we call “direct inputs”, is the set of all files used (i.e. read)
by the rule. We can also define an “indicating inputs set”. Consider comparing
build artifacts of two clean builds where some build inputs where changed. Here
“changed” means the
files differ between the first and second build. An indicating inputs set for a
rule is a set of files such that:</p>
<blockquote>
<p>a rule’s output may change only if at least one of the rule’s indicating inputs has changed.</p>
</blockquote>
<p>The
direct inputs is always a valid indicating inputs set. There can be other valid
indicating inputs sets that need not be a subset or equal to the direct inputs.
An indicating inputs set may include files outside the set of direct inputs (the
<a href="https://gitlab.haskell.org/ghc/ghc/wikis/Developing-Hadrian#libffi"><code>libffi</code> rules</a> are a
good example). Generally we try to pick a minimal or close to minimal set of
indicating inputs in order to keep the rule implementation simple.</p>
<p>On that note, the invariants to achieve the three levels of correctness defined
above are as follows. Understanding these invariants is fundamental to evaluating
incremental and cloud build correctness.</p>
<ol type="1">
<li>Clean Build: All rules <code>need</code> enough to build all direct inputs (this can
be via direct or transitively triggered rules).</li>
<li>Incremental Build: Clean build invariants + All rules <code>need</code> a valid
indicating inputs set.</li>
<li>Cloud Build: Clean and incremental invariants + All rules <code>produces</code>
all outputs (excluding the rule targets(s)).</li>
</ol>
<h2 id="dependency-lint-errors">Dependency Lint Errors</h2>
<p>Now that we understand the requirements for correctness, how can we find
correctness issues in Hadrian? Shake has a great linting feature (enabled with
<code>--lint-fsatrace</code>) that utilizes the Filesystem Access Tracer tool
(<a href="https://github.com/jacereda/fsatrace">fsatrace</a>) to observe file accesses
within a rule. This feature results in a linting error when any file is read
without first being declared with <code>need</code>. In other words, we get linting errors
when there is an omitted <code>need</code> for a direct input. Zero linting errors would
imply that all direct inputs are <code>need</code>ed and since the direct inputs are a
valid indicating input set, this would imply incremental build correctness.
Great! So how many lint errors do we have? At the start of my endeavor, about
400,000 lint errors! That’s 400,000 files used by various rules that forgot to
<code>need</code> them first.</p>
<p>Are all lint errors indicative of a correctness issue? Not necessarily.
Remember, lint errors identify omitted direct inputs, but we are concerned with
indicating inputs. As such, lint errors must be investigated individually. The
general workflow is:</p>
<ol type="1">
<li>Pick a lint error. The error which contains the rule and the omitted input
file paths.</li>
<li>Choose an indicating input set for the rule.</li>
<li>Ensure all indicating inputs are <code>need</code>ed in that rule.</li>
<li>The rule is now correct, so <code>trackAllow</code> any direct inputs not in the
indicating inputs set (this disables lint errors for those files).</li>
</ol>
<h2 id="challenges">Challenges</h2>
<p>So far there is nothing too daunting about this task. Even the large number of
lint errors is not too bad when you consider that individual fixes can resolve
large numbers of lint errors if the rule is run many times. It sounds like we
have our work cut out for us, but let’s look at two cases that prove tricky to
resolve.</p>
<h3 id="ghc-dependency-generation-and-cpp-inputs">GHC Dependency Generation and CPP Inputs</h3>
<p>Imagine we have a Haskell module that uses CPP:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="co">-- A.hs</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="ot">{-# LANGUAGE CPP #-}</span></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="pp">#include &quot;b.h&quot;</span></span></code></pre></div>
<div class="sourceCode" id="cb3"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="co">-- B.h</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="pp">#include &quot;c.h&quot;</span></span></code></pre></div>
<div class="sourceCode" id="cb4"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="co">-- C.h</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a>main <span class="ot">=</span> <span class="fu">putStrLn</span> <span class="st">&quot;Hello CPP&quot;</span></span></code></pre></div>
<p>Now when we build <code>A.hs</code> we must make sure to <code>need</code> the CPP includes i.e.
the rule for <code>A.hs</code> has direct inputs <code>A.hs</code>, <code>B.h</code>, and <code>C.h</code>. We ideally want to discover
the <code>.h</code> inputs dynamically so that if we, e.g., add new <code>#include</code> directives,
we don’t need to update our build system rules. In Hadrian we do this by generating a
<code>.dependencies</code> file generated using GHC’s dependency generation options
<code>-M -include-cpp-deps</code>. This is done in a
rule for the <code>.dependencies</code> file. Now the rule to build <code>A.hs</code> first <code>need</code>s
the <code>.dependencies</code> file, then dynamically needs the dependencies (i.e. inputs) listed within.
In this case <code>A.hs</code>, <code>B.h</code>, and <code>C.h</code>. The rules look something like this:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="st">&quot;.dependencies&quot;</span> <span class="op">%&gt;</span> _ <span class="ot">-&gt;</span> <span class="kw">do</span></span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a>  need [<span class="st">&quot;A.hs&quot;</span>]</span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a>  ghcBuidDeps <span class="st">&quot;A.hs&quot;</span>    <span class="co">-- Runs `ghc -M -include-cpp-deps A.hs ...`</span></span>
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a>[<span class="st">&quot;A.o&quot;</span>, <span class="st">&quot;A.hi&quot;</span>] <span class="op">&amp;%&gt;</span> _ <span class="ot">-&gt;</span> <span class="kw">do</span></span>
<span id="cb5-6"><a href="#cb5-6" aria-hidden="true" tabindex="-1"></a>  need [<span class="st">&quot;.dependencies&quot;</span>]</span>
<span id="cb5-7"><a href="#cb5-7" aria-hidden="true" tabindex="-1"></a>  inputs <span class="ot">&lt;-</span> getInputsFromFile <span class="st">&quot;A.o&quot;</span> <span class="st">&quot;.dependencies&quot;</span></span>
<span id="cb5-8"><a href="#cb5-8" aria-hidden="true" tabindex="-1"></a>  need inputs</span>
<span id="cb5-9"><a href="#cb5-9" aria-hidden="true" tabindex="-1"></a>  ghcBuild <span class="st">&quot;A.hs&quot;</span></span></code></pre></div>
<p>So what is the problem here? The rule for <code>["A.o", "A.hi"]</code> is fine as it tracks
the correct inputs. What about the <code>".dependencies"</code> rule? Running
<code>ghc -M -include-cpp-deps A.hs ...</code> reads <code>A.hs</code> then traverses all the
<code>#include</code>ed files, hence the direct inputs of <code>.dependencies</code> are <code>A.hs</code>, <code>B.h</code>,
and <code>C.h</code>. This can’t be reduced to a smaller indicating inputs set; any of
those files can change the output of <code>.dependencies</code>. Well, this is awkward! The
inputs of <code>.dependencies</code> are exactly the inputs that we are trying
to discover in the first place. If we now include <code>D.h</code> from <code>C.h</code> and
recompile, <code>A.hs</code> will recompile (it <code>need</code>s <code>C.h</code> which has changed), but
<code>.dependencies</code> will not be recalculated so <code>["A.o", "A.hi"]</code> will <em>not</em> track
the new <code>D.h</code> input. Now change <code>D.h</code> and rebuild. <code>A.hs</code>
will not be rebuilt (i.e. the <code>["A.o", "A.hi"]</code> rulewill not rerun)
even though the <code>D.h</code> input has changed.</p>
<p>A possible solution to this is to use Shake’s <code>needed</code> action in the <code>.dependencies</code> rule to
declare the inputs <em>after</em> running GHC’s dependency generation. This has a
couple of issues:</p>
<ul>
<li>GHC’s dependency generation also outputs the source file and other Haskell interface
files that are imported from this module. Unlike the CPP includes, these are
<em>not</em> indicating inputs of the <code>.dependencies</code> file. The distinction could be
made by observing file extensions, <code>.hi</code>/<code>.hs</code> vs others, though this is not
foolproof as CPP includes have no restriction on file extension.</li>
<li>This works fine if the CPP dependencies are source files in the source tree,
but doesn’t work if one of the dependencies needs to be generated by the build
system: we would need to <code>need</code> them a priori to ensure they exist and so can
be read to discover any further dependencies.</li>
</ul>
<p>Currently this is an unresolved issue in Hadrian. It is hard to say how likely
this issue is to surface as a bug in incremental/cloud builds.</p>
<h3 id="compiling-haskell-modules">Compiling Haskell Modules</h3>
<p>Consider a rule for a file <code>X.o</code> that compiles <code>X.hs</code> with <code>ghc</code>. We use
<code>ghc -M</code> which returns the following Makefile fragment:</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode makefile"><code class="sourceCode makefile"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="dv">X.o :</span><span class="dt"> X.hs X.hi Y.hi</span></span></code></pre></div>
<p>The <code>Y.hi</code> is there because module <code>X</code> imports module <code>Y</code>. We conclude that
<code>direct inputs = indicating inputs = { X.hs, X.hi, Y.hi }</code> So we implement the
rule like this (normally this is done dynamically using <code>.dependencies</code> as
described above, but we will list the dependencies statically here to illustrate
the problem better):</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="st">&quot;X.o&quot;</span> <span class="op">%&gt;</span> \ _ <span class="ot">-&gt;</span> <span class="kw">do</span></span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a>    need [<span class="st">&quot;X.hs&quot;</span>, <span class="st">&quot;X.hi&quot;</span>, <span class="st">&quot;Y.hi&quot;</span>]</span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a>    buildWithGhc <span class="st">&quot;X.o&quot;</span></span></code></pre></div>
<p>This seems correct, but running the rule with <code>--lint-fsatrace</code> complains that
the rule used a file <code>Z.hi</code> without <code>need</code>ing it. Upon further inspection,
module <code>Y</code> imports module <code>Z</code>. It turns out <code>ghc</code> often uses a <em>subset</em> of
transitively imported modules. This means the set of direct inputs is larger
than what we originally though, it contains transitive interface files.
Unfortunately there doesn’t seem to be any feasible way to predict which
transitive interface files <code>ghc</code> will use at compile time. Fortunately we only
need to <code>need</code> indicating inputs, so we can stay optimistic and try to show that
transitive interface files (.hi files) are not indicating inputs. This can be
done by showing that a change in any transitive interface files results in a change in
the non-transitive interface files (this is explained more in more detail on the
<a href="https://gitlab.haskell.org/ghc/ghc/wikis/Developing-Hadrian#reducing-the-indicating-inputs-set">wiki</a>:</p>
<pre><code>  change({transitive interface files})
        → change({indicating inputs} \ {transitive interface files})
= change({ Z.hi })
        → change({ X.hs, X.hi, Y.hi })</code></pre>
<p>Where <code>→</code> means “logically implies”. With some insight from an experienced GHC developer we see that all interface files
contain “a list of the fingerprints of everything it used when it last compiled
the file” (from the <a href="https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/separate_compilation.html?highlight=fingerprint#the-recompilation-checker">user
guide</a>).
Making the practical assumption that the fingerprint’s hashing function is
injective, we know that <code>change({ transitive interface files })</code> which implies
<code>change({ X.hi })</code> and trivially <code>change({ X.hs, X.hi, Y.hi })</code>
and hence it is safe to not <code>need</code> transitive interface files. Hence, we can <code>need</code>
the direct interface files reported by <code>ghc -M</code> and <code>trackAllow</code> all other interface
files.</p>
<p>In this particular case, the lint errors were a non-issue: there were no
omitted indicating inputs. This is good, but establishing correctness required
in-depth knowledge of the contents and invariants of interface files as well as a
solid understanding of how to manipulate the indicating inputs set.</p>
<h2 id="limitations">Limitations</h2>
<h3 id="caching-staged-builds">Caching Staged Builds</h3>
<p>Having seen two examples, we can see that fixing these lint errors isn’t
entirely trivial. So the cost of enabling caching has increased, but the benefits still sound great:
a large reduction in CI build times. Unfortunately this expectation is compromised
by the fact that GHC is usually built in two stages. The majority of the
second stage is built using the GHC binary produced in the first stage. Stage 1
GHC is less featureful than stage 2 and so takes only one-quarter to one-third of the total
build time. The key observation is that stage 1 GHC is a dependency for most of
stage 2. This means that any change to GHC will result in cache misses for the
majority of stage 2, severely degrading cache utilization. This should not be
understated.</p>
<p>A possible solution is to bypass the 2 stage build process with the help of
Hadrian’s <code>--freeze1</code> option. This freezes the stage 1 GHC. By keeping stage 1
frozen across multiple CI runs, stage 2 can now better utilize the cache. While
this sounds like a good idea at first, we strongly want to avoid incorrect
builds on CI. The correctness freezing stage 1 is questionable:</p>
<ul>
<li>Bugs may appear or be hidden by the frozen stage 1 compiler.</li>
<li>Stage 2 GHC is linked against the <code>base</code> package built by stage 1 GHC. This
could cause bugs or build failures if the base package or the interface file format
differs between stage 1 and stage 2 GHC (i.e. when using <code>--freeze1</code>).</li>
</ul>
<p>On a positive note, stage 1 still takes a significant portion of time to build,
and does not suffer from this cache utilization issue. A reduction in stage 1
compile times is already something to be celebrated.</p>
<h3 id="changes-in-hadrian-build-rules">Changes in Hadrian Build Rules</h3>
<p>An important note is that Hadrian is currently seeing regular updates and
changes to its build rules. Hadrian is under version control with the rest of
GHC, so when changing between commits you’re also potentially changing the
version of Hadrian. Cloud/incremental builds may be incorrect or fail when
Hadrian rules change between builds. While there are ways to protect against
this i.e. by making the Hadrian version a dependency of all rules, Hadrian
currently doesn’t do this. As a result it is not safe to run cloud/incremental
builds across changes to Hadrian. As an example, doing a cloud build of commit
<code>A</code> then commit <code>B</code> gives a failed build complaining of a missing
<code>GHC.Version</code> Haskell module. The build rules surrounding that module were
changed between commit <code>A</code> and <code>B</code>. Hence the cache directory
should be cleared when Hadrian has changed compared to previous cloud builds.
Alternatively you can maintain separate cache directories based on the version
of hadrian e.g. the latest commit that changed the hadrian directory:
<code>git rev-list -n1 HEAD -- ./hadrian</code>.</p>
<h3 id="relocatable-build-artifacts">Relocatable Build Artifacts</h3>
<p>We want to take advantage of the cloud cache regardless of the absolute
filesystem path of the build directory and GHC source directory. Unfortunately
some build artifacts depend on these paths. In other words, the build artifacts
are not relocatable. This makes cloud builds impractical when the build and
source paths are not held constant: it would result in poor cache utilization.
Issue <a href="https://gitlab.haskell.org/ghc/ghc/issues/16956"><a href="https://gitlab.haskell.org/ghc/ghc/issues/16956">#16956</a></a> documents this
problem further.</p>
<h2 id="what-this-means-for-ghc-developers">What This Means for GHC Developers</h2>
<p>Compared with the make build system, potential issues are much more visible due
to the fsatrace linting feature. Considering Hadrian is a port of the make
system, now with may lint errors fixed, it’s reasonable to expect similar if not
more confidence in Hadrian’s incremental builds as with make’s incremental
builds. More confidence in incremental builds is a welcome improvement and the
most impactful benefit of this work.</p>
<p>We can expect a similar level of confidence in cloud builds assuming that
hadrian rules are unchanged between builds. If you’re planning on running the
same builds multiple times then using the cloud build feature can benefit you.
Simply use the <code>--share</code> command line option when running Hadrian (or
<code>--share=DIR</code> to specify a cache location). Consider the use case of swapping
between build flavours. A simple solution would be to maintain separate build
directories per flavour, but you may not want to manage these directories
manually or perhaps you expect the flavours to share a significant amount of
build artifacts from the cloud build cache. Here I’ve run through all steps in
order with cloud build enabled then all steps again with cloud build disabled
(i.e. just as incremental builds). Before step 1, I always start with a clean
build and cache directory. You can see that cloud builds are much faster on the
second build:</p>
<div class="table">
<table>
<thead>
<tr class="header">
<th></th>
<th>Action (flavour)</th>
<th style="text-align: right;">Cloud Build Time</th>
<th style="text-align: right;">Non-Cloud Build Time</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>1</td>
<td>build a39a3cd663 (default)</td>
<td style="text-align: right;">24m37.775s</td>
<td style="text-align: right;">23m49.780s</td>
</tr>
<tr class="even">
<td>2</td>
<td>build a39a3cd663 (quick)</td>
<td style="text-align: right;">11m55.601s</td>
<td style="text-align: right;">11m16.476s</td>
</tr>
<tr class="odd">
<td>3</td>
<td>build a39a3cd663 (default)</td>
<td style="text-align: right;">1m23.450s</td>
<td style="text-align: right;">18m58.530s</td>
</tr>
<tr class="even">
<td>4</td>
<td>build a39a3cd663 (quick)</td>
<td style="text-align: right;">1m 2.805s</td>
<td style="text-align: right;">11m23.408s</td>
</tr>
</tbody>
</table>
</div>
<h2 id="conclusion">Conclusion</h2>
<p>The project of supporting correct cloud builds resulted in numerous
accomplishments. The number of fsatrace lint error has been reduced from 400,000
to 90,000 thanks numerous bug fixes in Hadrian. We now have
greater confidence in incremental and cloud builds. GHC developers can benefit from
cloud builds locally in some narrow use cases, and they frequently benefit from
improved incremental builds. We’ve developed a clear vocabulary for reasoning
about the degrees of build system correctness and what these require. Use of the
fsatrace linting feature will be invaluable to understanding and fixing newly
surfaced Hadrian bugs in the future. GHC’s <code>-include-cpp-deps</code> option was
implemented as part of this project, enabling more precise dependency tracking
in Hadrian and users’ build systems. This project also had a part to play in
recent ideas to simplify Haskell interface files (see issue
<a href="https://gitlab.haskell.org/ghc/ghc/issues/16885"><a href="https://gitlab.haskell.org/ghc/ghc/issues/16885">#16885</a></a>).</p>
<p>Still, there is plenty of room to further improve incremental and cloud builds. This
blog post is in part a call for help from the community. The remaining work is
challenging and interesting, requires little compiler expertise, and yet can have a
significant impact on GHC developers.
<a href="https://gitlab.haskell.org/ghc/ghc/issues/16926"><a href="https://gitlab.haskell.org/ghc/ghc/issues/16926">#16926</a></a> is a top level
“getting started” issue for continuing this project. Most of the remaining work
is focused on resolving fsatrace lint errors summarized in issue
<a href="https://gitlab.haskell.org/ghc/ghc/issues/16400"><a href="https://gitlab.haskell.org/ghc/ghc/issues/16400">#16400</a></a>. That issue also
explains how to get started using fsatrace linting. Specific issues of interest
include:</p>
<ul>
<li><a href="https://gitlab.haskell.org/ghc/ghc/issues/16868"><a href="https://gitlab.haskell.org/ghc/ghc/issues/16868">#16868</a></a> Unexpected CPP
dependencies in later (non CPP) build stages of GHC.</li>
<li><a href="https://gitlab.haskell.org/ghc/ghc/issues/16815"><a href="https://gitlab.haskell.org/ghc/ghc/issues/16815">#16815</a></a> Undeclared <code>hs-boot</code>
inputs when generating <code>.dependencies</code> files.</li>
<li><a href="https://gitlab.haskell.org/ghc/ghc/issues/16983"><a href="https://gitlab.haskell.org/ghc/ghc/issues/16983">#16983</a></a> Undeclared inputs
for <code>_build/generated/platformConstants/platformConstants</code>.</li>
<li><a href="https://gitlab.haskell.org/ghc/ghc/issues/16956"><a href="https://gitlab.haskell.org/ghc/ghc/issues/16956">#16956</a></a> Some build artifacts
are are sensitive to build directory location. This destroys cloud build cache
utilization when using multiple build directories.</li>
</ul>
<p>It’s highly recommended that you read through and contribute to the
<a href="https://gitlab.haskell.org/ghc/ghc/wikis/Developing-Hadrian">Developing Hadrian</a>
wiki page which goes into more detail about incremental and cloud build
correctness.</p>
]]></description>
    <pubDate>Wed, 31 Jul 2019 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20190731-hadrian-cloud-builds.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>Writing efficient free variable traversals</title>
    <link>http://haskell.org/ghc/blog/20190728-free-variable-traversals.html</link>
    <description><![CDATA[<h1>Writing efficient free variable traversals</h1>
<h4 class="text-muted">bgamari - 2019-07-28</h4>

<p>Imagine that I show you a fragment of a Haskell program:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="kw">let</span> x <span class="ot">=</span> y <span class="op">+</span> <span class="dv">1</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="kw">in</span> x</span></code></pre></div>
<p>and pose the question: “what are the variables in this program?” You would
likely respond <code>x</code> and <code>y</code>. Now I ask you: what is the difference between those
two variables?</p>
<p>One answer is that <code>x</code> is <em>bound</em> by the fragment whereas <code>y</code> comes from the
fragment’s surrounding context. Variables like <code>y</code> are known as <em>free
variables</em>.</p>
<p>When compiling a language like Haskell you often find yourself needing to
enumerate the free variables of types and expressions. Consequently, GHC’s
free variable traversals are some of the most heavily used pieces of code in
the compiler and we try hard to ensure that they are efficient.</p>
<p>How does one write an efficient free variable traversal? This is a question we
will try to answer in this post.</p>
<h2 id="a-naïve-solution">A naïve solution</h2>
<p>For the sake of concreteness, let’s consider a toy expression language:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="kw">data</span> <span class="dt">Var</span> <span class="ot">=</span> <span class="dt">Var</span> <span class="dt">Int</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="kw">data</span> <span class="dt">Expr</span> <span class="ot">=</span> <span class="dt">EVar</span> <span class="dt">Var</span>        <span class="co">-- a variable expression</span></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a>          <span class="op">|</span> <span class="dt">ELam</span> <span class="dt">Var</span> <span class="dt">Expr</span>   <span class="co">-- lambda abstraction</span></span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a>          <span class="op">|</span> <span class="dt">EApp</span> <span class="dt">Expr</span> <span class="dt">Expr</span>  <span class="co">-- function application</span></span>
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a>          <span class="op">|</span> <span class="dt">ELit</span> <span class="dt">Integer</span>    <span class="co">-- an integer literal</span></span></code></pre></div>
<p>Since we are talking about <em>sets</em> of variables, we need a way to represent such
things (in GHC this is implemented using <code>containers</code>’ <code>IntMap</code>, but anything
with this interface will do):</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="kw">data</span> <span class="dt">VarSet</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="kw">instance</span> <span class="dt">Monoid</span> <span class="dt">VarSet</span></span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a><span class="kw">instance</span> <span class="dt">Semigroup</span> <span class="dt">VarSet</span></span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a><span class="ot">insertVarSet ::</span> <span class="dt">Var</span> <span class="ot">-&gt;</span> <span class="dt">VarSet</span> <span class="ot">-&gt;</span> <span class="dt">VarSet</span></span>
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a><span class="ot">delVarSet    ::</span> <span class="dt">Var</span> <span class="ot">-&gt;</span> <span class="dt">VarSet</span> <span class="ot">-&gt;</span> <span class="dt">VarSet</span></span>
<span id="cb3-8"><a href="#cb3-8" aria-hidden="true" tabindex="-1"></a><span class="ot">unitVarSet   ::</span> <span class="dt">Var</span> <span class="ot">-&gt;</span> <span class="dt">VarSet</span></span></code></pre></div>
<p>With this groundwork in place, our first attempt at writing a free variable
traversal for such a language might look like this:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="co">-- A naïve free variable traversal.</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="ot">freeVars ::</span> <span class="dt">Expr</span> <span class="ot">-&gt;</span> <span class="dt">VarSet</span></span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a>freeVars (<span class="dt">EVar</span> v)       <span class="ot">=</span> unitVarSet v</span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a>freeVars (<span class="dt">ELam</span> v e)     <span class="ot">=</span> delVarSet (freeVars e)</span>
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a>freeVars (<span class="dt">EApp</span> fun arg) <span class="ot">=</span> freeVars fun <span class="op">&lt;&gt;</span> freeVars arg</span>
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a>freeVars (<span class="dt">ELit</span> _)       <span class="ot">=</span> <span class="fu">mempty</span></span></code></pre></div>
<p>Loading this into GHCi we see that this indeed gives us the right answer for a
simple example program:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="op">&gt;&gt;&gt;</span> f<span class="op">:</span>x<span class="op">:</span>y<span class="op">:</span>z<span class="op">:</span>_ <span class="ot">=</span> <span class="fu">map</span> (<span class="dt">EVar</span> <span class="op">.</span> <span class="dt">Var</span>) [<span class="dv">0</span><span class="op">..</span>]</span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a>    <span class="co">-- \x -&gt; (\y -&gt; f x) (f z)</span></span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a><span class="op">&gt;&gt;&gt;</span> e <span class="ot">=</span> <span class="dt">ELam</span> x ((<span class="dt">ELam</span> y (<span class="dt">EApp</span> f x)) <span class="ot">`EApp`</span> (<span class="dt">EApp</span> f z))</span>
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a><span class="op">&gt;&gt;&gt;</span> freeVars e</span>
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a><span class="dt">VarSet</span> (fromList [<span class="dt">EVar</span> (<span class="dt">Var</span> <span class="dv">0</span>), <span class="dt">EVar</span> (<span class="dt">Var</span> <span class="dv">3</span>)])</span></code></pre></div>
<p>However, this traversal is far from efficient:</p>
<ol type="1">
<li><p>We build <code>VarSet</code>s containing variables for which we have already encountered a
binding site. For instance, when computing <code>freeVars ELam y (EApp x y)</code>
we will build the full free variable set of the subexpression <code>EApp x y</code>,
then perform yet <em>another</em> allocation to remove the variable that we bind
(e.g. <code>y</code>). It would be better to avoid adding <code>y</code> to our result in the
first place.</p></li>
<li><p>the <code>EApp</code> case is not tail recursive, resulting in unnecessary stack and
heap allocation. To see this we look at the (cleaned-up) STG produced
for the RHS of <code>freeVar</code>‘s’ <code>EApp</code> case (compiled with <code>-O0</code>), recalling
that in STG <code>let</code> bindings correspond directly to thunk allocation:</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a>freeVars <span class="ot">=</span> \expr <span class="ot">-&gt;</span></span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a>  <span class="kw">case</span> expr <span class="kw">of</span></span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a>    <span class="dt">EApp</span> fun arg <span class="ot">-&gt;</span> </span>
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a>      <span class="kw">let</span> x <span class="ot">=</span> freeVars fun  <span class="co">-- allocate a thunk for the free vars of fun</span></span>
<span id="cb6-5"><a href="#cb6-5" aria-hidden="true" tabindex="-1"></a>          y <span class="ot">=</span> freeVars arg  <span class="co">-- allocate a thunk for the free vars of arg</span></span>
<span id="cb6-6"><a href="#cb6-6" aria-hidden="true" tabindex="-1"></a>      <span class="kw">in</span> (<span class="op">&lt;&gt;</span>) x y           <span class="co">-- call (&lt;&gt;) with the two thunks</span></span>
<span id="cb6-7"><a href="#cb6-7" aria-hidden="true" tabindex="-1"></a>    <span class="op">...</span></span></code></pre></div>
<p>Note that GHC, when invoked with <code>-O1</code>, will eliminate these thunk
allocations as it
<a href="https://gitlab.haskell.org/ghc/ghc/wikis/commentary/compiler/strictness-analysis">knows</a>
that <code>(&lt;&gt;)</code> is strict in its arguments.
This will produce slight less allocation-heavy STG (noting that <code>case</code> in
STG corresponds to forcing an expression):</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a>freeVars <span class="ot">=</span> \expr <span class="ot">-&gt;</span></span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a>  <span class="kw">case</span> expr <span class="kw">of</span></span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a>    <span class="dt">EApp</span> fun arg <span class="ot">-&gt;</span> </span>
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a>      <span class="kw">case</span> freeVars fun <span class="kw">of</span></span>
<span id="cb7-5"><a href="#cb7-5" aria-hidden="true" tabindex="-1"></a>        fun_fvs <span class="ot">-&gt;</span> </span>
<span id="cb7-6"><a href="#cb7-6" aria-hidden="true" tabindex="-1"></a>          <span class="kw">case</span> freeVars arg <span class="kw">of</span></span>
<span id="cb7-7"><a href="#cb7-7" aria-hidden="true" tabindex="-1"></a>            arg_fvs <span class="ot">-&gt;</span></span>
<span id="cb7-8"><a href="#cb7-8" aria-hidden="true" tabindex="-1"></a>              (<span class="op">&lt;&gt;</span>) fun_fvs arg_fvs</span>
<span id="cb7-9"><a href="#cb7-9" aria-hidden="true" tabindex="-1"></a>    <span class="op">...</span></span></code></pre></div>
<p>Now we have two nested <code>case</code> analyses, each of which will incur a
stack frame push and pop. This cost likely won’t be terrible, but we
can nevertheless do better.</p></li>
</ol>
<h2 id="improving-upon-our-attempt">Improving upon our attempt</h2>
<p>We can address the issues noted above with a two-pronged plan of attack:</p>
<ol type="1">
<li><p>Carry a set of bound variables downward with us as we traverse the
expression tree. Consequently, when we encounter a <code>EVar</code> we can first ask
whether we have seen a binding site for that variable <em>before</em> committing to
allocate a new <code>VarSet</code>.</p></li>
<li><p>Move to an <em>accumulator style</em>, refactoring <code>freeVars</code> to take a
partially-built set of free-variables we have seen thusfar as an argument.
This allows us to define <code>freeVars</code> tail recursively.</p></li>
</ol>
<p>An implementation of these optimizations might look like:</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="ot">freeVars&#39; ::</span> <span class="dt">VarSet</span>    <span class="co">-- ^ bound variable set</span></span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a>          <span class="ot">-&gt;</span> <span class="dt">Expr</span>      <span class="co">-- ^ the expresson we want the free variables of</span></span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a>          <span class="ot">-&gt;</span> <span class="dt">VarSet</span>    <span class="co">-- ^ the accumulator</span></span>
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a>          <span class="ot">-&gt;</span> <span class="dt">VarSet</span>    <span class="co">-- ^ the final free variable set</span></span>
<span id="cb8-5"><a href="#cb8-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb8-6"><a href="#cb8-6" aria-hidden="true" tabindex="-1"></a>freeVars&#39; boundVars (<span class="dt">EVar</span> v) acc</span>
<span id="cb8-7"><a href="#cb8-7" aria-hidden="true" tabindex="-1"></a>  <span class="op">|</span> memberVarSet v boundVars</span>
<span id="cb8-8"><a href="#cb8-8" aria-hidden="true" tabindex="-1"></a>  <span class="ot">=</span> acc  <span class="co">-- we have seen the binding site for the variable, not free</span></span>
<span id="cb8-9"><a href="#cb8-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb8-10"><a href="#cb8-10" aria-hidden="true" tabindex="-1"></a>  <span class="op">|</span> <span class="fu">otherwise</span></span>
<span id="cb8-11"><a href="#cb8-11" aria-hidden="true" tabindex="-1"></a>  <span class="ot">=</span> insertVarSet v acc</span>
<span id="cb8-12"><a href="#cb8-12" aria-hidden="true" tabindex="-1"></a>freeVars&#39; boundVars (<span class="dt">ELam</span> v e) acc</span>
<span id="cb8-13"><a href="#cb8-13" aria-hidden="true" tabindex="-1"></a>  <span class="ot">=</span> <span class="kw">let</span> <span class="co">-- we are binding &#39;v&#39; so add it to our bound variable set</span></span>
<span id="cb8-14"><a href="#cb8-14" aria-hidden="true" tabindex="-1"></a>        boundVars&#39; <span class="ot">=</span> insertVarSet v boundVars</span>
<span id="cb8-15"><a href="#cb8-15" aria-hidden="true" tabindex="-1"></a>    <span class="kw">in</span> freeVars&#39; boundVars&#39; e acc</span>
<span id="cb8-16"><a href="#cb8-16" aria-hidden="true" tabindex="-1"></a>freeVars&#39; boundVars (<span class="dt">EApp</span> fun arg) acc</span>
<span id="cb8-17"><a href="#cb8-17" aria-hidden="true" tabindex="-1"></a>  <span class="ot">=</span> freeVars&#39; boundVars fun <span class="op">$</span> freeVars&#39; boundVars arg acc</span>
<span id="cb8-18"><a href="#cb8-18" aria-hidden="true" tabindex="-1"></a>freeVars&#39; boundVars (<span class="dt">ELit</span> _) acc</span>
<span id="cb8-19"><a href="#cb8-19" aria-hidden="true" tabindex="-1"></a>  <span class="ot">=</span> acc</span>
<span id="cb8-20"><a href="#cb8-20" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb8-21"><a href="#cb8-21" aria-hidden="true" tabindex="-1"></a><span class="ot">freeVars ::</span> <span class="dt">Expr</span> <span class="ot">-&gt;</span> <span class="dt">VarSet</span></span>
<span id="cb8-22"><a href="#cb8-22" aria-hidden="true" tabindex="-1"></a>freeVars e <span class="ot">=</span> freeVars&#39; <span class="fu">mempty</span> e <span class="fu">mempty</span></span></code></pre></div>
<p>While a bit more verbose this gives much nicer performance characteristics:</p>
<ul>
<li><p>we have eliminated the allocation in the common case that we encounter a
variable bound in the fragment we are traversing</p></li>
<li><p>computing the <code>EApp</code> case now allocates only one return frame rather than
two:</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="kw">case</span> freeVars&#39; boundVars arg acc <span class="kw">of</span></span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a>  arg_vars <span class="ot">-&gt;</span></span>
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a>    freeVars&#39; boundVars fun acc</span></code></pre></div></li>
</ul>
<h3 id="aside-avoiding-redundant-inserts">Aside: Avoiding redundant inserts</h3>
<p>An additional optimization that can also be useful is to check whether we have
already added a variable to our accumulator <em>before</em> inserting:</p>
<div class="sourceCode" id="cb10"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a>freeVars&#39; boundVars (<span class="dt">EVar</span> v) acc</span>
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a>  <span class="op">|</span> memberVarSet v boundVars</span>
<span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a>  <span class="ot">=</span> acc  <span class="co">-- we have seen the binding site for the variable, not free</span></span>
<span id="cb10-4"><a href="#cb10-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb10-5"><a href="#cb10-5" aria-hidden="true" tabindex="-1"></a>  <span class="op">|</span> memberVarSet v acc</span>
<span id="cb10-6"><a href="#cb10-6" aria-hidden="true" tabindex="-1"></a>  <span class="ot">=</span> acc  <span class="co">-- the variable is free but has already been added to the accumulator</span></span>
<span id="cb10-7"><a href="#cb10-7" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb10-8"><a href="#cb10-8" aria-hidden="true" tabindex="-1"></a>  <span class="op">|</span> <span class="fu">otherwise</span></span>
<span id="cb10-9"><a href="#cb10-9" aria-hidden="true" tabindex="-1"></a>  <span class="ot">=</span> insertVarSet v acc</span></code></pre></div>
<p>In <code>VarSet</code> representations like the <code>IntMap</code> used by GHC this can alleviate
pressure on the garbage collector. Given that GC time is often considerable
in a heavily-allocating program like GHC this is likely a worthwhile
optimization (although I have not yet measured its effect).</p>
<p>However, as it is not critical to the current discussion, we will ignore it
for the remainder of the post.</p>
<h2 id="cleaning-up-the-implementation">Cleaning up the implementation</h2>
<p>It is nice that this new implementation is fast, but wouldn’t it be great if we
could recover the <em>readability</em> of our naïve approach? To do so we might be
tempted to define a type and some combinators to capture the patterns seen in
<code>freeVars'</code> above:</p>
<div class="sourceCode" id="cb11"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="co">-- | A computation to build a free variable set.</span></span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a><span class="kw">newtype</span> <span class="dt">FV</span> <span class="ot">=</span> <span class="dt">FV</span> {<span class="ot"> runFV ::</span> <span class="dt">VarSet</span>   <span class="co">-- bound variable set</span></span>
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a>                        <span class="ot">-&gt;</span> <span class="dt">VarSet</span>   <span class="co">-- the accumulator</span></span>
<span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a>                        <span class="ot">-&gt;</span> <span class="dt">VarSet</span>   <span class="co">-- the result</span></span>
<span id="cb11-5"><a href="#cb11-5" aria-hidden="true" tabindex="-1"></a>                }</span>
<span id="cb11-6"><a href="#cb11-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-7"><a href="#cb11-7" aria-hidden="true" tabindex="-1"></a><span class="kw">instance</span> <span class="dt">Monoid</span> <span class="dt">FV</span> <span class="kw">where</span></span>
<span id="cb11-8"><a href="#cb11-8" aria-hidden="true" tabindex="-1"></a>  <span class="co">-- The empty FV just passes the accumulator along unperturbed</span></span>
<span id="cb11-9"><a href="#cb11-9" aria-hidden="true" tabindex="-1"></a>  <span class="fu">mempty</span> <span class="ot">=</span> <span class="dt">FV</span> <span class="op">$</span> \_ acc <span class="ot">-&gt;</span> acc</span>
<span id="cb11-10"><a href="#cb11-10" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-11"><a href="#cb11-11" aria-hidden="true" tabindex="-1"></a><span class="kw">instance</span> <span class="dt">Semigroup</span> <span class="dt">FV</span> <span class="kw">where</span></span>
<span id="cb11-12"><a href="#cb11-12" aria-hidden="true" tabindex="-1"></a>  <span class="co">-- Unioning two FVs passes the accumulator produced by one to the other</span></span>
<span id="cb11-13"><a href="#cb11-13" aria-hidden="true" tabindex="-1"></a>  fv1 <span class="op">&lt;&gt;</span> fv2 <span class="ot">=</span> <span class="dt">FV</span> <span class="op">$</span> \boundVars acc <span class="ot">-&gt;</span> </span>
<span id="cb11-14"><a href="#cb11-14" aria-hidden="true" tabindex="-1"></a>    runFV fv1 boundVars (runFV fv2 boundVars acc)</span>
<span id="cb11-15"><a href="#cb11-15" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-16"><a href="#cb11-16" aria-hidden="true" tabindex="-1"></a><span class="co">-- | Consider a variable to be bound in the given &#39;FV&#39; computation.</span></span>
<span id="cb11-17"><a href="#cb11-17" aria-hidden="true" tabindex="-1"></a><span class="ot">bindVar ::</span> <span class="dt">Var</span> <span class="ot">-&gt;</span> <span class="dt">FV</span> <span class="ot">-&gt;</span> <span class="dt">FV</span></span>
<span id="cb11-18"><a href="#cb11-18" aria-hidden="true" tabindex="-1"></a>bindVar v fv <span class="ot">=</span> <span class="dt">FV</span> <span class="op">$</span> \boundVars acc <span class="ot">-&gt;</span></span>
<span id="cb11-19"><a href="#cb11-19" aria-hidden="true" tabindex="-1"></a>  runFV fv (insertVarSet v boundVars) acc</span>
<span id="cb11-20"><a href="#cb11-20" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-21"><a href="#cb11-21" aria-hidden="true" tabindex="-1"></a><span class="co">-- | Take note of a variable reference.</span></span>
<span id="cb11-22"><a href="#cb11-22" aria-hidden="true" tabindex="-1"></a><span class="ot">unitFV ::</span> <span class="dt">Var</span> <span class="ot">-&gt;</span> <span class="dt">FV</span></span>
<span id="cb11-23"><a href="#cb11-23" aria-hidden="true" tabindex="-1"></a>unitFV v <span class="ot">=</span> <span class="dt">FV</span> <span class="op">$</span> \boundVars acc <span class="ot">-&gt;</span></span>
<span id="cb11-24"><a href="#cb11-24" aria-hidden="true" tabindex="-1"></a>  <span class="kw">if</span> memberVarSet v boundVars</span>
<span id="cb11-25"><a href="#cb11-25" aria-hidden="true" tabindex="-1"></a>  <span class="kw">then</span> acc                 <span class="co">-- variable is known to be bound, ignore</span></span>
<span id="cb11-26"><a href="#cb11-26" aria-hidden="true" tabindex="-1"></a>  <span class="kw">else</span> insertVarSet v acc  <span class="co">-- variable is free, insert into accumulator</span></span>
<span id="cb11-27"><a href="#cb11-27" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-28"><a href="#cb11-28" aria-hidden="true" tabindex="-1"></a><span class="ot">fvToVarSet ::</span> <span class="dt">FV</span> <span class="ot">-&gt;</span> <span class="dt">VarSet</span></span>
<span id="cb11-29"><a href="#cb11-29" aria-hidden="true" tabindex="-1"></a>fvToVarSet fv <span class="ot">=</span> runFV fv <span class="fu">mempty</span> <span class="fu">mempty</span></span></code></pre></div>
<p>With this groundwork in place <code>freeVars</code> becomes a simple declarative
description of how to walk the <code>Expr</code> AST:</p>
<div class="sourceCode" id="cb12"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="ot">exprFV ::</span> <span class="dt">Expr</span> <span class="ot">-&gt;</span> <span class="dt">FV</span></span>
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a>exprFV (<span class="dt">EVar</span> v)       <span class="ot">=</span> unitFV v</span>
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a>exprFV (<span class="dt">ELam</span> v e)     <span class="ot">=</span> bindVar v (exprFV e)</span>
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a>exprFV (<span class="dt">EApp</span> fun arg) <span class="ot">=</span> exprFV fun <span class="op">&lt;&gt;</span> exprFV arg</span>
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a>exprFV (<span class="dt">ELit</span> _)       <span class="ot">=</span> <span class="fu">mempty</span></span>
<span id="cb12-6"><a href="#cb12-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-7"><a href="#cb12-7" aria-hidden="true" tabindex="-1"></a>freeVars <span class="ot">=</span> fvToVarSet <span class="op">.</span> exprFV</span></code></pre></div>
<h2 id="improving-code-re-use">Improving code re-use</h2>
<p>GHC has used a close relative of the <code>FV</code> type seen above for its free variable
traversals on its Core ASTs for a few years now. However, over the years the
varying needs of different parts of GHC have caused the codebase to sprout
several additional traverals:</p>
<ul>
<li>free variable collection that doesn’t guarantee determinism across compiler
runs (as GHC uses non-deterministic unique numbers to identify variables)</li>
<li>free variable collection which only returns local variables</li>
<li>free variable collection which only returns coercion variables (a variety of
variable beyond the scope of the present discussion; see the <a href="https://research.microsoft.com/en-us/um/people/simonpj/papers/ext-f/tldi22-sulzmann-with-appendix.pdf">System FC
paper</a>
for details)</li>
<li>traversal that only returns a boolean reflecting whether an expression has
any free variables</li>
</ul>
<p>Moreover, in GHC each of these must be implemented on each of the three ASTs
which comprise Core programs: <code>Expr</code>, <code>Type</code>, and <code>Coercion</code>.</p>
<p>Needless to say, this results in a significant amount of repetition. Is it
possible to abstract over the details of each travesal strategy and share the
bare skeleton of <code>exprFV</code> <em>and</em> get preserve our hard-fought performance
improvements? We would be poor functional programmers if we answered “no”.
Let’s see how.</p>
<h2 id="abstracting-the-traversal-strategy">Abstracting the traversal strategy</h2>
<p>To improve code re-use we want to separate the AST <em>traversal</em> (that is, how we
walk over the various parts of the AST) from what we call the <em>strategy</em> used
to build the free variable set. To guide our abstraction we can start by
looking at the operations used by the <code>exprFV</code> traversal above:</p>
<ul>
<li><code>unitFV</code> was used to declare the occurrence of a variable (free or otherwise)</li>
<li><code>bindVar</code> was used to declare a variable binding site</li>
<li><code>Monoid</code> was used to provide an empty free variable set</li>
<li><code>Semigroup</code> was used to union free variable sets</li>
</ul>
<p>Following a final tagless style, we write down a typeclass capturing all of
these operations (N.B. recall that <code>Semigroup</code> is implied by <code>Monoid</code>):</p>
<div class="sourceCode" id="cb13"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="kw">class</span> <span class="dt">Monoid</span> a <span class="ot">=&gt;</span> <span class="dt">FreeVarStrategy</span> a <span class="kw">where</span></span>
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a><span class="ot">  unitFV ::</span> <span class="dt">Var</span> <span class="ot">-&gt;</span> a</span>
<span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a><span class="ot">  bindVar ::</span> <span class="dt">Var</span> <span class="ot">-&gt;</span> a <span class="ot">-&gt;</span> a</span></code></pre></div>
<p>We can now define our traversals in terms of this class (note that only the
type signature has changed from the <code>exprFV</code> seen above; how nice!):</p>
<div class="sourceCode" id="cb14"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="ot">exprFV ::</span> <span class="dt">FreeVarStrategy</span> a <span class="ot">=&gt;</span> <span class="dt">Expr</span> <span class="ot">-&gt;</span> a</span>
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a>exprFV (<span class="dt">EVar</span> v)       <span class="ot">=</span> unitFV v</span>
<span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a>exprFV (<span class="dt">ELam</span> v e)     <span class="ot">=</span> bindVar v (exprFV e)</span>
<span id="cb14-4"><a href="#cb14-4" aria-hidden="true" tabindex="-1"></a>exprFV (<span class="dt">EApp</span> fun arg) <span class="ot">=</span> exprFV fun <span class="op">&lt;&gt;</span> exprFV arg</span>
<span id="cb14-5"><a href="#cb14-5" aria-hidden="true" tabindex="-1"></a>exprFV (<span class="dt">ELit</span> _)       <span class="ot">=</span> <span class="fu">mempty</span></span></code></pre></div>
<p>Finally we can write some strategies implementing this interface. To start, the
naïve implementation from the beginning of this post can be captured as:</p>
<div class="sourceCode" id="cb15"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="kw">newtype</span> <span class="dt">Naive</span> <span class="ot">=</span> <span class="dt">Naive</span> {<span class="ot"> runNaive ::</span> <span class="dt">VarSet</span> }</span>
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a><span class="kw">instance</span> <span class="dt">Monoid</span> <span class="dt">Naive</span> <span class="kw">where</span></span>
<span id="cb15-4"><a href="#cb15-4" aria-hidden="true" tabindex="-1"></a>  <span class="fu">mempty</span> <span class="ot">=</span> <span class="dt">Naive</span> <span class="fu">mempty</span></span>
<span id="cb15-5"><a href="#cb15-5" aria-hidden="true" tabindex="-1"></a><span class="kw">instance</span> <span class="dt">Semigroup</span> <span class="dt">Naive</span> <span class="kw">where</span></span>
<span id="cb15-6"><a href="#cb15-6" aria-hidden="true" tabindex="-1"></a>  <span class="dt">Naive</span> a <span class="op">&lt;&gt;</span> <span class="dt">Naive</span> b <span class="ot">=</span> <span class="dt">Naive</span> (a <span class="op">&lt;&gt;</span> b)</span>
<span id="cb15-7"><a href="#cb15-7" aria-hidden="true" tabindex="-1"></a><span class="kw">instance</span> <span class="dt">FreeVarStrategy</span> <span class="dt">Naive</span> <span class="kw">where</span></span>
<span id="cb15-8"><a href="#cb15-8" aria-hidden="true" tabindex="-1"></a>  unitFV <span class="ot">=</span> <span class="dt">Naive</span> <span class="op">.</span> unitVarSet</span>
<span id="cb15-9"><a href="#cb15-9" aria-hidden="true" tabindex="-1"></a>  bindVar v (<span class="dt">Naive</span> xs) <span class="ot">=</span> <span class="dt">Naive</span> (delVarSet v xs)</span></code></pre></div>
<p>Our optimized implementation is ported with a bit more work:</p>
<div class="sourceCode" id="cb16"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a><span class="kw">newtype</span> <span class="dt">FV</span> <span class="ot">=</span> <span class="dt">FV</span> {<span class="ot"> runFV ::</span> <span class="dt">VarSet</span>   <span class="co">-- bound variable set</span></span>
<span id="cb16-2"><a href="#cb16-2" aria-hidden="true" tabindex="-1"></a>                        <span class="ot">-&gt;</span> <span class="dt">VarSet</span>   <span class="co">-- the accumulator</span></span>
<span id="cb16-3"><a href="#cb16-3" aria-hidden="true" tabindex="-1"></a>                        <span class="ot">-&gt;</span> <span class="dt">VarSet</span>   <span class="co">-- the result</span></span>
<span id="cb16-4"><a href="#cb16-4" aria-hidden="true" tabindex="-1"></a>                }</span>
<span id="cb16-5"><a href="#cb16-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb16-6"><a href="#cb16-6" aria-hidden="true" tabindex="-1"></a><span class="kw">instance</span> <span class="dt">Monoid</span> <span class="dt">FV</span> <span class="kw">where</span></span>
<span id="cb16-7"><a href="#cb16-7" aria-hidden="true" tabindex="-1"></a>  <span class="fu">mempty</span> <span class="ot">=</span> <span class="dt">FV</span> <span class="op">$</span> \_ acc <span class="ot">-&gt;</span> acc</span>
<span id="cb16-8"><a href="#cb16-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb16-9"><a href="#cb16-9" aria-hidden="true" tabindex="-1"></a><span class="kw">instance</span> <span class="dt">Semigroup</span> <span class="dt">FV</span> <span class="kw">where</span></span>
<span id="cb16-10"><a href="#cb16-10" aria-hidden="true" tabindex="-1"></a>  fv1 <span class="op">&lt;&gt;</span> fv2 <span class="ot">=</span> <span class="dt">FV</span> <span class="op">$</span> \boundVars acc <span class="ot">-&gt;</span> </span>
<span id="cb16-11"><a href="#cb16-11" aria-hidden="true" tabindex="-1"></a>    runFV fv1 boundVars (runFV fv2 boundVars acc)</span>
<span id="cb16-12"><a href="#cb16-12" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb16-13"><a href="#cb16-13" aria-hidden="true" tabindex="-1"></a><span class="kw">instance</span> <span class="dt">FreeVarStrategy</span> <span class="dt">FV</span> <span class="kw">where</span></span>
<span id="cb16-14"><a href="#cb16-14" aria-hidden="true" tabindex="-1"></a>  unitFV v <span class="ot">=</span> <span class="dt">FV</span> <span class="op">$</span> \boundVars acc <span class="ot">-&gt;</span></span>
<span id="cb16-15"><a href="#cb16-15" aria-hidden="true" tabindex="-1"></a>    <span class="kw">if</span> memberVarSet v boundVars</span>
<span id="cb16-16"><a href="#cb16-16" aria-hidden="true" tabindex="-1"></a>    <span class="kw">then</span> acc</span>
<span id="cb16-17"><a href="#cb16-17" aria-hidden="true" tabindex="-1"></a>    <span class="kw">else</span> insertVarSet v acc</span>
<span id="cb16-18"><a href="#cb16-18" aria-hidden="true" tabindex="-1"></a>  bindVar v fv <span class="ot">=</span> <span class="dt">FV</span> <span class="op">$</span> \boundVars acc <span class="ot">-&gt;</span></span>
<span id="cb16-19"><a href="#cb16-19" aria-hidden="true" tabindex="-1"></a>    runFV fv (insertVarSet v boundVars) acc</span>
<span id="cb16-20"><a href="#cb16-20" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb16-21"><a href="#cb16-21" aria-hidden="true" tabindex="-1"></a><span class="ot">fvToVarSet ::</span> <span class="dt">FV</span> <span class="ot">-&gt;</span> <span class="dt">VarSet</span></span>
<span id="cb16-22"><a href="#cb16-22" aria-hidden="true" tabindex="-1"></a>fvToVarSet fv <span class="ot">=</span> runFV fv <span class="fu">mempty</span> <span class="fu">mempty</span></span></code></pre></div>
<p>Further, we can implement a strategy which determines whether an
expression has any free variables without writing any code looking at <code>Expr</code>
(using the same bound-variable set optimized as <code>FV</code>):</p>
<div class="sourceCode" id="cb17"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a><span class="kw">newtype</span> <span class="dt">NoFreeVars</span> <span class="ot">=</span> <span class="dt">NoFreeVars</span> {<span class="ot"> runNoFreeVars ::</span> <span class="dt">VarSet</span>   <span class="co">-- bound variable set</span></span>
<span id="cb17-2"><a href="#cb17-2" aria-hidden="true" tabindex="-1"></a>                                                <span class="ot">-&gt;</span> <span class="dt">Bool</span>     <span class="co">-- True is free variable set is empty</span></span>
<span id="cb17-3"><a href="#cb17-3" aria-hidden="true" tabindex="-1"></a>                                }</span>
<span id="cb17-4"><a href="#cb17-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb17-5"><a href="#cb17-5" aria-hidden="true" tabindex="-1"></a><span class="kw">instance</span> <span class="dt">Monoid</span> <span class="dt">NoFreeVars</span> <span class="kw">where</span></span>
<span id="cb17-6"><a href="#cb17-6" aria-hidden="true" tabindex="-1"></a>  <span class="fu">mempty</span> <span class="ot">=</span> <span class="dt">NoFreeVars</span> <span class="op">$</span> <span class="fu">const</span> <span class="dt">True</span></span>
<span id="cb17-7"><a href="#cb17-7" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb17-8"><a href="#cb17-8" aria-hidden="true" tabindex="-1"></a><span class="kw">instance</span> <span class="dt">Semigroup</span> <span class="dt">NoFreeVars</span> <span class="kw">where</span></span>
<span id="cb17-9"><a href="#cb17-9" aria-hidden="true" tabindex="-1"></a>  <span class="dt">NoFreeVars</span> f <span class="op">&lt;&gt;</span> <span class="dt">NoFreeVars</span> g <span class="ot">=</span> <span class="dt">NoFreeVars</span> <span class="op">$</span> \boundVars <span class="ot">-&gt;</span></span>
<span id="cb17-10"><a href="#cb17-10" aria-hidden="true" tabindex="-1"></a>    f boundVars <span class="op">&amp;&amp;</span> g boundVars</span>
<span id="cb17-11"><a href="#cb17-11" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb17-12"><a href="#cb17-12" aria-hidden="true" tabindex="-1"></a><span class="kw">instance</span> <span class="dt">FreeVarStrategy</span> <span class="dt">NoFreeVars</span> <span class="kw">where</span></span>
<span id="cb17-13"><a href="#cb17-13" aria-hidden="true" tabindex="-1"></a>  unitFV v <span class="ot">=</span> <span class="dt">NoFreeVars</span> <span class="op">$</span> \boundVars <span class="ot">-&gt;</span></span>
<span id="cb17-14"><a href="#cb17-14" aria-hidden="true" tabindex="-1"></a>    memberVarSet v boundVars</span>
<span id="cb17-15"><a href="#cb17-15" aria-hidden="true" tabindex="-1"></a>  bindVar tv (<span class="dt">NoFreeVars</span> f) <span class="ot">=</span> <span class="dt">NoFreeVars</span> <span class="op">$</span> \boundVars <span class="ot">-&gt;</span></span>
<span id="cb17-16"><a href="#cb17-16" aria-hidden="true" tabindex="-1"></a>    f <span class="op">$</span> insertVarSet v boundVars</span>
<span id="cb17-17"><a href="#cb17-17" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb17-18"><a href="#cb17-18" aria-hidden="true" tabindex="-1"></a><span class="ot">noFreeVars ::</span> <span class="dt">NoFreeVars</span> <span class="ot">-&gt;</span> <span class="dt">Bool</span></span>
<span id="cb17-19"><a href="#cb17-19" aria-hidden="true" tabindex="-1"></a>noFreeVars (<span class="dt">NoFreeVars</span> f) <span class="ot">=</span> f <span class="fu">mempty</span></span></code></pre></div>
<p>Finally, to guarantee that this abstration carries no cost, we can explicitly
ask GHC to specialise our <code>exprFV</code> traversal for these strategies:</p>
<div class="sourceCode" id="cb18"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a><span class="ot">{-# SPECIALISE exprFV :: Expr -&gt; Naive #-}</span></span>
<span id="cb18-2"><a href="#cb18-2" aria-hidden="true" tabindex="-1"></a><span class="ot">{-# SPECIALISE exprFV :: Expr -&gt; FV #-}</span></span>
<span id="cb18-3"><a href="#cb18-3" aria-hidden="true" tabindex="-1"></a><span class="ot">{-# SPECIALISE exprFV :: Expr -&gt; NoFreeVars #-}</span></span></code></pre></div>
<p>Looking at <code>-ddump-stg</code> output we can see that GHC has done a wonderful job in
optimising our abstration away.</p>
<h2 id="the-problem-of-mutual-recursion">The problem of mutual recursion</h2>
<p>While this has all worked out swimmingly so far, things can go awry with more
complex ASTs (such as Core). In particular, ASTs where the traversal
is part of a mutually recursive group can break the nice performance
characteristics that we have seen thusfar.</p>
<p>To see how, let’s augment our expression AST with some (admittedly rather
peculiar) dependent type system.</p>
<div class="sourceCode" id="cb19"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a><span class="kw">data</span> <span class="dt">Expr</span> <span class="ot">=</span> <span class="dt">EVar</span> <span class="dt">Var</span> <span class="dt">Type</span>        <span class="co">-- a variable expression and its type</span></span>
<span id="cb19-2"><a href="#cb19-2" aria-hidden="true" tabindex="-1"></a>          <span class="op">|</span> <span class="dt">ELam</span> <span class="dt">Var</span> <span class="dt">Expr</span>        <span class="co">-- lambda abstraction</span></span>
<span id="cb19-3"><a href="#cb19-3" aria-hidden="true" tabindex="-1"></a>          <span class="op">|</span> <span class="dt">EApp</span> <span class="dt">Expr</span> <span class="dt">Expr</span>       <span class="co">-- function application</span></span>
<span id="cb19-4"><a href="#cb19-4" aria-hidden="true" tabindex="-1"></a>          <span class="op">|</span> <span class="dt">ELit</span> <span class="dt">Integer</span>         <span class="co">-- an integer literal</span></span>
<span id="cb19-5"><a href="#cb19-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb19-6"><a href="#cb19-6" aria-hidden="true" tabindex="-1"></a><span class="kw">data</span> <span class="dt">Type</span> <span class="ot">=</span> <span class="op">...</span>                  <span class="co">-- these constructors are irrelevant</span></span>
<span id="cb19-7"><a href="#cb19-7" aria-hidden="true" tabindex="-1"></a>          <span class="op">|</span> <span class="dt">TExpr</span> <span class="dt">Expr</span></span></code></pre></div>
<p>Note here that the point here is not the type system itself but rather the fact
that our traversals now must be mutually recursive functions For instance, in
GHC Core this mutual recursion happens between the <code>Type</code> and <code>Coercion</code> types.</p>
<p>Writing traversals for this AST is straightforward:</p>
<div class="sourceCode" id="cb20"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a><span class="ot">exprFV ::</span> <span class="dt">FreeVarStrategy</span> a <span class="ot">=&gt;</span> <span class="dt">Expr</span> <span class="ot">-&gt;</span> a</span>
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a>exprFV (<span class="dt">EVar</span> v ty)    <span class="ot">=</span> unitFV v <span class="op">&lt;&gt;</span> typeFV ty</span>
<span id="cb20-3"><a href="#cb20-3" aria-hidden="true" tabindex="-1"></a>exprFV (<span class="dt">ELam</span> v e)     <span class="ot">=</span> bindVar v (exprFV e)</span>
<span id="cb20-4"><a href="#cb20-4" aria-hidden="true" tabindex="-1"></a>exprFV (<span class="dt">EApp</span> fun arg) <span class="ot">=</span> exprFV fun <span class="op">&lt;&gt;</span> exprFV arg</span>
<span id="cb20-5"><a href="#cb20-5" aria-hidden="true" tabindex="-1"></a>exprFV (<span class="dt">ELit</span> _)       <span class="ot">=</span> <span class="fu">mempty</span></span>
<span id="cb20-6"><a href="#cb20-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb20-7"><a href="#cb20-7" aria-hidden="true" tabindex="-1"></a><span class="ot">typeFV ::</span> <span class="dt">FreeVarStrategy</span> a <span class="ot">=&gt;</span> <span class="dt">Type</span> <span class="ot">-&gt;</span> a</span>
<span id="cb20-8"><a href="#cb20-8" aria-hidden="true" tabindex="-1"></a>typeFV (<span class="dt">TExpr</span> e)      <span class="ot">=</span> exprFV e</span>
<span id="cb20-9"><a href="#cb20-9" aria-hidden="true" tabindex="-1"></a><span class="co">-- omitted: traverse other constructors of Type</span></span></code></pre></div>
<p>However, if we look at the STG generated for <code>NoFreeVars</code> we see that things
have gone terribly wrong (again recalling that in STG <code>let</code> corresponds to heap
allocation):</p>
<div class="sourceCode" id="cb21"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true" tabindex="-1"></a><span class="ot">exprFV ::</span> <span class="dt">Expr</span> <span class="ot">-&gt;</span> <span class="dt">NoFreeVars</span></span>
<span id="cb21-2"><a href="#cb21-2" aria-hidden="true" tabindex="-1"></a>exprFV <span class="ot">=</span> \expr <span class="ot">-&gt;</span></span>
<span id="cb21-3"><a href="#cb21-3" aria-hidden="true" tabindex="-1"></a>  <span class="kw">case</span> expr <span class="kw">of</span></span>
<span id="cb21-4"><a href="#cb21-4" aria-hidden="true" tabindex="-1"></a>    <span class="dt">EApp</span> fun arg <span class="ot">-&gt;</span> </span>
<span id="cb21-5"><a href="#cb21-5" aria-hidden="true" tabindex="-1"></a>      <span class="kw">let</span><span class="ot"> fun_fvs ::</span> <span class="dt">NoFreeVars</span></span>
<span id="cb21-6"><a href="#cb21-6" aria-hidden="true" tabindex="-1"></a>          fun_fvs <span class="ot">=</span> exprFV fun</span>
<span id="cb21-7"><a href="#cb21-7" aria-hidden="true" tabindex="-1"></a>      <span class="kw">in</span></span>
<span id="cb21-8"><a href="#cb21-8" aria-hidden="true" tabindex="-1"></a>      <span class="kw">let</span><span class="ot"> arg_fvs ::</span> <span class="dt">NoFreeVars</span></span>
<span id="cb21-9"><a href="#cb21-9" aria-hidden="true" tabindex="-1"></a>          arg_fvs <span class="ot">=</span> exprFV arg</span>
<span id="cb21-10"><a href="#cb21-10" aria-hidden="true" tabindex="-1"></a>      <span class="kw">in</span></span>
<span id="cb21-11"><a href="#cb21-11" aria-hidden="true" tabindex="-1"></a>      <span class="kw">let</span><span class="ot"> r ::</span> <span class="dt">NoFreeVars</span></span>
<span id="cb21-12"><a href="#cb21-12" aria-hidden="true" tabindex="-1"></a>          r <span class="ot">=</span> \boundVars <span class="ot">-&gt;</span></span>
<span id="cb21-13"><a href="#cb21-13" aria-hidden="true" tabindex="-1"></a>            <span class="kw">case</span> fun_fvs boundVars <span class="kw">of</span></span>
<span id="cb21-14"><a href="#cb21-14" aria-hidden="true" tabindex="-1"></a>              <span class="dt">False</span> <span class="ot">-&gt;</span> <span class="dt">False</span></span>
<span id="cb21-15"><a href="#cb21-15" aria-hidden="true" tabindex="-1"></a>              <span class="dt">True</span>  <span class="ot">-&gt;</span> arg_fvs boundVars</span>
<span id="cb21-16"><a href="#cb21-16" aria-hidden="true" tabindex="-1"></a>      <span class="kw">in</span> r</span>
<span id="cb21-17"><a href="#cb21-17" aria-hidden="true" tabindex="-1"></a><span class="op">...</span></span></code></pre></div>
<p>Notice that GHC has now allocated a thunk for each application of <code>exprFV</code> (and
<code>typeFV</code>, although this is not seen in the above excerpt). As we will see
below, this is a result of the fact that GHC’s arity analysis does not
attempt to handle mutual recursion (see <code>Note [Arity analysis]</code> in
<code>CoreArity.hs</code>):</p>
<p>In the case of our untyped <code>Expr</code> AST the simplifier was able to see that
<code>exprFV</code> was of arity 2 (as we look through casts) and consequently
eta-expanded its right-hand side to yield the following Core after inlining
(ignoring casts):</p>
<div class="sourceCode" id="cb22"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb22-1"><a href="#cb22-1" aria-hidden="true" tabindex="-1"></a>exprFV <span class="ot">=</span> \expr boundVars <span class="ot">-&gt;</span></span>
<span id="cb22-2"><a href="#cb22-2" aria-hidden="true" tabindex="-1"></a>  <span class="kw">case</span> expr <span class="kw">of</span></span>
<span id="cb22-3"><a href="#cb22-3" aria-hidden="true" tabindex="-1"></a>    <span class="dt">EApp</span> fun arg <span class="ot">-&gt;</span> </span>
<span id="cb22-4"><a href="#cb22-4" aria-hidden="true" tabindex="-1"></a>      <span class="kw">case</span> fun_fvs boundVars <span class="kw">of</span></span>
<span id="cb22-5"><a href="#cb22-5" aria-hidden="true" tabindex="-1"></a>        <span class="dt">False</span> <span class="ot">-&gt;</span> <span class="dt">False</span></span>
<span id="cb22-6"><a href="#cb22-6" aria-hidden="true" tabindex="-1"></a>        <span class="dt">True</span>  <span class="ot">-&gt;</span> arg_fvs boundVars</span></code></pre></div>
<p>By contrast, in the typed AST arity analysis conservatively concludes that
<code>exprFV</code> is arity 1 and consequently this eta expansion does not happen.
Consequently <code>(&lt;&gt;)</code> will be inlined and have its arguments <code>let</code>-bound (which
GHC does to ensure inlining does not compromise sharing).</p>
<p>There are two ways via which this can be remedied:</p>
<ol type="1">
<li><em>Manually eta expand <code>exprFV</code> and the like</em>. This is what GHC’s free variable
traversal did for many years. Unfortunately this means giving up on the
ability to <code>newtype</code> <code>FV</code>.</li>
<li><em>Convince GHC to push <code>fun_fvs</code> and <code>arg_fvs</code></em> in to the lambda in <code>r</code>.
This is what the rest of this post will be about.</li>
</ol>
<h2 id="the-magical-oneshot-primitive">The magical <code>oneShot</code> primitive</h2>
<p>GHC calls the transform of pushing a <code>let</code> binding down an AST tree <em>floating
in</em>. In general GHC will not float a <code>let</code> binding into a lambda for
good reason: doing so may reduce sharing. For instance, if we have:</p>
<div class="sourceCode" id="cb23"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb23-1"><a href="#cb23-1" aria-hidden="true" tabindex="-1"></a>main <span class="ot">=</span> <span class="kw">do</span></span>
<span id="cb23-2"><a href="#cb23-2" aria-hidden="true" tabindex="-1"></a>  <span class="kw">let</span><span class="ot"> nthPrime ::</span> <span class="dt">Integer</span> <span class="ot">-&gt;</span> <span class="dt">Integer</span></span>
<span id="cb23-3"><a href="#cb23-3" aria-hidden="true" tabindex="-1"></a>      nthPrime <span class="ot">=</span></span>
<span id="cb23-4"><a href="#cb23-4" aria-hidden="true" tabindex="-1"></a>        <span class="kw">let</span><span class="ot"> primes ::</span> [<span class="dt">Integer</span>]</span>
<span id="cb23-5"><a href="#cb23-5" aria-hidden="true" tabindex="-1"></a>            primes <span class="ot">=</span> <span class="co">{- insert favorite method for enumerating primes here -}</span></span>
<span id="cb23-6"><a href="#cb23-6" aria-hidden="true" tabindex="-1"></a>        <span class="kw">in</span> \n <span class="ot">-&gt;</span> primes <span class="op">!!</span> n</span>
<span id="cb23-7"><a href="#cb23-7" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb23-8"><a href="#cb23-8" aria-hidden="true" tabindex="-1"></a>  <span class="fu">print</span> (nthPrime <span class="dv">10</span>)</span>
<span id="cb23-9"><a href="#cb23-9" aria-hidden="true" tabindex="-1"></a>  <span class="fu">print</span> (nthPrime <span class="dv">100</span>)</span></code></pre></div>
<p>We must ensure that <code>primes</code> is only evaluated once, not once for each
application. Consequently GHC will not float a <code>let</code> binding into a
lambda unless it can prove that the lambda is applied at most once (such a
lambda is said to be a <em>one-shot</em> lambda).</p>
<p>In the case of our free variable traversal, we indeed expect each <code>NoFreeVars</code>
value to be applied to precisely one bound-variable set (which, recall, is the
argument to the function inside a <code>NoFreeVars</code>). Happily, GHC gives us the
means to communicate this expectation via the <code>GHC.Magic.oneShot</code> combinator:</p>
<div class="sourceCode" id="cb24"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a><span class="ot">oneShot ::</span> (a <span class="ot">-&gt;</span> b) <span class="ot">-&gt;</span> a <span class="ot">-&gt;</span> b</span>
<span id="cb24-2"><a href="#cb24-2" aria-hidden="true" tabindex="-1"></a>oneShot <span class="ot">=</span> <span class="co">{- there be dragons here -}</span></span></code></pre></div>
<p>Applying this primitive to a lambda expression will cause GHC to consider that
lambda to be one-shot, even if it can’t prove this is the case.</p>
<p>Applying this to the <code>(&lt;&gt;)</code> definition of <code>NoFreeVars</code>:</p>
<div class="sourceCode" id="cb25"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb25-1"><a href="#cb25-1" aria-hidden="true" tabindex="-1"></a><span class="kw">instance</span> <span class="dt">Semigroup</span> <span class="dt">NoFreeVars</span> <span class="kw">where</span></span>
<span id="cb25-2"><a href="#cb25-2" aria-hidden="true" tabindex="-1"></a>  <span class="dt">NoFreeVars</span> f <span class="op">&lt;&gt;</span> <span class="dt">NoFreeVars</span> g <span class="ot">=</span></span>
<span id="cb25-3"><a href="#cb25-3" aria-hidden="true" tabindex="-1"></a>    <span class="dt">NoFreeVars</span> <span class="op">$</span> oneShot <span class="op">$</span> \boundVars <span class="ot">-&gt;</span>     <span class="co">-- &lt;=== oneShot here</span></span>
<span id="cb25-4"><a href="#cb25-4" aria-hidden="true" tabindex="-1"></a>      f boundVars <span class="op">&amp;&amp;</span> g boundVars</span></code></pre></div>
<p>This one-line change allows the simplifier to push the <code>let</code> bindings seen in
the <code>EApp</code> case of <code>exprFV</code> into the lambda in <code>r</code> as we expected, recovering
the nice efficient code that we saw in the untyped AST traversal.</p>
<p>We can use this same trick to fix the <code>FV</code> strategy. However, note that
<code>oneShot</code> only affects the lambda binder that it is immediately applied to.
Consequently, in the case of <code>FV</code> the incantation is a bit more verbose as we
must break what was previously a single syntactic lambda into several lambdas,
punctuated with <code>oneShot</code>s:</p>
<div class="sourceCode" id="cb26"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb26-1"><a href="#cb26-1" aria-hidden="true" tabindex="-1"></a><span class="kw">instance</span> <span class="dt">Semigroup</span> <span class="dt">FV</span> <span class="kw">where</span></span>
<span id="cb26-2"><a href="#cb26-2" aria-hidden="true" tabindex="-1"></a>  fv1 <span class="op">&lt;&gt;</span> fv2 <span class="ot">=</span> <span class="dt">FV</span> <span class="op">$</span> oneShot <span class="op">$</span> \boundVars <span class="ot">-&gt;</span> oneShot <span class="op">$</span> \acc <span class="ot">-&gt;</span> </span>
<span id="cb26-3"><a href="#cb26-3" aria-hidden="true" tabindex="-1"></a>    runFV fv1 boundVars (runFV fv2 boundVars acc)</span></code></pre></div>
<h2 id="summary">Summary</h2>
<p>In this post we have examined a few ways of writing free variable
travesals in Haskell. We started with a simple yet inefficient implementation
and then used some simple tricks to improve the efficiency of the produced code
at the expense of verbosity. We then abstracted away this verbosity
and in so doing allowed for easy implementation of more specialised traversal
strategies such as <code>NoFreeVars</code>.</p>
<p>Finally, we saw how a short-coming of GHC’s simplifier can cause poor code
generation for mutually-recursive traversals and described GHC’s <code>oneShot</code>
primitive. This allowed us to inform GHC of an assumption made by our
abstraction, enabling GHC to produce the code we would write by hand
from our simple, orthogonal specification of an AST traversal and free
variable strategy.</p>
]]></description>
    <pubDate>Sun, 28 Jul 2019 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20190728-free-variable-traversals.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 8.8.1-rc1 released</title>
    <link>http://haskell.org/ghc/blog/20190722-ghc-8.8.1-rc1-released.html</link>
    <description><![CDATA[<h1>GHC 8.8.1-rc1 released</h1>
<h4 class="text-muted">bgamari - 2019-07-22</h4>

<p>The GHC team is pleased to announce the second and likely last alpha
release of GHC 8.8.1. The source distribution, binary distributions, and
documentation are available from
<a href="https://downloads.haskell.org/~ghc/8.8.1-rc1">downloads.haskell.org</a>.
A draft of the release notes is also <a href="https://downloads.haskell.org/ghc/8.8.1-alpha2/docs/html/users_guide/8.8.1-notes.html">available</a>.</p>
<p>This release is the culmination of over 3000 commits by over one hundred
contributors and has several new features and numerous bug fixes
relative to GHC 8.6:</p>
<ul>
<li><p>Profiling now works correctly on 64-bit Windows (although still may
be problematic on 32-bit Windows due to platform limitations; see
<a href="https://gitlab.haskell.org/ghc/ghc/issues/15934">#15934</a>)</p></li>
<li><p>A new code layout algorithm for amd64’s native code generator</p></li>
<li><p>The introduction of a late lambda-lifting pass which may reduce
allocations significantly for some programs.</p></li>
<li><p>Further work on Trees That Grow, enabling improved code re-use of the
Haskell AST in tooling</p></li>
<li><p>More locations where users can write <code>forall</code> (<a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0007-instance-foralls.rst">GHC Proposal <a href="https://gitlab.haskell.org/ghc/ghc/issues/7">#7</a></a>)</p></li>
<li><p>A comprehensive audit of GHC’s memory ordering barriers has been
performed, resulting in a number of fixes that should significantly
improve the reliability of programs on architectures with
weakly-ordered memory models (e.g. PowerPC, many ARM and AArch64
implementations).</p></li>
<li><p>A long-standing linker limitation rendering GHCi unusable with
projects with cyclic symbol dependencies has been fixed (<a href="https://gitlab.haskell.org/ghc/ghc/issues/13786">#13786</a>)</p></li>
<li><p>Further work on the Hadrian build system</p></li>
<li><p>Numerous bug-fixes</p></li>
</ul>
<p>As always, if anything looks amiss do let us know.</p>
<p>Happy compiling!</p>
]]></description>
    <pubDate>Mon, 22 Jul 2019 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20190722-ghc-8.8.1-rc1-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>Improvements in GHC's testsuite infrastructure</title>
    <link>http://haskell.org/ghc/blog/20190708-testsuite-work.html</link>
    <description><![CDATA[<h1>Improvements in GHC's testsuite infrastructure</h1>
<h4 class="text-muted">Ben Gamari - 2019-07-08</h4>

<p>GHC’s testsuite is our first line of defense against correctness regressions.
However, as is often the case, the infrastructure that keeps it running has
been long neglected. Our recent efforts in enforcing a CI-cleanliness in all
GHC builds has resulted in a few bits of work that I thought would be nice to
share.</p>
<h2 id="improving-testsuite-driver-maintainability">Improving testsuite driver maintainability</h2>
<p>GHC’s testsuite is a collection of Makefiles and Haskell programs all glued
together with a <a href="https://gitlab.haskell.org/ghc/ghc/tree/master/testsuite/driver">clump of
Python</a> known
as the testsuite driver. The testsuite driver is a clever albeit quirky piece
of software which, despite its implementation language, displays the marks of a
codebase written by a functional programmer. It defines a small embedded DSL
for describing tests , the user-facing interface of which is
generally declarative. For instance, a simple test definition might look like:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a>test(<span class="st">&#39;T13618&#39;</span>, normal, compile_and_run, [<span class="st">&#39;-v0&#39;</span>])</span></code></pre></div>
<p>To provide this succinct language, the implementation relies on a number of
clever tricks, often involving global variables, functions returning functions,
and good helping of mutation.</p>
<p>Of course, all of these clever tricks are implemented in a dynamically-typed
language in a codebase that has evolved over the course of nearly 20 years (the
first
<a href="https://gitlab.haskell.org/ghc/ghc/commit/e5063a042c9a1701ea7273da7bacb530d5c077d3">commit</a>
to <code>testlib.py</code> was by Simon Marlow in 2003). In its nearly 5kLoC
implementation one will find integers used as booleans, magic
strings, undeclared global variables, variables that are sometimes thread-local
yet elsewhere considered global, heaps of string concatenation, and numerous
other curiosities. Needless to say, comprehending, let alone
modifying, the testsuite driver has been getting harder and harder with every
accrued feature.</p>
<p>In recent years the Python community has gradually awoken to the
promise of statically-checked types. Python 3’s type annotation syntax in
conjunction with the <a href="http://mypy-lang.org/">mypy</a> typechecker has given us a
path to bringing order to this cleverness. <code>mypy</code> implements a pleasantly complete
type system in which most any Haskell 98 user would feel at home, supporting
for newtypes, sums, and parametric polymorphism.</p>
<p>Over the last few weeks the driver has grown hundreds of lines of type
annotations, all checked by <code>mypy</code>. Not only has this made the codebase
significantly more readable but the process unearthed a few latent bugs as well.
Of course, to ensure that the testsuite driver doesn’t regress, it is now
<a href="https://gitlab.haskell.org/ghc/ghc/commit/95f56853d6288076551a5326ad7b4778742a51ce">typechecked</a>
during the <code>lint</code> stage of GHC’s CI pipeline.</p>
<p>In addition to typechecking, we took this opportunity to perform some
long-overdue refactoring to use modern Python interfaces (e.g. <code>pathlib</code>
instead of strings, <code>bool</code> instead of <code>int</code>, use of <code>None</code> where appropriate)
and added numerous assertions (revealing yet more unnoticed bugs, some of which
were silently causing tests to be inappropriately skipped or run).</p>
<h2 id="fragile-and-broken-tests">Fragile and broken tests</h2>
<p>GHC’s testsuite has a sizeable configuration space, with over 30 “ways” in
which tests may be run (e.g. normal, profiled, with the threaded RTS, etc.) and
a few “speeds” which select a subset of tests to be run.</p>
<p>For most of its existence GHC’s CI infrastructure (in its various forms) has
tested only a small subset of the testsuite tests (namely the <code>normal</code> speed
with around a dozen of the ways enabled). While we have periodically looked
at the full <code>slow</code> testsuite output, rarely were we able to make significant
headway in fixing the many issues we found.</p>
<p>Recently our new CI infrastructure has placed a renewed emphasis on
improving testsuite coverage by regularly (e.g. at least on a nightly basis)
testing the entire testsuite (as well as <code>nofib</code>, our performance testsuite).
This, of course, meant fixing the hundreds of failing tests in the full
testsuite run.</p>
<p>These failures generally broke down into a few classes:</p>
<ol type="1">
<li>tests that are themselves buggy</li>
<li>tests on which GHC has regressed (but we hadn’t noticed due to the test not
being run in the default testsuite configuration)</li>
<li>tests which are broken on in certain ways</li>
<li>tests which fail non-deterministically in some or all ways</li>
</ol>
<p>To handle cases (1-3) GHC has long had an <code>expect_broken</code> test modifier to
mark a test as known to be broken due to a particular ticket, e.g.:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>test(<span class="st">&#39;T13366&#39;</span>,</span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a>     [when(opsys(<span class="st">&#39;darwin&#39;</span>), expect_broken(<span class="dv">16083</span>))],</span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a>     compile_and_run,</span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a>     [<span class="st">&#39;-lstdc++ -v0&#39;</span>])</span></code></pre></div>
<p>This modifier causes the test to be run, failing if it somehow successfully
finishes (to ensure that we notice if the test is inadvertently fixed).
Moreover, it encodes the fact that <a href="https://gitlab.haskell.org/ghc/ghc/issues/16083">#16083</a> is the ticket where the breakage is
documented.</p>
<h2 id="tracking-fragile-test-outcomes">Tracking fragile test outcomes</h2>
<p>Sadly, the <code>expect_broken</code> mechanism is not appropriate for fragile tests,
which may pass or fail nondeterministically.
For this case we have introduced a new <code>fragile</code> modifier which runs the test but
merely takes note of whether it passed. We can then report this information in
two places:</p>
<ul>
<li>In the testsuite report printed at the end of the run, ensuring that it
shows up in the testsuite log</li>
<li>In the JUnit report produced by the testsuite run.</li>
</ul>
<p>While <code>fragile</code> is a step up from simply skipping broken tests, we clearly want
to ensure that the desigation is eventually removed from tests that have been
stabilized (intentionally or not).
For a few weeks we tried checking for such tests by hand: manually examining
recent testsuite logs and looking for patterns of fragile tests which routinely
pass. However, not only was this time-consuming but it was also quite
error-prone as some of our fragile tests pass over 90% of the time.</p>
<p>For this reason we have developed <a href="https://gitlab.haskell.org/ghc/ghc-bot/blob/master/test_tracking/ingest_junit.py">a tiny bit of
automation</a>
to help with this process: a GitLab webhook ingests the JUnit output from each
testsuite run into a relational database for later analysis. This turns the
previously-arduous task of identifying no-longer-fragile tests into a simple
SQL query:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode sql"><code class="sourceCode sql"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="kw">SELECT</span> <span class="op">*</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="kw">FROM</span> results_view <span class="kw">AS</span> x</span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="kw">WHERE</span> message <span class="op">=</span> <span class="st">&#39;fragile&#39;</span></span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a>  <span class="kw">AND</span> <span class="kw">NOT</span> <span class="kw">EXISTS</span> (<span class="kw">SELECT</span> <span class="op">*</span></span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a>                  <span class="kw">FROM</span> results_view</span>
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a>                  <span class="kw">WHERE</span> test_name <span class="op">!=</span> x.test_name</span>
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a>                    <span class="kw">AND</span> other<span class="op">-&gt;</span><span class="st">&#39;reason&#39;</span> <span class="op">=</span> <span class="st">&#39;fragile fail&#39;</span></span>
<span id="cb3-8"><a href="#cb3-8" aria-hidden="true" tabindex="-1"></a>                    <span class="kw">AND</span> <span class="dt">date</span> <span class="op">&gt;</span> now() <span class="op">-</span> <span class="dt">interval</span> <span class="st">&#39;4 day&#39;</span>;</span>
<span id="cb3-9"><a href="#cb3-9" aria-hidden="true" tabindex="-1"></a>                 )</span></code></pre></div>
<h2 id="diagnosing-fragile-tests">Diagnosing fragile tests</h2>
<p>One of the challenges in fixing fragile tests is characterising how they fail.
Frequently, fragile tests have several failure modes. Knowing the differences
and similarities between these modes can be remarkably helpful in localizing
the root cause of the failure. Moreover, it’s not uncommon for failure modes to
be shared by multiple fragile tests. Unfortunately, identifying and correlating
these modes can be quite time-consuming, especially with infrequently-failing
tests.</p>
<p>To aid in this we extended the testsuite driver’s JUnit output to include
failing test output. This is then persisted in the test tracking database
described above for later reference. This information has already proven to be
incredibly useful.</p>
<h2 id="an-unexpected-clean-up">An unexpected clean-up</h2>
<p>One unexpected source of improvement in our testsuite performance recently
arose from our recent
<a href="https://gitlab.haskell.org/ghc/ghc/merge_requests/1159">addition</a> of an Alpine
Linux CI target (<a href="https://gitlab.haskell.org/ghc/ghc/issues/14502">#14502</a>). Alpine, unlike the other Linux platforms that we test
on, uses the <code>musl</code> C runtime implementation. Due to differences in <code>musl</code>’s
file flushing semantics, testing on Alpine immediately shed light on a few
subtly fragile testcases which we had previously noticed but had not yet
investigated.</p>
<p>This was a helpful reminder that writing and testing software for portability
is not only good for users but it can also improve correctness by shedding
light on subtly-flawed assumptions.</p>
<h2 id="closing">Closing</h2>
<p>In this post we discussed a few of measures we have taken to improve and
maintain GHC’s correctness while lowering maintenance overhead. By tackling
long-standing technical debt and putting in place tools to correlate test
failures across testsuite runs, testcases, and time, we have gained
significantly deeper insight into when, where, and how our tests are failing.</p>
<p>We look forward to sharing similar steps being taken on the compiler
performance front in a future post.</p>
]]></description>
    <pubDate>Mon, 08 Jul 2019 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20190708-testsuite-work.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>HIE Files - coming soon to a GHC near you!</title>
    <link>http://haskell.org/ghc/blog/20190626-HIEFiles.html</link>
    <description><![CDATA[<h1>HIE Files - coming soon to a GHC near you!</h1>
<h4 class="text-muted">wz1000 - 2019-06-26</h4>

<p>When GHC compiles your programs, it has to work out a bunch of information -
it figures out where stuff is defined, assigns types to expressions, solves
constraints and so on. However, all this information is not easily accessible
to you after GHC is finished. To get your hands on this, you need to set
up a GHC environment, and tediously use the GHC API to extract whatever
information you care about.</p>
<p>HIE files are a new type of file that can be emitted by GHC via the
<code>-fwrite-ide-info</code> flag. They serialize a bunch of useful information about
your source, so that it is easy and fast to access when you need it.</p>
<p>HIE files will be appearing for the first time in GHC 8.8.</p>
<h2 id="how-you-can-make-use-of-.hie-files-right-now">How you can make use of .hie files right now</h2>
<p>First, you need to generate some .hie files. To do this, you need GHC 8.8,
or a recently built version of GHC HEAD.</p>
<p>Once you have these, you need to compile some files with <code>-fwrite-ide-info</code>.</p>
<p>You can do this by invoking GHC explicitly, or by adding this flag to the
<code>ghc-options</code> section of a <code>.cabal</code> file. The compiler will output one <code>.hie</code>
file for each module it compiles. The file is a binary format which
can be read using a simple function from the GHC API.</p>
<p>The output directory for the files can be set using the <code>-hiedir &lt;dir&gt;</code> flag.
This way it’s easy to collate all the files for your project into one place.</p>
<p>The rest of this blog post will be about projects which already use HIE files
and some future ideas that we have for using them.</p>
<h3 id="using-hiedb-to-lookup-information-about-your-code">Using hiedb to lookup information about your code</h3>
<p><a href="https://github.com/wz1000/HieDb"><code>hiedb</code></a> is a command line tool that makes
it easy to query <code>.hie</code> files. It stores the information from the
files in a SQLite db, to enable very fast indexing and querying.</p>
<p>Once you have installed <code>hiedb</code>, you can index your <code>.hie</code> files. For fun,
we’ll index GHC itself. The files were easy to generate just by passing
<code>-fwrite-ide-info</code>.</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> hiedb index hiefiles/ghc</span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="ex">Processing</span> file 561/561: /home/matt/ghc/hie-files/Check.hie... done</span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="ex">Completed!</span></span></code></pre></div>
<p>The whole process takes less than a minute to index the 561 files. Reindexing
is very fast, less than one second, so you can incrementally update the
database as you work on your project and generate updated HIE files.</p>
<p><code>hiedb</code> can dump the original Haskell source of a module (useful when
your build tool doesn’t keep this around):</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> hiedb cat Main</span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="ex">{-#</span> LANGUAGE CPP, NondecreasingIndentation, TupleSections <span class="co">#-}</span></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="ex">{-#</span> OPTIONS <span class="at">-fno-warn-incomplete-patterns</span> <span class="at">-optc-DNON_POSIX_SOURCE</span> <span class="co">#-}</span></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a><span class="ex">-----------------------------------------------------------------------------</span></span>
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a><span class="ex">--</span></span>
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a><span class="ex">--</span> GHC Driver program</span>
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a><span class="ex">--</span></span>
<span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a><span class="ex">--</span> <span class="er">(</span><span class="ex">c</span><span class="kw">)</span> <span class="ex">The</span> University of Glasgow 2005</span>
<span id="cb2-10"><a href="#cb2-10" aria-hidden="true" tabindex="-1"></a><span class="ex">--</span></span>
<span id="cb2-11"><a href="#cb2-11" aria-hidden="true" tabindex="-1"></a><span class="ex">-----------------------------------------------------------------------------</span></span>
<span id="cb2-12"><a href="#cb2-12" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-13"><a href="#cb2-13" aria-hidden="true" tabindex="-1"></a><span class="ex">module</span> Main <span class="er">(</span><span class="ex">main</span><span class="kw">)</span> <span class="ex">where</span></span></code></pre></div>
<p>Now let’s suppose we want to know everywhere in GHC which uses the <code>eqType</code>
function. <code>hiedb</code> can be queried to find all references to this name:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> hiedb name-refs eqType</span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="ex">TcBinds:863:34-863:42</span></span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="ex">TcBinds:1018:48-1018:56</span></span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a><span class="ex">OptCoercion:121:55-121:63</span></span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a><span class="ex">OptCoercion:121:116-121:124</span></span>
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a><span class="ex">OptCoercion:266:9-266:17</span></span>
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a><span class="ex">OptCoercion:799:9-799:17</span></span>
<span id="cb3-8"><a href="#cb3-8" aria-hidden="true" tabindex="-1"></a><span class="ex">OptCoercion:1045:8-1045:16</span></span>
<span id="cb3-9"><a href="#cb3-9" aria-hidden="true" tabindex="-1"></a><span class="ex">TcHsSyn:1692:37-1692:45</span></span>
<span id="cb3-10"><a href="#cb3-10" aria-hidden="true" tabindex="-1"></a><span class="ex">TcMType:354:20-354:28</span></span>
<span id="cb3-11"><a href="#cb3-11" aria-hidden="true" tabindex="-1"></a><span class="ex">TcMType:355:20-355:28</span></span>
<span id="cb3-12"><a href="#cb3-12" aria-hidden="true" tabindex="-1"></a><span class="ex">...</span></span></code></pre></div>
<p>There are quite a few!</p>
<p>For tooling you might want to know about the references for an identifier
at certain source position. <code>hiedb</code> also supports this query, and it works for
locally defined and unexported names.</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a>eqType t1 t2 <span class="ot">=</span> isEqual <span class="op">$</span> nonDetCmpType t1 t2</span></code></pre></div>
<p>Pointing it to the <code>t1</code> parameter of <code>eqType</code>, line 2500, column 9:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> hiedb point-refs Type 2500 9</span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="ex">Name</span> t1 at <span class="er">(</span><span class="ex">2500,9</span><span class="kw">)</span> <span class="ex">is</span> used in:</span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a><span class="ex">Type:2500:8-2500:10</span></span>
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a><span class="ex">Type:2500:40-2500:42</span></span></code></pre></div>
<p>The two references to <code>t1</code>, the definition and its sole usage are returned.
Similarly, we can query for the type at a point. Asking for the type of
the usage of <code>t1</code> in the body, we find that its type is … <code>Type</code>!.</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> hiedb point-type Type 2500 40</span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a><span class="ex">Type</span></span></code></pre></div>
<p>There are a few more commands you can learn about by looking at the help text:</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> hiedb <span class="at">--help</span></span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a><span class="ex">hiedb</span> <span class="at">-</span> a tool to query groups of .hie files</span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a><span class="ex">Usage:</span> hiedb [-D<span class="kw">|</span><span class="ex">--database</span> DATABASE] [-v<span class="kw">|</span><span class="ex">--trace]</span> [-q<span class="kw">|</span><span class="ex">--quiet]</span></span>
<span id="cb7-5"><a href="#cb7-5" aria-hidden="true" tabindex="-1"></a>             <span class="ex">[-f</span><span class="kw">|</span><span class="ex">--virtual-file]</span> COMMAND</span>
<span id="cb7-6"><a href="#cb7-6" aria-hidden="true" tabindex="-1"></a>  <span class="ex">Query</span> .hie files</span>
<span id="cb7-7"><a href="#cb7-7" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-8"><a href="#cb7-8" aria-hidden="true" tabindex="-1"></a><span class="ex">Available</span> options:</span>
<span id="cb7-9"><a href="#cb7-9" aria-hidden="true" tabindex="-1"></a>  <span class="ex">-D,--database</span> DATABASE   References</span>
<span id="cb7-10"><a href="#cb7-10" aria-hidden="true" tabindex="-1"></a>                           <span class="ex">Database</span> <span class="er">(</span><span class="ex">default:</span> <span class="st">&quot;/home/zubin/.local/share/default.hiedb&quot;</span><span class="kw">)</span></span>
<span id="cb7-11"><a href="#cb7-11" aria-hidden="true" tabindex="-1"></a>  <span class="ex">-h,--help</span>                Show this help text</span>
<span id="cb7-12"><a href="#cb7-12" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-13"><a href="#cb7-13" aria-hidden="true" tabindex="-1"></a><span class="ex">Available</span> commands:</span>
<span id="cb7-14"><a href="#cb7-14" aria-hidden="true" tabindex="-1"></a>  <span class="ex">init</span>                     Initialize databse</span>
<span id="cb7-15"><a href="#cb7-15" aria-hidden="true" tabindex="-1"></a>  <span class="ex">index</span>                    Index database</span>
<span id="cb7-16"><a href="#cb7-16" aria-hidden="true" tabindex="-1"></a>  <span class="ex">name-refs</span>                Lookup references of value MODULE.NAME</span>
<span id="cb7-17"><a href="#cb7-17" aria-hidden="true" tabindex="-1"></a>  <span class="ex">type-refs</span>                Lookup references of type MODULE.NAME</span>
<span id="cb7-18"><a href="#cb7-18" aria-hidden="true" tabindex="-1"></a>  <span class="ex">name-def</span>                 Lookup definition of value MODULE.NAME</span>
<span id="cb7-19"><a href="#cb7-19" aria-hidden="true" tabindex="-1"></a>  <span class="ex">type-def</span>                 Lookup definition of type MODULE.NAME</span>
<span id="cb7-20"><a href="#cb7-20" aria-hidden="true" tabindex="-1"></a>  <span class="fu">cat</span>                      Dump contents of MODULE as stored in the hiefile</span>
<span id="cb7-21"><a href="#cb7-21" aria-hidden="true" tabindex="-1"></a>  <span class="fu">ls</span>                       List all indexed files/modules</span>
<span id="cb7-22"><a href="#cb7-22" aria-hidden="true" tabindex="-1"></a>  <span class="fu">rm</span>                       Remove targets from index</span>
<span id="cb7-23"><a href="#cb7-23" aria-hidden="true" tabindex="-1"></a>  <span class="ex">module-uids</span>              List all the UnitIds MODULE is indexed under in the</span>
<span id="cb7-24"><a href="#cb7-24" aria-hidden="true" tabindex="-1"></a>                           <span class="ex">db</span></span>
<span id="cb7-25"><a href="#cb7-25" aria-hidden="true" tabindex="-1"></a>  <span class="ex">lookup-hie</span>               Lookup the location of the .hie file corresponding to</span>
<span id="cb7-26"><a href="#cb7-26" aria-hidden="true" tabindex="-1"></a>                           <span class="ex">MODULE</span></span>
<span id="cb7-27"><a href="#cb7-27" aria-hidden="true" tabindex="-1"></a>  <span class="ex">point-refs</span>               Find references for symbol at point/span</span>
<span id="cb7-28"><a href="#cb7-28" aria-hidden="true" tabindex="-1"></a>  <span class="ex">point-types</span>              List types of ast at point/span</span>
<span id="cb7-29"><a href="#cb7-29" aria-hidden="true" tabindex="-1"></a>  <span class="ex">point-defs</span>               Find definition for symbol at point/span</span>
<span id="cb7-30"><a href="#cb7-30" aria-hidden="true" tabindex="-1"></a>  <span class="ex">point-info</span>               Print name, module name, unit id for symbol at</span>
<span id="cb7-31"><a href="#cb7-31" aria-hidden="true" tabindex="-1"></a>                           <span class="ex">point/span</span></span></code></pre></div>
<h3 id="type-information-in-haddocks-hyperlinked-source">Type information in Haddock’s hyperlinked source</h3>
<p><code>hiedb</code> is a great way to consume HIE files but it’s not the only way.
Since GHC 8.8 and the Haddock version that ships with it (2.23.0),
the hyperlinker has been re-engineered to use <code>.hie</code> files to generate
hyperlinked source. This allows the generated hyperlinked source files to
report types of expressions on hover.</p>
<p>To use this, you just need to build haddock documentation for your project
with <code>--hyperlinked-source</code> enabled.</p>
<p><img src="./images/20190626-HIEFiles/HyperlinkedSource.png" width="600" /></p>
<h3 id="code-navigation-and-type-information-in-your-github-editor-using-hie-lsif">Code navigation and type information in your Github editor using hie-lsif</h3>
<p>The <a href="https://microsoft.github.io/language-server-protocol/overview">Language Server
Protocol</a> is a
language agnostic protocol for editors and tools to communicate. A LSP client,
such as vscode, sends requests to a LSP server, such as <code>haskell-ide-engine</code>
for information such as what to display on a hover or what references a
certain symbol has.</p>
<p><a href="https://code.visualstudio.com/blogs/2019/02/19/lsif">LSIF files</a> are a new
extension to the protocol which provide a static snapshot of how a language
server would respond to a request for a fixed piece of code.
These allow editors and other clients to provide code intelligence
for a project without having to run an LSP server. This can be used to answer
queries like “go to definition”, “find references”, “hover”, etc. in editors
as well as interfaces like GitHub’s PR code review.</p>
<p>You can use the <a href="https://github.com/mpickering/hie-lsif"><code>hie-lsif</code></a> tool
to generate an LSIF file for your project using <code>.hie</code> files.</p>
<p>LSIF files are planned to be <a href="https://code.visualstudio.com/blogs/2018/12/04/rich-navigation">integrated
into</a> GitHub
pull requests soon. With the release of GHC 8.8, Haskell will be in a good
position to take advantage of this feature.</p>
<p><img src="./images/20190626-HIEFiles/LSIF.png" width="600" /></p>
<h2 id="future-developments">Future developments</h2>
<p>There’s a couple more applications of <code>.hie</code> files that we’re excited
about which are in the works.</p>
<h3 id="fast-low-memory-usage-and-persistent-code-intelligence-for-language-servers">Fast, low memory usage and persistent code intelligence for language servers</h3>
<p><code>.hie</code> files are good way to power some of the code intelligence features of
language servers like haskell-ide-engine. They are easy to use and require
very few system resources to answer queries. They can be used on their own,
or as a fallback when typechecked modules aren’t available.</p>
<p>Furthermore, if you load a file in <code>haskell-ide-engine</code> that doesn’t compile,
it will not be able to give you any code intelligence for that file. <code>.hie</code> files
offer a way to persist some of the data <code>haskell-ide-engine</code> requires to
answer queries.</p>
<p>Integrating <code>hiedb</code> with <code>haskell-ide-engine</code> will also enable cross project
go-to definition and symbol references, two long requested features.</p>
<p>I plan to work on this during the rest of the summer.</p>
<h3 id="ghcis-set-c---now-powered-by-.hie-files">GHCi’s :set +c - now powered by .hie files</h3>
<p>GHCi’s :set +c functionality also exposes features like type-at-point,
references-at-point etc. This is being rewritten to use <code>.hie</code> files,
which should make it faster and more reliable.</p>
<p>You can track progress on this here: <a href="https://gitlab.haskell.org/ghc/ghc/issues/16804" class="uri">https://gitlab.haskell.org/ghc/ghc/issues/16804</a></p>
<h2 id="conclusion">Conclusion</h2>
<p><code>.hie</code> files have already been put to good use and they haven’t event been
released yet! They provide a convenient middle ground between querying GHCi for
information and writing a full blown source plugin. There’s a lot of information,
probably all you need, in a simple and easy to consume format.</p>
<p>We’re looking forward to seeing how people use <code>.hie</code> files and if you have any
problems with them make sure to open tickets on the issue tracker.</p>
]]></description>
    <pubDate>Wed, 26 Jun 2019 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20190626-HIEFiles.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 8.8.1-alpha2 released</title>
    <link>http://haskell.org/ghc/blog/20190615-ghc-8.8.1-alpha2-released.html</link>
    <description><![CDATA[<h1>GHC 8.8.1-alpha2 released</h1>
<h4 class="text-muted">bgamari - 2019-06-19</h4>

<p>The GHC team is pleased to announce the second and likely last alpha
release of GHC 8.8.1. The source distribution, binary distributions, and
documentation are available from
<a href="https://downloads.haskell.org/~ghc/8.8.1-alpha2">downloads.haskell.org</a>.
A draft of the release notes is also <a href="https://downloads.haskell.org/ghc/8.8.1-alpha2/docs/html/users_guide/8.8.1-notes.html">available</a>.</p>
<p>This release is the culmination of over 3000 commits by over one hundred
contributors and has several new features and numerous bug fixes
relative to GHC 8.6:</p>
<ul>
<li><p>Profiling now works correctly on 64-bit Windows (although still may
be problematic on 32-bit Windows due to platform limitations; see
<a href="https://gitlab.haskell.org/ghc/ghc/issues/15934">#15934</a>)</p></li>
<li><p>A new code layout algorithm for amd64’s native code generator</p></li>
<li><p>The introduction of a late lambda-lifting pass which may reduce
allocations significantly for some programs.</p></li>
<li><p>Further work on Trees That Grow, enabling improved code re-use of the
Haskell AST in tooling</p></li>
<li><p>More locations where users can write <code>forall</code> (<a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0007-instance-foralls.rst">GHC Proposal <a href="https://gitlab.haskell.org/ghc/ghc/issues/7">#7</a></a>)</p></li>
<li><p>Further work on the Hadrian build system</p></li>
</ul>
<p>This release brings a number of fixes since alpha 1:</p>
<ul>
<li><p>A number of linker fixes (<a href="https://gitlab.haskell.org/ghc/ghc/issues/16779">#16779</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/16784">#16784</a>)</p></li>
<li><p>The process, binary, Cabal, time, terminfo libraries have all been
bumped to their final release versions</p></li>
<li><p>A regression rendering TemplateHaskell unusable in cross-compiled
configurations has been fixed (<a href="https://gitlab.haskell.org/ghc/ghc/issues/16331">#16331</a>)</p></li>
<li><p>A regression causing compiler panics on compilation of some programs
has been fixed (<a href="https://gitlab.haskell.org/ghc/ghc/issues/16449">#16449</a>)</p></li>
<li><p><code>-Wmissing-home-modules</code> now handles hs-boot files correctly (<a href="https://gitlab.haskell.org/ghc/ghc/issues/16551">#16551</a>)</p></li>
<li><p>A regression causing some programs to fail at runtime has been fixed
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/16066">#16066</a>)</p></li>
</ul>
<p>Due to on-going work on our release and testing infrastructure this
cycle is proceeding at a pace significantly slower than expected.
However, we anticipate that this investment will allow us to release a
more reliable, easier-to-install compiler on the planned six-month
release cadence in the future.</p>
<p>As always, if anything looks amiss do let us know.</p>
<p>Happy compiling!</p>
]]></description>
    <pubDate>Wed, 19 Jun 2019 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20190615-ghc-8.8.1-alpha2-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 8.8.1-alpha1 released</title>
    <link>http://haskell.org/ghc/blog/20190425-ghc-8.8.1-alpha1-released.html</link>
    <description><![CDATA[<h1>GHC 8.8.1-alpha1 released</h1>
<h4 class="text-muted">bgamari - 2019-04-25</h4>

<p>The GHC team is pleased to announce the first alpha release of GHC 8.8.1.
The source distribution, binary distributions, and documentation are
available at <a href="https://downloads.haskell.org/~ghc/8.8.1-alpha1">downloads.haskell.org</a>. A draft of the release notes is
also <a href="https://downloads.haskell.org/ghc/8.8.1-alpha1/docs/html/users_guide/8.8.1-notes.html">available</a>.</p>
<p>This release is the culmination of over 3000 commits by over one hundred
contributors and has several new features and numerous bug fixes
relative to GHC 8.6:</p>
<ul>
<li><p>Profiling now works correctly on 64-bit Windows (although still may
be problematic on 32-bit Windows due to platform limitations; see
<a href="https://gitlab.haskell.org/ghc/ghc/issues/15934">#15934</a>)</p></li>
<li><p>A new code layout algorithm for amd64’s native code generator</p></li>
<li><p>The introduction of a late lambda-lifting pass which may reduce
allocations significantly for some programs.</p></li>
<li><p>Further work on Trees That Grow, enabling improved code re-use of the
Haskell AST in tooling</p></li>
<li><p>More locations where users can write <code>forall</code> (<a href="https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0007-instance-foralls.rst">GHC Proposal <a href="https://gitlab.haskell.org/ghc/ghc/issues/7">#7</a></a>)</p></li>
<li><p>Continued work on the Hadrian build system</p></li>
</ul>
<p>This release starts the pre-release cycle for GHC 8.8. This cycle is
starting quite a bit later than expected due recent work on GHC’s CI and
release infrastructure. See the <a href="https://www.haskell.org/ghc/blog/20190405-ghc-8.8-status.html">GHC Blog</a> for more on this.</p>
<p>As always, if anything looks amiss do let us know.</p>
<p>Happy compiling!</p>
]]></description>
    <pubDate>Thu, 25 Apr 2019 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20190425-ghc-8.8.1-alpha1-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 8.6.5 released</title>
    <link>http://haskell.org/ghc/blog/20190423-ghc-8.6.5-released.html</link>
    <description><![CDATA[<h1>GHC 8.6.5 released</h1>
<h4 class="text-muted">bgamari - 2019-04-23</h4>

<p>The GHC team is proud to announce the release of GHC 8.6.5. The source
distribution, binary distributions, and documentation are available at
<a href="https://downloads.haskell.org/~ghc/8.6.5">downloads.haskell.org</a>.
Release notes are also <a href="http://downloads.haskell.org/~ghc/8.6.5/docs/html/users_guide/8.6.5-notes.html">available</a></p>
<p>This release fixes a handful of issues with 8.6.4:</p>
<ul>
<li><p>Binary distributions once again ship with Haddock documentation including
syntax highlighted source of core libraries (<a href="https://gitlab.haskell.org/ghc/ghc/issues/16445">#16445</a>)</p></li>
<li><p>A build system issue where use of GCC with <code>-flto</code> broke <code>configure</code>
was fixed (<a href="https://gitlab.haskell.org/ghc/ghc/issues/16440">#16440</a>)</p></li>
<li><p>An bug affecting Windows platforms wherein XMM register values could be
mangled when entering STG has been fixed (<a href="https://gitlab.haskell.org/ghc/ghc/issues/16514">#16514</a>)</p></li>
<li><p>Several Windows packaging issues resulting from the recent CI rework.
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/16408">#16408</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/16398">#16398</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/16516">#16516</a>)</p></li>
</ul>
<p>Do note that due to linking issues (see <a href="https://gitlab.haskell.org/ghc/ghc/issues/15934">#15934</a>) profiling will be rather
unreliable on Windows. This will be fixed in 8.8.1.</p>
<p>As always, if anything looks amiss do let us know.</p>
<p>Happy compiling!</p>
]]></description>
    <pubDate>Tue, 23 Apr 2019 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20190423-ghc-8.6.5-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 8.6.5-rc1 released</title>
    <link>http://haskell.org/ghc/blog/201904080-ghc-8.6.5-rc1-released.html</link>
    <description><![CDATA[<h1>GHC 8.6.5-rc1 released</h1>
<h4 class="text-muted">bgamari - 2019-04-08</h4>

<p>The GHC team is proud to announce the first release candidate of 8.6.5.
The source distribution, binary distributions, and documentation are
available on
<a href="https://downloads.haskell.org/~ghc/8.6.5-rc1">downloads.haskell.org</a>.</p>
<p>This release fixes a handful of issues with 8.6.4:</p>
<ul>
<li><p>Binary distributions once again ship with Haddock documentation including
syntax highlighted source of core libraries (<a href="https://gitlab.haskell.org/ghc/ghc/issues/16445">#16445</a>)</p></li>
<li><p>A build system issue where use of GCC with <code>-flto</code> broke <code>configure</code>
was fixed (<a href="https://gitlab.haskell.org/ghc/ghc/issues/16440">#16440</a>)</p></li>
<li><p>An bug affecting Windows platforms wherein XMM register values could be
mangled when entering STG has been fixed (<a href="https://gitlab.haskell.org/ghc/ghc/issues/16514">#16514</a>)</p></li>
<li><p>Several Windows packaging issues resulting from the recent CI rework.
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/16408">#16408</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/16398">#16398</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/16516">#16516</a>)</p></li>
</ul>
<p>Since this is a relatively small bugfix release we are bypassing the
alpha releases and moving right to the release candidate stage. If all
goes well the final release will be cut next week.</p>
<p>As always, if anything looks amiss do let us know.</p>
<p>Happy testing!</p>
]]></description>
    <pubDate>Mon, 08 Apr 2019 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/201904080-ghc-8.6.5-rc1-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 8.8 Status</title>
    <link>http://haskell.org/ghc/blog/20190405-ghc-8.8-status.html</link>
    <description><![CDATA[<h1>GHC 8.8 Status</h1>
<h4 class="text-muted">Ben Gamari - 2019-04-04</h4>

<p>With the release of GHC 8.4 we discussed a reorganization of our release cycle,
increasing the release frequency from roughly one release every twelve months
to a predictable two releases per year. This aggressive increase in
release frequency was to be enabled by reimagining of GHC’s continuous
integration infrastructure, allowing us to reduce the cost of making releases
while not compromising quality.</p>
<p>However, it took a few false-starts to realize the promise of the
comprehensive CI rework that we envisioned. While an early attempt at <a href="https://www.haskell.org/ghc/blog/20170801-jenkins-ci.html">Jenkins
infrastructure</a>
ultimately proved to be a dead-end, a second attempt at using
CircleCI and Appveyor had significantly more traction. By the time of the 8.6.2
release we had sufficient CI infrastructure in place to make a few of our
binary distributions via CI but we were still far from the comprehensive CI
story necessary to sustain the accelerated schedule due to platform limitations
and lacking build capacity.</p>
<p>Late last fall we resolved to consolidate GHC’s infrastructure on GitLab. While
our original plan called for us to continue to use CircleCI and Appveyor as the
basis for our testing infrastructure, circumstances eventually rendered this
plan infeasible. However, nearly five months later we are
<a href="20190403-infra-status.html">emerging</a> on the other side of this migration effort, not only
with significantly streamlined contributor workflow but also most of the
testing infrastructure that we have been seeking.</p>
<p>Needless to say, bringing this migration to a close ultimately required that we
compromise on the 8.8.1 release schedule. According to our planned cadence, the
8.8 cycle was slated to begin in December 2018, three months after the release
of 8.6.1. This would have started a succession of pre-releases which would
culminate in a final release in mid-March 2019.</p>
<p>After we resolved to proceed with the GitLab migration I had tentatively
planned to push this cycle back, starting the alpha releases shortly after the
expected conclusion of <a href="20190403-infra-status.html">phase 2</a> of the GitLab migration in
February 2019. This timeframe ended up being a bit optimistic but I believe we
are now in a place where we can begin realistically restart release engineering
work (and indeed I have been busily preparing the <code>ghc-8.6</code> and <code>ghc-8.8</code>
branches over the past weeks).</p>
<p>At this point our plan is as follows:</p>
<ol type="1">
<li><p>In the next few days we will be pushing out a 8.6.5-alpha1 release.
This will include a few important bug fixes as well as some
packaging issues, particularly affecting Windows</p>
<p>Assuming no serious regressions are reported the final 8.6.5 release will be
cut a week later, likely marking the end of the 8.6 series.</p></li>
<li><p>Once 8.6.5-alpha1 is out we will aim to quickly turnaround an 8.8.1-alpha1.
Thanks to the <code>head.hackage</code> infrastructure introduced
<a href="20190403-infra-status.html">earlier</a> we have already had some experience building user
code with this branch and hope to move quickly through one or two
pre-releases, culminating in a final 8.8.1 release in mid-May.</p></li>
<li><p>We will plan on starting the alpha cycle for 8.10 in mid-June, as previously
planned.</p></li>
</ol>
<p>All-in-all this schedule should allow us to proceed in cutting 8.8.1 (and
subsequent minor releases) with little-to-no effect on the 8.10 series.</p>
<p>I am also happy to share that we have been working on a few of other exciting
projects in GHC-land in the past months, concurrently to the GitLab migration.
I look forward to sharing more about these in a future post.</p>
<p>Onwards and upwards!</p>
<ul>
<li>Ben</li>
</ul>
]]></description>
    <pubDate>Thu, 04 Apr 2019 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20190405-ghc-8.8-status.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC Infrastructure Update</title>
    <link>http://haskell.org/ghc/blog/20190403-infra-status.html</link>
    <description><![CDATA[<h1>GHC Infrastructure Update</h1>
<h4 class="text-muted">Ben Gamari - 2019-04-03</h4>

<p>Around five months ago I proposed that we undertake what became a comprehensive
rebuild of GHC’s infrastructure. Since November we have been quietly working behind
the scenes to make this new infrastructure a reality; this has been a massive
project and however I’m happy to say we are now emerging on the other side and
we are very happy with the result.</p>
<p>In this post I want to take this opportunity to describe why this project was
needed, what it has entailed, and where it has brought us. Enjoy!</p>
<h2 id="motivation">Motivation</h2>
<p>Most of our users are aware that GHC is an old project: the <a href="https://haskell.org/ghc/download_ghc_029.shtml">earliest
release</a> I have found is GHC
0.29, released nearly 23 years ago.</p>
<p>In addition to being old, GHC is also a large project and, like most large
projects, has a significant amount of infrastructure to keep things moving
smoothly. Before the migation this infrastructure included:</p>
<ul>
<li><a href="https://gitolite.com/gitolite/">gitolite</a>, our repository hosting service (<code>git.haskell.org</code>)</li>
<li>home-grown infrastructure for maintaining git mirrors to and from GitHub
our homepage (<code>haskell.org/ghc</code>)</li>
<li><a href="https://trac.edgewall.org/">Trac</a>, our issue tracker and wiki (<code>ghc.haskell.org/trac/ghc</code>)</li>
<li>a number of home-grown linting scripts for ensuring code quality and
preventing mistakes</li>
<li><a href="https://phabricator.com/">Phabricator</a>, our code review tool (<code>phabricator.haskell.org</code>)</li>
<li>our continuous integration services (Phabricator and more recently
CircleCI/Appveyor)</li>
</ul>
<p>While this all worked reasonably well it was not without its share of pain-points.
These issues ranged from minor (e.g. a
constant trickle of effort going towards maintaining consistency between
Phabricator, <code>git</code>, and Trac) to serious (e.g. our servers stuck on a
soon-to-be deprecated Debian release; a need for constant fiddling to keep CI
builders running). Nevertheless, none of these issues seemed significant enough
to force any immediate change.</p>
<p>This calculation changed around twelve months ago, when we received word that
Rackspace would be ending its open-source software program, which graciously provided
hosting for our servers for the last six years (thank you, Rackspace!).</p>
<p>Our first inclination was to simply rebuild GHC’s existing services on a new
hosting provider. However, as I began this process in the summer of 2018 the scale of
the challenge became apparent. Not only was our primary server an organic mix
of scripts and configuration with varying degrees of documentation, but some of our services ranged
from unsupported (e.g. Phabricator, which no longer supported non-paying
customers), to infrequently maintained (e.g. many of the plugins
used by our Trac instance have not had a release in four years or more),
to obsolete (e.g. we still used gitolite v2, which has been
deprecated for years),</p>
<p>In light of this, it seemed clear that simply rebuilding our existing
infrastructure would prove to be a mistake: despite requiring a
significant investment in resources, the rebuild would solve none of the
friction that our existing infrastructure incurred and would likely once again
devolve into an difficult-to-maintain jungle of configuration. If there was
ever a time to change it was now.</p>
<p>However, to complicate matters we were already deep in a rebuild of our continuous
integration infrastructure, building upon CircleCI and Appveyor, to
support our new six-month release cadence. While this change was in many ways a
great improvement over our previous CI infrastructure, it also introduced a
number of integration challenges (i.e. tying build results back to
Phabricator) that we were still in the process of trying to solve.</p>
<h2 id="planning-the-migration">Planning the migration</h2>
<p>To replace our infrastructure there were two serious contenders: GitHub and
GitLab. Happily, both options would move us towards a more git-centric
contribution workflow, addressing one of the greatest concerns that potential
contributors expressed in our development priorities survey last fall.</p>
<p>While other projects (namely Rust) have demonstrated that it is possible
to maintain a large-scale open-source project on GitHub, it was far from clear
that GHC could pull this off with our comparatively limited resources and
significantly larger legacy migration needs (e.g. we concluded early on that any
migration must faithfully preserve GHC’s ticket history, including ticket
numbers).</p>
<p>In addition, GitLab was been sucessfully adopted by
<a href="https://www.gnome.org/">GNOME</a>, and
<a href="https://freedesktop.org/">freedesktop.org</a>, with <a href="https://kde.org/">KDE</a>’s
making motions towards a migration as well.</p>
<p>For these and other reasons that are well-covered
<a href="https://mail.haskell.org/pipermail/ghc-devs/2018-October/016425.html">elsewhere</a>
GitLab seemed like a better fit for GHC’s needs.</p>
<p>By early November 2018 there was consensus to move ahead with a migration to
move GHC to GitLab. To keep the migration managable, we carefully limited the
<a href="https://gitlab.haskell.org/ghc/ghc/wikis/git-lab-migration">project’s scope</a>
to migrate code review, repository hosting, ticket tracking, and the wiki,
leaving any continuous integration migration for future work.</p>
<h2 id="starting-work">Starting work</h2>
<p>In mid-November we started work on the migration as two parallel efforts:</p>
<ul>
<li><em>phase 1</em>: migrating repository hosting and code review</li>
<li><em>phase 2</em>: migrating ticket tracking and the wiki</li>
</ul>
<p>Phase 1 was intended to be a small project, allowing us to migrate quickly to
our new code review platform and begin the process of decommissioning our old
systems.</p>
<p>Phase 2 was significantly riskier, involving the migration of 16,000 tickets,
carrying over 100,000 comments of human-written markup. Thankfully, we had the
benefit of being able to <a href="https://gitlab.haskell.org/bgamari/trac-to-remarkup">build
upon</a> Matthew Pickering’s
<a href="https://mail.haskell.org/pipermail/ghc-devs/2017-January/013500.html">previous</a>
prototype infrastructure for migrating Trac tickets to Maniphest, Phabricator’s
issue tracker.</p>
<h2 id="phase-1-and-scope-creep">Phase 1 and scope creep</h2>
<p>It is sometimes said that no plan survives first contact with reality; GHC’s
migration plan was no exception. In early December 2018 we were
<a href="https://mail.haskell.org/pipermail/ghc-devops-group/2018-December/000273.html">notified</a>
that imminent changes to CircleCI’s pricing model would essentially preclude
further use of the platform. While GitLab provided us with a convenient
alternative to CircleCI, this development significantly enlarged the
previously carefully-bounded scope of our migration plan.</p>
<p>While CircleCI generously provided us with a two-week extension to our (free)
CI plan, the weeks that followed were a scramble to rebuild our CI
infrastructure before support vanished.</p>
<p>Regardless, by late December we had finished phase 1 of the migration, including
rudimentary CI support, and designated <a href="https://gitlab.haskell.org/ghc/ghc" class="uri">https://gitlab.haskell.org/ghc/ghc</a>
as GHC’s official upstream source repository.</p>
<p>Throughout this process we were lucky to have the support of GitLab’s director of
community relations, David Planella. David has been an invaluable resource,
helping us plan our migration and quickly draw attention to the occassional bug
report.</p>
<p>Moreover, GitLab was remarkably responsive to the pain-points that we
encountered in our workflow. While many examples can be found via the GHC
migration <a href="https://gitlab.com/gitlab-org/gitlab-ce/issues/55039">tracking
ticket</a>, one in
particular stands out: soon after moving code review to GitLab we quickly found
that our use of the “fast-forward only” merge strategy (necessary to preserve
bisectability), coupled with our long six-hour CI build times, resulted in a
<a href="https://gitlab.com/gitlab-org/gitlab-ce/issues/55039#note_127882246">very poor patch merge
workflow</a>.
While we adopted <a href="https://github.com/smarkets/marge-bot">marge-bot</a> as a
near-term workaround, David and James of GitLab were happy to hear out and
reflect on our use-case, using our experience to design the <a href="https://gitlab.com/gitlab-org/gitlab-ee/issues/9186">merge
train feature</a> that will be
available in a coming GitLab release.</p>
<h2 id="wiki-and-ticket-migration">Wiki and ticket migration</h2>
<p>Phase 2 of the migration involved migrating GHC’s tickets and nearly
wiki pages to GitLab. For the former we used a relatively straightforward
<a href="https://gitlab.haskell.org/bgamari/trac-to-remarkup/blob/master/src/Trac/Parser.hs">parser</a>
of Trac’s markup syntax and a simple
<a href="https://gitlab.haskell.org/bgamari/trac-to-remarkup/blob/master/src/Trac/Writer.hs">pretty-printer</a>.</p>
<p>While this worked well enough for ticket descriptions and comments, its
performance on Wiki pages was unacceptably poor due to syntactic ambiguity and
the significantly richer markup used in wiki pages. To handle this we augmented
our conversion script with an HTML parser to back out Markdown from rendered
Trac wiki pages. While inelegant, this approach was significantly
better in preserving the rich markup found in many wiki pages.</p>
<p>After several dry-run migrations in Janary and February the conversion
quality was deemed acceptable by early March, with the final migration being
carried out on 9 March 2019. This was a bit later than our goal of finishing
the final import by mid-February, but this wasn’t surprising. given the scale
of the task.</p>
<h2 id="improving-ci-coverage">Improving CI coverage</h2>
<p>Testing the many configurations supported by GHC has been a challenge on each
of the CI platforms we have used. Most recently, while CircleCI offered many
benefits, it complicated testing of non-x86-64/Linux targets due to
the platform’s limited operating system support, build time limits, and the
high cost of build time. In this respect the move to GitLab opened up a number
of opportunities.</p>
<p>Throughout February and March 2019 we focused on extending the CI
infrastructure we built in phase 1 to cover these non-standard configurations.
As of today, every GHC merge request is tested on over a dozen operating
system/architecture/build-parameter configurations, with binary distribution
artifacts produced and archived for most of these.</p>
<p>In addition to plain GHC builds, we have also realized the long-sought goal of
regularly testing GHC snapshots against user code. For this we have incorporated
Herbert Valerio Riedel’s <a href="http://github.com/hvr/head.hackage">head.hackage</a>
patch-set with Matthew Pickering’s
<a href="https://github.com/mpickering/ghc-artefact-nix">ghc-artefact-nix</a> nix
expression. In conjunction with some glue logic this combination
gives us the ability to test CI-produced binary distributions against a several
dozen Hackage packages, with more to be added in the future.</p>
<p>In addition to testing for regressions in correctness, our <code>head.hackage</code> CI
records compile-time and allocation metrics, allowing us to track compiler
performance on real-world Haskell code. We hope that this will provide better
insight into GHC’s compile-time costs and expect to use this insight in future
work on improving compiler performance.</p>
<h2 id="further-automation">Further automation</h2>
<p>One of the major motivations for the move to GitLab was the promise of
consolidating and automating more project management tasks, removing
human bottlenecks and increasing GHC’s bus factor. Towards this end we have
automated many of the more mundane aspects of GHC’s infrastructure:</p>
<ul>
<li>CI-triggered builds of the <a href="https://gitlab.haskell.org/ghc/ci-images">Docker
images</a> on which our CI processes
are built</li>
<li>automated deployment of GHC <a href="https://ghc.gitlab.haskell.org/ghc/doc/">documentation snapshots</a></li>
<li>automated generation and deployment of GHC’s <a href="http://gitlab.haskell.org/ghc/homepage">website</a> (including this blog)</li>
<li>well-documented, version-controlled, and maintainable configuration for our
servers and CI runners built upon <a href="https://nixos.org/">NixOS</a></li>
</ul>
<p>While each of these investments is small, we hope that making them now will pay
dividends in more development time to work on GHC itself in the years to come.</p>
<h2 id="documenting-the-development-process">Documenting the development process</h2>
<p>The move to GitLab has meant that we redesign many of the conventions and
protocols used in the course of GHC’s development. In this process we have taken
the opportunity to more coherently document these conventions. From GHC’s
<a href="https://gitlab.haskell.org/ghc/ghc/wikis/contributing#working-conventions">Working Conventions</a> page contributors will now find links the comprehensive
documentation describing GHC’s <a href="https://gitlab.haskell.org/ghc/ghc/wikis/gitlab/issues">ticket
triage</a> and <a href="https://gitlab.haskell.org/ghc/ghc/wikis/gitlab/merge-requests">code
review</a>
protocols.</p>
<p>We have also rewritten our <a href="https://gitlab.haskell.org/ghc/ghc/wikis/contributing#newcomers-to-ghc">newcomer’s
documentation</a>,
making it easier for someone new to GHC development to get from forking the
compiler to submitting a patch.</p>
<h2 id="what-remains-to-be-done">What remains to be done</h2>
<p>While the dust from the migration has started to settle, there is still
<a href="https://gitlab.haskell.org/bgamari/gitlab-migration">plenty</a> to be done. While
the wiki import is done, there is still a great deal of cleanup that remains.
If you have a few idle minutes feel free to <a href="https://gitlab.haskell.org/ghc/ghc/wikis">browse
around</a> looking for import mistakes and spurious Trac references.</p>
<p>There is also much to be done to further improve the state of GHC’s
continuous integration jobs. From fixing broken tests on Windows, via contributing
a FreeBSD builder, to making the <code>head.hackage</code> job output more legible, there
are plenty of ways in which we appreciate helps.</p>
<p>Additionally for the 8.10 release cycle we would like to greatly increase the size of the
package set tested by <code>head.hackage</code> and automate the publication of the
<code>head.hackage.org</code> package repository. This will allow all users to easily test
their packages against GHC snapshots and prereleases and will further shrink
GHC’s development feedback cycle.</p>
<p>Finally, one of the casualties of the GitLab migration has been the 8.8 release
schedule, which was originally slated to culminate with the 8.8.1 in mid-March.
However, this is a topic I will leave to discuss in another blog post.</p>
<h2 id="closing-thoughts">Closing thoughts</h2>
<p>Needless to say, the last few months have been a whirlwind. However, we think
that the result is quite exciting. Not only is GHC’s test
infrastructure both more reliable and thorough than it has ever been, but the
tools with which the project is developed, released, and maintained are more
sustainable and far more inviting to newcomers than they were only six short
months ago.</p>
<p>If you are interested in contributing to GHC, but so far have been intimidated
by our tools, we encourage you to give it another go. Start from the
<a href="https://gitlab.haskell.org/ghc/ghc/wikis/contributing#newcomers-to-ghc">newcomer’s
guide</a>,
browse our list of <a href="https://gitlab.haskell.org/ghc/ghc/issues?label_name=newcomer">newcomer-friendly
tickets</a>, and
pick something that suits your skills. As always, if you ever get stuck or find
some documentation that is unclear, just ping us on <code>#ghc</code> on Freenode or on
<a href="https://mail.haskell.org/mailman/listinfo/ghc-devs">ghc-devs</a>.</p>
<h2 id="acknowledgements">Acknowledgements</h2>
<p>This migration would not have been possible without people both inside and
outside of the Haskell community:</p>
<ul>
<li>Matthew Pickering for his help in configuring and maintaining our GitLab instance, including many thankless hours debugging <code>marge-bot</code></li>
<li>Takenobu Tani for his attention to detail in spotting and fixing issues with GHC’s wiki and documentation both before and after the migration</li>
<li>Tobias Dammers for his work on the import script and help cleaning up the wiki</li>
<li><a href="https://packet.com/">Packet</a> for generously offering their excellent hosting services</li>
<li>Google X, Serokell, and Packet for their sponsorship of our CI infrastructure</li>
<li>Carter Schonwald for his work in looking after our macOS builder</li>
<li>Davean Scies and Futureice for their donations of GHC’s macOS builders</li>
<li>The members of the <a href="https://gitlab.haskell.org/ghc/ghc/wikis/dev-ops-group-charter">GHC devops
group</a> for
their consideration and feedback over the course of the migration.</li>
<li>David Planella and everyone at GitLab for their help executing the migration</li>
<li>All of GHC’s users and contributors for their patience while we worked our way through this migration</li>
</ul>
]]></description>
    <pubDate>Wed, 03 Apr 2019 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20190403-infra-status.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 8.6.4 released</title>
    <link>http://haskell.org/ghc/blog/20190305-ghc-8.6.4-released.html</link>
    <description><![CDATA[<h1>GHC 8.6.4 released</h1>
<h4 class="text-muted">Ben Gamari - 2019-03-05</h4>

<p>The GHC team is very happy to announce the availability of GHC 8.6.4, a
bugfix release in the GHC 8.6 series. The source distribution, binary
distributions, and documentation for this release are available at
<a href="https://downloads.haskell.org/~ghc/8.6.4">downloads.haskell.org</a>.</p>
<p>The 8.6.4 release fixes several regressions present in 8.6.3 including:</p>
<ul>
<li><p>A regression resulting in segmentation faults on Windows introduced
by the fix for <a href="https://gitlab.haskell.org/ghc/ghc/issues/16071">#16071</a> backported in 8.6.3. This fix has been reverted,
meaning that 8.6.4 is once again susceptible to <a href="https://gitlab.haskell.org/ghc/ghc/issues/16071">#16071</a>. <a href="https://gitlab.haskell.org/ghc/ghc/issues/16071">#16071</a> will
be fixed in GHC 8.8.1.</p></li>
<li><p>A bug resulting in incorrect locking on Darwin, potentially resulting
in hangs at shutdown (<a href="https://gitlab.haskell.org/ghc/ghc/issues/16150">#16150</a>)</p></li>
<li><p>A few bugs in the profiled runtime resulting in the potential for
memory unsafety has been fixed (<a href="https://gitlab.haskell.org/ghc/ghc/issues/15508">#15508</a>).</p></li>
<li><p>The <code>process</code> and <code>transformers</code> libraries shipped properly reflect
released Hackage releases (<a href="https://gitlab.haskell.org/ghc/ghc/issues/16199">#16199</a>)</p></li>
<li><p>A bug where TH name resolution would break in a plugin context has
been fixed (<a href="https://gitlab.haskell.org/ghc/ghc/issues/16104">#16104</a>)</p></li>
<li><p>Compilers that do not support TemplateHaskell no longer advertise
such support in <code>--supported-languages</code> (<a href="https://gitlab.haskell.org/ghc/ghc/issues/16331">#16331</a>)</p></li>
</ul>
<p>As a few of these issues are rather serious users are strongly
encouraged to upgrade. See
<a href="https://ghc.haskell.org/trac/ghc/query?status=closed&amp;milestone=8.6.4&amp;col=id&amp;col=summary&amp;col=status&amp;col=type&amp;col=priority&amp;col=milestone&amp;col=component&amp;order=priority">Trac</a>
for a full list of issues resolved
in this release.</p>
<p>Note that this release ships with one significant but long-standing bug
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/14251">#14251</a>): Calls to functions taking both Float# and Double# may result
in incorrect code generation when compiled using the LLVM code generator.
This is not a new issue, it has existed as long as the LLVM code
generator has existed; however, changes in code generation in 8.6 made
it more likely that user code using only lifted types will trigger it.</p>
<p>Note also that this is the first release cut from our (yet again)
revamped continuous integration infrastructure. While we have done a
great deal of checking to ensure that the build configuration reflects
that of previous releases, do let us know if something looks off.</p>
<p>Happy compiling!</p>
]]></description>
    <pubDate>Tue, 05 Mar 2019 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20190305-ghc-8.6.4-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 8.6.3 released</title>
    <link>http://haskell.org/ghc/blog/20181208-ghc-8.6.3-released.html</link>
    <description><![CDATA[<h1>GHC 8.6.3 released</h1>
<h4 class="text-muted">Ben Gamari - 2018-12-08</h4>

<p>The GHC team is very happy to announce the availability of GHC 8.6.3, a
bugfix release in the GHC 8.6 series. The source distribution, binary
distributions, and documentation for this release are <a href="https://downloads.haskell.org/~ghc/8.6.3">available</a>.</p>
<p>The 8.6 release fixes several regressions present in 8.6.2 including:</p>
<ul>
<li><p>A code generation bug resulting in segmentations faults in some
programs (<a href="https://gitlab.haskell.org/ghc/ghc/issues/15892">#15892</a>)</p></li>
<li><p>Darwin binary distributions are now correctly built against an
in-tree GMP (<a href="https://gitlab.haskell.org/ghc/ghc/issues/15404">#15404</a>)</p></li>
<li><p>Three bugs leading to linker failures on Windows (<a href="https://gitlab.haskell.org/ghc/ghc/issues/15105">#15105</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/15894">#15894</a>,
<a href="https://gitlab.haskell.org/ghc/ghc/issues/15934">#15934</a>)</p></li>
<li><p>A bug leading to programs with deep stacks crashing when run with
retainer profiling enabled (<a href="https://gitlab.haskell.org/ghc/ghc/issues/14758">#14758</a>)</p></li>
<li><p>A bug resulting in potential heap corruption during stable name
allocation (<a href="https://gitlab.haskell.org/ghc/ghc/issues/15906">#15906</a>)</p></li>
<li><p>Plugins are now loaded during GHCi sessions (<a href="https://gitlab.haskell.org/ghc/ghc/issues/15633">#15633</a>)</p></li>
</ul>
<p>As a few of these issues are rather serious users are strongly
encouraged to upgrade. See <a href="https://ghc.haskell.org/trac/ghc/query?status=closed&amp;milestone=8.6.3&amp;col=id&amp;col=summary&amp;col=status&amp;col=type&amp;col=priority&amp;col=milestone&amp;col=component&amp;order=priority">Trac</a> for a full list of issues resolved
in this release.</p>
<p>Note that this release ships with one significant but long-standing bug
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/14251">#14251</a>): Calls to functions taking both Float# and Double# may result
in incorrect code generation when compiled using the LLVM code generator.
This is not a new issue, it has existed as long as the LLVM code
generator has existed; however, changes in code generation in 8.6 made
it more likely that user code using only lifted types will trigger it.</p>
<p>Happy compiling!</p>
]]></description>
    <pubDate>Sat, 08 Dec 2018 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20181208-ghc-8.6.3-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 8.6.2 released</title>
    <link>http://haskell.org/ghc/blog/20181105-ghc-8.6.2-released.html</link>
    <description><![CDATA[<h1>GHC 8.6.2 released</h1>
<h4 class="text-muted">Ben Gamari - 2018-11-05</h4>

<p>The GHC team is very happy to announce the availability of GHC 8.6.2, a
bugfix release to GHC 8.6.1. The source distribution, binary
distributions, and documentation for this release are available at <a href="https://downloads.haskell.org/~ghc/8.6.2">haskell.org</a>.</p>
<p>The 8.6 release fixes several regressions present in 8.6.1 including:</p>
<ul>
<li><p>A long-standing (but previously hard to manifest) bug resulting in
undefined behavior for some applications of dataToTag# has been fixed
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/15696">#15696</a>)</p></li>
<li><p>An incorrect linker path to libgmp in the Mac OS binary distributions
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/15404">#15404</a>)</p></li>
<li><p>A regression rendering Windows installations to read-only directories
unusable (<a href="https://gitlab.haskell.org/ghc/ghc/issues/15667">#15667</a>)</p></li>
<li><p>A regression resulting in panics while compiling some record updates
of GADTs constructors (<a href="https://gitlab.haskell.org/ghc/ghc/issues/15499">#15499</a>)</p></li>
<li><p>A regression resulting in incorrect type errors when splicing types
into constraint contexts has been fixed (<a href="https://gitlab.haskell.org/ghc/ghc/issues/15815">#15815</a>)</p></li>
<li><p>Around a dozen other issues.</p></li>
</ul>
<p>See [<a href="https://ghc.haskell.org/trac/ghc/query?status=closed&amp;milestone=8.6.2&amp;col=id&amp;col=summary&amp;col=status&amp;col=type&amp;col=priority&amp;col=milestone&amp;col=component&amp;order=priority">|Trac</a>] for a full list of issues resolved in this release.</p>
<p>Note that this release ships with one significant but long-standing bug
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/14251">#14251</a>): Calls to functions taking both Float# and Double# may result
in incorrect code generation when compiled using the LLVM code generator.
This is not a new issue, it has existed as long as the LLVM code
generator has existed; however, changes in code generation in 8.6 made
it more likely that user code using only lifted types will trigger it.</p>
<p>Happy compiling!</p>
<p>Cheers,</p>
<ul>
<li>Ben</li>
</ul>
]]></description>
    <pubDate>Mon, 05 Nov 2018 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20181105-ghc-8.6.2-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 8.4.4 released</title>
    <link>http://haskell.org/ghc/blog/20181014-ghc-8.4.4-released.html</link>
    <description><![CDATA[<h1>GHC 8.4.4 released</h1>
<h4 class="text-muted">Ben Gamari - 2018-10-14</h4>

<p>The GHC team is pleased to announce the availability of GHC 8.4.4, a
patch-level release in the 8.4 series. The source distribution, binary
distributions, and documentation for this release are available at
<a href="https://downloads.haskell.org/~ghc/8.4.4">downloads.haskell.org</a>.</p>
<p>This release fixes several bugs present in 8.4.3. These include,</p>
<ul>
<li><p>A bug which could result in memory unsafety with certain uses of
<code>touch#</code> has been resolved. (<a href="https://gitlab.haskell.org/ghc/ghc/issues/14346">#14346</a>)</p></li>
<li><p>A compiler panic triggered by some GADT record updates has been
fixed (<a href="https://gitlab.haskell.org/ghc/ghc/issues/15499">#15499</a>)</p></li>
<li><p>The <code>text</code> library has been updated, fixing several serious bugs in
the version shipped with GHC 8.4.3 (see <code>text</code> issues <a href="https://gitlab.haskell.org/ghc/ghc/issues/227">#227</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/221">#221</a>,
and <a href="https://gitlab.haskell.org/ghc/ghc/issues/197">#197</a>.</p></li>
<li><p>A serious code generation bug in the LLVM code generation,
potentially resulting in incorrect evaluation of floating point
expressions, has been fixed (<a href="https://gitlab.haskell.org/ghc/ghc/issues/14251">#14251</a>)</p></li>
</ul>
<p>As always, the full release notes can be found in the <a href="https://downloads.haskell.org/~ghc/8.4.4/docs/html/users_guide/8.4.4-notes.html">users guide</a>.</p>
<p>Thanks to everyone who has contributed to developing, documenting, and
testing this release!</p>
<p>As always, let us know if you encounter trouble.</p>
]]></description>
    <pubDate>Sun, 14 Oct 2018 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20181014-ghc-8.4.4-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 8.6.1 released</title>
    <link>http://haskell.org/ghc/blog/20180922-ghc-8.6.1-released.html</link>
    <description><![CDATA[<h1>GHC 8.6.1 released</h1>
<h4 class="text-muted">Ben Gamari - 2018-09-22</h4>

<p>The GHC team is pleased to announce the availability of GHC 8.6.1, the
fourth major release in the GHC 8 series. The source distribution, binary
distributions, and documentation for this release are available at <a href="https://downloads.haskell.org/~ghc/8.6.1">downloads.haskell.org</a>.</p>
<p>The 8.6 release fixes over 400 bugs from the 8.4 series and introduces a
number of exciting features. These most notably include:</p>
<ul>
<li><p>A new deriving mechanism, <code>deriving via</code>, providing a convenient way
for users to extend Haskell’s typeclass deriving mechanism</p></li>
<li><p>Quantified constraints, allowing forall quantification in constraint contexts</p></li>
<li><p>An early version of the GHCi <code>:doc</code> command</p></li>
<li><p>The <code>ghc-heap-view</code> package, allowing introspection into the
structure of GHC’s heap</p></li>
<li><p>Valid hole fit hints, helping the user to find terms to fill typed
holes in their programs</p></li>
<li><p>The BlockArguments extension, allowing the <code>$</code> operator to be omitted
in some unambiguous contexts</p></li>
<li><p>An exciting new plugin mechanism, source plugins, allowing plugins to
inspect and modify a wide variety of compiler representations.</p></li>
<li><p>Improved recompilation checking when plugins are used</p></li>
<li><p>Significantly better handling of macOS linker command size limits,
avoiding linker errors while linking large projects</p></li>
<li><p>The next phase of the <code>MonadFail</code> proposal, enabling
<code>-XMonadFailDesugaring</code> by default</p></li>
</ul>
<p>A full list of the changes in this release can be found in the
<a href="https://downloads.haskell.org/~ghc/8.6.1/docs/html/users_guide/8.6.1-notes.html">release notes</a>.</p>
<p>Perhaps of equal importance, GHC 8.6 is the second major release made
under GHC’s accelerated six-month release schedule and the first set of
binary distributions built primarily using our new continuous
integration scheme. While the final 8.6 release is around three weeks
later than initially scheduled due to late-breaking bug reports, we
expect that the 8.8 release schedule shouldn’t be affected.</p>
<p><code>cabal-install</code> users should note that GHC 8.6 can only be used with <code>cabal-install</code> 2.4.0.1 or later.</p>
<p>Thanks to everyone who has contributed to developing, documenting, and
testing this release!</p>
<p>As always, let us know if you encounter trouble.</p>
]]></description>
    <pubDate>Sat, 22 Sep 2018 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20180922-ghc-8.6.1-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 8.4.3 released</title>
    <link>http://haskell.org/ghc/blog/20180529-ghc-8.4.3-released.html</link>
    <description><![CDATA[<h1>GHC 8.4.3 released</h1>
<h4 class="text-muted">Ben Gamari - 2018-05-29</h4>

<p>Hello everyone,</p>
<p>The GHC team is pleased to announce the availability of GHC 8.4.3. The
source distribution, binary distributions, and documentation for this
release are available <a href="https://downloads.haskell.org/~ghc/8.4.3">here</a>.</p>
<p>This release includes a few bug fixes including:</p>
<ul>
<li><p>A code generation bug resulting in crashing of some programs using
<code>UnboxedSums</code> has been fixed (<a href="https://gitlab.haskell.org/ghc/ghc/issues/15038">#15038</a>).</p></li>
<li><p><a href="https://gitlab.haskell.org/ghc/ghc/issues/14381">#14381</a>, where Cabal and GHC would disagree about <code>abi-depends</code>,
resulting in build failures, has been worked around. Note that the
work-around patch has already been shipped by several distributions
in previous releases, so this change may not be visible to you.</p></li>
<li><p>By popular demand, GHC now logs a message when it reads a package
environment file, hopefully eliminating some of the confusion wrought
by this feature.</p></li>
<li><p>GHC now emits assembler agreeable to newer versions of Gnu binutils,
fixing <a href="https://gitlab.haskell.org/ghc/ghc/issues/15068">#15068</a>.</p></li>
<li><p><code>SmallArray#</code>s can now be compacted into a compact region</p></li>
</ul>
<p>Thanks to everyone who has contributed to developing, documenting, and
testing this release!</p>
<p>As always, let us know if you encounter trouble.</p>
]]></description>
    <pubDate>Tue, 29 May 2018 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20180529-ghc-8.4.3-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 8.4.2 released</title>
    <link>http://haskell.org/ghc/blog/20180420-ghc-8.4.2-released.html</link>
    <description><![CDATA[<h1>GHC 8.4.2 released</h1>
<h4 class="text-muted">Ben Gamari - 2018-04-20</h4>

<p>The GHC team is pleased to announce the availability of GHC 8.4.2. The
source distribution, binary distributions, and documentation for this
release are available at</p>
<pre><code>https://downloads.haskell.org/~ghc/8.4.2</code></pre>
<p>This release is a bug-fix release, fixing numerous regressions and bugs
present in GHC 8.4.1. These include:</p>
<ul>
<li><p>A regression resulting in some uses of <code>Control.Exception.evaluate</code>
to be inappropriately optimised away (see <a href="https://gitlab.haskell.org/ghc/ghc/issues/13930">#13930</a>)</p></li>
<li><p>A regression resulting in segmentation faults of programs compiled
with profiling (<a href="https://gitlab.haskell.org/ghc/ghc/issues/14705">#14705</a>)</p></li>
<li><p>A bug causing runtime system panics while running programs with
retainer profiling (<a href="https://gitlab.haskell.org/ghc/ghc/issues/14947">#14947</a>)</p></li>
<li><p>The configure scripts now accepts a <code>--disable-dtrace</code> option, again
allowing GHC to be bootstrapped on FreeBSD (<a href="https://gitlab.haskell.org/ghc/ghc/issues/15040">#15040</a>)</p></li>
<li><p>The version number of the <code>base</code> package has been bumped to
4.11.1.0 to reflect the addition of the <code>GHC.IO.FixIOException</code> type.
This interface was added in 8.4.1 but the version bump was missed due to
an oversight.</p></li>
<li><p>Support for DWARF debug information has been significantly improved
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/14894">#14894</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/14779">#14779</a>)</p></li>
</ul>
<p>A more thorough list of the changes in this release can be found in the
release notes,</p>
<p>https://downloads.haskell.org/~ghc/8.4.2/docs/html/users_guide/8.4.2-notes.html</p>
<p>Thanks to everyone who has contributed to developing, documenting, and
testing this release!</p>
<p>As always, let us know if you encounter trouble.</p>
<h3 id="how-to-get-it">How to get it</h3>
<p>This release can be downloaded from</p>
<pre><code>https://www.haskell.org/ghc/download_ghc_8_4_2.html</code></pre>
<p>For older versions see</p>
<pre><code>https://www.haskell.org/ghc/</code></pre>
<p>We supply binary builds in the native package format for many platforms, and the
source distribution is available from the same place.</p>
<h3 id="background">Background</h3>
<p>Haskell is a standard lazy functional programming language.</p>
<p>GHC is a state-of-the-art programming suite for Haskell. Included is
an optimising compiler generating efficient code for a variety of
platforms, together with an interactive system for convenient, quick
development. The distribution includes space and time profiling
facilities, a large collection of libraries, and support for various
language extensions, including concurrency, exceptions, and foreign
language interfaces. GHC is distributed under a BSD-style open source license.</p>
<p>A wide variety of Haskell related resources (tutorials, libraries,
specifications, documentation, compilers, interpreters, references,
contact information, links to research groups) are available from the
Haskell home page (see below).</p>
<p>On-line GHC-related resources
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</p>
<p>Relevant URLs on the World-Wide Web:</p>
<ul>
<li><a href="https://www.haskell.org/ghc/">GHC home page</a></li>
<li><a href="https://ghc.haskell.org/trac/ghc/">GHC developers’ home page</a></li>
<li><a href="https://www.haskell.org/">Haskell home page</a></li>
</ul>
<h3 id="supported-platforms">Supported Platforms</h3>
<p>The list of platforms we support, and the people responsible for them,
is <a href="https://ghc.haskell.org/trac/ghc/wiki/Contributors">here</a></p>
<p>Ports to other platforms are possible with varying degrees of
difficulty. The <a href="http://ghc.haskell.org/trac/ghc/wiki/Building">Building Guide</a> describes how to go about porting to a
new platform.</p>
<h3 id="developers">Developers</h3>
<p>We welcome new contributors. Instructions on accessing our source
code repository, and getting started with hacking on GHC, are
available from the GHC’s developer’s site run by <a href="http://ghc.haskell.org/trac/ghc/">Trac</a>.</p>
<h3 id="community-resources">Community Resources</h3>
<p>There are mailing lists for GHC users, develpoers, and monitoring bug tracker
activity; to subscribe, use the Mailman
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo">web interface</a>.</p>
<p>There are several other Haskell and GHC-related mailing lists on
<a href="http://www.haskell.org">haskell.org</a>; for the full list, see the
<a href="https://mail.haskell.org/cgi-bin/mailman/listinfo">lists page</a>.</p>
<p>Some GHC developers hang out on the <code>#ghc</code> and <code>#haskell</code> of the Freenode IRC
network, too. See the <a href="http://www.haskell.org/haskellwiki/IRC_channel">Haskell wiki</a> for details.</p>
<p>Please report bugs using our bug tracking system. Instructions on reporting bugs
can be found <a href="http://www.haskell.org/ghc/reportabug">here</a>.</p>
]]></description>
    <pubDate>Fri, 20 Apr 2018 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20180420-ghc-8.4.2-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 8.4.1 released</title>
    <link>http://haskell.org/ghc/blog/20180308-ghc-8.4.1-released.html</link>
    <description><![CDATA[<h1>GHC 8.4.1 released</h1>
<h4 class="text-muted">Ben Gamari - 2018-03-08</h4>

<p>The GHC developers are very happy to announce the 8.4.1 release of
Glasgow Haskell Compiler. Binary and source distributions can be found
at</p>
<pre><code>https://downloads.haskell.org/~ghc/8.4.1/</code></pre>
<p>This is the third major release in the GHC 8 series. As such, the focus
of this release is performance, stability, and consolidation.
Consequently numerous cleanups can be seen throughout the compiler
including,</p>
<ul>
<li><p>Further refinement of TypeInType, including significant improvements
in error messages.</p></li>
<li><p>Improvements in code generation resulting in noticeable performance
improvements in some types of programs.</p></li>
<li><p>Core library improvements, including phase 2 of the Semigroup/Monoid
proposal</p></li>
<li><p>Many improvements to instance deriving</p></li>
<li><p>The resolution of nearly 300 other tickets</p></li>
</ul>
<p>A more thorough list of the changes in this release can be found in the
release notes,</p>
<p>https://downloads.haskell.org/~ghc/8.4.1/docs/html/users_guide/8.4.1-notes.html</p>
<p>There are a few changes in release-engineering matters that should be
noted,</p>
<ul>
<li><p>This is GHC’s first release on it’s new, accelerated release
schedule. From now on GHC will produce one release every six months.</p></li>
<li><p>While we typically strive to produce OpenBSD builds, the gcc shipped
with OpenBSD 6.1 is unfortunately too old to compile this release.</p></li>
<li><p>FreeBSD builds are still in progress</p></li>
</ul>
<p>This release has been the result of approximately six months of work by
over one hundred code contributors. Thanks to everyone who has helped in
writing patches, testing, reporting bugs, and offering feedback over the
last year.</p>
<p>As always, let us know if you encounter trouble.</p>
<h3 id="how-to-get-it">How to get it</h3>
<p>This release can be downloaded from</p>
<pre><code>https://www.haskell.org/ghc/download_ghc_8_4_1.html</code></pre>
<p>For older versions see</p>
<pre><code>https://www.haskell.org/ghc/</code></pre>
<p>We supply binary builds in the native package format for many platforms, and the
source distribution is available from the same place.</p>
<h3 id="background">Background</h3>
<p>Haskell is a standard lazy functional programming language.</p>
<p>GHC is a state-of-the-art programming suite for Haskell. Included is
an optimising compiler generating efficient code for a variety of
platforms, together with an interactive system for convenient, quick
development. The distribution includes space and time profiling
facilities, a large collection of libraries, and support for various
language extensions, including concurrency, exceptions, and foreign
language interfaces. GHC is distributed under a BSD-style open source license.</p>
<p>A wide variety of Haskell related resources (tutorials, libraries,
specifications, documentation, compilers, interpreters, references,
contact information, links to research groups) are available from the
Haskell home page (see below).</p>
<p>On-line GHC-related resources
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</p>
<p>Relevant URLs on the World-Wide Web:</p>
<ul>
<li><a href="https://www.haskell.org/ghc/">GHC home page</a></li>
<li><a href="https://ghc.haskell.org/trac/ghc/">GHC developers’ home page</a></li>
<li><a href="https://www.haskell.org/">Haskell home page</a></li>
</ul>
<h3 id="supported-platforms">Supported Platforms</h3>
<p>The list of platforms we support, and the people responsible for them,
is <a href="https://ghc.haskell.org/trac/ghc/wiki/Contributors">here</a></p>
<p>Ports to other platforms are possible with varying degrees of
difficulty. The <a href="http://ghc.haskell.org/trac/ghc/wiki/Building">Building Guide</a> describes how to go about porting to a
new platform.</p>
<h3 id="developers">Developers</h3>
<p>We welcome new contributors. Instructions on accessing our source
code repository, and getting started with hacking on GHC, are
available from the GHC’s developer’s site run by <a href="http://ghc.haskell.org/trac/ghc/">Trac</a>.</p>
<h3 id="community-resources">Community Resources</h3>
<p>There are mailing lists for GHC users, develpoers, and monitoring bug tracker
activity; to subscribe, use the Mailman
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo">web interface</a>.</p>
<p>There are several other Haskell and GHC-related mailing lists on
<a href="http://www.haskell.org">haskell.org</a>; for the full list, see the
<a href="https://mail.haskell.org/cgi-bin/mailman/listinfo">lists page</a>.</p>
<p>Some GHC developers hang out on the <code>#ghc</code> and <code>#haskell</code> of the Freenode IRC
network, too. See the <a href="http://www.haskell.org/haskellwiki/IRC_channel">Haskell wiki</a> for details.</p>
<p>Please report bugs using our bug tracking system. Instructions on reporting bugs
can be found <a href="http://www.haskell.org/ghc/reportabug">here</a>.</p>
]]></description>
    <pubDate>Thu, 08 Mar 2018 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20180308-ghc-8.4.1-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 8.2.2 is available</title>
    <link>http://haskell.org/ghc/blog/20171121-ghc-8.2.2-released.html</link>
    <description><![CDATA[<h1>GHC 8.2.2 is available</h1>
<h4 class="text-muted">Ben Gamari - 2017-11-21</h4>

<p>The GHC Team is pleased to announce a new minor release of GHC. This release
builds on the performance and stability improvements of 8.2.1, fixing a variety
of correctness bugs, improving error messages, and making the compiler more
portable.</p>
<p>Notable bug-fixes include</p>
<ul>
<li><p>A correctness issue resulting in segmentation faults in some
FFI-users (<a href="https://gitlab.haskell.org/ghc/ghc/issues/13707">#13707</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/14346">#14346</a>)</p></li>
<li><p>A correctness issue resulting in undefined behavior in some programs
using STM (<a href="https://gitlab.haskell.org/ghc/ghc/issues/14171">#14171</a>)</p></li>
<li><p>A bug which may have manifested in segmentation faults in
out-of-memory condition (<a href="https://gitlab.haskell.org/ghc/ghc/issues/14329">#14329</a>)</p></li>
<li><p>clearBit of Natural no longer bottoms (<a href="https://gitlab.haskell.org/ghc/ghc/issues/13203">#13203</a>)</p></li>
<li><p>A specialisation bug resulting in exponential blowup of compilation
time in some specialisation-intensive programs (<a href="https://gitlab.haskell.org/ghc/ghc/issues/14379">#14379</a>)</p></li>
<li><p>ghc-pkg now works even in environments with misconfigured NFS mounts
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/13945">#13945</a>)</p></li>
<li><p>GHC again supports production of position-independent executables
(<a href="https://gitlab.haskell.org/ghc/ghc/issues/13702">#13702</a>)</p></li>
<li><p>Better error messages around kind mismatches (<a href="https://gitlab.haskell.org/ghc/ghc/issues/11198">#11198</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/12373">#12373</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/13530">#13530</a>,
<a href="https://gitlab.haskell.org/ghc/ghc/issues/13610">#13610</a>)</p></li>
</ul>
<p>A thorough list of the changes in the release can be found in the release
notes,</p>
<pre><code>https://haskell.org/ghc/docs/8.2.2/html/users_guide/8.2.2-notes.html</code></pre>
<h3 id="how-to-get-it">How to get it</h3>
<p>This release can be downloaded from</p>
<pre><code>https://www.haskell.org/ghc/download_ghc_8_2_2.html</code></pre>
<p>For older versions see</p>
<pre><code>https://www.haskell.org/ghc/</code></pre>
<p>We supply binary builds in the native package format for many platforms, and the
source distribution is available from the same place.</p>
<h3 id="background">Background</h3>
<p>Haskell is a standard lazy functional programming language.</p>
<p>GHC is a state-of-the-art programming suite for Haskell. Included is
an optimising compiler generating efficient code for a variety of
platforms, together with an interactive system for convenient, quick
development. The distribution includes space and time profiling
facilities, a large collection of libraries, and support for various
language extensions, including concurrency, exceptions, and foreign
language interfaces. GHC is distributed under a BSD-style open source license.</p>
<p>A wide variety of Haskell related resources (tutorials, libraries,
specifications, documentation, compilers, interpreters, references,
contact information, links to research groups) are available from the
Haskell home page (see below).</p>
<p>On-line GHC-related resources
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</p>
<p>Relevant URLs on the World-Wide Web:</p>
<ul>
<li><a href="https://www.haskell.org/ghc/">GHC home page</a></li>
<li><a href="https://ghc.haskell.org/trac/ghc/">GHC developers’ home page</a></li>
<li><a href="https://www.haskell.org/">Haskell home page</a></li>
</ul>
<h3 id="supported-platforms">Supported Platforms</h3>
<p>The list of platforms we support, and the people responsible for them,
is <a href="https://ghc.haskell.org/trac/ghc/wiki/Contributors">here</a></p>
<p>Ports to other platforms are possible with varying degrees of
difficulty. The <a href="http://ghc.haskell.org/trac/ghc/wiki/Building">Building Guide</a> describes how to go about porting to a
new platform.</p>
<h3 id="developers">Developers</h3>
<p>We welcome new contributors. Instructions on accessing our source
code repository, and getting started with hacking on GHC, are
available from the GHC’s developer’s site run by <a href="http://ghc.haskell.org/trac/ghc/">Trac</a>.</p>
<h3 id="community-resources">Community Resources</h3>
<p>There are mailing lists for GHC users, develpoers, and monitoring bug tracker
activity; to subscribe, use the Mailman
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo">web interface</a>.</p>
<p>There are several other Haskell and GHC-related mailing lists on
<a href="http://www.haskell.org">haskell.org</a>; for the full list, see the
<a href="https://mail.haskell.org/cgi-bin/mailman/listinfo">lists page</a>.</p>
<p>Some GHC developers hang out on the <code>#ghc</code> and <code>#haskell</code> of the Freenode IRC
network, too. See the <a href="http://www.haskell.org/haskellwiki/IRC_channel">Haskell wiki</a> for details.</p>
<p>Please report bugs using our bug tracking system. Instructions on reporting bugs
can be found <a href="http://www.haskell.org/ghc/reportabug">here</a>.</p>
]]></description>
    <pubDate>Tue, 21 Nov 2017 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20171121-ghc-8.2.2-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>Meet Jenkins: GHC's new CI and build infrastructure</title>
    <link>http://haskell.org/ghc/blog/20170801-jenkins-ci.html</link>
    <description><![CDATA[<h1>Meet Jenkins: GHC's new CI and build infrastructure</h1>
<h4 class="text-muted">Ben Gamari - 2017-08-01</h4>

<p>While Phabricator is generally well-liked among GHC developers, GHC’s
interaction with Harbormaster, Phabricator’s continuous integration
component, has been less than rosy. The problem is in large part a mismatch
between Harbormaster’s design assumptions and GHC’s needs, but it’s also
in part attributable to the somewhat half-finished state in which
Harbormaster seems to linger. Regardless, we won’t go into detail here;
these issues are well covered <a href="https://gitlab.haskell.org/ghc/ghc/wikis/ticket:13716">elsewhere</a>.</p>
<p>Suffice it to say that, after having looked at a number of alternatives to
Harbormaster (including <a href="https://buildbot.net/">buildbot</a>, GitLab’s
<a href="https://gitlab.com/">Pipelines</a>, <a href="https://concourse.ci/">Concourse</a>,
and home-grown solutions), Jenkins seems to be the best option at
the moment. Of course, this is not to say that it is perfect; as we have
learned over the last few months it is very far from perfect. However,
it has the maturity and user-base to be almost-certainly able to handle
what we need of it on the platforms that we care about.</p>
<p>See the Trac ticket <a href="https://gitlab.haskell.org/ghc/ghc/issues/13716">#13716</a></p>
<p>Let’s see what we get out of this new bit of infrastructure:</p>
<h4 id="pre-merge-testing">Pre-merge testing</h4>
<p>Currently there are two ways that code ends up in <code>master</code>,</p>
<ul>
<li>a Differential is opened, built with Harbormaster, and eventually
landed (hopefully, but not always, after Harbormaster successfully finishes)</li>
<li>someone pushes commits directly</li>
</ul>
<p>Bad commits routinely end up merged via both channels. This means that
authors of patches failing CI often need to consider whether <em>their</em>
patch is incorrect or whether they rather simply had the misfortune of
basing their patch on a bad commit. Even worse, if the commit isn’t
quickly reverted or fixed GHC will end up with a hole in its commit
history where neither bisection nor performance tracking will be possible.
For these reasons, we want to catch these commits before they make it
into <code>master</code>.</p>
<p>To accomplish this we have developed some
<a href="https://github.com/bgamari/ghc-auto-push">tooling</a> to run CI on
commits <em>before</em> they are finally merged to <code>master</code>. By making CI the
only path patches can take to get to <code>master</code>, improve our changes of
rejecting bad patches before they turn the tree red.</p>
<h4 id="automation-of-the-release-builds">Automation of the release builds</h4>
<p>Since the 7.10.3 release we have been gradually working towards
automating GHC’s release process. Thanks to this work, today a single
person can build binary distributions for all seven tier-1
configurations in approximately a day, most of which is spent simply
waiting. This has allowed us to take responsibility (starting in
8.2.1) for the OpenBSD, FreeBSD, ARMv7 and AArch64 builds in addition to
the traditional tier-1 platforms, allowing us to eliminate the week-long
wait between source distribution availability and the binary
distribution announcement previously needed for correspondence with
binary build contributors..</p>
<p>However, we are far from done: our new Jenkins-based build infrastructure
(see <a href="https://gitlab.haskell.org/ghc/ghc/issues/13716">#13716</a>) will allow us to produce binary distributions directly from CI,
reducing the cost of producing release builds to nearly nothing.</p>
<h4 id="testing-of-ghc-against-user-packages">Testing of GHC against user packages</h4>
<p>While GHC is already tested against Hackage and Stackage prior to release
candidate availability, these builds have been of limited use as
packages low on the dependency tree (think <code>hashable</code> and <code>lens</code>)
often don’t build prior to the first release candidate. While we do our
best to fix these packages up, the sheer number of them makes
this a losing battle for a small team such as GHC’s.</p>
<p>Having the ability to cheaply produce binary distributions means that we
can produce and validate nightly snapshot releases. This gives users a
convenient way to test pre-release compilers and fix their libraries
accordingly. We hope this will spread the maintenance effort across a
larger fraction of the Haskell community and over a longer period of
time, meaning there will be less to do at release time and consequently
pre-release Stackage builds will be more fruitful.</p>
<p>Once the Jenkins infrastructure is stable, we can consider introducing
nightly builds of user packages as well. While building a large
population such as Stackage would likely not be productive, working with
a smaller sample of popular, low-dependency-count packages would be
quite possible. For testing against larger package repositories, leaning on a dedicated tool such as the
<a href="https://matrix.hackage.haskell.org/">Hackage Matrix Builder</a> will
likely be a more productive path.</p>
<h4 id="expanded-platform-coverage-of-ci">Expanded platform coverage of CI</h4>
<p>While GHC targets a wide variety of architectures and operating systems
(and don’t forget cross-compilation targets),
by far the majority of developers use Linux, Darwin, or Windows on
amd64. This means that breakage often only comes to light long after the
culpable patch was merged.</p>
<p>Of course, GHC, being a project with modest financial resources, can’t
test each commit on every supported platform. We can, however, shrink
the time between a bad commit being merged and the breakage being found
by testing these “unusual” platforms on a regular (e.g. nightly) basis.</p>
<p>By catching regressions early, we hope to reduce the amount of time
spent bisecting and fixing bugs around release time.</p>
<h4 id="tracking-core-libraries">Tracking core libraries</h4>
<p>Keeping GHC’s core library dependencies (e.g. <code>directory</code>, <code>process</code>) up-to-date with their respective upstreams
is important to ensure that tools that link against the <code>ghc</code> library (e.g. <code>ghc-mod</code>) can build easily.
However, it also requires that we work with nearly a dozen upstream
maintainers at various points in their own release cycles to arrange
that releases are made prior to the GHC release. Moreover, there is
inevitably a fair amount of work propagating verion bounds changes down
the dependency tree. While this work takes relatively little effort in
terms of man-hours,</p>
<p>Jenkins can help us here by allowing us to automate integration testing
of upstream libraries, catching bounds issues and other compatibility
issues well before they are in the critical path of the release.</p>
<h4 id="improved-debugging-tools">Improved debugging tools</h4>
<p>One of the most useful ways to track down a bugs in GHC is bisection.
This is especially true for regressions found in release candidates,
where you have at most a few thousand commits to bisect through.
Nevertheless, GHC builds are long and developer time scarce so this
approach isn’t used as often as it could be.</p>
<p>Having an archive of nightly GHC builds will free the developer from
having to build dozens of compilers during bisection, making the process
a significantly more enjoyable experience than it is today. This will
allow us to solve more bugs in less time and with far fewer grey hairs.</p>
<h3 id="status-of-jenkins-effort">Status of Jenkins effort</h3>
<p>The Jenkins CI overhaul has been an on-going project throughout the
spring and summer and is nearing completion. The Jenkins configuration
can be seen in the <code>wip/jenkins</code> branch on <code>git.haskell.org</code>
(<a href="https://git.haskell.org/ghc.git/shortlog/refs/heads/wip/jenkins">gitweb</a>). At the moment the prototype is running on a few private machines but we will be setting up a publicly accessible test instance in the coming
weeks. Jenkins will likely coexist with our current Harbormaster
infrastructure for a month or so while we validate that things are
stable.</p>
]]></description>
    <pubDate>Tue, 01 Aug 2017 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20170801-jenkins-ci.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>Reflections on GHC's release schedule</title>
    <link>http://haskell.org/ghc/blog/20170801-2017-release-schedule.html</link>
    <description><![CDATA[<h1>Reflections on GHC's release schedule</h1>
<h4 class="text-muted">Ben Gamari - 2017-08-01</h4>

<p>Looking back on GHC’s past release schedule reveals a rather checkered past,</p>
<div class="table">
<table>
<colgroup>
<col style="width: 14%" />
<col style="width: 47%" />
<col style="width: 38%" />
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Release</th>
<th style="text-align: left;">Date</th>
<th style="text-align: left;">Time to next major release</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">6.12.1</td>
<td style="text-align: left;">mid December 2009</td>
<td style="text-align: left;"></td>
</tr>
<tr class="even">
<td style="text-align: left;"></td>
<td style="text-align: left;"></td>
<td style="text-align: left;">12 months</td>
</tr>
<tr class="odd">
<td style="text-align: left;">7.0.1</td>
<td style="text-align: left;">mid November 2010</td>
<td style="text-align: left;"></td>
</tr>
<tr class="even">
<td style="text-align: left;"></td>
<td style="text-align: left;"></td>
<td style="text-align: left;">9.5 months</td>
</tr>
<tr class="odd">
<td style="text-align: left;">7.2.1</td>
<td style="text-align: left;">early August 2011</td>
<td style="text-align: left;"></td>
</tr>
<tr class="even">
<td style="text-align: left;"></td>
<td style="text-align: left;"></td>
<td style="text-align: left;">6 months</td>
</tr>
<tr class="odd">
<td style="text-align: left;">7.4.1</td>
<td style="text-align: left;">early February 2012</td>
<td style="text-align: left;"></td>
</tr>
<tr class="even">
<td style="text-align: left;"></td>
<td style="text-align: left;"></td>
<td style="text-align: left;">7 months</td>
</tr>
<tr class="odd">
<td style="text-align: left;">7.6.1</td>
<td style="text-align: left;">early September 2012</td>
<td style="text-align: left;"></td>
</tr>
<tr class="even">
<td style="text-align: left;"></td>
<td style="text-align: left;"></td>
<td style="text-align: left;">19 months</td>
</tr>
<tr class="odd">
<td style="text-align: left;">7.8.1</td>
<td style="text-align: left;">early April 2014</td>
<td style="text-align: left;"></td>
</tr>
<tr class="even">
<td style="text-align: left;"></td>
<td style="text-align: left;"></td>
<td style="text-align: left;">13 months</td>
</tr>
<tr class="odd">
<td style="text-align: left;">7.10.1</td>
<td style="text-align: left;">late March 2015</td>
<td style="text-align: left;"></td>
</tr>
<tr class="even">
<td style="text-align: left;"></td>
<td style="text-align: left;"></td>
<td style="text-align: left;">14 months</td>
</tr>
<tr class="odd">
<td style="text-align: left;">8.0.1</td>
<td style="text-align: left;">late May 2016</td>
<td style="text-align: left;"></td>
</tr>
<tr class="even">
<td style="text-align: left;"></td>
<td style="text-align: left;"></td>
<td style="text-align: left;">14 months</td>
</tr>
<tr class="odd">
<td style="text-align: left;">8.2.1</td>
<td style="text-align: left;">late July 2017</td>
<td style="text-align: left;"></td>
</tr>
<tr class="even">
<td style="text-align: left;"></td>
<td style="text-align: left;"></td>
<td style="text-align: left;">-</td>
</tr>
<tr class="odd">
<td style="text-align: left;">8.4.1</td>
<td style="text-align: left;">TDB and the topic of this post</td>
<td style="text-align: left;"></td>
</tr>
</tbody>
</table>
</div>
<p>There are a few things to notice here:</p>
<ul>
<li>release cadence has swung rather wildly</li>
<li>the release cycle has stretched in the last several releases</li>
<li>time-between-releases generally tends to be on the order of a year</li>
</ul>
<p>While GHC is far from the only compiler with such an extended release
schedule, others (namely LLVM, Go, and, on the extreme end, Rust) have shown
that shorter cycles are possible. I personally think that a more
stable, shorter release cycle would be better for developers and users
alike,</p>
<ul>
<li>developers have a tighter feedback loop, inducing less pressure
to get new features and non-critical bugfixes into minor releases</li>
<li>release managers have fewer patches to cherry-pick</li>
<li>users see new features and bugfixes more quickly</li>
</ul>
<p>With 8.2.1 at long last behind us, now is a good time to reflect
on why these cycles are so long, what release schedule we would like
to have, and what we can change to realize such a schedule. On the way we’ll take some time to examine the circumstances that lead to the 8.2.1 release which, while not typical, remind us that there is a certain amount of unpredictability inherent in developing large systems like GHC; a fact that must be born in mind when considering release policy.</p>
<p>Let’s dig in…</p>
<h3 id="the-release-process-today">The release process today</h3>
<p>Cutting a GHC release is a fairly lengthy process involving many
parties and a significant amount of planning. The typical process
for a major release looks something like this,</p>
<ol type="1">
<li><em>(a few months after the previous major release)</em> A set
of release priorities are defined determining which major features
we want in the coming release</li>
<li>wait until all major features are merged to the <code>master</code> branch</li>
<li>when all features are merged, cut a stable branch</li>
<li>in parallel:
<ol type="a">
<li>coordinate with core library authors to determine which library
versions the new release should ship</li>
<li>prepare release documentation</li>
<li>do preliminary testing against Hackage and Stackage to identify and
fix early bugs</li>
<li>backport significant fixes merged to <code>master</code></li>
</ol></li>
<li>when the tasks in (4) are sufficiently advanced, cut a source
release for a release candidate</li>
<li>produce tier-1 builds and send source tarballs to binary packagers,
wait a week to prepare binary builds; if anyone finds the tree is
unbuildable, go back to (5)</li>
<li>upload release artifacts, announce release candidate</li>
<li>wait a few weeks for testing</li>
<li>if there are significant issues: fix them and return to (5)</li>
<li>finalize release details (e.g. release notes, last check over core library versions)</li>
<li>cut source tarball, send to binary build contributors, wait a week for builds</li>
<li>announce final release, celebrate!</li>
</ol>
<p>Typically the largest time-sinks in this process are waiting for
regression fixes and coordinating with core library authors. In
particular, the coordination involved in the latter isn’t difficult, but
merely high latency.</p>
<p>In the case of 8.2.1, the timeline looked something like this,</p>
<div class="table">
<table>
<thead>
<tr class="header">
<th style="text-align: left;">Time</th>
<th style="text-align: left;">Event</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">Fall 2016</td>
<td style="text-align: left;">release priorities for 8.2 discussed</td>
</tr>
<tr class="even">
<td style="text-align: left;">Early March 2017</td>
<td style="text-align: left;">stable branch cut</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Early April 2017</td>
<td style="text-align: left;">most core library versions set</td>
</tr>
<tr class="even">
<td style="text-align: left;"></td>
<td style="text-align: left;">release candidate 1 cut</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Mid May 2017</td>
<td style="text-align: left;">release candidate 2 cut</td>
</tr>
<tr class="even">
<td style="text-align: left;">Early July 2017</td>
<td style="text-align: left;">release candidate 3 cut</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Late July 2017</td>
<td style="text-align: left;">final release cut</td>
</tr>
</tbody>
</table>
</div>
<h3 id="unexpected-set-backs">Unexpected set-backs</h3>
<p>This timeline was a bit more extended than desired for a few
reasons.</p>
<p>The first issues were <a href="https://gitlab.haskell.org/ghc/ghc/issues/13426">#13426</a> and <a href="https://gitlab.haskell.org/ghc/ghc/issues/13535">#13535</a>, compile-time performance regressions which
came to light shortly after the branch and after the first release
candidate, respectively. In <a href="https://gitlab.haskell.org/ghc/ghc/issues/13535">#13535</a> it was observed that the testsuite of
the <code>vector</code> package (already
<a href="https://ghc.haskell.org/trac/ghc/ticket/10800">known</a> for its
propensity to reveal compiler regressions) increased by nearly a factor
of five in compile-time allocations over 8.0.2.</p>
<p>While a performance regression would rarely classify as a release
blocker, both the severity of the regressions combined with the fact that
8.2 was intended to be a performance-oriented release made releasing
before fixes were available quite unappealing. For this reason David
Feuer, Reid Barton, and I invested significant effort to try to track down the
culprits. Unfortunately, the timescale on which this sort of bug is
resolved span days, stretching to weeks when time is split with other
responsibilities. While Reid’s valiant efforts lead to the resolution of
<a href="https://gitlab.haskell.org/ghc/ghc/issues/13426">#13426</a>, we were eventually forced to set <a href="https://gitlab.haskell.org/ghc/ghc/issues/13535">#13535</a> aside as the release
cycle wore on.</p>
<p>The second setback came in the form of two quite grave correctness
issues (<a href="https://gitlab.haskell.org/ghc/ghc/issues/13615">#13615</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/13916">#13916</a>) late in the cycle. GHC being a compiler, we take
correctness very seriously: Users’ confidence that GHC will
compile their programs faithfully is crucial for language adoption, yet
also very easily shaken. Consequently, while neither of these issues
were regressions from 8.0, we deemed it important to hold the 8.2
release until these issues were resolved (which ended up being significant efforts in their own right; a blog post on this will be coming soon).</p>
<p>Finally, there was the realization (<a href="https://gitlab.haskell.org/ghc/ghc/issues/13739">#13739</a>) after release candidate 2
that some BFD linker releases suffered from very poor performance when
linking with split-sections enabled (the default behavior in 8.2.1).
This served as a forcing function to act on <a href="https://gitlab.haskell.org/ghc/ghc/issues/13541">#13541</a>, which we originally
planned for 8.4. As expected, it took quite some time to follow through
on this in a way that satisfied users and distribution packagers in a
portable manner.</p>
<h3 id="moving-forward-compressing-the-release-schedule">Moving forward: Compressing the release schedule</h3>
<p>Collectively the above issues set the release back by perhaps six or
eight weeks in total, including the additional release candidate
necessary to validate the raft of resulting patches. While set-backs due
to long-standing bugs are hard to avoid, there are a few areas where we
can do better,</p>
<ol type="a">
<li>automate the production of release artifacts</li>
<li>regularly test GHC against user packages in between releases</li>
<li>expand continuous integration of GHC to less common platforms to
ensure that compatibility problems are caught before the release
candidate stage</li>
<li>regularly synchronize with core library maintainers between releases
to reduce need for version bound bumps at release time</li>
<li>putting in place tools to ease bisection, which is frequently a
useful debugging strategy around release-time</li>
</ol>
<p>As it turns out, nearly all of these are helped by our on-going effort
to move GHC’s CI infrastructure to Jenkins (see <a href="https://gitlab.haskell.org/ghc/ghc/issues/13716">#13716</a>). As this is a
rather deep topic in its own right, I’ll leave this more technical
discussion for a second post (blog:jenkins-ci).</p>
<p>With the above tooling and process improvements, I think it would be
feasible to get the GHC release cycle down to six months or shorter if
we so desired. Of course, shorter isn’t necessarily better: we need to
be careful to balance the desire for a short release cycle against the
need for an adequate post-release “percolation” time. This time is crucial to allow the community
to adopt the new release, discover and fix its regressions. In fact, the
predictability that a short release schedule (hopefully) affords is
arguably more important than the high cadence itself.</p>
<p>Consequently, we are considering tightening up the release schedule for
future GHC releases in a slow and measured manner. Given that we are now
well into the summer, I think positioning the 8.4 release around
February 2018, around seven months from now, would be a sensible
timeline. However, we would like to hear your opinions.</p>
<p>Here are some things to think about,</p>
<ol type="1">
<li>Do you feel that it takes too long for GHC features to make it to users’ hands?</li>
<li>How many times per year do you envision upgrading your compiler
before the process becomes too onerous? Would the current load of interface changes per release be acceptable under a faster release cadence?</li>
<li>Should we adjust the
<a href="https://prime.haskell.org/wiki/Libraries/3-Release-Policy">three-release policy</a>
to counteract a shorter GHC release cycle?</li>
<li>Would you feel more likely to contribute to GHC if your work were more quickly available in a release?</li>
</ol>
<p>We would love to hear your thoughts. Be sure to mention whether you are a user, GHC contributor, or both.</p>
]]></description>
    <pubDate>Tue, 01 Aug 2017 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20170801-2017-release-schedule.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 8.2.1 is available</title>
    <link>http://haskell.org/ghc/blog/20170723-ghc-8.2.11-released.html</link>
    <description><![CDATA[<h1>GHC 8.2.1 is available</h1>
<h4 class="text-muted">Ben Gamari - 2017-07-23</h4>

<p>= The Glasgow Haskell Compiler – version 8.2.1 =</p>
<p>The GHC developers are very happy to announce the long-awaited 8.2.1
release of Glasgow Haskell Compiler. Binary and source distributions can
be found at <a href="https://downloads.haskell.org/~ghc/8.2.1/" class="uri">https://downloads.haskell.org/~ghc/8.2.1/</a>.</p>
<p>This is the second release in the 8.0 series. As such, the focus of this
release is performance, stability, and consolidation. Consequently
numerous cleanups can be seen throughout the compiler including,</p>
<ul>
<li><p>Significant improvements in compiler performance</p></li>
<li><p>More robust support for levity polymorphism</p></li>
<li><p>Reliable DWARF debugging information</p></li>
<li><p>Improved runtime system performance on NUMA systems</p></li>
<li><p>Retooling of the cost-center profiler, including support for live
streaming of profile data via the GHC event log</p></li>
<li><p>Interface file determinism</p></li>
<li><p>More robust treatment of join points, enabling significantly better
code generation in many cases</p></li>
<li><p>Numerous improvements in robustness on Windows</p></li>
<li><p>and the resolution of over 500 other tickets</p></li>
</ul>
<p>In addition, there are a number of new features,</p>
<ul>
<li><p>A new, more type-safe type reflection mechanism</p></li>
<li><p>The long-awaited Backpack module system</p></li>
<li><p>Deriving strategies to disambiguate between GHC’s various instance
deriving mechanisms</p></li>
<li><p>Unboxed sum types, for efficient unpacked representation of sum data
types</p></li>
<li><p>Compact regions, allowing better control over garbage collection
in the presence of large heaps containing many long-lived objects.</p></li>
<li><p>Colorful messages and caret diagnostics for more legible errors</p></li>
</ul>
<p>A more thorough list of the changes in this release can be found in the
<a href="https://haskell.org/ghc/docs/8.2.1/html/users_guide/8.2.1-notes.html">release notes</a>.</p>
<p>There are a few changes in release-engineering that should be noted,</p>
<ul>
<li><p>Binary distributions for 32-bit CentOS 6.7 have been dropped.
Moreover, there are no dedicated CentOS 7.0 distributions as CentOS 7
can use can use Debian 8 binaries. If you would like us to continue
to produce 32-bit CentOS 6.7 distributions please let us know.</p></li>
<li><p>GHC HQ now builds FreeBSD and OpenBSD distributions for amd64; this
comes after many years of these distributions being faithfully
provided by Karel Gardas and Pali Gabor Janos, who we should heartily
thank for their contributions.</p></li>
</ul>
<p>GHC HQ building these distributions ourselves will allow us to more
quickly ship distributions to users by eliminating the need for a
long lag time between source release availability and having all
binary distributions available.</p>
<ul>
<li><p>There is a technology-preview of an AArch64 Linux binary
distribution, as well as an ARM Linux build. AArch64 support is quite
preliminary but should be stable in 8.4 thanks to further linker
fixes by Moritz Angerman. ARM should be stable.</p></li>
<li><p>GHC now tries to use the gold and lld linkers by default. These
linkers are significantly faster than the BFD linker implementation
that most Linux distributions use by default. If gold or lld are not
available GHC will use the system’s default linker. GHC can be forced
to use the default linker by passing –disable-ld-override to
configure.</p></li>
</ul>
<p>This release has been the result of over a year of hard work by over 150
code contributors. Thanks to everyone who has helped in writing patches,
testing, reporting bugs, and offering feedback over the last year.</p>
<p>This release cycle was admittedly quite drawn out, significantly longer
than expected or desired. While we are confident that the result is
worth the wait, we have been steadily working on infrastructure which
should help shrink future release cycles and give us better testing
between releases. More details on this coming soon.</p>
<p>As always, let us know if you encounter trouble.</p>
<h4 id="how-to-get-it">How to get it</h4>
<p>Both the source tarball and binary distributions for a wide variety of platforms are available <a href="https://downloads.haskell.org/~ghc/8.2.1/">here</a>.</p>
<h3 id="background">Background</h3>
<p>Haskell is a standard lazy functional programming language.</p>
<p>GHC is a state-of-the-art programming suite for Haskell. Included is
an optimising compiler generating efficient code for a variety of
platforms, together with an interactive system for convenient, quick
development. The distribution includes space and time profiling
facilities, a large collection of libraries, and support for various
language extensions, including concurrency, exceptions, and foreign
language interfaces. GHC is distributed under a BSD-style open source license.</p>
<p>A wide variety of Haskell related resources (tutorials, libraries,
specifications, documentation, compilers, interpreters, references,
contact information, links to research groups) are available from the
Haskell home page (see below).</p>
<p>On-line GHC-related resources
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</p>
<p>Relevant URLs on the World-Wide Web:</p>
<ul>
<li><a href="https://www.haskell.org/ghc/">GHC home page</a></li>
<li><a href="https://ghc.haskell.org/trac/ghc/">GHC developers’ home page</a></li>
<li><a href="https://www.haskell.org/">Haskell home page</a></li>
</ul>
<h3 id="supported-platforms">Supported Platforms</h3>
<p>The list of platforms we support, and the people responsible for them,
is <a href="https://ghc.haskell.org/trac/ghc/wiki/Contributors">here</a></p>
<p>Ports to other platforms are possible with varying degrees of
difficulty. The <a href="http://ghc.haskell.org/trac/ghc/wiki/Building">Building Guide</a> describes how to go about porting to a
new platform.</p>
<h3 id="developers">Developers</h3>
<p>We welcome new contributors. Instructions on accessing our source
code repository, and getting started with hacking on GHC, are
available from the GHC’s developer’s site run by <a href="http://ghc.haskell.org/trac/ghc/">Trac</a>.</p>
<h3 id="community-resources">Community Resources</h3>
<p>There are mailing lists for GHC users, developers, and monitoring bug tracker
activity; to subscribe, use the Mailman
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo">web interface</a>.</p>
<p>There are several other Haskell and GHC-related mailing lists on
<a href="http://www.haskell.org">haskell.org</a>; for the full list, see the
<a href="https://mail.haskell.org/cgi-bin/mailman/listinfo">lists page</a>.</p>
<p>Some GHC developers hang out on the <code>#ghc</code> and <code>#haskell</code> of the Freenode IRC
network, too. See the <a href="http://www.haskell.org/haskellwiki/IRC_channel">Haskell wiki</a> for details.</p>
<p>Please report bugs using our bug tracking system. Instructions on reporting bugs
can be found <a href="http://www.haskell.org/ghc/reportabug">here</a>.</p>
]]></description>
    <pubDate>Sun, 23 Jul 2017 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20170723-ghc-8.2.11-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 8.0.2 is available!</title>
    <link>http://haskell.org/ghc/blog/20170111-ghc-8.0.2-released.html</link>
    <description><![CDATA[<h1>GHC 8.0.2 is available!</h1>
<h4 class="text-muted">bgamari - 2017-01-11</h4>

<p>The GHC team is happy to at last announce the 8.0.2 release of the
Glasgow Haskell Compiler. Source and binary distributions are available
at</p>
<pre><code>http://downloads.haskell.org/~ghc/8.0.2/</code></pre>
<p>This is the second release of the 8.0 series and fixes nearly
two-hundred bugs. These include,</p>
<ul>
<li><p>Interface file build determinism (<a href="https://gitlab.haskell.org/ghc/ghc/issues/4012">#4012</a>).</p></li>
<li><p>Compatibility with macOS Sierra and GCC compilers which compile
position-independent executables by default</p></li>
<li><p>Compatibility with systems which use the gold linker</p></li>
<li><p>Runtime linker fixes on Windows (see <a href="https://gitlab.haskell.org/ghc/ghc/issues/12797">#12797</a>)</p></li>
<li><p>A compiler bug which resulted in undefined reference errors while
compiling some packages (see <a href="https://gitlab.haskell.org/ghc/ghc/issues/12076">#12076</a>)</p></li>
<li><p>A number of memory consistency bugs in the runtime system</p></li>
<li><p>A number of efficiency issues in the threaded runtime which manifest
on larger core counts and large numbers of bound threads.</p></li>
<li><p>A typechecker bug which caused some programs using
-XDefaultSignatures to be incorrectly accepted.</p></li>
<li><p>More than two-hundred other bugs. See <a href="https://ghc.haskell.org/trac/ghc/query?status=closed&amp;milestone=8.0.2&amp;col=id&amp;col=summary&amp;col=status&amp;col=type&amp;col=priority&amp;col=milestone&amp;col=component&amp;order=priority">Trac</a> for a complete
listing.</p></li>
<li><p><a href="https://gitlab.haskell.org/ghc/ghc/issues/12757">#12757</a>, which lead to broken runtime behavior and even crashes in
the presence of primitive strings.</p></li>
<li><p><a href="https://gitlab.haskell.org/ghc/ghc/issues/12844">#12844</a>, a type inference issue affecting partial type signatures.</p></li>
<li><p>A bump of the <code>directory</code> library, fixing buggy path
canonicalization behavior (<a href="https://gitlab.haskell.org/ghc/ghc/issues/12894">#12894</a>). Unfortunately this required a
major version bump in <code>directory</code> and minor bumps in several other
libraries.</p></li>
<li><p><a href="https://gitlab.haskell.org/ghc/ghc/issues/12912">#12912</a>, where use of the <code>select</code> system call would lead to runtime
system failures with large numbers of open file handles.</p></li>
<li><p><a href="https://gitlab.haskell.org/ghc/ghc/issues/10635">#10635</a>, wherein -Wredundant-constraints was included in the -Wall
warning set</p></li>
</ul>
<p>A more detailed list of the changes included in this release can be
found in the <a href="https://downloads.haskell.org/~ghc/8.0.2/docs/html/users_guide/8.0.2-notes.html">release notes</a>.</p>
<p>Please note that this release breaks with our usual tendency to avoid
major version bumps of core libraries in minor GHC releases by including
an upgrade of the <code>directory</code> library to 1.3.0.0.</p>
<p>Also note that, due to a rather serious bug (<a href="https://gitlab.haskell.org/ghc/ghc/issues/13100">#13100</a>) affecting Windows
noticed late in the release cycle, the Windows binary distributions were
produced using a slightly <a href="http://downloads.haskell.org/~ghc/8.0.2/0001-SysTools-Revert-linker-flags-change.patch">patched</a> source tree. Users compiling from
source for Windows should be certain to include this patch in their
build.</p>
<p>This release is the result of six months of effort by the GHC
development community. We’d like to thank everyone who has contributed
code, bug reports, and feedback to this release. It’s only due to
their efforts that GHC remains a vibrant and exciting project.</p>
<h3 id="how-to-get-it">How to get it</h3>
<p>Both the source tarball and binary distributions for a wide variety of platforms
are available <a href="http://www.haskell.org/ghc/">here</a>.</p>
<h3 id="background">Background</h3>
<p>Haskell is a standardized lazy functional programming language.</p>
<p>The Glasgow Haskell Compiler (GHC) is a state-of-the-art programming suite for
Haskell. Included is an optimising compiler generating efficient code for a
variety of platforms, together with an interactive system for convenient, quick
development. The distribution includes space and time profiling facilities, a
large collection of libraries, and support for various language extensions,
including concurrency, exceptions, and foreign language interfaces. GHC is
distributed under a BSD-style open source license.</p>
<h3 id="supported-platforms">Supported Platforms</h3>
<p>The list of platforms we support, and the people responsible for them, can be
found on the <a href="https://gitlab.haskell.org/ghc/ghc/wikis/Platforms">GHC wiki</a></p>
<p>Ports to other platforms are possible with varying degrees of difficulty. The
<a href="https://gitlab.haskell.org/ghc/ghc/wikis/Building">Building Guide</a> describes how to go about porting to a new platform.</p>
<h3 id="developers">Developers</h3>
<p>We welcome new contributors. Instructions on getting started with hacking on GHC
are available from GHC’s <a href="http://ghc.haskell.org/trac/ghc/">developer site</a>.</p>
<h3 id="community-resources">Community Resources</h3>
<p>There are mailing lists for GHC users, develpoers, and monitoring bug tracker
activity; to subscribe, use the Mailman
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo">web interface</a>.</p>
<p>There are several other Haskell and GHC-related mailing lists on
<a href="http://www.haskell.org">haskell.org</a>; for the full list, see the
<a href="https://mail.haskell.org/cgi-bin/mailman/listinfo">lists page</a>.</p>
<p>Some GHC developers hang out on the <code>#ghc</code> and <code>#haskell</code> of the Freenode IRC
network, too. See the <a href="http://www.haskell.org/haskellwiki/IRC_channel">Haskell wiki</a> for details.</p>
<p>Please report bugs using our bug tracking system. Instructions on reporting bugs
can be found <a href="http://www.haskell.org/ghc/reportabug">here</a>.</p>
]]></description>
    <pubDate>Wed, 11 Jan 2017 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20170111-ghc-8.0.2-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>Call for Nominations: GHC Steering Committee</title>
    <link>http://haskell.org/ghc/blog/20160905-steering-committee-cfn.html</link>
    <description><![CDATA[<h1>Call for Nominations: GHC Steering Committee</h1>
<h4 class="text-muted">bgamari - 2016-09-05</h4>

<p>Hello everyone,</p>
<p>As you likely know, over the last few months we have been discussing
options for reforming the process for proposing language and
compiler changes to GHC. After much discussion, we have a <a href="http://github.com/ghc-proposals/ghc-proposals">process</a>
which, while not perfect, is acceptable to a majority of our contributor
base and will be an improvement over the status quo. While we invite
suggestions for future improvements, we are at a point where we can move
ahead with implementation.</p>
<p>Consequently, we are seeking nominations for the initial GHC steering
committee. This body is responsible for overseeing the progression of
proposals through the process, working with authors on refining their
ideas, and evaluating proposals for acceptance. The committee will
consist of five to eight members of diverse backgrounds.</p>
<p>We would like to offer the following as a criteria for membership. Note
that a candidate is not expected to satisfy all or even most of these
criteria, but a good candidate should satisfy at least one:</p>
<ul>
<li><p>A history of contributions to the design of new language features</p></li>
<li><p>Experience developing Haskell libraries and applications</p></li>
<li><p>A demonstrated track record of contributing code to GHC</p></li>
<li><p>A pedagogical background, with experience in either teaching or
authoring educational materials</p></li>
<li><p>Experience in compiler development</p></li>
<li><p>Knowledge of functional programming language theory</p></li>
</ul>
<p>I would like to emphasize that committee membership is as much a duty as it
is a privilege. Membership is not intended to be a platform to be used
by members to drive their own ideas; rather it is a way of serving the
Haskell community by helping other community members refine and advance
their proposals. This, of course, requires an investment of
time and effort, which you should be willing and able to consistently
put forth.</p>
<p>If you would like to be considered for committee membership then please
write a statement describing why you feel you are well-qualified to
serve, in terms of the criteria above and any others that you would like
to offer. Please send your statements to ben at well-typed.com by September
30th. The initial committee selection will be made by the Simons soon
thereafter.</p>
<p>Thanks to everyone for their feedback and cooperation so far!</p>
<dl>
<dt>Cheers,</dt>
<dd>
<p>Ben</p>
</dd>
</dl>
]]></description>
    <pubDate>Mon, 05 Sep 2016 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20160905-steering-committee-cfn.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>Rethinking GHC's approach to managing proposals</title>
    <link>http://haskell.org/ghc/blog/20160709-rethinking-proposals.html</link>
    <description><![CDATA[<h1>Rethinking GHC's approach to managing proposals</h1>
<h4 class="text-muted">bgamari - 2016-07-09</h4>

<p>Recently there has been a <a href="https://www.reddit.com/r/haskell/comments/4oyxo2/blog_contributing_to_ghc/">fair bit</a> of <a href="https://www.reddit.com/r/haskell/comments/4isua9/ghc_development_outsidein/">discussion</a> around the
mechanisms by which proposed changes to GHC are evaluated. While we have
something of a formal proposal <a href="https://ghc.haskell.org/trac/ghc/wiki/WorkingConventions/AddingFeatures">protocol</a>, it is not clearly
documented, inconsistently applied, and may be failing to serve a
significant fraction of GHC’s potential contributor pool.</p>
<p>Over the last few weeks, I have been doing a fair amount of reading,
thinking, and discussing to try to piece together a proposal scheme
which better serves our community.</p>
<p>The <a href="https://github.com/ghc-proposals/ghc-proposals/pull/1/files?short_path=14d66cd#diff-14d66cda32248456a5f223b6333c6132">resulting proposal</a> is strongly inspired by the <a href="https://github.com/rust-lang/rfcs">RFC process</a> in
place in the Rust community, the leaders of which have thought quite
hard about fostering community growth and participation. While no
process is perfect, I feel like the Rust process is a good starting
point for discussion, offering enough structure to guide new
contributors through the process while requiring only a modest
investment of developer time.</p>
<p>To get a sense for how well this will work in our community, I propose
that we attempt to self-host the proposed process. To this end I have
setup a <code>ghc-proposals</code> <a href="https://github.com/ghc-proposals/ghc-proposals">repository</a> and opened a pull request for
discussion of the <a href="https://github.com/ghc-proposals/ghc-proposals/pull/1/files?short_path=14d66cd#diff-14d66cda32248456a5f223b6333c6132">process proposal</a>.</p>
<p>Let’s see how this goes.</p>
<dl>
<dt>Cheers,</dt>
<dd>
<p>Ben</p>
</dd>
</dl>
]]></description>
    <pubDate>Sat, 09 Jul 2016 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20160709-rethinking-proposals.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>Contributing to GHC</title>
    <link>http://haskell.org/ghc/blog/20160620-ContributingToGhc.html</link>
    <description><![CDATA[<h1>Contributing to GHC</h1>
<h4 class="text-muted">simonpj - 2016-06-20</h4>

<p>This post is a response to <a href="http://www.arcadianvisions.com/blog/2016/ghc-contributing.html">Anthony’s blog post</a> about contributing to GHC, and the subsequent <a href="https://www.reddit.com/r/haskell/comments/4isua9/ghc_development_outsidein">Reddit discussion</a>. You’ll find it easier to follow my comments below if you read Anthony’s post first. Short summary: many of Anthony’s criticisms are accurate, but they are not easy to address, especially in a volunteer-only project. However we will do something about the feature-request process.</p>
<h3 id="barrier-to-entry">Barrier to entry</h3>
<p>I am ashamed that GHC seems difficult to contribute to. The details don’t matter; the fact that it made you feel that way is by definition bad. I’m really sorry. We should find a way to do better.</p>
<p>An underlying issue is one of effort budget. GHC has essentially no full-timers, unlike many open-source projects. In particular, Simon Marlow and I are volunteers like everyone else, and like everyone else we have a day job. Microsoft Research generously pays Well Typed for front-line support, manifested in the heroic form of Ben and Austin, totalling around one FTE. But their effort is fully absorbed by managing releases, reviewing patches, maintaining the infrastructure, and so on.</p>
<p>It’s a real challenge to maintain a low barrier to entry for a large complex project, whose motive force is primarily volunteers. It means that any initiative will only fly if someone steps up to drive it.</p>
<h3 id="technical-documentation">Technical documentation</h3>
<p>The questions of scattered and inconsistent documentation are difficult to address. GHC is twenty-five years old; it has hundreds of authors and documentation that was once accurate falls out of date. I would love it to have consistent, well-explained documentation. But I don’t know how to achieve it.</p>
<p>GHC’s technical documentation is either in the code itself, or on GHC’s wiki. An advantage of a wiki is that anyone can edit it. Yes, instructions and technical descriptions go out of date. Who will fix them? You, gentle reader! There is no one else.</p>
<p>But in practice few do. Perhaps that’s because such work is invisible, so no one even knows you’ve done it? What would make people feel “I’d really like to improve those instructions or that documentation?”</p>
<p>I will argue for two things. First, I find Notes incredibly helpful. They live with the code, so they are less likely to go out of date. They don’t mess up the flow of the code. They can be referred to from multiple places. They are the single most successful code documentation mechanism we have. (To be fair to Anthony, I don’t think was complaining about Notes, just expressing surprise.)</p>
<p>Second, I really do think that each new proposed feature needs a description, somewhere, of what it is, why it’s a good thing, and as precisely as possible what its specification is. Plus perhaps some implementation notes. It’s very important when reading an implementation to know what it is that the code is seeking to implement. So yes, I do frequently ask for a specification.</p>
<h3 id="arc-github-phabricator-etc">Arc, github, phabricator, etc</h3>
<p>Personally I carry no torch for <code>arc</code>. I do whatever I’m told, workflow-wise. If GitHub has got a lot better since we took the Arc decision, and there’s a consensus that we should shift, I’m all for it provided someone explains to me what my new workflows should be. I am absolutely in favour of reducing barriers to contribution. (Other members of the <a href="https://gitlab.haskell.org/ghc/ghc/wikis/wiki:TeamGHC">GHC team</a> have much stronger and better informed views than me, though.)</p>
<p>But there <em>are</em> costs to moving, especially if the move implies friction in the future. In particular, those that worry me most are those surrounding issue tracking. Github’s issue tracker simply doesn’t seem sufficient for a project as large and multi-faceted as GHC; in particular, tags as the only form of metadata is extremely limiting.</p>
<p>One alternative would be to use Github and Trac side-by-side, but then we face the issue of conflicting ticket number spaces as both systems insist on ticket numbers of the form #NNNN.</p>
<h3 id="coding-style">Coding style</h3>
<p>Coding style is rather a personal thing, and we have been reluctant to enforce a single uniform style. (Quite apart from the task of reformatting 150k lines of Haskell.) Personally I don’t find it an obstacle to reading other people’s code.</p>
<h3 id="feature-requests">Feature requests</h3>
<p>That leaves the most substantial issue that Anthony poses: the process of making a contribution.</p>
<p>For fixing a bug, I think that (aside from the <code>arc</code>/Github debate) things are not too bad. On the arc/Github question, Austin has been working with the Phabricator maintainers to try to have them introduce a workflow which might be more familiar and more convenient for Github experts.</p>
<p>But for offering a new feature, Anthony argues that the process is unacceptably arduous. There are lots of things to think about</p>
<ul>
<li><p>GHC has tons of features implemented by talented and motivated folk… who have since moved on. So when a new feature is proposed, my baseline guess is that I will personally be responsible for maintaining it in five years time. So I want to understand what the feature is. I want to understand how the implementation works. I want to be reasonably sure that it doesn’t add a bunch of complexity to an already very complicated code base. And since <em>any</em> new feature adds some complexity, I want to have some confidence that the feature commands broad support – even when it’s behind a language extension flag.</p>
<p>So actually I think it’s reasonable that the process should be somewhat arduous. A new feature imposes costs on every single person who works on that code in the future. We don’t really make this point explicitly, but the <a href="https://secure.phabricator.com/book/phabcontrib/article/contributing_code/">contributor guidelines for Phabricator</a> do. It might be helpful if we articulated similar guidelines.</p></li>
<li><p>“Any proposal needs a lightweight way to gauge broad support, then a period of constructive refinement”. Indeed! What would be such a lightweight way? The trouble is that there is an enormous silent majority, and discussions are typically driven by a handful of articulate and well-informed contributors. All credit to them, but they may very well be an unrepresentative sample. I simply don’t know how to gauge true broad support.</p></li>
<li><p>There is a problem with my own personal lack of bandwidth. I am one of the main gatekeepers for some big chunks of GHC, the renamer, typechecker and optimisation passes. That is good in a way, because if GHC lacked gatekeepers, it would soon lose conceptual integrity and become a huge ball of mud. But it is bad in other ways. I review a lot of code; but not fast enough! In prioritising I am guided by my (doubtless flawed) perceptions of things that lots of people are eagerly awaiting. The same thing goes for Simon Marlow, especially in the runtime system. We both have other day jobs. Even writing this post means that I’m not reviewing someone’s code.</p>
<p>But I am acutely aware that “Simon and Simon are busy” is pretty cold comfort to someone awaiting a review. Maybe there should be a bunch of other people playing this role. That would be great. For example, Richard Eisenberg has taken responsibility for Template Haskell, which is totally fantastic. I would love to hear from people who are willing to take overall responsibility for a piece of GHC.</p></li>
</ul>
<p>None of this is an argument for the status quo. Simon, Ben, Austin, Herbert, and I have been talking about a rather more systematic process for new features. We’d like to learn from experience elsewhere, rather than reinvent the wheel, such as the <a href="https://github.com/rust-lang/rfcs#before-creating-an-rfc">Rust process</a>. Please suggest processes that you have seen working well elsewhere.</p>
]]></description>
    <pubDate>Mon, 20 Jun 2016 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20160620-ContributingToGhc.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC 8.0.1 is available!</title>
    <link>http://haskell.org/ghc/blog/20160521-ghc-8.0.1-released.html</link>
    <description><![CDATA[<h1>GHC 8.0.1 is available!</h1>
<h4 class="text-muted">bgamari - 2016-05-21</h4>

<p>The GHC developers are very pleased to announce the release of the first
new super-major version of our Haskell compiler in six years, GHC 8.0.1.
This release features dozens of exciting developments including,</p>
<ul>
<li><p>A more refined interface for implicit call-stacks, allowing libraries to
provide more helpful runtime error messages to users</p></li>
<li><p>The introduction of the <code>DuplicateRecordFields</code> language
extension, allowing multiple datatypes to declare fields of the same name</p></li>
<li><p>Significant improvements in error message readability and content, including
facilities for libraries to provide custom error messages, more aggressive
warnings for fragile rewrite rules, and more helpful errors for missing
imports</p></li>
<li><p>A rewritten and substantially more thorough pattern match checker, providing
more precise exhaustiveness checking in GADT pattern matches</p></li>
<li><p>More reliable debugging information including experimental backtrace support,
allowing better integration with traditional debugging tools</p></li>
<li><p>Support for desugaring do-notation to use <code>Applicative</code> combinators, allowing
the intuitive do notation to be used in settings which previously required
the direct use of Applicative combinators</p></li>
<li><p>The introduction of <code>Strict</code> and <code>StrictData</code> language extensions, allowing
modules to be compiled with strict-by-default evaluation of bindings</p></li>
<li><p>Great improvements in portability, including more reliable linking on
Windows, a new PPC64 code generator, support for the AIX operating system,
unregisterised m68k support, and significant stabilization on ARM targets</p></li>
<li><p>A greatly improved user’s guide, with beautiful and modern PDF and HTML
output</p></li>
<li><p>Introduction of type application syntax, reducing the need for proxies</p></li>
<li><p>More complete support for pattern synonyms, including record pattern synonyms
and the ability to export patterns “bundled” with a type, as you would a data
constructor</p></li>
<li><p>Support for injective type families and recursive superclass relationships</p></li>
<li><p>An improved generics representation leveraging GHC’s support for type-level
literals</p></li>
<li><p>The <code>TypeInType</code> extension, which unifies types and kinds, allowing GHC to
reason about kind equality and enabling promotion of more constructs to the
type level</p></li>
<li><p>…and more!</p></li>
</ul>
<p>A more thorough list of the changes included in this release can be found in the
<a href="https://downloads.haskell.org/~ghc/8.0.1/docs/html/users_guide/8.0.1-notes.html">release notes</a>,</p>
<p>As always, we have collected various points of interest for users of previous
GHC releases on the GHC 8.0 <a href="https://gitlab.haskell.org/ghc/ghc/wikis/Migration/8.0">migration page</a>,
Please let us know if you encounter anything missing or unclear on this page.</p>
<p>This release is the culmination of nearly eighteen months of effort by over one
hundred contributors. We’d like to thank everyone who has contributed code, bug
reports, and feedback over the past year. It’s only because of their efforts
that GHC continues to evolve.</p>
<h3 id="how-to-get-it">How to get it</h3>
<p>Both the source tarball and binary distributions for a wide variety of platforms
are available <a href="http://www.haskell.org/ghc/">here</a>.</p>
<h3 id="background">Background</h3>
<p>Haskell is a standardized lazy functional programming language.</p>
<p>The Glasgow Haskell Compiler (GHC) is a state-of-the-art programming suite for
Haskell. Included is an optimising compiler generating efficient code for a
variety of platforms, together with an interactive system for convenient, quick
development. The distribution includes space and time profiling facilities, a
large collection of libraries, and support for various language extensions,
including concurrency, exceptions, and foreign language interfaces. GHC is
distributed under a BSD-style open source license.</p>
<h3 id="supported-platforms">Supported Platforms</h3>
<p>The list of platforms we support, and the people responsible for them, can be
found on the <a href="https://gitlab.haskell.org/ghc/ghc/wikis/Platforms">GHC wiki</a></p>
<p>Ports to other platforms are possible with varying degrees of difficulty. The
<a href="https://gitlab.haskell.org/ghc/ghc/wikis/Building">Building Guide</a> describes how to go about porting to a new platform.</p>
<h3 id="developers">Developers</h3>
<p>We welcome new contributors. Instructions on getting started with hacking on GHC
are available from GHC’s <a href="http://ghc.haskell.org/trac/ghc/">developer site</a>.</p>
<h3 id="community-resources">Community Resources</h3>
<p>There are mailing lists for GHC users, develpoers, and monitoring bug tracker
activity; to subscribe, use the Mailman
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo">web interface</a>.</p>
<p>There are several other Haskell and GHC-related mailing lists on
<a href="http://www.haskell.org">haskell.org</a>; for the full list, see the
<a href="https://mail.haskell.org/cgi-bin/mailman/listinfo">lists page</a>.</p>
<p>Some GHC developers hang out on the <code>#ghc</code> and <code>#haskell</code> of the Freenode IRC
network, too. See the <a href="http://www.haskell.org/haskellwiki/IRC_channel">Haskell wiki</a> for details.</p>
<p>Please report bugs using our bug tracking system. Instructions on reporting bugs
can be found <a href="http://www.haskell.org/ghc/reportabug">here</a>.</p>
]]></description>
    <pubDate>Sat, 21 May 2016 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20160521-ghc-8.0.1-released.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC Weekly News - 2015/10/16</title>
    <link>http://haskell.org/ghc/blog/20151017-weekly20151016.html</link>
    <description><![CDATA[<h1>GHC Weekly News - 2015/10/16</h1>
<h4 class="text-muted">thoughtpolice - 2015-10-17</h4>

<p>Hi *,</p>
<p>Welcome for the latest entry in the GHC Weekly News, which has been somewhat irregularly scheduled - but we’re as busy as ever!</p>
<h3 id="release-roadmap">8.0.1 release roadmap</h3>
<p>We’re still steaming ahead on GHC 8.0.1 - any interested participants are suggested to look at the wiki:Status/GHC-8.0.1 page, to see where we’re currently at.</p>
<p>These past few weeks have been good: we’ve gotten the first part of the overloaded record fields work in, and we have plans to land the kind equalities work in November. Furthermore, Simon Marlow, Peter Wortmann and Ben are working on reviewing all of the DWARF improvements, and hopefully the start of this work will land next week.</p>
<p>But 8.0 isn’t the only thing that’ll be getting released…</p>
<h3 id="and-some-other-minor-releases">And some other minor releases</h3>
<p>In a total, unprecedented upset - we’re aiming to do <em>three</em> GHC releases in a fairly short amount of time.</p>
<h4 id="section">7.10.3</h4>
<p>Ben Gamari has been working on steadily hacking away at GHC 7.10.3, and the hopes are that we’ll be able to ship it soon. This will fix several dozen bugs, some of which are critical for our users.</p>
<p>You can keep up to date by following the wiki:Status/GHC-7.10.3 page.</p>
<h4 id="section-1">7.8.5</h4>
<p>Simultaneously, your author will <em>also</em> be working on a GHC 7.8.5 release. While we were alerted a few months ago to this breakage, it seems rather unfortunate for the 7.8 series to remain broken on such a popular OS.</p>
<p>Furthermore, the “Three GHC Release Policy” for many authors - to support the last three major versions of GHC - would mean that 7.8 would be broken for OS X developers for an <em>entire year until GHC 8.2.1</em>. Which is a pretty unfortunate circumstance.</p>
<p>It’s not expected the 7.8.5 release will contain any other fixes, however.</p>
<h3 id="list-chatter">List chatter</h3>
<p>(Over the past two weeks)</p>
<ul>
<li><p>Ben Gamari wrote in about <strong>switching the users guide to reStructuredText</strong>, and the TL;DR is - it’s done! We’ll have a beautiful new users guide for GHC 8.0.1 <a href="https://mail.haskell.org/pipermail/ghc-devs/2015-October/010029.html" class="uri">https://mail.haskell.org/pipermail/ghc-devs/2015-October/010029.html</a></p></li>
<li><p>Matthew Pickering comments about the state of pattern synonym signatures, remarking that they’re currently confusing, noting down some things we could possibly fix. <a href="https://mail.haskell.org/pipermail/ghc-devs/2015-October/010024.html" class="uri">https://mail.haskell.org/pipermail/ghc-devs/2015-October/010024.html</a></p></li>
<li><p>Ben Gamari talked about the status of the recent DWARF work, and so far it’s looking good. The needed patches are still in the review pipeline, but the hope is that they’ll all be done in time for 8.0.1. <a href="https://mail.haskell.org/pipermail/ghc-devs/2015-October/010039.html" class="uri">https://mail.haskell.org/pipermail/ghc-devs/2015-October/010039.html</a></p></li>
<li><p>David A Roberts wrote in to ask a question: now that we have <code>ApplicativeDo</code>, what about <code>Applicative</code> comprehensions? The responses indicate this seems like it would be a great addition. <a href="https://mail.haskell.org/pipermail/ghc-devs/2015-October/010062.html" class="uri">https://mail.haskell.org/pipermail/ghc-devs/2015-October/010062.html</a></p></li>
<li><p>Richard Eisenberg sent in a status update about his work on kind equalities, and the hope is it will land shortly in November! (Your editor then hassled him for a syntax change before landing.) <a href="https://mail.haskell.org/pipermail/ghc-devs/2015-October/010077.html" class="uri">https://mail.haskell.org/pipermail/ghc-devs/2015-October/010077.html</a></p></li>
<li><p>Adam Foltzer has requested another release of the GHC 7.8 series, due to it being completely broken on OS X El Capitan. Expect more news on this soon. <a href="https://mail.haskell.org/pipermail/ghc-devs/2015-October/010078.html" class="uri">https://mail.haskell.org/pipermail/ghc-devs/2015-October/010078.html</a></p></li>
<li><p>Erik de Castro Lopo has recently been working with LLVM, and decided to publish his automation so interested GHC hackers could keep up to date and try new LLVMs easily. <a href="https://mail.haskell.org/pipermail/ghc-devs/2015-October/010086.html" class="uri">https://mail.haskell.org/pipermail/ghc-devs/2015-October/010086.html</a></p></li>
</ul>
<h3 id="noteworthy-commits">Noteworthy commits</h3>
<p>(Over the past two weeks)</p>
<ul>
<li><p>Commit 4fd6207ec6960c429e6a1bcbe0282f625010f52a - Move the users guide to reStructured Text.</p></li>
<li><p>Commit 6cde981a8788b225819be28659caddc35b77972d - Make <code>GHC.Generics</code> capable of handling unboxed tuples.</p></li>
<li><p>Commit 0eb8fcd94b29ee9997b386e64203037bdf2aaa04 - Enable <code>Enumeration is empty</code> warnings for <code>Integer</code></p></li>
<li><p>Commit 620fc6f909cd6e51b5613454097ec1c9f323839a - Make Windows linker more robust to unknown sections</p></li>
<li><p>Commit 5d841108acef950fed6a5e608ac9b18e7431aa87 - Add short library names support to the Windows linker</p></li>
<li><p>Commit f8fbf385b879fe177409a25cc9499275ea3dc45d - Reinstate monomorphism-restriction warnings</p></li>
<li><p>Commit dcc342870b4d8a739ccbed3ae26e84dcc3579914 - Don’t inline/apply other rules when simplifying a rule RHS.</p></li>
<li><p>Commit dec5cd4085488686b5ed50bb26ccbc0ba7b645ec - base: Add <code>forkOSWithUnmask</code></p></li>
<li><p>Commit e8c8173923302268ef950c3b21e276779e45ac83 - Allow <code>arr ∧ (first ∨ (***))</code> as minimal definition of Arrow instance</p></li>
<li><p>Commit 29310b622801733e1b29a9a61988406872db13ca - Switch to LLVM version 3.7</p></li>
<li><p>Commit 04e8366608fee4f5e3358acc855bc6f556c3f508 - ELF/x86_64: map object file sections separately into the low 2GB</p></li>
<li><p>Commit b1884b0e62f62e3c0859515c4137124ab0c9560e - Implement <code>DuplicateRecordFields</code></p></li>
<li><p>Commit 75492e7467ff962f2f2e29e5c8b2c588c94ae8a7 - Add typed holes support in Template Haskell.</p></li>
<li><p>Commit 6a8ca65032c6b3ed61b5378765e70120083cf5da - Allow <code>left ∨ (+++)</code> as minimal definition of ArrowChoice instance</p></li>
</ul>
<h3 id="closed-tickets">Closed tickets</h3>
<p>(Over the past two weeks)</p>
<p><a href="https://gitlab.haskell.org/ghc/ghc/issues/10392">#10392</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/7883">#7883</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10475">#10475</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10745">#10745</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10926">#10926</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/9238">#9238</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10700">#10700</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10810">#10810</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10342">#10342</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/365">#365</a>(!), <a href="https://gitlab.haskell.org/ghc/ghc/issues/10361">#10361</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10929">#10929</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10563">#10563</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/9907">#9907</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10513">#10513</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10868">#10868</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10932">#10932</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/8920">#8920</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10516">#10516</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10416">#10416</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/5966">#5966</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/8335">#8335</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10520">#10520</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10687">#10687</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10571">#10571</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/9058">#9058</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10939">#10939</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10938">#10938</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/9590">#9590</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10949">#10949</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10153">#10153</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10947">#10947</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10948">#10948</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10936">#10936</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/1883">#1883</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/5289">#5289</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10733">#10733</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10950">#10950</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10611">#10611</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10959">#10959</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10960">#10960</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10831">#10831</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10796">#10796</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10890">#10890</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/8010">#8010</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10216">#10216</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10965">#10965</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10953">#10953</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10964">#10964</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10931">#10931</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10714">#10714</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10888">#10888</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10633">#10633</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/8652">#8652</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/3971">#3971</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10882">#10882</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10977">#10977</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10267">#10267</a>, and <a href="https://gitlab.haskell.org/ghc/ghc/issues/10911">#10911</a>.</p>
]]></description>
    <pubDate>Sat, 17 Oct 2015 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20151017-weekly20151016.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC Weekly News - 2015/09/17</title>
    <link>http://haskell.org/ghc/blog/20150917-weekly20150917.html</link>
    <description><![CDATA[<h1>GHC Weekly News - 2015/09/17</h1>
<h4 class="text-muted">thoughtpolice - 2015-09-17</h4>

<p>Hi *,</p>
<p>Welcome for the latest entry in the GHC Weekly News. It’s been a little while, but here we are!</p>
<p>And your author has finally returned from his 8 week sabbatical, too! So without any further ado, lets get going…</p>
<h3 id="release-roadmap">8.0.1 release roadmap</h3>
<p>So <code>HEAD</code> has been steaming along pretty smoothly for the past few months now. After talking with Simon last week, we decided that the best course of action would be to release 8.0.1 (a super-major release) sometime around late February, which were the plans for 7.10 (modulo a few weeks due to the FTP debates). The current schedule is roughly:</p>
<ul>
<li>November: Fork the new <code>ghc-8.0</code> STABLE branch</li>
<li>At this point, <code>master</code> development will probably slow as we fix bugs.</li>
<li>This gives us 2 months or so until branch, from Today.</li>
<li>This is nice as the branch is close to the first RC.</li>
<li>December: First release candidate</li>
<li>Mid/late February: Final release.</li>
</ul>
<p>“<strong>Why call it 8.0.1?</strong>”, you ask? Because we have a lot of excellent features planned! I’m particularly partial to Richard’s work for merging types and kinds (Phab:D808). But there’s a lot of other stuff.</p>
<p>For all the nitty gritty details, be sure to check <a href="https://gitlab.haskell.org/ghc/ghc/wikis/wiki:Status/GHC-8.0.1">8.0.1 status page</a> to keep track of everything - it will be our prime source of information and coordination. And be sure to <a href="https://mail.haskell.org/pipermail/ghc-devs/2015-September/009952.html">read my email to <code>ghc-devs</code></a> for more info.</p>
<h4 id="and-a-7.10.3-release-perhaps">… and a 7.10.3 release perhaps?</h4>
<p>On top of this, we’ve been wondering if another release in the 7.10 branch should be done. Ben did the release shortly after I left, and for the most part looked pretty great. But there have been some snags, as usual.</p>
<p>So we’re asking: <a href="https://mail.haskell.org/pipermail/ghc-devs/2015-September/009953.html">who needs GHC 7.10.3?</a> We’d really like to know of any major showstoppers you’ve found with 7.10 that are preventing you from using it. Especially if you’re stuck or there’s no clear workaround.</p>
<p>Currently, we’re still not 100% committed to this course of action (since the release will take time away from other things). However, we’ll keep the polls open for a while - so <em>please</em> get in touch with us if you need it! (Be sure to read my email for specific information.)</p>
<h3 id="list-chatter">List chatter</h3>
<p>(Over the past two weeks)</p>
<ul>
<li><p>Bartosz Nitka writes to <code>ghc-devs</code> about the ongoing work to try and fix deterministic compilation in GHC (the dreaded ticket <a href="https://gitlab.haskell.org/ghc/ghc/issues/4012">#4012</a>). There’s a very detailed breakdown of the current problems and issues in play, with responses from others - https://mail.haskell.org/pipermail/ghc-devs/2015-September/009964.html</p></li>
<li><p>Richard Eisenberg wants to know - how can I download all of <code>Hackage</code> to play with it? GHC developers are surely interested in this, so they can find regressions quickly - https://mail.haskell.org/pipermail/ghc-devs/2015-September/009956.html</p></li>
<li><p>I wrote to the list about the upcoming tentative 7.10.3 plans, as I mentioned above. https://mail.haskell.org/pipermail/ghc-devs/2015-September/009953.html</p></li>
<li><p>I <em>also</em> wrote to the list about the tentative 8.0.1 plans, too. https://mail.haskell.org/pipermail/ghc-devs/2015-September/009952.html</p></li>
<li><p>Johan Tibell asks about his ongoing work for implementing unboxed sum types - in particular, converting unboxed sum types in <code>StgCmm</code>. https://mail.haskell.org/pipermail/ghc-devs/2015-September/009926.html</p></li>
<li><p>Ryan Scott wrote a proposal for the automatic derivation of <code>Lift</code> through GHC’s deriving mechanism, specifically for <code>template-hasekll</code> users. The response was positive and the code is going through review now (Phab:D1168). https://mail.haskell.org/pipermail/ghc-devs/2015-September/009838.html</p></li>
<li><p>Andrew Gibiansky writes in with his own proposal for a new “Argument Do” syntax - a change which would allow <code>do</code> to appear in positions without <code>($)</code> or parenthesis, essentially changing the parser to insert parens as needed. The code is up at Phabricator for brave souls (Phab:D1219). https://mail.haskell.org/pipermail/ghc-devs/2015-September/009821.html</p></li>
<li><p>Edward Yang started a monstrous thread after some discussions at ICFP about a future for <em>unlifted</em> data types in GHC. These currently exist as special magic, but the proposals included would allow users to declare their own types as unlifted, and make unlifted values more flexible (allowing <code>newtype</code> for example). See wiki:UnliftedDataTypes and Edward’s thread for more. https://mail.haskell.org/pipermail/ghc-devs/2015-September/009799.html</p></li>
</ul>
<h3 id="noteworthy-commits">Noteworthy commits</h3>
<p>(Over the past several weeks)</p>
<ul>
<li><p>Commit 374457809de343f409fbeea0a885877947a133a2 - <strong>Injective Type Families</strong></p></li>
<li><p>Commit 8ecf6d8f7dfee9e5b1844cd196f83f00f3b6b879 - <strong>Applicative Do notation</strong></p></li>
<li><p>Commit 6740d70d95cb81cea3859ff847afc61ec439db4f - Use IP-based CallStack in <code>error</code> and <code>undefined</code></p></li>
<li><p>Commit 43eb1dc52a4d3cbba9617f5a26177b8251d84b6a - Show <code>MINIMAL</code> complete definition in GHCi’s <code>:info</code></p></li>
<li><p>Commit 296bc70b5ff6c853f2782e9ec5aa47a52110345e - Use a response file for linker command line arguments</p></li>
<li><p>Commit 4356dacb4a2ae29dfbd7126b25b72d89bb9db1b0 - Forbid annotations when Safe Haskell is enabled</p></li>
<li><p>Commit 7b211b4e5a38efca437d76ea442495370da7cc9a - Upgrade GCC/binutils to 5.2.0 release for Windows (i386/amd64)</p></li>
</ul>
<h3 id="closed-tickets">Closed tickets</h3>
<p>(Over the past two weeks)</p>
<p><a href="https://gitlab.haskell.org/ghc/ghc/issues/10834">#10834</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10830">#10830</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10047">#10047</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/9943">#9943</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/1851">#1851</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/1477">#1477</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/8229">#8229</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/8926">#8926</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/8614">#8614</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10777">#10777</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/8596">#8596</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10788">#10788</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/9500">#9500</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/9087">#9087</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10157">#10157</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10866">#10866</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10806">#10806</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10836">#10836</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10849">#10849</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10869">#10869</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10682">#10682</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10863">#10863</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10880">#10880</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10883">#10883</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10787">#10787</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/8552">#8552</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10884">#10884</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/7305">#7305</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/5757">#5757</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/9389">#9389</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/8689">#8689</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10105">#10105</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/8168">#8168</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/9925">#9925</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10305">#10305</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/4438">#4438</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/9710">#9710</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10889">#10889</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10885">#10885</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10825">#10825</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10821">#10821</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10790">#10790</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10781">#10781</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/9855">#9855</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/9912">#9912</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10033">#10033</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/9782">#9782</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10035">#10035</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/9976">#9976</a>, <a href="https://gitlab.haskell.org/ghc/ghc/issues/10847">#10847</a>, and <a href="https://gitlab.haskell.org/ghc/ghc/issues/10865">#10865</a>.</p>
]]></description>
    <pubDate>Thu, 17 Sep 2015 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20150917-weekly20150917.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC Weekly News - 2015/08/06</title>
    <link>http://haskell.org/ghc/blog/20150825-weekly20150806.html</link>
    <description><![CDATA[<h1>GHC Weekly News - 2015/08/06</h1>
<h4 class="text-muted">bgamari - 2015-08-25</h4>

<p>Hello *,</p>
<p>Here is a rather belated Weekly News which I found sitting nearly done on my
work-queue. I hope this will make for a good read despite its age. The next
edition of the Weekly News will be posted soon.</p>
<h3 id="warnings-for-missed-specialization-opportunities">Warnings for missed specialization opportunities</h3>
<p>Simon Peyton Jones recently
[a4261549afaee56b00fbea1b4bc1a07c95e60929 introduced] a warning in <code>master</code> to
alert users when the compiler was unable to specialize an imported binding
despite it being marked as <code>INLINEABLE</code>. This change was motivated by <a href="https://gitlab.haskell.org/ghc/ghc/issues/10720">#10720</a>,
where the reporter observed poor runtime performance despite taking care to
ensure his binding could be inlined. Up until now, ensuring that the compiler’s
optimizations meet the user’s expectation would require a careful look at the
produced Core. With this change the user is notified of exactly where the
compiler had to stop specializing, along with a helpful hint on where to add a
<code>INLINABLE</code> pragma.</p>
<h3 id="ticky-ticky-profiling">Ticky-Ticky profiling</h3>
<p>Recently I have been looking into breathing life back into GHC’s <a href="https://gitlab.haskell.org/ghc/ghc/wikis/wiki:Debugging/TickyTicky">ticky-ticky</a>
profiling mechanism. When enabled, ticky-ticky maintains low-level counters of various runtime-system events. These include closure entries, updates, and allocations. While ticky doesn’t provide nearly the detail that the cost-center profiler allows, it is invisible to the Core-to-Core optimization passes and has minimal runtime overhead (manifested as a bit more memory traffic due to counter updates). For this reason, the ticky-ticky profiler can be a useful tool for those working on the Core simplifier.</p>
<p>Sadly, ticky-ticky has fallen into quite a state of disrepair in recent years as the runtime system and native code generator have evolved. As the beginning of an effort to resuscitate the ticky-ticky profiler I’ve started putting together a <a href="https://ghc.haskell.org/trac/ghc/wiki/Debugging/TickyTicky#Ticky-Tickycounters">list</a> of the counters currently implemented and whether they can be expected to do something useful. Evaluating the functionality of these counters is non-trivial, however, so this will be an on-going effort.</p>
<p>One of our goals is to eventually do a systematic comparison of the heap allocation numbers produced by the ticky-ticky profiler, the cost-center profiler, and ticky-ticky. While this will help validate some of the more coarse-grained counters exposed by ticky, most of them will need a more thorough read-through of the runtime system to verify.</p>
<h3 id="integer-gmp-performance"><code>integer-gmp</code> Performance</h3>
<p>Since the 7.10.2 release much of my effort has been devoted to characterizing the performance of various benchmarks over various GHC versions. This is part of an effort to find places where we have regressed in the past few versions. One product of this effort is a complete comparison of <a href="http://home.smart-cactus.org/~ben/nofib.html">results</a> from our <code>nofib</code> benchmark suite ranging from 7.4.2 to 7.10.1.</p>
<p>The good news is there are essentially no disastrous regressions. Moreover, on the mean runtimes are over 10% faster than they were in 7.4.2. There are, however, a few cases which have regressed. The runtime of the <code>integer</code> test, for instance, has increased by 7%. Looking at the trend across versions, it becomes apparent that the regression began with 7.10.1.</p>
<p>One of the improvements that was introduced with 7.10 was a rewrite of the <code>integer-gmp</code> library, which this benchmark tests heavily. To isolate this potential cause, I recompiled GHC 7.10.1 with the old <code>integer-gmp-0.5</code>. Comparing 7.10.1 with the two <code>integer-gmp</code> versions reveals a 4% increase in allocations.</p>
<p>While we can’t necessarily attribute all of the runtime increase to these allocations, they are something that should be addressed if possible. Herbert Valerio Riedel, the author of the <code>integer-gmp</code> rewrite, believes that the cause may be due to the tendency for the rewrite to initially allocate a conservatively-sized backing <code>ByteArray#</code> for results. This leads to increased allocations due to the reallocations that are later required to accommodate larger-than-expected results.</p>
<p>While being more liberal in the initial allocation sizes would solve the reallocation issue, this approach may substantially increase working-set sizes and heap fragmentation for integer-heavy workloads. For this reason, Herbert will be looking into exploiting a feature of our heap allocator. Heap allocations in GHC occur by bumping a pointer into an allocation block. Not only is this a very efficient means of allocating, it potentially allows one to efficiently grow an existing allocation. In this case, if we allocate a buffer and soon after realize that our request was too small we can simply bump the heap pointer by the size deficit, so long as no other allocations have occurred since our initial allocation. We can do this since we know that the memory after the heap pointer is available; we merely need to ensure that the current block we are allocating into is large enough.</p>
<p>Simon Marlow and Herbert will be investigating this possibility in the coming weeks.</p>
<p>== D924: <code>mapM_</code> and <code>traverse_</code></p>
<p>As discussed in the <a href="https://ghc.haskell.org/trac/ghc/blog#AMP-relatedperformanceregression">most recent</a> Weekly News, one issue on our plate at the moment is Phab:D924, which attempted to patch up two remaining facets of the Applicative-Monad Proposal,</p>
<ol type="1">
<li>Remove the override of <code>mapM</code> for the <code>[]</code> <code>Traversal</code> instance</li>
<li>Rewrite <code>mapM_</code> in terms of <code>traverse_</code></li>
</ol>
<p>While (1) seems like an obvious cleanup, (2) is a bit tricky. As noted last time, <code>traverse_</code> appears to give rise to non-linear behavior in this context.</p>
<p><code>akio</code> has contributed an insightful <a href="https://ghc.haskell.org/trac/ghc/timeline?from=2015-08-01T10%3A00%3A33Z&amp;precision=second">analysis</a> shedding light on the cause of this behavior. Given that the quadratic behavior is intrinsic to the <code>Applicative</code> formulation, we’ll be sending this matter back to the Core Libraries Committee to inform their future design decisions.</p>
<p>That is all for this week!</p>
<dl>
<dt>Cheers,</dt>
<dd>
<p>Ben</p>
</dd>
</dl>
]]></description>
    <pubDate>Tue, 25 Aug 2015 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20150825-weekly20150806.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC Weekly News - 2015/07/29</title>
    <link>http://haskell.org/ghc/blog/20150729-weekly20150729.html</link>
    <description><![CDATA[<h1>GHC Weekly News - 2015/07/29</h1>
<h4 class="text-muted">bgamari - 2015-07-29</h4>

<p>Hi *,</p>
<p>Welcome for the latest entry in the GHC Weekly News. Today GHC HQ met to discuss plans post-7.10.2.</p>
<h2 id="ghc-7.10.2-release">GHC 7.10.2 release</h2>
<p>GHC 7.10.2 has been <a href="https://mail.haskell.org/pipermail/haskell/2015-July/024634.html">released</a>!</p>
<p>Feel free to grab a <a href="https://www.haskell.org/ghc/download_ghc_7_10_2">tarball</a> and enjoy! See the <a href="https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/release-7-10-2.html">release notes</a> for discussion of what has changed.</p>
<p>As always, if you suspect that you have found a regression don’t hesitate to <a href="https://ghc.haskell.org/trac/ghc/wiki/ReportABug">open a Trac ticket</a>. We are especially interested in performance regressions with fairly minimal reproduction cases.</p>
<h3 id="ghc-7.10.2-and-the-text-package">GHC 7.10.2 and the <code>text</code> package</h3>
<p>A few days ago a report came in of long compilations times under 7.10.2 on a program with many <code>Text</code> literals (<a href="https://gitlab.haskell.org/ghc/ghc/issues/10528">#10528</a>). This ended up being due to a change in the simplifier which caused it to perform rule rewrites on the left-hand-side of other rules. While this is questionable (read “buggy”) behavior, it doesn’t typically cause trouble so long as rules are properly annotated with phase control numbers to ensure they are performed in the correct order. Unfortunately, it turns out that the rules provided by the <code>text</code> package for efficiently handling string literals did not include phase control annotations. This resulted in a rule from <code>base</code> being performed on the literal rules, which rendered the literal rules ineffective. The simplifier would then expend a great deal of effort trying to simplify the rather complex terms that remained.</p>
<p>Thankfully, the <a href="https://github.com/bos/text/pull/129/files">fix</a> is quite straightforward: ensure that the the text literal rules fire in the first simplifier phase (phase 2). This avoids interference from the <code>base</code> rules, allowing them to fire as expected.</p>
<p>This fix is now present in <code>text-1.2.1.2</code>. <strong>Users of GHC 7.10.2 should be use this release if at all possible.</strong> Thanks to <code>text</code>’s maintainer, Bryan O’Sullivan for taking time out of his vacation to help me get this new release out.</p>
<p>While this mis-behaviour was triggered by a bug in GHC, a similar outcome could have arisen even without this bug. This highlights the importance of including phase control annotations on <code>INLINE</code> and <code>RULE</code> pragmas: Without them the compiler may choose the rewrite in an order that you did not anticipate. This has also drawn attention to a few shortcomings in the current rewrite rule mechanism, which lacks the expressiveness to encode complex ordering relationships between rules. This limitation pops up in a number of places, including when trying to write rules on class-overloaded functions. Simon Peyton Jones is currently pondering possible solutions to this on <a href="https://gitlab.haskell.org/ghc/ghc/issues/10595">#10595</a>.</p>
<h2 id="strictdata">StrictData</h2>
<p>This week we merged the long-anticipated <code>-XStrictData</code> extension (Phab:D1033) by Adam Sandberg Ericsson. This implements a subset of the [StrictPragma] proposal initiated by Johan Tibell.In particular, <code>StrictData</code> allows a user to specify that datatype fields should be strict-by-default on a per-module basis, greatly reducing the syntactic noise introduced by this common pattern. In addition to implementing a useful feature, the patch ended up being a nice clean-up of the GHC’s handling of strictness annotations.</p>
<p>What remains of this proposal is the more strong <code>-XStrict</code> extension which essentially makes all bindings strict-by-default. Adam has indicated that he may take up this work later this summer.</p>
<p>$ AMP-related performance regression</p>
<p>In late May Herbert Valerio Riedel opened Phab:D924, which removed an explicit definition for <code>mapM</code> in the <code>[]</code> <code>Traversable</code> instance, as well as redefined <code>mapM_</code> in terms of <code>traverse_</code> to <a href="https://mail.haskell.org/pipermail/libraries/2015-May/025708.html">bring consistency</a> with the post-AMP world. The patch remains unmerged, however, due to a failing ghci testcase. It turns out the regression is due to the redefinition of <code>mapM_</code>, which uses <code>(*&gt;)</code> where <code>(&gt;&gt;)</code> was once used. This tickles poor behavior in ghci’s <code>ByteCodeAsm</code> module. The problem can be resolved by defining <code>(*&gt;) = (&gt;&gt;)</code> in the <code>Applicative Assembler</code> instance (e.g. Phab:1097). That being said, the fact that this change has already exposed performance regressions raises doubts as to whether it is prudent.</p>
<h2 id="ghc-performance-work">GHC Performance work</h2>
<p>Over the last month or so I have been working on nailing down a variety of performance issues in GHC and the code it produces. This has resulted in a number of patches which in some cases dramatically improve compilation time (namely Phab:1012 and Phab:D1041). Now since 7.10.2 is out I’ll again be spending most of my time on these issues. We have heard a number of reports that GHC 7.10 has regressed on real-world programs. If you have a reproducible performance regression that you would like to see addressed please open a Trac ticket.</p>
<h2 id="merged-patches">Merged patches</h2>
<ul>
<li>Phab:D1028: Fixity declarations are now allowed for infix data constructors in GHCi (thanks to Thomas Miedema)</li>
<li>Phab:D1061: Fix a long-standing correctness issue arising when pattern matching on floating point values</li>
<li>Phab:D1085: Allow programs to run in environments lacking iconv (thanks to Reid Barton)</li>
<li>Phab:D1094: Improve code generation in <code>integer-gmp</code> (thanks to Reid Barton)</li>
<li>Phab:D1068: Implement support for the <code>MO_U_Mul2</code> <code>MachOp</code> in the LLVM backend (thanks to Michael Terepeta)</li>
<li>Phab:D524: Improve runtime system allocator performance with two-step allocation (thanks to Simon Marlow)</li>
</ul>
<p>That’s all for this time. Enjoy your week!</p>
<p>Cheers,</p>
<ul>
<li>Ben</li>
</ul>
]]></description>
    <pubDate>Wed, 29 Jul 2015 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20150729-weekly20150729.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>
<item>
    <title>GHC Weekly News - 2015/07/21</title>
    <link>http://haskell.org/ghc/blog/20150721-weekly20150721.html</link>
    <description><![CDATA[<h1>GHC Weekly News - 2015/07/21</h1>
<h4 class="text-muted">bgamari - 2015-07-21</h4>

<p>Hi *,</p>
<p>Welcome for the latest entry in the GHC Weekly News. Today GHC HQ met
to discuss the status of the imminent 7.10.2 release.</p>
<h2 id="status">7.10.2 Status</h2>
<p>In the past weeks we have been busily tracking down a number of regressions in
the <code>ghc-7.10</code> branch. At this point we have built up an impressive
<a href="https://ghc.haskell.org/trac/ghc/wiki/Status/GHC-7.10.2">list</a> of fixes.
Thanks to everyone who has helped in this process!</p>
<p>In addition to resolving a number of simplifier regressions and portability issues
(some mentioned in the Weekly News from 6 July), GHC 7.10.2 should be the first
release which works out-of-the-box with GHCJS, thanks to a fix from Luite Stegeman.
Moreover, we will have support for running in even the most minimal container
environment (<a href="https://gitlab.haskell.org/ghc/ghc/issues/10623">#10623</a>).</p>
<p>At this point we have successfully tested the pre-release against Stackage
(thanks for Michael Snoyman and Herbert Valerio Riedel for making this possible)
and have found no major issues. A source tarball will be finalized and sent to
the binary builders today. With luck we will have releasable binaries by the end of
the week.</p>
<h2 id="things">7.11 Things</h2>
<h3 id="testing">Testing</h3>
<p>Thomas Miedema has been doing some amazing work fixing some long-standing
validation failures on the <code>master</code> branch. Moreover, he has been examining
the viability of enabling
<a href="https://phabricator.haskell.org/D1074">larger swaths</a> of the testsuite in
Harbormaster validations.</p>
<p>In addition, Thomas has been doing some great work smoothing over a variety of
rough edges in the build system and generally keeping things running smoothly.
Thanks Thomas!</p>
<h3 id="typeable-implementation">Typeable implementation</h3>
<p>Another subject of discussion in this week’s GHC call was
<a href="https://phabricator.haskell.org/D757">Phabricator D757</a>, a long-languishing
change which moves the generation of <code>Typeable</code> instances from types’ use sites to
their definition sites. This change involves a trade-off as it moves compilation
effort to the defining module, which will adversely affect compilation times of
modules defining many types. Moreover, in the event that <code>Typeable</code> is never actually used
this time is wasted effort. That being said, the current design of generating
<code>Typeable</code> instances at the point of use makes the class a bit of a black sheep
at the moment.</p>
<h3 id="runtime-system-matters">Runtime system matters</h3>
<p>This week Simon Marlow will merge his <a href="https://phabricator.haskell.org/D524">D524</a>,
a rework of the runtime system’s allocator which he reports has improved
performance significantly in his workloads. This commit splits the concerns of
reserving address space and requesting backing memory for this address space. While the former is relatively cheap, the latter can be quite expensive due to page-table setup.
Consequently, his rework allocates a large chunk of addressing space up front
and then incrementally commits it as needed. Interested readers are encouraged
to look at the patch, which offers a nice glimpse into the inner workings of
GHC’s memory allocator.</p>
<p>Simon also has finished Phab:D1076, which should improve garbage collector performance by
reworking the logic responsible for scavenging static objects. This work will
be merged shortly.</p>
<p>Also discussed was the profiler mis-attribution issue mentioned in the
Weekly News from 6 July 2015 (<a href="https://gitlab.haskell.org/ghc/ghc/issues/10007">#10007</a>). Peter Wortmann is currently looking at this issue,
which ends up being due to an infelicity in the semantics implemented by the
runtime system. Simon Marlow expressed that he did not know of a way to resolve
this that isn’t quite invasive. We will have to see what Peter proposes.</p>
<h3 id="applicative-do">Applicative <code>do</code></h3>
<p>For some time now Simon Marlow has been working on
<a href="https://phabricator.haskell.org/D729">implementing</a> the [[ApplicativeDo]]
proposal. Today in the call we discussed the status of this work and concluded
that while some refactoring is likely possible, the work can be merged as-is.
Hopefully at some point in the next few weeks this work will land.</p>
<h3 id="haddock-comments-for-gadt-constructors">Haddock comments for GADT constructors</h3>
<p>It came to our attention that the GHC parser was unable to parse Haddock
comments attached to GADT constructors. As it turns out, this is a rather long-standing
problem. Despite this fact, the <a href="https://phabricator.haskell.org/D1086">fix</a>
ended up being quite straightforward and will be in 7.12.</p>
<h2 id="backwards-compatibility">Backwards Compatibility</h2>
<p>In general one should be able to compile the current GHC <code>master</code> branch with
the last two compiler releases. Recently, however, the reality is a bit less
clear-cut: while the current <code>ghc-7.10</code> branch GHC will technically <strong>build</strong> with
GHC 7.6 and 7.8, the tree does not necessarily pass the <code>validate</code> script due
to a variety of imports rendered redundant by AMP and FTP. Moreover, the
official policy on backwards compatibility is rather well-hidden on the
[[Commentary/CodingStyle]] page.</p>
<p>This was discussed in today’s meeting and it was decided that we will in the future
maintain full validation-compatibility with the previous two releases. To ease this
we will relax the use of <code>-Werror</code> when building the stage 1 compiler.</p>
<p>On a related note, this week Thomas Miedema
<a href="https://phabricator.haskell.org/D904">ripped out</a> some <code>#ifdefs</code> for GHC 7.6
compatibility from the <code>master</code> branch. Be aware that you will now need GHC 7.8 or newer to build <code>master</code>.</p>
<h2 id="mac-os-x-el-capitan-support">Mac OS X El Capitan support</h2>
<p>It is well-known that the next Mac OS X release, El Capitan, will default to
“root-less” mode, a security feature which restricts the operations available to
even the <code>root</code> user. As a result of this feature some system calls in the El Capitan developer preview fail with
<code>EPERM</code> instead of the usual <code>EACCES</code>. This
change uncovered a bug in the <code>unix</code> library where <code>EPERM</code> was not treated
similarly to <code>EACCES</code>. This was
<a href="https://github.com/haskell/unix/pull/18">fixed</a> in November 2014, a fix which
is included in GHC 7.10.1.</p>
<p>However, there have been a
<a href="https://mail.haskell.org/pipermail/ghc-devs/2015-July/009403.html">few calls</a>
on <code>ghc-devs</code> for a bugfix release of the 7.8 series including the updated <code>unix</code>. We
discussed this in the call today and concluded that we would not make such a
release. Given that El Capitan is not yet released and the issue is fixed in 7.10, it doesn’t seem worthwhile to put more developer time into 7.8. We would suggest that any El
Capitan user unable to update to GHC 7.10.1 or newer disable root-less mode for
the time being. This can be accomplished with,</p>
<pre><code>sudo nvram boot-args=&quot;rootless=0&quot;</code></pre>
<h2 id="infrastructure">Infrastructure</h2>
<p>Recently it came to our attention that one of the build machines used by
Harbormaster (Phabricator’s build mechanism) was still running GHC 7.6. If you
have seen strange validation issues on Harbormaster builds in the past, this is may
be the cause. As of today this is fixed; all Harbormaster validations are now
being built with GHC 7.8.4.</p>
<p>Harbormaster has historically had trouble working with Differentials which
changed submodule revisions. This has made testing revisions involving submodules quite tricky. Thanks to a
<a href="https://github.com/haskell-infra/phab-ghc-builder/pull/2">patch</a> from Adam Sandberg Eriksson Harbormaster can now grab submodule commits from non-upstream repositories if set in <code>.gitmodules</code>.</p>
<p>Herbert Valerio Riedel has been making great strides improving the
responsiveness of Trac. A Trac upgrade, a move to Postresql, and some fiddling
with the WSGI configuration should result in a much better experience for
everyone.</p>
<dl>
<dt>Have a great week!</dt>
<dd>
<p>Ben</p>
</dd>
</dl>
]]></description>
    <pubDate>Tue, 21 Jul 2015 00:00:00 UT</pubDate>
    <guid>http://haskell.org/ghc/blog/20150721-weekly20150721.html</guid>
    <dc:creator>ghc-devs</dc:creator>
</item>

    </channel>
</rss>
