22 months agoFix over-eager error suppression in TcErrors
Simon Peyton Jones [Thu, 5 Oct 2017 16:40:28 +0000 (17:40 +0100)] 
Fix over-eager error suppression in TcErrors

See Note [Given insolubles] in TcRnTypes

Fixes Trac #14325.

(cherry picked from commit c81f66ccafdb4c6c7a09cfaf6819c8797c518491)

22 months agobase: Make Foreign.Marshal.Alloc.allocBytes[Aligned] NOINLINE
Ben Gamari [Tue, 24 Oct 2017 16:19:08 +0000 (12:19 -0400)] 
base: Make Foreign.Marshal.Alloc.allocBytes[Aligned] NOINLINE

As noted in #14346, touch# may be optimized away when the simplifier can see
that the continuation passed to allocaBytes will not return. Marking CPS-style
functions with NOINLINE ensures that the simplier can't draw any unsound

Ultimately the right solution here will be to do away with touch# and instead
introduce a scoped primitive as is suggested in #14375.

22 months agorts/posix: Ensure that memory commit succeeds
Ben Gamari [Mon, 16 Oct 2017 21:30:12 +0000 (17:30 -0400)] 
rts/posix: Ensure that memory commit succeeds

Previously we wouldn't check that mmap would succeed. I suspect this may
have been the cause of #14329.

Test Plan: Validate under low-memory condition

Reviewers: simonmar, austin, erikd

Reviewed By: simonmar

Subscribers: rwbarton, thomie

GHC Trac Issues: #14329

Differential Revision:

(cherry picked from commit a69fa5441c944d7f74c76bdae9f3dd198007ee42)

22 months agoFix panic for `ByteArray#` arguments in CApiFFI foreign imports
Herbert Valerio Riedel [Mon, 16 Oct 2017 17:02:01 +0000 (19:02 +0200)] 
Fix panic for `ByteArray#` arguments in CApiFFI foreign imports

Declarations such as

  foreign import capi  unsafe "string.h strlen"
      c_strlen_capi :: ByteArray# -> IO CSize

  foreign import capi  unsafe "string.h memset"
      c_memset_capi :: MutableByteArray# s -> CInt -> CSize -> IO ()

would cause GHC to panic because the CApiFFI c-wrapper generator didn't
know what C type to use for `(Mutable)ByteArray#` types (unlike the
`ccall` codepath).

This addresses #9274

Reviewed By: bgamari

Differential Revision:

(cherry picked from commit add85cc2a3ec0bda810dca2a35264308ffaab069)

22 months agoEnable testing 'Natural' type in TEST=arith011
Herbert Valerio Riedel [Sat, 14 Oct 2017 18:37:47 +0000 (20:37 +0200)] 
Enable testing 'Natural' type in TEST=arith011

