ghc.git
21 months agoRmove a call to mkStatePrimTy
Simon Peyton Jones [Tue, 19 Dec 2017 10:37:13 +0000 (10:37 +0000)] 
Rmove a call to mkStatePrimTy

This is a tiny refactoring that removes one of the calls
to mkStatePrimTy, in service to Trac #14596

21 months agoStop runRW# being magic
Simon Peyton Jones [Tue, 19 Dec 2017 10:35:27 +0000 (10:35 +0000)] 
Stop runRW# being magic

Triggered by thinking about Trac #14596, I found that runRW#
does not need to be a "magic" wired-in Id, now that we have
levity polymorphism.

This patch stops it being wired-in.

21 months agoGet rid of some stuttering in comments and docs
Gabor Greif [Tue, 19 Dec 2017 12:52:06 +0000 (13:52 +0100)] 
Get rid of some stuttering in comments and docs

22 months agoTypos in comments
Gabor Greif [Mon, 18 Dec 2017 17:36:58 +0000 (18:36 +0100)] 
Typos in comments

22 months agotestsuite: Semigroup/Monoid compat for T3001-2
Ben Gamari [Thu, 14 Dec 2017 22:26:43 +0000 (17:26 -0500)] 
testsuite: Semigroup/Monoid compat for T3001-2

22 months agotestsuite: Exit with non-zero exit code when tests fail
Ben Gamari [Thu, 14 Dec 2017 22:08:36 +0000 (17:08 -0500)] 
testsuite: Exit with non-zero exit code when tests fail

22 months agoBlackholes can be large objects (#14497)
Simon Marlow [Mon, 18 Dec 2017 16:23:16 +0000 (11:23 -0500)] 
Blackholes can be large objects (#14497)

Test Plan: validate

Reviewers: bgamari, niteria, erikd, dfeuer

Reviewed By: dfeuer

Subscribers: Yuras, dfeuer, rwbarton, thomie, carter

GHC Trac Issues: #14497

Differential Revision: https://phabricator.haskell.org/D4254

22 months agoFix scoping of pattern-synonym existentials
Simon Peyton Jones [Mon, 18 Dec 2017 12:03:33 +0000 (12:03 +0000)] 
Fix scoping of pattern-synonym existentials

This patch fixes Trac #14998, where we eventually decided that
the existential type variables of the signature of a pattern
synonym should not scope over the pattern synonym.

See Note [Pattern synonym existentials do not scope] in TcPatSyn.

22 months agoTiny refactor: use mkTyVarNamePairs
Simon Peyton Jones [Mon, 18 Dec 2017 12:01:58 +0000 (12:01 +0000)] 
Tiny refactor: use mkTyVarNamePairs

22 months agoAdd missing case to HsExpr.isMonadFailStmtContext
Simon Peyton Jones [Mon, 18 Dec 2017 11:55:16 +0000 (11:55 +0000)] 
Add missing case to HsExpr.isMonadFailStmtContext

This fixes Trac #14591

I took the opportunity to delete the dead code isMonadCompExpr

22 months agoAdd some commentary re: fix to #11203
Richard Eisenberg [Fri, 15 Dec 2017 19:27:47 +0000 (14:27 -0500)] 
Add some commentary re: fix to #11203

The fix for #11203 prohibits duplicate SigTvs in non-CUSK kind
signatures by checking for duplicates after type inference is
done. This works well. GHC also checks for duplicate SigTvs
after working with partial type signatures (another place where
SigTvs arise). However, neither fix eliminates this whole class
of problems (because doing so would be heavier than we would
like). So, this comment adds a warning to users of newSigTyVar
to be aware of problems with duplicates.

22 months agoFix tcDataKindSig
Simon Peyton Jones [Fri, 15 Dec 2017 09:29:12 +0000 (09:29 +0000)] 
Fix tcDataKindSig

This patch fixes an outright bug in tcDataKindSig, shown up in Trac
of a data type declaration.  See Note [TyConBinders for the result kind
signature of a data type]

I also took the opportunity to elminate the DataKindCheck argument
and data type from tcDataKindSig, instead moving the check to the
call site, which is easier to understand.

22 months agousers-guide: Fix various bits of markup
Ben Gamari [Thu, 14 Dec 2017 21:52:59 +0000 (16:52 -0500)] 
users-guide: Fix various bits of markup

(cherry picked from commit 15b2b959abbc724187b0e58979968d24ab323681)

22 months agousers-guide: Consistently document LLVM version requirement
Ben Gamari [Thu, 14 Dec 2017 18:44:52 +0000 (13:44 -0500)] 
users-guide: Consistently document LLVM version requirement

(cherry picked from commit fdccc6666d838cf8708b9fc03a9ce2aa04fe9439)

22 months agoFix #14135 by validity checking matches
Carlos Tomé [Mon, 11 Dec 2017 20:38:03 +0000 (15:38 -0500)] 
Fix #14135 by validity checking matches

We filter the complete patterns given in a COMPLETE set to only those that
subsume the type we are matching. Otherwise we end up introducing an ill-typed
equation into the overlap checking, provoking a crash. This was the cause of
Trac #14135.

Reviewers: austin, bgamari, mpickering, gkaracha, simonpj, RyanGlScott,
carlostome

Reviewed By: bgamari

Subscribers: carter, dfeuer, RyanGlScott, goldfire, rwbarton, thomie

GHC Trac Issues: #14135

Differential Revision: https://phabricator.haskell.org/D3981

22 months agotypos in local var
Gabor Greif [Thu, 14 Dec 2017 15:57:28 +0000 (16:57 +0100)] 
typos in local var

22 months agoBetter tc-trace messages
Simon Peyton Jones [Thu, 14 Dec 2017 13:27:52 +0000 (13:27 +0000)] 
Better tc-trace messages

22 months agoFix an outright bug in the unflattener
Simon Peyton Jones [Thu, 14 Dec 2017 13:25:48 +0000 (13:25 +0000)] 
Fix an outright bug in the unflattener

Trac #14554 showed up an outright bug in the unflattening code in
TcFlatten.  I was filling in a coercion with the wrong coercion (a Syn
in the wrong place).  Result: "Bad coercion hole" assertion failures,
and Core Lint Errors.

Easily fixed, and the code is simpler too.

22 months agoAdd test for Trac #14580
Simon Peyton Jones [Thu, 14 Dec 2017 11:39:19 +0000 (11:39 +0000)] 
Add test for Trac #14580

22 months agoTypofix in comment
Gabor Greif [Wed, 13 Dec 2017 21:59:03 +0000 (22:59 +0100)] 
Typofix in comment

22 months agoFurther improvements to well-kinded types
Simon Peyton Jones [Wed, 13 Dec 2017 12:53:26 +0000 (12:53 +0000)] 
Further improvements to well-kinded types

The typechecker has the invariant that every type should be well-kinded
as it stands, without zonking.  See Note [The well-kinded type invariant]
in TcType.

That invariant was not being upheld, which led to Trac #14174.  I fixed
part of it, but T14174a showed that there was more.  This patch finishes
the job.

* See Note [The tcType invariant] in TcHsType, which articulates an
  invariant that was very nearly, but not quite, true.  One place that
  falisified it was the HsWildCardTy case of tc_hs_type, so I fixed that.

* mkNakedCastTy now makes no attempt to eliminate casts; indeed it cannot
  lest it break Note [The well-kinded type invariant].  The prior comment
  suggested that it was crucial for performance but happily it seems not
  to be. The extra Refls are eliminated by the zonker.

* I found I could tidy up TcHsType.instantiateTyN and instantiateTyUntilN
  by eliminating one of its parameters.  That led to a cascade of minor
  improvements in TcTyClsDecls. Hooray.

22 months agoRe-centre perf for T5321Fun
Simon Peyton Jones [Wed, 13 Dec 2017 16:00:14 +0000 (16:00 +0000)] 
Re-centre perf for T5321Fun

Bytes allocated has fallen by around 5%. I think this due
to some of my recent refactoring of the typechecker, but
I'm not certain about exactly which change did it.

Good though!

22 months agoAdd missing stderr for Trac #14561
Simon Peyton Jones [Wed, 13 Dec 2017 15:56:41 +0000 (15:56 +0000)] 
Add missing stderr for Trac #14561

22 months agoTidy up of wired-in names
Simon Peyton Jones [Wed, 13 Dec 2017 10:49:31 +0000 (10:49 +0000)] 
Tidy up of wired-in names

Two things here:

* While debugging Trac #14561 I found it hard to understand
  ghcPrimIds and magicIds in MkId.  This patch adds more
  structure and comments.

* I also discovered that ($) no longer needs to be a wiredInId
  because we now have levity polymorphism.  So I took dollarId
  out of MkId; and gave it a levity-polymorphic type in GHC.Base

22 months agoDetect levity-polymorphic uses of unsafeCoerce#
Simon Peyton Jones [Wed, 13 Dec 2017 10:46:26 +0000 (10:46 +0000)] 
Detect levity-polymorphic uses of unsafeCoerce#

This bug was shown up by Trac #14561. The deguarer carefully
detects unsaturated and levity-polymorphic uses of primops,
but not of things like unsafeCoerce#.

The fix is simple: see Note [Levity-polymorphic Ids] in Id.

22 months agoMinor refactor of TcExpr.tcApp
Simon Peyton Jones [Wed, 13 Dec 2017 10:37:57 +0000 (10:37 +0000)] 
Minor refactor of TcExpr.tcApp

This refactoring has no change in behaviour but makes the
structure clearer

22 months agoAdd regression test for #14040
Ryan Scott [Tue, 12 Dec 2017 15:16:39 +0000 (10:16 -0500)] 
Add regression test for #14040

This adds a regression test for the original program in #14040.

This does not fix #14040 entirely, though, as the program in
https://ghc.haskell.org/trac/ghc/ticket/14040#comment:2 still
panics, so there is more work to be done there.

22 months agobase: fdReady(): Return only after sycall returns after `msecs` have passed
Niklas Hambüchen [Mon, 11 Dec 2017 18:07:38 +0000 (13:07 -0500)] 
base: fdReady(): Return only after sycall returns after `msecs` have passed

Reviewers: bgamari, austin, hvr, dfeuer

Reviewed By: dfeuer

Subscribers: syd, dfeuer, rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D4012

22 months agofdReady: Use C99 bools / CBool in signature
Niklas Hambüchen [Mon, 11 Dec 2017 18:06:33 +0000 (13:06 -0500)] 
fdReady: Use C99 bools / CBool in signature

Reviewers: bgamari, Phyx, austin, hvr, simonmar

Reviewed By: bgamari

Subscribers: syd, rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D4041

22 months agoAllow users to ignore optimization changes
David Feuer [Mon, 11 Dec 2017 18:03:52 +0000 (13:03 -0500)] 
Allow users to ignore optimization changes

* Add a new flag, `-fignore-optim-changes`, allowing them to avoid
  recompilation if the only changes are to the `-O` level or to
  flags controlling optimizations.

* When `-fignore-optim-changes` is *off*, recompile when optimization
  flags (e.g., `-fno-full-laziness`) change. Previously, we ignored
  these unconditionally when deciding whether to recompile a module.

Reviewers: austin, bgamari, simonmar

Reviewed By: simonmar

Subscribers: duog, carter, simonmar, rwbarton, thomie

GHC Trac Issues: #13604

Differential Revision: https://phabricator.haskell.org/D4123

22 months agoAlways use the safe open() call
Simon Marlow [Mon, 11 Dec 2017 17:56:09 +0000 (12:56 -0500)] 
Always use the safe open() call

open() can sometimes take a long time, for example on NFS or FUSE
filesystems.  We recently had a case where open() was taking multiple
seconds to return for a (presumably overloaded) FUSE filesystem, which
blocked GC and caused severe issues.

Test Plan: validate

Reviewers: niteria, bgamari, nh2, hvr, erikd

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #13296

Differential Revision: https://phabricator.haskell.org/D4239

22 months agorts: Don't default to single capability when profiled
Ben Gamari [Mon, 11 Dec 2017 17:55:31 +0000 (12:55 -0500)] 
rts: Don't default to single capability when profiled

This was presumably a vestige of the days when the profiled RTS couldn't
run threaded. Fixes #14545.

Test Plan: simonmar

Reviewers: erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14545

Differential Revision: https://phabricator.haskell.org/D4245

22 months agoAdd NOINLINE pragma to hPutStr'
Matthew Pickering [Mon, 11 Dec 2017 17:54:18 +0000 (12:54 -0500)] 
Add NOINLINE pragma to hPutStr'

There appears to be no benefit in inlining this function.
If you turn up the unfolding threshold a lot then it eventually
inlines which produces a bit unoptimisable program.

Reviewers: hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision: https://phabricator.haskell.org/D4246

22 months agoAdd information about irrefutable pattern Syntax to XStrict.
klebinger.andreas@gmx.at [Mon, 11 Dec 2017 17:53:54 +0000 (12:53 -0500)] 
Add information about irrefutable pattern Syntax to XStrict.

This information was present in the ghc wiki but not the user guide.
[skip ci]

Test Plan: None

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: RyanGlScott, rwbarton, thomie, carter

Differential Revision: https://phabricator.haskell.org/D4250

22 months agoImprove Control.Monad.guard and Control.Monad.MonadPlus docs
Nathan Collins [Mon, 11 Dec 2017 17:52:55 +0000 (12:52 -0500)] 
Improve Control.Monad.guard and Control.Monad.MonadPlus docs

This fixes Issue #12372: documentation for Control.Monad.guard not
useful after AMP.

Reviewers: hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision: https://phabricator.haskell.org/D4258

22 months agoFixed misprint 'aqcuired'
Kirill Zaborsky [Mon, 11 Dec 2017 15:04:55 +0000 (18:04 +0300)] 
Fixed misprint 'aqcuired'

22 months agoOnly look for locales of the form LL.VV
Gabor Greif [Thu, 30 Nov 2017 19:49:03 +0000 (20:49 +0100)] 
Only look for locales of the form LL.VV

Because in recent RHEL7 suddenly locales like `bokmål` pop up, which
screw up reading-in of ASCII strings a line later. This additional
criterion reliably eliminates those unicode characters.

22 months agoFix SigTvs at the kind level
Simon Peyton Jones [Mon, 11 Dec 2017 15:53:32 +0000 (15:53 +0000)] 
Fix SigTvs at the kind level

This patch fixes two bugs in the treatment of SigTvs at the
kind level:

- We should always generalise them, never default them
  (Trac #14555, #14563)

- We should check if they get unified with each other
  (Trac #11203)

Both are described in TcHsType
   Note [Kind generalisation and SigTvs]

22 months agoBuild only well-kinded types in type checker
Simon Peyton Jones [Mon, 11 Dec 2017 11:52:44 +0000 (11:52 +0000)] 
Build only well-kinded types in type checker

During type inference, we maintain the invariant that every type is
well-kinded /without/ zonking; and in particular that typeKind does
not fail (as it can for ill-kinded types).

But TcHsType.tcInferApps was not guaranteeing this invariant,
resulting in Trac #14174 and #14520.

This patch fixes it, making things better -- but it does /not/
fix the program in Trac #14174 comment:5, which still crashes.
So more work to be done.

See Note [Ensure well-kinded types] in TcHsType

22 months agoImproved panic message for zonkTcTyVarToTyVar
Simon Peyton Jones [Fri, 8 Dec 2017 17:32:16 +0000 (17:32 +0000)] 
Improved panic message for zonkTcTyVarToTyVar

22 months agoAdd hadrian as a submodule
Ben Gamari [Fri, 8 Dec 2017 18:02:06 +0000 (13:02 -0500)] 
Add hadrian as a submodule

It will remain a submodule until we are ready to merge Hadrian into the
tree.

22 months agoRip out hadrian subtree
Ben Gamari [Fri, 8 Dec 2017 17:42:35 +0000 (12:42 -0500)] 
Rip out hadrian subtree

Sadly subtrees haven't worked quite as well as we would have liked for
developers. See Hadrian #440.

22 months agoOccurrrence analysis improvements for NOINLINE functions
Simon Peyton Jones [Fri, 8 Dec 2017 15:39:05 +0000 (15:39 +0000)] 
Occurrrence analysis improvements for NOINLINE functions

This patch fixes #14567.  The idea is simple: if a function
is marked NOINLINE then it makes a great candidate for a loop
breaker.

Implementation is easy too, but it needs a little extra plubming,
notably the occ_unf_act field in OccEnv

22 months agoImprove LiberateCase
Simon Peyton Jones [Fri, 8 Dec 2017 15:31:36 +0000 (15:31 +0000)] 
Improve LiberateCase

This patch, which fixes Trac #14566, makes LiberateCase a little
more conservative.  In particular:

* In libCaseBind, treat a recursive group as a whole, rather than
  binding-by-binding, allowing the group to be duplicated only if
    - the bindings /considered together/ are smaller than the
      liberate-case threshold (which is large by default)
    - none of them are thunks
    - none of them are guaranteed-diverging

  The latter condidtion is new, and happens to apply in the
  case of Data/Typeable/Internal.mkTrApp

22 months agoRefactor kcHsTyVarBndrs
Simon Peyton Jones [Thu, 7 Dec 2017 14:31:53 +0000 (14:31 +0000)] 
Refactor kcHsTyVarBndrs

This refactoring

* Renames kcHsTyVarBndrs to kcLHsQTyVars,
  which is more truthful. It is only used in getInitialKind.

* Pulls out bind_telescope from that function, and calls it
  kcLHsTyVarBndrs, again to reflect its argument

* Uses the new kcLHsTyVarBndrs in kcConDecl, where the old
  function was wild overkill.

There should not be any change in behaviour

22 months agoRevert accidental hsc2hs submodule downgrade
Herbert Valerio Riedel [Thu, 7 Dec 2017 19:05:56 +0000 (20:05 +0100)] 
Revert accidental hsc2hs submodule downgrade

This submodule update was committed unintentionally in
fa29df02a1b0b926afb2525a258172dcbf0ea460

22 months agoRefactor ConDecl: Trac #14529
Simon Peyton Jones [Tue, 28 Nov 2017 11:33:37 +0000 (11:33 +0000)] 
Refactor ConDecl: Trac #14529

This patch refactors HsDecls.ConDecl.  Specifically

* ConDeclGADT was horrible, with all the information hidden
  inside con_res_ty.  Now it's kept separate, as it should be.

* ConDeclH98: use [LHsTyVarBndr] instead of LHsQTyVars for the
  existentials. There is no implicit binding here.

* Add a field con_forall to both ConDeclGADT and ConDeclH98
  which says if there is an explicit user-written forall.

* Field renamings in ConDecl
     con_cxt     to con_mb_cxt
     con_details to con_args

There is an accompanying submodule update to Haddock.

Also the following change turned out to remove a lot of clutter:

* add a smart constructor for HsAppsTy, namely mkHsAppsTy,
  and use it consistently. This avoids a lot of painful pattern
  matching for the common singleton case.

Two api-annotation tests (T10278, and T10399) are broken, hence marking
them as expect_broken(14529).  Alan is going to fix them, probably by
changing the con_forall field to
   con_forall :: Maybe SrcSpan
instead of Bool

22 months agoForward-port changes from GHC 8.2 branch
Herbert Valerio Riedel [Thu, 7 Dec 2017 08:58:00 +0000 (09:58 +0100)] 
Forward-port changes from GHC 8.2 branch

(cherry picked from commit 3fa061a647d2fdc182eff9296eea02d6a7d516cd)

22 months agoutils/hsc2hs: update submodule
Sergei Trofimovich [Tue, 5 Dec 2017 07:51:16 +0000 (07:51 +0000)] 
utils/hsc2hs: update submodule

This pulls single change to fix building of cross-compilers:
* ghc.mk: Use the same conditional install logic from unlit

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision: https://phabricator.haskell.org/D4248

22 months agorts: fix filename case for mingw32 target
Sergei Trofimovich [Tue, 5 Dec 2017 07:49:24 +0000 (07:49 +0000)] 
rts: fix filename case for mingw32 target

The failure is visible when we build a cross-compiler
from linux to mingw32 as:

```
    $ ./configure --host=x86_64-pc-linux-gnu \
                  --target=x86_64-w64-mingw32
    $ make
    rts/linker/PEi386.c:159:10: error:
         fatal error: Psapi.h: No such file or directory
         #include <Psapi.h>
                  ^~~~~~~~~
        |
    159 | #include <Psapi.h>
        |          ^
```

The problem here is case-sensitive linux filesystem. On windows
it does not matter what case is used for includes and libraries.

mingw32 provides all libraries and headers lowercase. This change
fixes case for <dbghelp.h>, <psapi.h>, -ldbghelp, -lpsapi.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Reviewers: bgamari, erikd, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision: https://phabricator.haskell.org/D4247

22 months agoBump version to 8.5 ghc-8.5-start
Ben Gamari [Wed, 29 Nov 2017 14:54:14 +0000 (09:54 -0500)] 
Bump version to 8.5

The ghc-8.4 branch has now been cut. Updates the haddock submodule.

22 months agoFix ghc_packages
Ben Gamari [Mon, 4 Dec 2017 21:15:52 +0000 (16:15 -0500)] 
Fix ghc_packages

The LaTeX produced by this previously failed to compile. Changing the first cell
of the row from an inline to a paragraph fixes this. Then I noticed that the
table overflowed the page. This is fixed by applying the longtable class.

22 months agotemplate-haskell: Rip out FamFlavour
Ben Gamari [Mon, 4 Dec 2017 18:50:36 +0000 (13:50 -0500)] 
template-haskell: Rip out FamFlavour

This was scheduled to happen for 8.2, it looks like it will actually
happen in 8.4.

22 months agoMake the Con and Con' patterns produce evidence
David Feuer [Mon, 4 Dec 2017 13:27:18 +0000 (08:27 -0500)] 
Make the Con and Con' patterns produce evidence

Matching with the `Con` and `Con'` patterns can reveal evidence
that the type in question is *not* an application. This can help
the pattern checker.

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: carter, rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D4139

22 months agoCache TypeRep kinds aggressively
David Feuer [Fri, 1 Dec 2017 22:00:24 +0000 (17:00 -0500)] 
Cache TypeRep kinds aggressively

Cache `TypeRep k` in each `TrApp` or `TrTyCon` constructor of
`TypeRep (a :: k)`. This makes `typeRepKind` cheap.

With this change, we won't need any special effort to deserialize
typereps efficiently. The downside, of course, is that we make
`TypeRep`s slightly larger.

Reviewers: austin, hvr, bgamari, simonpj

Reviewed By: bgamari, simonpj

Subscribers: carter, simonpj, rwbarton, thomie

GHC Trac Issues: #14254

Differential Revision: https://phabricator.haskell.org/D4085

22 months agoAdd trace injection
David Feuer [Fri, 1 Dec 2017 20:59:24 +0000 (15:59 -0500)] 
Add trace injection

Add support for injecting runtime calls to `trace` in `DsM`. This
allows the desugarer to add compile-time information to a runtime
trace.

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: carter, thomie, rwbarton

Differential Revision: https://phabricator.haskell.org/D4162

22 months agoHandle CPP properly in Backpack
Edward Z. Yang [Sat, 25 Nov 2017 02:12:05 +0000 (10:12 +0800)] 
Handle CPP properly in Backpack

Summary:
Previously, we attempted to lookup 'hole' packages for
include directories; this obviously is not going to work.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Test Plan: validate

Reviewers: ekmett, bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #14525

Differential Revision: https://phabricator.haskell.org/D4234

22 months agoMake use of boot TyThings during typechecking.
Edward Z. Yang [Mon, 30 Oct 2017 00:15:07 +0000 (20:15 -0400)] 
Make use of boot TyThings during typechecking.

Summary:
Suppose that you are typechecking A.hs, which transitively imports,
via B.hs, A.hs-boot.  When we poke on B.hs and discover that it
has a reference to a type from A, what TyThing should we wire
it up with?  Clearly, if we have already typechecked A, we
should use the most up-to-date TyThing: the one we freshly
generated when we typechecked A.  But what if we haven't typechecked
it yet?

For the longest time, GHC adopted the policy that this was
*an error condition*; that you MUST NEVER poke on B.hs's reference
to a thing defined in A.hs until A.hs has gotten around to checking
this.  However, actually ensuring this is the case has proven
to be a bug farm.  The problem was especially poignant with
type family consistency checks, which eagerly happen before
any typechecking takes place.

This patch takes a different strategy: if we ever try to access
an entity from A which doesn't exist, we just fall back on the
definition of A from the hs-boot file.  This means that you may
end up with a mix of A.hs and A.hs-boot TyThings during the
course of typechecking.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Test Plan: validate

Reviewers: simonpj, bgamari, austin, goldfire

Subscribers: thomie, rwbarton

GHC Trac Issues: #14396

Differential Revision: https://phabricator.haskell.org/D4154

22 months agoDarwin: Use gmp from homebrew
Ben Gamari [Wed, 29 Nov 2017 22:02:17 +0000 (17:02 -0500)] 
Darwin: Use gmp from homebrew

As discussed on ghc-devs, OS X appears to ship an old or otherwise broken gmp.

https://mail.haskell.org/pipermail/ghc-devs/2017-June/014321.html

22 months agoDarwin: Set deployment target
Ben Gamari [Wed, 29 Nov 2017 22:01:07 +0000 (17:01 -0500)] 
Darwin: Set deployment target

22 months agoBump unix submodule
Ben Gamari [Wed, 29 Nov 2017 20:23:41 +0000 (15:23 -0500)] 
Bump unix submodule

Fixes FreeBSD build.

22 months agoComments only: Trac #14511
Simon Peyton Jones [Tue, 28 Nov 2017 16:02:18 +0000 (16:02 +0000)] 
Comments only: Trac #14511

22 months agoMinor tweaks to codegens.rst
Steven Shaw [Wed, 29 Nov 2017 07:16:14 +0000 (17:16 +1000)] 
Minor tweaks to codegens.rst

A couple of nits involving the letter 'C'.

22 months agoCircleCI: Freeze all packages at fixed index state
Ben Gamari [Wed, 29 Nov 2017 15:22:50 +0000 (10:22 -0500)] 
CircleCI: Freeze all packages at fixed index state

We will periodically bump this as necessary.

22 months agoCircleCI: Disallow hscolour 1.24.3
Ben Gamari [Wed, 29 Nov 2017 14:58:42 +0000 (09:58 -0500)] 
CircleCI: Disallow hscolour 1.24.3

This release does not build.

22 months agoCLabel: A bit of documentation
Ben Gamari [Tue, 28 Nov 2017 20:35:32 +0000 (15:35 -0500)] 
CLabel: A bit of documentation

22 months agoCmm: Add missing cases for BlockInfoTable
Ben Gamari [Tue, 28 Nov 2017 19:32:34 +0000 (14:32 -0500)] 
Cmm: Add missing cases for BlockInfoTable

Silly rabbit, BlockInfoTables are data. This fixes the unregisterised build,
finally fixing #14454.

22 months agoCLabel: More specific debug output from CLabel
Ben Gamari [Tue, 28 Nov 2017 19:23:02 +0000 (14:23 -0500)] 
CLabel: More specific debug output from CLabel

22 months agonativeGen: Use foldl' instead of foldl
Ben Gamari [Tue, 28 Nov 2017 01:02:55 +0000 (20:02 -0500)] 
nativeGen: Use foldl' instead of foldl

22 months agonativeGen: Use plusUFMList instead of foldr
Ben Gamari [Tue, 28 Nov 2017 01:02:25 +0000 (20:02 -0500)] 
nativeGen: Use plusUFMList instead of foldr

22 months agoCLabel: Refactor pprDynamicLinkerAsmLabel
Ben Gamari [Tue, 14 Nov 2017 19:58:40 +0000 (14:58 -0500)] 
CLabel: Refactor pprDynamicLinkerAsmLabel

22 months agocmm: Use LocalBlockLabel instead of AsmTempLabel to represent blocks
Ben Gamari [Mon, 13 Nov 2017 17:34:54 +0000 (12:34 -0500)] 
cmm: Use LocalBlockLabel instead of AsmTempLabel to represent blocks

blockLbl was originally changed in 8b007abbeb3045900a11529d907a835080129176 to
use mkTempAsmLabel to fix an inconsistency resulting in #14221. However, this
breaks the C code generator, which doesn't support AsmTempLabels (#14454).

Instead let's try going the other direction: use a new CLabel variety,
LocalBlockLabel. Then we can teach the C code generator to deal with
these as well.

22 months agoCLabel.labelType: Make catch-all case explicit
Ben Gamari [Tue, 14 Nov 2017 22:34:36 +0000 (17:34 -0500)] 
CLabel.labelType: Make catch-all case explicit

22 months agobase: Rip out old RTS statistics interface
Ben Gamari [Mon, 27 Nov 2017 19:02:56 +0000 (14:02 -0500)] 
base: Rip out old RTS statistics interface

Test Plan: Validate

Reviewers: simonmar, hvr

Subscribers: rwbarton, thomie

GHC Trac Issues: #14516

Differential Revision: https://phabricator.haskell.org/D4228

22 months agorelnotes: Rework treatment of included package list
Ben Gamari [Mon, 27 Nov 2017 19:01:02 +0000 (14:01 -0500)] 
relnotes: Rework treatment of included package list

Previously the included package lists took a disproportionate amount of
space in the resulting document and were difficult to maintain. Turn it
into a table.

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D4230

22 months agoDon't call alex for Cabal lib during GHC build
Tobias Dammers [Mon, 27 Nov 2017 19:00:50 +0000 (14:00 -0500)] 
Don't call alex for Cabal lib during GHC build

The Cabal library now commits `Lexer.hs` directly to the source tree,
so the build step where we'd call alex ourselves to generate that file
is no longer necessary, nor will it work.

See also: https://ghc.haskell.org/trac/ghc/ticket/14459

Reviewers: bgamari, hvr

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14459

Differential Revision: https://phabricator.haskell.org/D4240

22 months agotypecheck: Consistently use pretty quotes in error messages
Ben Gamari [Mon, 27 Nov 2017 19:00:06 +0000 (14:00 -0500)] 
typecheck: Consistently use pretty quotes in error messages

Subscribers: rwbarton, thomie, carter

Differential Revision: https://phabricator.haskell.org/D4241

22 months agoCheck quantification for partial type signatues
Simon Peyton Jones [Tue, 14 Nov 2017 15:26:19 +0000 (15:26 +0000)] 
Check quantification for partial type signatues

Trac #14449 showed that we were failing to check that the
quantified type variables of a partial type signature remained
distinct.

See Note [Quantified variables in partial type signatures]
in TcBinds.

A little refactoring along the way.

22 months agoboot: Eliminate superfluous output
Ben Gamari [Mon, 27 Nov 2017 15:20:59 +0000 (10:20 -0500)] 
boot: Eliminate superfluous output

22 months agoRtsFlags: allow +RTS -K0
Ben Gamari [Mon, 27 Nov 2017 14:46:55 +0000 (09:46 -0500)] 
RtsFlags: allow +RTS -K0

Reviewers: erikd, simonmar, hvr

Reviewed By: hvr

Subscribers: hvr, rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D4238

22 months agoAdd obvious Outputable Integer instance.
klebinger.andreas@gmx.at [Mon, 27 Nov 2017 14:46:32 +0000 (09:46 -0500)] 
Add obvious Outputable Integer instance.

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D4232

22 months agoFollow symlinks in the Win32 code for System.Environment.getExecutablePath
Alp Mestanogullari [Mon, 27 Nov 2017 14:45:52 +0000 (09:45 -0500)] 
Follow symlinks in the Win32 code for System.Environment.getExecutablePath

This partially addresses #14483 by fixing the Windows implementation of
System.Environment.getExecutablePath. This is achieved by using
GetFinalPathNameByHandleW to resolve potential symlinks, while making
sure we do not get back a UNC path (see #14460).

Test Plan: Validate

Reviewers: Phyx, bgamari, angerman, hvr, goldfire

Reviewed By: Phyx, bgamari

GHC Trac Issues: #14483

Differential Revision: https://phabricator.haskell.org/D4227

22 months agoDon't complain about UNPACK in -fno-code.
Edward Z. Yang [Mon, 27 Nov 2017 14:45:23 +0000 (09:45 -0500)] 
Don't complain about UNPACK in -fno-code.

Test Plan: validate

Reviewers: ekmett, austin, bgamari

Reviewed By: bgamari

Subscribers: duog, goldfire, rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D4155

22 months agoCircleCI: Reenable artifact collection on Darwin
Ben Gamari [Thu, 23 Nov 2017 20:03:18 +0000 (15:03 -0500)] 
CircleCI: Reenable artifact collection on Darwin

Supposedly the original issue has been fixed.

22 months agobase: fdReady(): Fix timeouts > ~49 days overflowing. Fixes #14262.
Niklas Hambüchen [Thu, 23 Nov 2017 18:17:24 +0000 (13:17 -0500)] 
base: fdReady(): Fix timeouts > ~49 days overflowing. Fixes #14262.

On 64-bit UNIX and Windows, Haskell `Int` has 64 bits
but C `int msecs` has 32 bits, resulting in an overflow.

This commit fixes it by switching fdReady() to take int64_t,
into which a Haskell `Int` will always fit.

(Note we could not switch to `long long` because that is
32 bit on 64-bit Windows machines.)

Further, to be able to actually wait longer than ~49 days,
we put loops around the waiting syscalls (they all accept only
32-bit integers).

Note the timer signal would typically interrupt the syscalls
before the ~49 days are over, but you can run Haskell programs
without the timer signal, an we want it to be correct in all
cases.

Reviewers: bgamari, austin, hvr, NicolasT, Phyx

Reviewed By: bgamari, Phyx

Subscribers: syd, Phyx, rwbarton, thomie

GHC Trac Issues: #14262

Differential Revision: https://phabricator.haskell.org/D4011

22 months agousers-guide: Fix :default: placement
Ben Gamari [Thu, 23 Nov 2017 18:14:33 +0000 (13:14 -0500)] 
users-guide: Fix :default: placement

22 months agoDynFlags: Expand $topdir in --info output
Ben Gamari [Thu, 23 Nov 2017 18:05:30 +0000 (13:05 -0500)] 
DynFlags: Expand $topdir in --info output

Test Plan: Try running nofib on Windows

Reviewers: Phyx

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D4222

22 months agoSysTools: Split up TopDir logic into new module
Ben Gamari [Thu, 23 Nov 2017 18:05:05 +0000 (13:05 -0500)] 
SysTools: Split up TopDir logic into new module

Test Plan: Validate on Linux and Windows

Reviewers: erikd

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D4225

22 months agoSysTools: Expand occurrences of $topdir anywhere in a Settings path
Ben Gamari [Thu, 23 Nov 2017 18:04:55 +0000 (13:04 -0500)] 
SysTools: Expand occurrences of $topdir anywhere in a Settings path

Subscribers: rwbarton, thomie, Phyx

Differential Revision: https://phabricator.haskell.org/D4221

22 months agorts/Printer: add closure name entries for small arrays (Fixes #14513)
Takano Akio [Thu, 23 Nov 2017 17:17:24 +0000 (12:17 -0500)] 
rts/Printer: add closure name entries for small arrays (Fixes #14513)

Test Plan: ./validate

Reviewers: bgamari, erikd, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #14513

Differential Revision: https://phabricator.haskell.org/D4226

22 months agoCircleCI: Install lbzip2 and patch
Ben Gamari [Wed, 22 Nov 2017 17:07:29 +0000 (12:07 -0500)] 
CircleCI: Install lbzip2 and patch

tar needs lbzip2 to extract the GMP tarball. Patch is needed to, well, patch.

22 months agocircleci: Build with Hadrian
Ben Gamari [Sat, 18 Nov 2017 19:50:24 +0000 (14:50 -0500)] 
circleci: Build with Hadrian

22 months agoCircleCI: Try validating LLVM as well
Ben Gamari [Sun, 12 Nov 2017 00:04:42 +0000 (19:04 -0500)] 
CircleCI: Try validating LLVM as well

22 months agoCircleCI: Perform nightly validation of unregisterised build
Ben Gamari [Sat, 11 Nov 2017 23:53:56 +0000 (18:53 -0500)] 
CircleCI: Perform nightly validation of unregisterised build

22 months agoFix README
Ben Gamari [Thu, 23 Nov 2017 14:53:30 +0000 (09:53 -0500)] 
Fix README

This was unfortunately overwritten by the Hadrian README in a previous
Hadrian merge.

22 months agoRevert "Add new mbmi and mbmi2 compiler flags"
Ben Gamari [Wed, 22 Nov 2017 19:27:55 +0000 (14:27 -0500)] 
Revert "Add new mbmi and mbmi2 compiler flags"

This broke the 32-bit build.

This reverts commit f5dc8ccc29429d0a1d011f62b6b430f6ae50290c.

22 months agoUpdate Hadrian
Ben Gamari [Wed, 22 Nov 2017 13:50:45 +0000 (08:50 -0500)] 
Update Hadrian

22 months agoSquashed 'hadrian/' changes from fa3771fe6b..4499b294e4
Ben Gamari [Wed, 22 Nov 2017 13:47:55 +0000 (08:47 -0500)] 
Squashed 'hadrian/' changes from fa3771fe6b..4499b294e4

4499b294e4 Follow GHC changes
8fd68186b2 Add ways to build hadrian using nix
e5c7a29c23 Do not depend on the in-tree filepath library
9dd7ad2acc Fix dependencies
497184390e Bring mtl dependency back
6c5f5c9bd9 Minor clean up of Hadrian dependencies
9aff81d424 Fix Windows build
fa95caa8df Unbreak `cabal new-build`

git-subtree-dir: hadrian
git-subtree-split: 4499b294e4a53f71f8808d6eb55a7dd0b341cfb8

22 months agoErrUtils: Ensure timing dumps are always output on one line
Ben Gamari [Wed, 22 Nov 2017 03:59:28 +0000 (22:59 -0500)] 
ErrUtils: Ensure timing dumps are always output on one line

This output is supposed to be machine-readable; having random line-breaks
defeats this.

22 months agoErrUtils: Refactor dump file logic
Ben Gamari [Wed, 22 Nov 2017 03:57:27 +0000 (22:57 -0500)] 
ErrUtils: Refactor dump file logic

This refactors the dump file setup path, separating concerns a bit. It also
fixes an exception-unsafe usage of openFile.