This now passes thanks to 5984a698fc2974b719365a9647a7cae1bed51eec (re #13203)

(cherry picked from commit 843772b86b62df686a9e57648fa9d3ed06b13973)

22 months agoOverride default `clearBit` method impl for `Natural`
Herbert Valerio Riedel [Mon, 16 Oct 2017 20:12:03 +0000 (22:12 +0200)] 
Override default `clearBit` method impl for `Natural`

The default implementation of `clearBit` is in terms of
`complement`. However, `complement` is not well-defined
for `Natural` and this consequently renders the default
implementation of `clearBit` dysfunctional.

This implements `clearBit` in terms of `testBit`
and `setBit` which are both well-defined for `Natural`s.

This addresses #13203

(cherry picked from commit 5984a698fc2974b719365a9647a7cae1bed51eec)

22 months agoDo not quantify over deriving clauses
Simon Peyton Jones [Thu, 12 Oct 2017 08:25:25 +0000 (09:25 +0100)] 
Do not quantify over deriving clauses

Trac #14331 showed that in a data type decl like

   data D = D deriving (C (a :: k))

we were quantifying D over the 'k' in the deriving clause.  Yikes.

Easily fixed, by deleting code in RnTypes.extractDataDefnKindVars

See the discussion on the ticket, esp comment:8.

(cherry picked from commit 82b77ec375ab74678ac2afecf55dc574fa24490f)

22 months agoFix nasty bug in w/w for absence analysis
Simon Peyton Jones [Mon, 2 Oct 2017 14:25:02 +0000 (15:25 +0100)] 
Fix nasty bug in w/w for absence analysis

This dark corner was exposed by Trac #14285.  It involves the
interaction between absence analysis and INLINABLE pragmas.

There is a full explanation in Note [aBSENT_ERROR_ID] in MkCore,
which you can read there.  The changes in this patch are

* Make exprIsHNF return True for absentError, treating
  absentError like an honorary data constructor.

* Make absentError /not/ be diverging, unlike other error Ids.

This is all a bit horrible.

* While doing this I found that exprOkForSpeculation didn't
  have a case for value lambdas so I added one.  It's not
  really called on lifted types much, but it seems like the
  right thing

(cherry picked from commit dbbee1bacef1a8accc630908c31cf267a3cb98a9)

23 months agoPackageDb: Explicitly unlock package database before closing
Ben Gamari [Tue, 29 Aug 2017 18:45:28 +0000 (14:45 -0400)] 
PackageDb: Explicitly unlock package database before closing

Reviewers: austin

Subscribers: rwbarton, thomie

GHC Trac Issues: #13945

Differential Revision:

(cherry picked from commit 779b9e6965416ee08af6eb15354cf09e9f40e0d9)

23 months agoghc-pkg: Try opening lockfiles in read-write mode first
Ben Gamari [Tue, 29 Aug 2017 18:26:55 +0000 (14:26 -0400)] 
ghc-pkg: Try opening lockfiles in read-write mode first

As pointed out in #13945, some filesystems only allow allow exclusive
locks if the fd being locked was opened for write access. This causes
ghc-pkg to fail as it first attempts to open and exclusively lock its
lockfile in read-only mode to accomodate package databases for which we
lack write permissions (e.g.  global package databases).

Instead, we now try read-write mode first, falling back to read-only
mode if this fails.

Reviewers: austin

Subscribers: rwbarton, thomie

GHC Trac Issues: #13945

Differential Revision:

(cherry picked from commit f86de44dac0a6ca40c5fcd65f3a1944c45fa6011)

23 months agoFix bug in the short-cut solver
Simon Peyton Jones [Mon, 2 Oct 2017 14:58:46 +0000 (15:58 +0100)] 
Fix bug in the short-cut solver

Trac #13943 showed that the relatively-new short-cut solver
for class constraints (aka -fsolve-constant-dicts) was wrong.
In particular, see "Type families" under Note [Shortcut solving]
in TcInteract.

The short-cut solver recursively solves sub-goals, but it doesn't
flatten type-family applications, and as a result it erroneously
thought that C (F a) cannot possibly match (C 0), which is
simply untrue.  That led to an inifinte loop in the short-cut

The significant change is the one line

+                 , all isTyFamFree preds  -- See "Type families" in
+                                          -- Note [Shortcut solving]

but, as ever, I do some other refactoring.  (E.g. I changed the
name of the function to shortCutSolver rather than the more
generic trySolveFromInstance.)

I also made the short-cut solver respect the solver-depth limit,
so that if this happens again it won't just produce an infinite

A bit of other refactoring, notably moving isTyFamFree
from TcValidity to TcType

(cherry picked from commit a8fde1831f4b99885b8ed444f9cd7dffd9252150)

23 months agoInclude libraries which fill holes as deps when linking.
Edward Z. Yang [Tue, 3 Oct 2017 19:08:24 +0000 (15:08 -0400)] 
Include libraries which fill holes as deps when linking.

Fixes the issue reported at
and fixes #14304 in the GHC tracker.

Signed-off-by: Edward Z. Yang <>
Test Plan: validate

Reviewers: bgamari, austin, goldfire

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #14304

Differential Revision:

(cherry picked from commit f3f624aeb1360c1f902930b3cc62346d2e5201c0)

23 months agouser-guide: fix examples of ghci commands
Takenobu Tani [Thu, 17 Aug 2017 14:28:01 +0000 (10:28 -0400)] 
user-guide: fix examples of ghci commands

Fix examples of ghci commands:
  * correct typos
  * add top-level binding without let statement
  * modify Time.getClockTime to Data.Time.getZonedTime
  * modify Directory.setCurrentDirectory
  * modify ghc version number

Test Plan: build

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision:

(cherry picked from commit 3385669683b8bc150c6df3cb43320dfc6f80fcd9)

23 months agouser-guide: add `:type +d` and `:type +v` in release highlight
Takenobu Tani [Thu, 17 Aug 2017 14:29:43 +0000 (10:29 -0400)] 
user-guide: add `:type +d` and `:type +v` in release highlight

Add new ghci command to release highlight and fix link anchor.

This commit is for ghc-8.2 branch.

Test Plan: build

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #11975

Differential Revision:

(cherry picked from commit 82ee71fa85aca087b2cd62cb354fc3df46db4411)

23 months agoModel divergence of retry# as ThrowsExn, not Diverges
Ben Gamari [Wed, 13 Sep 2017 16:22:27 +0000 (12:22 -0400)] 
Model divergence of retry# as ThrowsExn, not Diverges

The demand signature of the retry# primop previously had a Diverges
result.  However, this caused the demand analyser to conclude that a
program of the shape,

    catchRetry# (... >> retry#)

would diverge. Of course, this is plainly wrong; catchRetry#'s sole
reason to exist is to "catch" the "exception" thrown by retry#. While
catchRetry#'s demand signature correctly had the ExnStr flag set on its
first argument, indicating that it should catch divergence, the logic
associated with this flag doesn't apply to Diverges results. This
resulted in #14171.

The solution here is to treat the divergence of retry# as an exception.
Namely, give it a result type of ThrowsExn rather than Diverges.

Updates stm submodule for tests.

Test Plan: Validate with T14171

Reviewers: simonpj, austin

Subscribers: rwbarton, thomie

GHC Trac Issues: #14171, #8091

Differential Revision:

(cherry picked from commit 10a1a4781c646f81ca9e2ef7a2585df2cbe3a014)

23 months ago[RTS] Make -po work
Bartosz Nitka [Thu, 14 Sep 2017 09:50:05 +0000 (02:50 -0700)] 
[RTS] Make -po work

db2a667655506c43dd3c8260d29031bde55f1bee added `-po` option, but
the part that parses it was missing.

Test Plan:
On a simple file:
./inplace/bin/ghc-stage2 A.hs -prof -main-is A; ./A +RTS -P -potest
produced file and didn't produce file.

./A +RTS -P
produced file

Reviewers: simonmar, bgamari, austin, erikd

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision:

(cherry picked from commit b6b56dd1b6adc9051593955eecaef85c9d6e96b8)

23 months agouser-guide: Fix :since: annotation of -pie and add documentation for -fPIE
Ben Gamari [Mon, 2 Oct 2017 22:02:40 +0000 (18:02 -0400)] 
user-guide: Fix :since: annotation of -pie and add documentation for -fPIE

[skip ci]

(cherry picked from commit d5e60de307874432f42aa7fea2460e6901c057e1)

23 months agoAdd support for producing position-independent executables
Ben Gamari [Tue, 22 Aug 2017 15:41:47 +0000 (11:41 -0400)] 
Add support for producing position-independent executables

Previously due to #12759 we disabled PIE support entirely. However, this
breaks the user's ability to produce PIEs. Add an explicit flag, -fPIE,
allowing the user to build PIEs.

Test Plan: Validate

Reviewers: rwbarton, austin, simonmar

Subscribers: trommler, simonmar, trofi, jrtc27, thomie

GHC Trac Issues: #12759, #13702

Differential Revision:

(cherry-picked from commit 3625728a0e3a9b56c2b85ae7ea8bcabdd83ece6a)

23 months agouser-guide: Mention COMPLETE pragma in release notes
Ben Gamari [Mon, 2 Oct 2017 14:59:13 +0000 (10:59 -0400)] 
user-guide: Mention COMPLETE pragma in release notes

23 months agoRevert "Fix #11963 by checking for more mixed type/kinds"
Ben Gamari [Mon, 2 Oct 2017 14:13:42 +0000 (10:13 -0400)] 
Revert "Fix #11963 by checking for more mixed type/kinds"

This reverts commit 18dee8912f6afdcf13073d3d95d85513c14180e3.

It causes a few Hackage programs to be rejected, which we want to avoid
for a point release.

23 months agoUse libpthread instead of libthr on FreeBSD
Ben Gamari [Mon, 24 Jul 2017 23:02:56 +0000 (19:02 -0400)] 
Use libpthread instead of libthr on FreeBSD

Since #847 we have used libthr due to reported hangs with FreeBSD's
KSE-based M:N pthread implementation. However, this was nearly 12 years
ago and today libpthread seems to work fine. Moreover, adding -lthr to
the linker flags break when used in conjunction with -r when gold is
used (since -l and -r are incompatible although BFD ld doesn't

Test Plan: Validate on FreeBSD

Reviewers: kgardas, austin

Subscribers: rwbarton, thomie

GHC Trac Issues: #847

Differential Revision:

(cherry picked from commit d8051c6cf08f02331f98fed7d5e88a95bd76e534)

23 months agoconfigure: Make sure we try all possible linkers
Ben Gamari [Wed, 27 Sep 2017 19:30:18 +0000 (15:30 -0400)] 
configure: Make sure we try all possible linkers

Previously if we had both ld.lld and installed but a gcc which
didn't support -fuse-ld=lld we would fail when trying ld.lld and fall
immediately back to plain ld. Now we will try as well. This was
brought to light by #14280, where using ld.bfd resulted in a broken
stage2 compiler.

Test Plan: Configure

Reviewers: angerman, hvr, austin

Reviewed By: angerman

Subscribers: rwbarton, thomie, erikd

GHC Trac Issues: #14280

Differential Revision:

(cherry picked from commit a10729f028d7175980d9f65e22c9bb9a933461c2)

23 months agoincludes/rts: Drop trailing comma ghc-8.2.2-rc1
Ben Gamari [Fri, 8 Sep 2017 02:49:22 +0000 (22:49 -0400)] 
includes/rts: Drop trailing comma

This trailing comma snuck in in a recent patch. There is nothing wrong with the
comma; it's perfectly valid C99, yet nevertheless Mac OS X's dtrace utility
chokes on it with,

    dtrace: failed to compile script rts/RtsProbes.d:
            "includes/rts/EventLogFormat.h", line 245: syntax error near "}"
    make[1]: *** [rts/dist/build/RtsProbes.h] Error 1

(cherry picked from commit be514a694f2cddbb1b23af971430364a223eb894)

23 months agomkDataConRep: fix bug in strictness signature (#14290)
Simon Marlow [Thu, 28 Sep 2017 17:08:45 +0000 (13:08 -0400)] 
mkDataConRep: fix bug in strictness signature (#14290)

The strictness signature for a data con wrapper wasn't including any
dictionary arguments, which meant that bangs on the fields of a
constructor with an existential context would be moved to the wrong
fields.  See T14290 for an example.

Test Plan:
* New test T14290
* validate

Reviewers: simonpj, niteria, austin, bgamari, erikd

Reviewed By: simonpj, bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #14290

Differential Revision:

(cherry picked from commit 5935acdb1302263011c2023d5e7f4ec496c972c0)

23 months agodesugar: Catch levity polymorphism in unboxed sum expressions
Ben Gamari [Tue, 26 Sep 2017 18:52:26 +0000 (14:52 -0400)] 
desugar: Catch levity polymorphism in unboxed sum expressions

Fixes #13929.

(cherry picked from commit 018c40fb1bb27853d0cefa5b90a44ce13e91a856)

23 months agotestsuite: Add unboxed sum to T13929
Ben Gamari [Tue, 19 Sep 2017 23:09:58 +0000 (19:09 -0400)] 
testsuite: Add unboxed sum to T13929

Test Plan: Validate

Reviewers: austin

Subscribers: rwbarton, thomie

GHC Trac Issues: #13929

Differential Revision:

(cherry picked from commit d86b237d612bf6ca1faa61ff1130ad9144e32a52)

23 months agoFix #13929 by adding another levity polymorphism check
Richard Eisenberg [Wed, 16 Aug 2017 15:35:26 +0000 (11:35 -0400)] 
Fix #13929 by adding another levity polymorphism check

test case: typecheck/should_fail/T13929

(cherry picked from commit fa626f3b1c1140a1f10bba60fdde10f767863f70)

23 months agoRelease console for ghci wrapper
Tamar Christina [Tue, 26 Sep 2017 18:43:15 +0000 (19:43 +0100)] 
Release console for ghci wrapper

It seems the call that caused issues with the gcc wrapper before
was needed for the ghci wrapper in order for the child process
to be the one handling console events.

This code slightly refactors the wrappers to make sure only ghci
calls FreeConsole and nothing else.

Test Plan: ./validate , open ghci.exe press ctrl+c

Reviewers: RyanGlScott, austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, erikd

GHC Trac Issues: #14150

Differential Revision:

(cherry picked from commit 3ec579d5d13dd00af58380a34daa2d57f0b9aa9e)

23 months agoFix "Glasgow Haskell Compiler <release> Users Guide"
Bartosz Nitka [Mon, 17 Apr 2017 16:49:34 +0000 (12:49 -0400)] 
Fix "Glasgow Haskell Compiler <release> Users Guide"

If you go to
the window title has `<release>` in it.  I don't understand how it all
works, but inspired by the line below which produces a correct string in
the docs I just blindly changed it in the same way.  Cabal appears to
have the same problem.

Test Plan:
it'd be nice if I could check the result
on harbormaster, can I?

Reviewers: thomie, bgamari, austin

Reviewed By: bgamari

Subscribers: rwbarton, simonmar

Differential Revision:

23 months agoFix unused-given-constraint bug
Simon Peyton Jones [Tue, 19 Sep 2017 11:37:13 +0000 (12:37 +0100)] 
Fix unused-given-constraint bug

This bug was shown up by Trac #14237.  It turned out
to be an outright error in TcSimplify.neededEvVars,
easily fixed.

I improved the comments.

(cherry picked from commit 1db0f4a48e9db5e85782e32f074cc83bbc145cb7)

23 months agoDeal with large extra-contraints wildcards
Simon Peyton Jones [Thu, 21 Sep 2017 16:35:11 +0000 (17:35 +0100)] 
Deal with large extra-contraints wildcards

For reasons explained in TcHsType
Note [Extra-constraint holes in partial type signatures],
if we had
  f :: (_) => blahs
and the '_' was filled in by more than a 62-tuple of contraints,
GHC crashed.

The same Note explains the hacky solution I have adopted to
evade this.  Maybe there is some better way, but I couldn't
see one that didn't involve a great deal of work. And the problem
is a very narrow one!  If the hack bites us we'll need to think

(cherry picked from commit 3c74a51232813eb733b27c43c94ce005112a0ddb)

23 months agoDocument Typeable's treatment of kind polymorphic tycons
Ben Gamari [Mon, 25 Sep 2017 22:33:06 +0000 (18:33 -0400)] 
Document Typeable's treatment of kind polymorphic tycons

Test Plan: Read it

Reviewers: dfeuer, goldfire, austin, hvr

Reviewed By: dfeuer

Subscribers: rwbarton, thomie

GHC Trac Issues: #14199

Differential Revision:

(cherry picked from commit 6de1a5a96cdaba080570e9f47ff8711796e2e83b)

23 months agoBump Cabal submodule
Ben Gamari [Tue, 26 Sep 2017 14:11:12 +0000 (10:11 -0400)] 
Bump Cabal submodule

23 months agoRevert "Improve error messages around kind mismatches."
Ben Gamari [Tue, 19 Sep 2017 21:14:25 +0000 (17:14 -0400)] 
Revert "Improve error messages around kind mismatches."

This reverts commit eb870ae0e9d3943268263e6f9ef1c844cdd4cdc5.
This reverts commit 6a024a55fa5deefaa45bc2abee9efa63d290266d.

There was some disagreement in #11198 regarding whether this patch was
in fact the right solution to the issue at hand.

23 months agoOption "-ddump-rn-ast" dumps imports and exports too
Alan Zimmerman [Wed, 13 Sep 2017 12:02:42 +0000 (14:02 +0200)] 
Option "-ddump-rn-ast" dumps imports and exports too

Previously the renamed source decls only were dumped, now the imports, exports
and doc_hdr are too.

Test Plan: ./validate

Reviewers: bgamari, austin

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #14197

Differential Revision:

(cherry picked from commit 2fe6f6baba70de071c391bccc77197ab4f81064d)

23 months agoSetLevels: Substitute in ticks in lvlMFE
Ben Gamari [Mon, 4 Sep 2017 12:05:33 +0000 (08:05 -0400)] 
SetLevels: Substitute in ticks in lvlMFE

Previously SetLevels.lvlMFE would fail to substitute in ticks, unlike
lvlExpr.  This lead to #13481. Fix this.

Test Plan: `make test TEST=T12622 WAY=ghci`

Reviewers: austin, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, thomie

GHC Trac Issues: #13481

Differential Revision:

(cherry picked from commit cd857dd415378ac4204a164407d350b0c3ede5ae)

23 months agorts: Add heap breakdown type for -hT
Ben Gamari [Mon, 4 Sep 2017 12:15:08 +0000 (08:15 -0400)] 
rts: Add heap breakdown type for -hT

Test Plan: Build, program with `-eventlog`, try running with `+RTS -h`

Reviewers: austin, erikd, simonmar

Subscribers: rwbarton, thomie

GHC Trac Issues: #14096

Differential Revision:

(cherry picked from commit 24e50f988f775c6bba7d1daaee2e23c13650aa3b)

23 months agoeventlog: Clean up profiling heap breakdown type
Ben Gamari [Mon, 4 Sep 2017 12:14:38 +0000 (08:14 -0400)] 
eventlog: Clean up profiling heap breakdown type

Reviewers: austin, erikd, simonmar

Subscribers: rwbarton, thomie

GHC Trac Issues: #14096

Differential Revision:

(cherry picked from commit 822abbb1b4300ebaa3f12014b9fc477261283143)

23 months agoDeal with unbreakable blocks in Applicative Do
David Feuer [Fri, 8 Sep 2017 03:56:35 +0000 (23:56 -0400)] 
Deal with unbreakable blocks in Applicative Do

The renamer wasn't able to deal with more than a couple strict
patterns in a row with `ApplicativeDo` when using the heuristic
splitter. Update it to work with them properly.

Reviewers: simonmar, austin, bgamari, hvr

Reviewed By: simonmar

Subscribers: RyanGlScott, lippling, rwbarton, thomie

GHC Trac Issues: #14163

Differential Revision:

(cherry picked from commit 011e15aa2d6949fc56126f1028ea25d5497196d9)

23 months agoBetter document TypeRep patterns
Ben Gamari [Wed, 13 Sep 2017 16:23:47 +0000 (12:23 -0400)] 
Better document TypeRep patterns

As pointed out in #14199 these are rather non-trivial; extra
documentation is in order.

[skip ci]

Test Plan: Read it

Reviewers: dfeuer, austin, hvr

Subscribers: rwbarton, thomie

GHC Trac Issues: #14199

Differential Revision:

(cherry picked from commit f9bf621caf2fc17d829dee0ee48b204144927e72)

23 months agoReally fix Trac #14158
Simon Peyton Jones [Wed, 30 Aug 2017 15:19:37 +0000 (16:19 +0100)] 
Really fix Trac #14158

I dug more into how #14158 started working. I temporarily reverted the
patch that "fixed" it, namely

    commit a6c448b403dbe8720178ca82100f34baedb1f47e
    Author: Simon Peyton Jones <>
    Date:   Mon Aug 28 17:33:59 2017 +0100

    Small refactor of getRuntimeRep

Sure enough, there was a real bug, described in the new
TcExpr Note [Visible type application zonk]

In general, syntactic substituion should be kind-preserving!
Maybe we should check that invariant...

(cherry picked from commit 2c133b67df374c73bc8069cefd7d57e1d2a14fc3)

23 months agoFix subtle bug in TcTyClsDecls.mkGADTVars
Simon Peyton Jones [Sat, 2 Sep 2017 17:13:32 +0000 (18:13 +0100)] 
Fix subtle bug in TcTyClsDecls.mkGADTVars

This bug was revealed by Trac #14162.  In a GADT-style data-family
instance we ended up a data constructor whose type mentioned
an out-of-scope variable.  (This variable was in the kind of
a variable in the kind of a variable.)

Only Lint complained about this (actually only when the
data constructor was injected into the bindings by CorePrep).
So it doesn't matter much -- but it's a solid bug and might
bite us some day.

It took me quite a while to unravel because the test case was itself
quite tricky.  But the fix is easy; just add a missing binding to the
substitution we are building up.  It's in the regrettably-subtle
mkGADTVars function.

(cherry picked from commit 3a27e34f7a59a30f91fad9dd2ca194acdb1bcb1a)

23 months agoRenamer now preserves location for IEThingWith list items
Alan Zimmerman [Fri, 15 Sep 2017 18:35:51 +0000 (14:35 -0400)] 
Renamer now preserves location for IEThingWith list items

Prior to this, in the RenamedSource for

    module Renaming.RenameInExportedType
      MyType (NT)
      ) where

    data MyType = MT Int | NT

The (NT) was given the location of MyType earlier on the line in the
export list.

Also the location was discarded for any field labels, and replaced with
a `noLoc`.

Test Plan: ./validate

Reviewers: bgamari, austin

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #14189

Differential Revision:

(cherry picked from commit 9498c50ef5af2680305e0aaea6f32439cacc3da0)

23 months agoFix #14228 by marking SumPats as non-irrefutable
Ryan Scott [Fri, 15 Sep 2017 18:34:58 +0000 (14:34 -0400)] 
Fix #14228 by marking SumPats as non-irrefutable

`isIrrefutableHsPat` should always return `False` for unboxed sum
patterns (`SumPat`s), since they always have at least one other
corresponding pattern of the same arity (since the minimum arity for a
`SumPat` is 2). Failure to do so causes incorrect code to be generated
for pattern synonyms that use unboxed sums, as shown in #14228.

Test Plan: make test TEST=T14228

Reviewers: austin, bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, thomie

GHC Trac Issues: #14228

Differential Revision:

(cherry picked from commit f4d50a0ec0d23dbcd61a014c8a773030c8fe310d)

23 months agoAdd a Note describing #14128
Ben Gamari [Tue, 29 Aug 2017 23:14:22 +0000 (19:14 -0400)] 
Add a Note describing #14128

I prematurely committed the D3892 before adding a Note. Fix this.

(cherry picked from commit 6f1ccaa50f905bdc586a7a92ab7e38e30c1e7ff5)

23 months agotestsuite: Add test for #14128
Ben Gamari [Sat, 26 Aug 2017 20:16:47 +0000 (16:16 -0400)] 
testsuite: Add test for #14128

Reviewers: austin, goldfire

Subscribers: rwbarton, thomie

GHC Trac Issues: #14128

Differential Revision:

(cherry picked from commit 248ad30385acc0f81f1959b6345a7388be76dc85)

23 months agodesugar: Ensure that a module's dep_orphs doesn't contain itself
Ben Gamari [Sat, 26 Aug 2017 20:17:18 +0000 (16:17 -0400)] 
desugar: Ensure that a module's dep_orphs doesn't contain itself

Consider that we have two modules, A and B, both with hs-boot files,

  * A.hs contains a SOURCE import of B
  * B.hs-boot contains a SOURCE import of A
  * A.hs-boot declares an orphan instance
  * A.hs defines the orphan instance

In this case, B's dep_orphs will contain A due to its SOURCE import of
A.  Consequently, A will contain itself in its imp_orphs due to its
import of B.  This fact would end up being recorded in A's interface
file. This would then break the invariant asserted by calculateAvails
that a module does not itself in its dep_orphs. This was the cause
of #14128.

The solution is to remove self-references from imp_orphs when
constructing dep_orphs; we already did a similar thing for dep_mods. I
believe we should do the same for dep_finsts, although I'm treating this
as a separate bug.

Reviewers: austin

Subscribers: rwbarton, thomie

Differential Revision:

(cherry picked from commit db3a8e168ad81f54ec58eebc4c75a0eaad889daf)

23 months agoTest #11672 in typecheck/should_fail/T11672.
Richard Eisenberg [Thu, 1 Jun 2017 22:28:57 +0000 (18:28 -0400)] 
Test #11672 in typecheck/should_fail/T11672.

I believe this was fixed with the fix for #11198.

(cherry picked from commit 9a54975665f23df8c8137da24028a5aec4c77fba)

23 months agoFix tests
Ben Gamari [Tue, 19 Sep 2017 20:15:05 +0000 (16:15 -0400)] 
Fix tests

2 years agoImprove error messages around kind mismatches.
Richard Eisenberg [Thu, 1 Jun 2017 21:27:14 +0000 (17:27 -0400)] 
Improve error messages around kind mismatches.

Previously, when canonicalizing (or unifying, in uType) a
heterogeneous equality, we emitted a kind equality and used the
resulting coercion to cast one side of the heterogeneous equality.

While sound, this led to terrible error messages. (See the bugs
listed below.) The problem is that using the coercion built from
the emitted kind equality is a bit like a wanted rewriting a wanted.
The solution is to keep heterogeneous equalities as irreducible.

See Note [Equalities with incompatible kinds] in TcCanonical.

This commit also removes a highly suspicious switch to FM_SubstOnly
when flattening in the kinds of a type variable. I have no idea
why this was there, other than as a holdover from pre-TypeInType.
I've not left a Note because there is simply no reason I can conceive
of that the FM_SubstOnly should be there.

One challenge with this patch is that the emitted derived equalities
might get emitted several times: when a heterogeneous equality is
in an implication and then gets floated out from the implication,
the Derived is present both in and out of the implication. This
causes a duplicate error message. (Test case:
typecheck/should_fail/T7368) Solution: track the provenance of
Derived constraints and refuse to float out a constraint that has
an insoluble Derived.

Lastly, this labels one test (dependent/should_fail/RAE_T32a)
as expect_broken, because the problem is really #12919. The
different handling of constraints in this patch exposes the error.

This fixes bugs #11198, #12373, #13530, and #13610.

test cases:

(cherry picked from commit 8e15e3d370e9c253ae0dbb330e25b72cb00cdb76)

2 years agoFix decomposition error on Windows
Tamar Christina [Tue, 29 Aug 2017 21:59:38 +0000 (22:59 +0100)] 
Fix decomposition error on Windows

Fix the path decomposition error that occurs when the Symlink resolver
fails. `Win32.try` throws an exception, so catch it and assume the path
isn't a symlink to use the old behavior.

Test Plan: ./validate

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #14159

Differential Revision:

(cherry picked from commit 3c6b2fc3b5ca11a5410405664e4640767ef941dd)

2 years agoSmall refactor of getRuntimeRep
Simon Peyton Jones [Mon, 28 Aug 2017 16:33:59 +0000 (17:33 +0100)] 
Small refactor of getRuntimeRep

Instead of using a string argument, use HasDebugCallStack.
(Oddly, some functions were using both!)

Plus, use getRuntimeRep rather than getRuntimeRep_maybe when
if the caller panics on Nothing. Less code, and a better debug

(cherry picked from commit a6c448b403dbe8720178ca82100f34baedb1f47e)

2 years agoUse a well-kinded substitution to instantiate
Simon Peyton Jones [Mon, 28 Aug 2017 16:21:14 +0000 (17:21 +0100)] 
Use a well-kinded substitution to instantiate

In tcDataConPat we were creating an ill-kinded substitution
-- or at least one that is well kinded only after you have solved
other equalities.  THat led to a crash, because the instantiated
data con type was ill-kinded.

This patch guarantees that the instantiating substitution is

Fixed Trac #14154

(cherry picked from commit 4455c86d1635bfb846e750b21dda36dcee028b5e)

2 years agoDo not discard insolubles in implications
Simon Peyton Jones [Thu, 27 Jul 2017 13:52:38 +0000 (14:52 +0100)] 
Do not discard insolubles in implications

Trac #14000 showed up two errors

* In TcRnTypes.dropInsolubles we dropped all implications, which
  might contain the very insolubles we wanted to keep.  This was
  an outright error, and is why the out-of-scope error was actually
  lost altogether in Trac #14000

* In TcSimplify.simplifyInfer, if there are definite (insoluble)
  errors, it's better to suppress the following ambiguity test,
  because the type may be bogus anyway.  See TcSimplify
  Note [Quantification with errors].  This fix seems a bit clunky,
  but it'll do for now.

(cherry picked from commit 452755de717fad5d8fbfc6330cb42a3335c8912d)

2 years agoFix string escaping in JSON
Dmitry Malikov [Sat, 5 Aug 2017 14:28:40 +0000 (16:28 +0200)] 
Fix string escaping in JSON

It seems to that double quotes is not escaped well at the moment.

We'd noticed this with @alexbiehl during the work on
(cherry picked from commit e8fe12f83b17dc39d9272d44c4168946fa54e7a0)

2 years agoEnsure that we always link against libm
Ben Gamari [Fri, 28 Jul 2017 17:41:04 +0000 (13:41 -0400)] 
Ensure that we always link against libm is particularly picky that we declare all of our link
dependencies on Nix. See #14022.

Test Plan: Validate on Nix

Reviewers: austin

Subscribers: hvr, rwbarton, thomie

GHC Trac Issues: #14022

Differential Revision:

(cherry picked from commit 0e3c10160472df082fd3decd98c2489a2f8e68bd)

2 years agoFix #13947 by checking for unbounded names more
Ryan Scott [Tue, 11 Jul 2017 17:59:29 +0000 (13:59 -0400)] 
Fix #13947 by checking for unbounded names more

Commit 2484d4dae65c81f218dcfe494b963b2630bb8fa6 accidentally dropped a
call to `isUnboundName` in an important location. This re-adds it.

Fixes #13947.

Test Plan: make test TEST=T13947

Reviewers: adamgundry, austin, bgamari

Reviewed By: adamgundry

Subscribers: rwbarton, thomie

GHC Trac Issues: #13947

Differential Revision:

(cherry picked from commit 85ac65c5f0b057f1b07ed7bf9a8d9aeae4ce1390)

2 years agoFix #11963 by checking for more mixed type/kinds
Richard Eisenberg [Tue, 18 Jul 2017 19:49:38 +0000 (15:49 -0400)] 
Fix #11963 by checking for more mixed type/kinds

This is a straightforward fix -- there were just some omitted

test case: typecheck/should_fail/T11963

(cherry picked from commit 10d13b62c7ba8c44000a0d25afd66788de8040c4)

2 years agoFix #14125 by normalizing data family instances more aggressively
Ryan Scott [Tue, 22 Aug 2017 13:28:43 +0000 (09:28 -0400)] 
Fix #14125 by normalizing data family instances more aggressively

Commit 3540d1e1a23926ce0a8a6ae83a36f5f6b2497ccf inadvertently broke
the ability for newtype instances to be used as marshallable types in FFI
declarations. The reason is a bit silly: an extra check was added for type
synonyms with no type families on the RHS in `normalise_tc_app`, but this check
would only skip over type families, not //data// families, since the predicate
being used was `not . isTypeFamilyCon`.

The fix is simple: just use `not . isFamilyCon` instead so that data families
are also skipped by this check.

Test Plan: make test TEST=T14125

Reviewers: goldfire, simonpj, austin, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, thomie

GHC Trac Issues: #14125

Differential Revision:

(cherry picked from commit 6982ee99fb97c252c3faf37faae34131fb66f67c)

2 years agoFix incorrect retypecheck loop in -j (#14075)
Edward Z. Yang [Tue, 22 Aug 2017 12:44:25 +0000 (08:44 -0400)] 
Fix incorrect retypecheck loop in -j (#14075)

The parallel codepath was incorrectly retypechecking the
hs-boot ModIface prior to typechecking the hs file,
which was inconsistent with the non-parallel case.  The
non-parallel case gets it right: you don't want to retypecheck
the hs-boot file itself (forwarding its declarations to hs)
because you need it to be consistently knot-tied with itself
when you compare the interfaces.

Signed-off-by: Edward Z. Yang <>
Test Plan: validate

Reviewers: bgamari, simonpj, austin

Reviewed By: bgamari

Subscribers: duog, rwbarton, thomie

GHC Trac Issues: #14075

Differential Revision:

(cherry picked from commit 4717ce8658f12f425aebd1fc7f7ad8fe04a81df5)

2 years agoKnownUniques: Handle DataCon wrapper names
Ben Gamari [Tue, 1 Aug 2017 02:33:24 +0000 (22:33 -0400)] 
KnownUniques: Handle DataCon wrapper names

For some reason these weren't handled. I seem to remember thinking I had
a reason for omitting them when writing the original patch, but I don't
recall what that reason was at this point and clearly workers do show up
in interface files.

Test Plan: Validate against T14051

Reviewers: austin

Subscribers: rwbarton, thomie, RyanGlScott

GHC Trac Issues: #14051

Differential Revision:

(cherry picked from commit 5a7af95ad2ce38e4b80893d869948c630454683b)

2 years agoCNF: Implement compaction for small pointer arrays
Ben Gamari [Fri, 25 Aug 2017 01:55:27 +0000 (21:55 -0400)] 
CNF: Implement compaction for small pointer arrays

Test Plan: Validate

Reviewers: austin, erikd, simonmar, dfeuer

Reviewed By: dfeuer

Subscribers: rwbarton, andrewthad, thomie, dfeuer

GHC Trac Issues: #13860, #13857

Differential Revision:

(cherry picked from commit 5f3d2d3be034e04ba872f2695ab6d7b75de66663)

2 years agoFix loading of dlls on 32bit windows
Sergey Vinokurov [Sun, 20 Aug 2017 21:40:08 +0000 (00:40 +0300)] 
Fix loading of dlls on 32bit windows

The point of fix is to handle case when loaded dll loads no
other dlls, i.e. it's import table is empty.

GHC Trac Issues: #14081

(cherry picked from commit 34bd43d9c24207a1897aaa4ee6cb70592a3f7acc)

2 years agotestsuite: Fix test output of determ021
Ben Gamari [Mon, 21 Aug 2017 20:32:56 +0000 (16:32 -0400)] 
testsuite: Fix test output of determ021

2 years agoFix #11400, #11560 by documenting an infelicity.
Richard Eisenberg [Thu, 1 Jun 2017 22:09:05 +0000 (18:09 -0400)] 
Fix #11400, #11560 by documenting an infelicity.

Really, the fix for both of these is #11307.

(cherry picked from commit c9667d321c94ff0f67b73aa7bd560c38873f7df5)

2 years agoFix a bug in -foptimal-applicative-do
Simon Marlow [Mon, 12 Jun 2017 21:00:39 +0000 (17:00 -0400)] 
Fix a bug in -foptimal-applicative-do

Test Plan: validate

Reviewers: bgamari, niteria, austin, erikd

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision:

(cherry picked from commit 7e0ef11324712b4ff3ac8f39259e5ecbd63c2356)

2 years agoDocument that type holes kill polymorphic recursion
Richard Eisenberg [Tue, 18 Jul 2017 19:55:21 +0000 (15:55 -0400)] 
Document that type holes kill polymorphic recursion

This "fixes" #11995.

(cherry picked from commit ca471860494484210b6291dd96d1e0868da750e7)

2 years agoaclocal.m4: respect user's --with-ar= choice
Sergei Trofimovich [Mon, 17 Apr 2017 08:41:49 +0000 (09:41 +0100)] 
aclocal.m4: respect user's --with-ar= choice

'FP_PROG_AR' macro has a minor bug: it ignores
already existing value stored in '$fp_prog_ar'.

I've noticed it when tried to built UNREG ghc using thin LTO:

  $ ./configure --enable-unregisterised \
                --with-nm=gcc-nm \
                --with-ar=gcc-ar \
                --with-ranlib=gcc-ranlib \

./configure refused to use 'gcc-ar' (LTO-aware variant of 'ar')
and kept using 'ar'.

'$fp_prog_ar' is initialized (in a complex manner) in '' as:

    FP_ARG_WITH_PATH_GNU_PROG([AR], [ar], [ar])

The change keeps that value.

Signed-off-by: Sergei Trofimovich <>
(cherry picked from commit 79848f18805ad8eba48c9897c5d53afbd17ab44d)

2 years agoconfigure: Ensure that user's LD setting is respected
Ben Gamari [Fri, 28 Jul 2017 17:35:01 +0000 (13:35 -0400)] 
configure: Ensure that user's LD setting is respected

This broke in the fix for #13541.

(cherry picked from commit d08b9ccdf2812e8f8fa34d0c89275deee574524c)

2 years agoFix lld detection if both gold and lld are found
Ben Gamari [Fri, 28 Jul 2017 15:48:52 +0000 (11:48 -0400)] 
Fix lld detection if both gold and lld are found

If you have and ld.lld, then will be selected by the
detection logic. This patch prioritizes lld by changing the order. The
rationale for checking lld first is that it's (right now) not part of,
say, a default Linux distro installation and if it's available, it's
very likely that it was installed explicitly and should be seen as a
sign of preference. On FreeBSD LLVM is the (default) base toolchain and
the changed order makes sense there as well, since can be
available in /usr/local via ports/pkg. I don't have access to macOS and
can't say anything about their LLVM toolchain.

At some point we could add a check for LD=ld.lld or as an
optional override to explicitly select a linker.

Since I cannot really remove gcc on Linux, this was the only way to
configure GHC to use ld.lld.

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, erikd

Tags: PHID-PROJ-5azim3sqhsf7wzvlvaag

Differential Revision:

(cherry picked from commit 2974f81f8c3529657a0b808b8415a4d2ad9ed6d1)

2 years agoFix errant whitespace
Ben Gamari [Sun, 23 Jul 2017 19:48:56 +0000 (15:48 -0400)] 
Fix errant whitespace


(cherry picked from commit 0ff40df30128d24118947c82bd970fc013522e18)

2 years agoFix more documentation wibbles
Ben Gamari [Sun, 23 Jul 2017 18:13:16 +0000 (14:13 -0400)] 
Fix more documentation wibbles

Fixes #14020, #14016, #14015, #14019

(cherry picked from commit 2dff2c7fbb5aa68445e617d691451c0427fad0a5)

2 years agousers-guide: Fix various wibbles
Ben Gamari [Sun, 23 Jul 2017 16:59:49 +0000 (12:59 -0400)] 
users-guide: Fix various wibbles

(cherry picked from commit c9451959d8796ee5458cd0666dd2bc2114ac10d7)

2 years agousers-guide: Standardize and repair all flag references
Patrick Dougherty [Sun, 23 Jul 2017 16:55:37 +0000 (12:55 -0400)] 
users-guide: Standardize and repair all flag references

This patch does three things:

1.) It simplifies the flag parsing code in `` to properly display
flag definitions created by `.. (ghc|rts)-flag::`. Additionally, all flag
references must include the associated arguments. Documentation has been
added to `editing-guide.rst` to explain this.

2.) It normalizes all flag definitions to a similar format. Notably, all
instances of `<>` have been replaced with `⟨⟩`. All references across the
users guide have been updated to match.

3.) It fixes a couple issues with the flag reference table's generation code,
which did not handle comma separated flags in the same cell and did not
properly reference flags with arguments.

Test Plan:
`SPHINXOPTS = -n` to activate "nitpicky" mode, which reports all broken
references. All remaining errors are references to flags without any

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13980

Differential Revision:

(cherry picked from commit 44b090be9a6d0165e2281542a7c713da1799e885)

2 years agodistrib/configure: Carry FFI include/lib paths from source distribution
Ben Gamari [Sun, 23 Jul 2017 14:43:52 +0000 (10:43 -0400)] 
distrib/configure: Carry FFI include/lib paths from source distribution

`FFILibDir` and `FFIIncludeDir` both show up in the `rts` library's
package registration file.  We therefore must define them or else we'll
end up with spurious `@FFILibDir@` strings in the package registration.

In principle I think we could also take these as arguments to the
bindist configure but this seems simpler and I don't want to verify this
at the moment.

Test Plan: Build bindist while passing `--with-ffi-libraries=...` to
source distribution configure then try to install and use bindist.

Reviewers: austin, hvr

Subscribers: rwbarton, thomie, erikd

Differential Revision:

(cherry picked from commit 98ab12ad0c13b6723cc667d6a00fe592f1833bf4)

2 years agoFix up ghci changelog
Ben Gamari [Sun, 23 Jul 2017 15:15:06 +0000 (11:15 -0400)] 
Fix up ghci changelog

2 years agoFix compact regions notes
Ben Gamari [Sun, 23 Jul 2017 14:27:42 +0000 (10:27 -0400)] 
Fix compact regions notes

2 years agoFix links to SPJ’s papers (fixes #12578)
Takenobu Tani [Wed, 19 Jul 2017 19:06:27 +0000 (15:06 -0400)] 
Fix links to SPJ’s papers (fixes #12578)

This fixes #12578.
Update links to SPJ's papers in following files:

  * compiler/coreSyn/CoreSyn.hs
  * docs/users_guide/using-optimisation.rst
  * docs/users_guide/parallel.rst
  * docs/users_guide/glasgow_exts.rst

This commit is for ghc-8.2 branch.

Test Plan: build

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #12578

Differential Revision:

(cherry picked from commit 1ed41a7413a45e11a9bad3aafcfb7ee3f26236e4)

2 years agoAdd some missing release notes entries
Ben Gamari [Sun, 23 Jul 2017 13:29:06 +0000 (09:29 -0400)] 
Add some missing release notes entries

2 years agoSet RELEASE=NO
Ben Gamari [Sat, 22 Jul 2017 21:52:08 +0000 (17:52 -0400)] 

2 years agoFix label type for __stginit_* labels: those are .data labels, not .text
Sergei Trofimovich [Sat, 22 Jul 2017 09:49:12 +0000 (10:49 +0100)] 
Fix label type for __stginit_* labels: those are .data labels, not .text

Noticed when was building --enable-unregisterised build for x86_64:

  /tmp/ghc22931_0/ghc_3.hc:5:9: error:
       error: '__stginit_ghczmprim_GHCziTypes' redeclared as different kind of symbol
       StgWord __stginit_ghczmprim_GHCziTypes[]__attribute__((aligned(8)))= {
  5 | StgWord __stginit_ghczmprim_GHCziTypes[]__attribute__((aligned(8)))= {
    |         ^

  In file included from /tmp/ghc22931_0/ghc_3.hc:3:0: error:

  /tmp/ghc22931_0/ghc_3.hc:4:5: error:
       note: previous declaration of '__stginit_ghczmprim_GHCziTypes' was here

The error here is mismatch in symbol type: EF_ ("external function")
It should be EC_ ("external closure").

The same build failure does not happen in HEAD because the __stginit_*
is not generated there anymore (see a92ff5d66182d992d02dfaad4c446ad074582368)

Fixes #14009

Signed-off-by: Sergei Trofimovich <>
2 years agoaclocal.m4: allow arbitrary <vendor> string in toolchain triplets
Sergei Trofimovich [Sat, 8 Jul 2017 08:47:12 +0000 (09:47 +0100)] 
aclocal.m4: allow arbitrary <vendor> string in toolchain triplets

Canonical triplets have a form of

Checking for vendor is almost never correct as it's an
arbitrary string.

It's useful to have multiple "vendors" to denote
otherwise the same (WRT <arch>, <os>, <abi>) target:

Do not fail unknown vendors. Only emit a warning.
Ideally configure checks should never use "vendor".

Signed-off-by: Sergei Trofimovich <>
(cherry picked from commit c2303dff95aa174021a1950656fdf9a1cf983959)

2 years agoRelease 8.2.1 ghc-8.2.1-release
Ben Gamari [Fri, 21 Jul 2017 21:28:19 +0000 (17:28 -0400)] 
Release 8.2.1

2 years agorelnotes: Fix wibbles
Ben Gamari [Fri, 21 Jul 2017 22:39:22 +0000 (18:39 -0400)] 
relnotes: Fix wibbles

2 years agorelnotes: Address split sections and linker changes
Ben Gamari [Fri, 21 Jul 2017 22:10:06 +0000 (18:10 -0400)] 
relnotes: Address split sections and linker changes

Thanks to @duog for mentioning that this wasn't covered.

2 years agoUpdate autoconf scripts
Ben Gamari [Fri, 21 Jul 2017 21:58:22 +0000 (17:58 -0400)] 
Update autoconf scripts

Scripts taken from autoconf 81497f5aaf50a12a9fe0cba30ef18bda46b62959

2 years agoBump integer-gmp version
Ben Gamari [Fri, 21 Jul 2017 21:31:03 +0000 (17:31 -0400)] 
Bump integer-gmp version

2 years agoBump Cabal submodule to
Ben Gamari [Fri, 21 Jul 2017 18:56:05 +0000 (14:56 -0400)] 
Bump Cabal submodule to

2 years agotypo: -XUndeci[d]ableInstances
Chris Martin [Sun, 16 Jul 2017 00:23:50 +0000 (19:23 -0500)] 
typo: -XUndeci[d]ableInstances

(cherry picked from commit 927e7810f7dcea295c1f8e93535835e52da0edbb)

2 years agobase: Improve docs to clarify when finalizers may not be run
Andrew Martin [Thu, 13 Jul 2017 15:09:34 +0000 (11:09 -0400)] 
base: Improve docs to clarify when finalizers may not be run

(cherry picked from commit b066d936a919f6943de1acdc358d9e014b2cc663)

2 years agorelnotes: More updates
Ben Gamari [Fri, 21 Jul 2017 01:48:01 +0000 (21:48 -0400)] 
relnotes: More updates

2 years agobuild system: Ensure there are no duplicate files in bindist list
Ben Gamari [Fri, 21 Jul 2017 01:39:27 +0000 (21:39 -0400)] 
build system: Ensure there are no duplicate files in bindist list

Several executables inexplicably appear twice in bindist.list, which
ends up producing multiple tar file entries, consequently breaking BSD
tar during extraction. I spent a fair amount of time trying to work out
where these duplicates were coming from to no avail. Since Hadrian is
right around the corner I'm satisfied with a terrible hack: just uniq
bindist.list before producing the bindist tarball.

Test Plan: Validate

Reviewers: austin

Subscribers: rwbarton, thomie

GHC Trac Issues: #13979, #13974

Differential Revision:

(cherry picked from commit fefcbfa86b73517d5002366d0703ce694c6d228d)

2 years agoHsPat: Assume that no spliced patterns are irrefutable
Ben Gamari [Thu, 20 Jul 2017 23:24:00 +0000 (19:24 -0400)] 
HsPat: Assume that no spliced patterns are irrefutable

This is a conservative assumption which will limit some uses of spliced
patterns, but it fixes #13984.

Test Plan: Validate

Reviewers: RyanGlScott, AaronFriel, austin

Reviewed By: RyanGlScott

Subscribers: rwbarton, thomie

GHC Trac Issues: #13984

Differential Revision:

(cherry picked from commit 36e8bcba08446dbc4e7532ef9db5517c13977bf9)

2 years agoBump process submodule to
Ben Gamari [Thu, 20 Jul 2017 16:54:00 +0000 (12:54 -0400)] 
Bump process submodule to

2 years agoMake IfaceAxiom typechecking lazier.
Edward Z. Yang [Thu, 20 Jul 2017 15:30:46 +0000 (11:30 -0400)] 
Make IfaceAxiom typechecking lazier.

Fixes #13803, but adds a note about a yet to be fixed #13981.

Signed-off-by: Edward Z. Yang <>
Test Plan: validate

Reviewers: bgamari, austin

Reviewed By: bgamari

Subscribers: simonpj, rwbarton, thomie

GHC Trac Issues: #13803

Differential Revision:

(cherry picked from commit fdb6a5bfd545094782fb539951b561ac2467443d)

2 years agodistrib/configure: Canonicalize triples
Ben Gamari [Thu, 20 Jul 2017 15:34:00 +0000 (11:34 -0400)] 
distrib/configure: Canonicalize triples

Previously we failed to do this, which meant that the bindist's
configure would fail when passed --target (as you may need to do when
installing an armv7 bindist on an aarch64 machine, for instance).

Reviewers: hvr, erikd, austin

Reviewed By: hvr

Subscribers: rwbarton, thomie

GHC Trac Issues: #13934

Differential Revision:

(cherry picked from commit 1480080b31e9f7cd47ca7b677455b3558b0da2bc)

2 years agorts: Claim AP_STACK before adjusting Sp
Ben Gamari [Thu, 20 Jul 2017 15:33:51 +0000 (11:33 -0400)] 
rts: Claim AP_STACK before adjusting Sp

In the fix to #13615 we introduced some logic to atomically blackhole
AP_STACKs closures upon entry. However, this logic was placed *after* a
stack pointer adjustment. This meant that if someone else beat us to
blackholing the AP_STACK we would suspend the thread with uninitialized
content on the stack.  This would then later blow up when threadPaused
attempted to walk the stack, hence #13970.

Silly bug but still cost lots of head-scratching to find.

Thanks to albertov for the great repro.

Fixes #13970. Bug originally introduced by the fix to #13615.

Reviewers: austin, erikd, simonmar

Reviewed By: erikd, simonmar

Subscribers: rwbarton, thomie

GHC Trac Issues: #13970, #13615

Differential Revision:

(cherry picked from commit bade356f79d44c9f6e8918a89d9ffac7f5608dbf)

2 years agoghc-prim: Bump version
Ben Gamari [Thu, 20 Jul 2017 15:27:45 +0000 (11:27 -0400)] 
ghc-prim: Bump version

2 years agoBump haddock submodule
Ben Gamari [Thu, 20 Jul 2017 12:43:01 +0000 (08:43 -0400)] 
Bump haddock submodule

2 years agodmdAnal: Ensure that ExnStr flag isn't dropped inappropriately
Ben Gamari [Wed, 19 Jul 2017 19:07:52 +0000 (15:07 -0400)] 
dmdAnal: Ensure that ExnStr flag isn't dropped inappropriately

This fixes #13977 and consequently #13615. Here an optimization in the
demand analyser was too liberal, causing us to drop the ExnStr flag and
consequently resulting in incorrect demand signatures. This manifested
as a segmentation fault in #13615 as we incorrectly concluded that an
application of catchRetry# would bottom.

Specifically, we had

    orElse' :: STM a -> STM a -> STM a
    orElse' x = catchRetry# x y
      where y = {- some action -}

Where the catchRetry# primop places a demand of <xC(S),1*C1(U)> on its
first argument. However, due to #13977 the demand analyser would assign
a demand of <C(S),1*C1(U)> on the first argument of orElse'. Note the
missing `x`.

    case orElse' bottomingAction anotherAction of { x -> Just x }

being transformed to,

    case orElse' bottomingAction anotherAction of {}

by the simplifier. This would naturally blow up when orElse' returned at
runtime, causing the segmentation fault described in #13615.

Test Plan: Validate, perhaps add a testcase

Reviewers: austin, simonpj

Reviewed By: simonpj

Subscribers: rwbarton, thomie

GHC Trac Issues: #13977, #13615

Differential Revision:

(cherry picked from commit c940e3b92f4527ca59fcae93f36c869de3e7ccb9)