2 years agoReplace -fshow-source-paths with -fhide-source-paths
Sylvain Henry [Tue, 29 Nov 2016 18:39:28 +0000 (13:39 -0500)] 
Replace -fshow-source-paths with -fhide-source-paths

This patch reverts the change introduced with
587dcccfdfa7a319e27300a4f3885071060b1f8e and restores the previous
default output of GHC (i.e., show source path and object path for each
compiled module).

The -fhide-source-paths flag can be used to hide these paths and reduce
the line

Reviewers: gracjan, nomeata, austin, bgamari, simonmar, hvr

Reviewed By: hvr

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12851

2 years agotestsuite: Mention CLEANUP option in README
Ben Gamari [Tue, 29 Nov 2016 18:38:37 +0000 (13:38 -0500)] 
testsuite: Mention CLEANUP option in README

Test Plan: Read it

Reviewers: austin

Subscribers: mpickering, thomie

Differential Revision:

2 years agoMinor cleanup of foldRegs{Used,Defd}
Michal Terepeta [Tue, 29 Nov 2016 18:31:28 +0000 (13:31 -0500)] 
Minor cleanup of foldRegs{Used,Defd}

This makes the two functions strict in the accumulator - it seems that
there are only two users of those functions: `CmmLive` and `CmmSink`
and in both cases the strict fold fits better.

The commit also removes a few unused functions (`filterRegsUsed`),
instances (for `Maybe` and `RegSet`) and gets rid of unnecessary
inculde of `HsVersions.h`.

The performance effect of avoiding unnecessary thunks is mostly
negligible, although we do allocate a tiny bit less (nofib's section
on compile allocations):
-1 s.d.                -----            -0.2%
+1 s.d.                -----            -0.1%
Average                -----            -0.2%

Signed-off-by: Michal Terepeta <>
Test Plan: validate

Reviewers: simonmar, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

2 years agoDetect color support
Phil Ruffwind [Tue, 29 Nov 2016 18:31:16 +0000 (13:31 -0500)] 
Detect color support

Test Plan: validate

Reviewers: erikd, Phyx, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #8809

2 years agoMake diagnostics slightly more colorful
Phil Ruffwind [Tue, 29 Nov 2016 18:31:01 +0000 (13:31 -0500)] 
Make diagnostics slightly more colorful

This is a preliminary commit to add colors to diagnostics (warning and
error messages).  The aesthetic changes are:

  - 'warning', 'error', and 'fatal' are all colored magenta, red, and
    red respectively.
  - The warning annotation [-Wsomething] shares the same color.
  - Warnings and errors are also bolded (this is consistent with what
    other compilers do).

A new flag has been added to control the behavior:


This flag is 'auto' by default.  However, auto-detection is not
implemented yet, so it effectively it defaults to off.

Test Plan: validate

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #8809

2 years agousers_guide: Bring 8.0.2 release notes up-to-date with ghc-8.0 branch
Ben Gamari [Tue, 29 Nov 2016 18:29:54 +0000 (13:29 -0500)] 
users_guide: Bring 8.0.2 release notes up-to-date with ghc-8.0 branch

I've been editing the release notes on the `ghc-8.0` branch; fold those
changes into `master`.

2 years agoDefine thread primitives if they're supported.
Shea Levy [Tue, 29 Nov 2016 18:28:27 +0000 (13:28 -0500)] 
Define thread primitives if they're supported.

On iOS, we use the pthread-based implementation of Itimer.c even for a
non-threaded RTS. Since 999c464, this relies on synchronization
primitives like Mutex, so ensure those primitives are defined whenever
they are supported, even if !THREADED_RTS.

Fixes #12799.

Reviewers: erikd, austin, simonmar, bgamari

Reviewed By: simonmar, bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12799

2 years agoStore string as parsed in SourceText for CImport
Alan Zimmerman [Tue, 29 Nov 2016 19:06:52 +0000 (21:06 +0200)] 
Store string as parsed in SourceText for CImport

2 years agoTypos in comments
Gabor Greif [Tue, 29 Nov 2016 15:18:07 +0000 (16:18 +0100)] 
Typos in comments

2 years agoZonk the free tvs of a RULE lhs to TyVars
Simon Peyton Jones [Tue, 29 Nov 2016 14:03:46 +0000 (14:03 +0000)] 
Zonk the free tvs of a RULE lhs to TyVars

Previously we were making them into skolem TcTyVars,
which is wrong for the output of the type checker, which
no TcTyVars should surive.

See Note [Zonking the LHS of a RULE] in TcHsSyn

This was flushed out by the new IfaceTcTyVar thing;
I found some more TcTyVars that were being serialised into
an interface file, which is wrong wrong wrong.

2 years agoMake note of #12881 in 8.0.2 release notes
Ryan Scott [Tue, 29 Nov 2016 13:43:46 +0000 (08:43 -0500)] 
Make note of #12881 in 8.0.2 release notes

Summary: Resolves #12881.

Test Plan: Read it, commit it, merge it, ship it

Reviewers: hvr, simonpj, austin, bgamari

Reviewed By: simonpj

Subscribers: simonpj, thomie

Differential Revision:

GHC Trac Issues: #12881

2 years agoComments only (related to #12789)
Simon Peyton Jones [Mon, 28 Nov 2016 17:41:27 +0000 (17:41 +0000)] 
Comments only (related to #12789)

It took me some time to find the right Note for the
fix to #12789.  This comment patch tries to add pointers
from relevant places.

2 years agoTest Trac #12885
Simon Peyton Jones [Mon, 28 Nov 2016 17:15:16 +0000 (17:15 +0000)] 
Test Trac #12885

...which is fixed by

  commit 0476a64e70c91b326b53db2fc55adbbaa8e5c270
  Author: Simon Peyton Jones <>
  Date:   Tue Oct 25 15:22:17 2016 +0100

    Fix a bug in mk_superclasses_of

2 years agoTest Trac #12776
Simon Peyton Jones [Mon, 28 Nov 2016 16:43:49 +0000 (16:43 +0000)] 
Test Trac #12776

2 years agoTypos in comments only [ci skip]
Gabor Greif [Mon, 28 Nov 2016 09:40:13 +0000 (10:40 +0100)] 
Typos in comments only [ci skip]

2 years agoFix an long-standing bug in OccurAnal
Simon Peyton Jones [Sun, 27 Nov 2016 23:35:12 +0000 (23:35 +0000)] 
Fix an long-standing bug in OccurAnal

This bug was beautifully characterised in Trac #12776,
which showed a small program for which the inliner went
into an infinite loop.  Eeek.

It turned out to be a genuine and long-standing bug in
the occurrence analyer, specifically in the bit that
identifies loop breakers.  In this line

  pairs | isEmptyVarSet weak_fvs
        = reOrderNodes   0 bndr_set weak_fvs tagged_nodes []
        | otherwise
        = loopBreakNodes 0 bndr_set weak_fvs loop_breaker_edges []

the 'tagged_nodes' should be 'loop_breaker_edges'.
That's it!

The diff looks a lot bigger because I did some work on
comments and variable naming, but that's all it is.  We
were using the wrong set of dependencies!

I'm astonished that this bug has not caused more trouble.
It dates back to at least 2011 and maybe further.

2 years agoBe a bit more selective about improvement
Simon Peyton Jones [Thu, 24 Nov 2016 22:21:08 +0000 (22:21 +0000)] 
Be a bit more selective about improvement

This patch makes [W] constraints not participate in
improvement.   See Note [Do not do improvement for WOnly]
in TcSMonad.

Removes some senseless work duplication in some cases (notably
Trac #12860); should not change behaviour.

2 years agoA tiny bit more tc tracing
Simon Peyton Jones [Fri, 25 Nov 2016 11:43:10 +0000 (11:43 +0000)] 
A tiny bit more tc tracing

2 years agoFix inference of partial signatures
Simon Peyton Jones [Fri, 25 Nov 2016 11:35:50 +0000 (11:35 +0000)] 
Fix inference of partial signatures

When we had
  f :: ( _ ) => blah
we were failing to call growThetaTyVars, as we do in the
no-type-signature case, and that meant that we weren't generalising
over the right type variables.  I'm quite surprised this didn't cause
problems earlier.

Anyway Trac #12844 showed it up and this patch fixes it

2 years agoRefactor functional dependencies a bit
Simon Peyton Jones [Thu, 24 Nov 2016 13:47:02 +0000 (13:47 +0000)] 
Refactor functional dependencies a bit

* Rename CoAxiom.Eqn = Pair Type to TypeEqn,
  and use it for fundeps

* Use the FunDepEqn for injectivity, which lets us share a bit
  more code, and (more important) brain cells

* When generating fundeps, take the max depth of the two
  constraints.  This aimed at tackling the strange loop in
  Trac #12860, but there is more to come for that.

* Improve pretty-printing with -ddump-tc-trace

2 years agoImprove pretty-printing of types
Simon Peyton Jones [Thu, 24 Nov 2016 12:32:11 +0000 (12:32 +0000)] 
Improve pretty-printing of types

In this commit
   commit 6c0f10fac767c49b65ed71e8eb8e78ca4f9062d5
   Author: Ben Gamari <>
   Date:   Sun Nov 13 16:17:37 2016 -0500

    Kill Type pretty-printer

we switched to pretty-printing a type by converting it to an
IfaceType and pretty printing that.  Very good.

This patch fixes two things

* The new story is terrible for debug-printing with -ddump-tc-trace,
  because all the extra info in an open type was discarded ty the
  conversion to IfaceType.

  This patch adds IfaceTcTyVar to IfaceType, to carry a TcTyVar in
  debug situations.  Quite an easy change, happily.  These things
  never show up in interface files.

* Now that we are going via IfaceType, it's essential to tidy before
  converting; otherwise
     forall k_23 k_34. blah
  is printed as
     forall k k. blah
  which is very unhelpful.  Again this only shows up in debug

2 years agoUse TyVars in PatSyns
Simon Peyton Jones [Fri, 25 Nov 2016 11:39:38 +0000 (11:39 +0000)] 
Use TyVars in PatSyns

I found that some TcTyVars were lurking in a PatSyn, because
tc_patsyn_finish was using the TcType -> TcType zonker rather
than the TcType -> Type zonker.  Eeek.

I fixing this I also tided up function naming a bit (still not
terrific), and removed the unused TcTyBinder type entirely.

2 years agoUse TyVars in a DFunUnfolding
Simon Peyton Jones [Thu, 24 Nov 2016 13:50:53 +0000 (13:50 +0000)] 
Use TyVars in a DFunUnfolding

En route to something else I discovered that TcInstDcls.addDFunPrags
was building a DFunUnfolding that had TcTyVars in it.  They should
never survive beyond type checking.  It was harmeless, but now affects
type pretty-printing.

This patch fixes it.

2 years agoUse 'v' instead of 'tpl' for template vars
Simon Peyton Jones [Thu, 24 Nov 2016 12:36:11 +0000 (12:36 +0000)] 
Use 'v' instead of 'tpl' for template vars

Just affects Id.mkTemplateLocal, and should make debug prints
a little less voluminous.  No user-visible change here.

2 years agoKill off ifaceTyVarsOfType
Simon Peyton Jones [Thu, 24 Nov 2016 12:26:24 +0000 (12:26 +0000)] 
Kill off ifaceTyVarsOfType

IfaceTypes are really not well suited to finding free variables etc.
Nevertheless, there was quite a lot of code to do just that; but it
was only used to see if a kind is variable-free so as to decide
whether to print a forall binder.

This patch simplifies to deal with just that case, replacing all
the free-vars stuff with just ifTypeIsVarFree

2 years agoTest Trac #12845
Simon Peyton Jones [Thu, 24 Nov 2016 12:15:34 +0000 (12:15 +0000)] 
Test Trac #12845

2 years agoTest Trac #12867
Simon Peyton Jones [Tue, 22 Nov 2016 10:35:28 +0000 (10:35 +0000)] 
Test Trac #12867

2 years agoFix a name-space problem with promotion
Simon Peyton Jones [Fri, 25 Nov 2016 14:31:33 +0000 (14:31 +0000)] 
Fix a name-space problem with promotion

Trac #12686 showed that we were allowing a term variable into
a type, by promotion.  I chose to squash this in the renamer.

2 years agoTypos in comments
Gabor Greif [Fri, 25 Nov 2016 13:09:47 +0000 (14:09 +0100)] 
Typos in comments

2 years agoPerf improvements in T6048, T10547
Simon Peyton Jones [Fri, 25 Nov 2016 08:29:43 +0000 (08:29 +0000)] 
Perf improvements in T6048, T10547

I think this wave of commits just made these two a little better;
they must have been close to the threshold before.

2 years agoRemove redundant kind check
Simon Peyton Jones [Thu, 24 Nov 2016 13:57:04 +0000 (13:57 +0000)] 
Remove redundant kind check

The invariants for CTyEqCan mean that this check isn't needed.
Turn it into an ASSERT.

2 years agoAllow TyVars in TcTypes
Simon Peyton Jones [Wed, 23 Nov 2016 16:00:00 +0000 (16:00 +0000)] 
Allow TyVars in TcTypes

Up to now we've had a rule that a TyVar can't apppear in a type
seen by the type checker; they should all be TcTyVars.  But:

a) With -XTypeInType it becomes much harder to exclude them;
   see Note [TcTyVars in the typechecker] in TcType.

b) It's unnecessary to exculde them; instead we can just treat
   a TyVar just like vanillaSkolemTv.

This is what was causing an ASSERT error in
indexed-types/should_fail/T12041, reported in Trac #12826.

That patch allows a TyVar in a TcType.  The most significant
change is to make Var.tcTyVarDetails return vanillaSkolemTv.
In fact it already did, but (a) it was not documented, and
(b) we never exploited it.  Now we rely on it.

2 years agoAnother major constraint-solver refactoring
Simon Peyton Jones [Tue, 25 Oct 2016 16:41:45 +0000 (17:41 +0100)] 
Another major constraint-solver refactoring

This patch takes further my refactoring of the constraint
solver, which I've been doing over the last couple of months
in consultation with Richard.

It fixes a number of tricky bugs that made the constraint
solver actually go into a loop, including

  Trac #12526
  Trac #12444
  Trac #12538

The main changes are these

* Flatten unification variables (fmvs/fuvs) appear on the LHS
  of a tvar/tyvar equality; thus
           fmv ~ alpha
  and not
           alpha ~ fmv

  See Note [Put flatten unification variables on the left]
  in TcUnify.  This is implemented by TcUnify.swapOverTyVars.

* Don't reduce a "loopy" CFunEqCan where the fsk appears on
  the LHS:
      F t1 .. tn ~ fsk
  where 'fsk' is free in
  See Note [FunEq occurs-check principle] in TcInteract

  This neatly stops some infinite loops that people reported;
  and it allows us to delete some crufty code in reduce_top_fun_eq.
  And it appears to be no loss whatsoever.

  As well as fixing loops, ContextStack2 and T5837 both terminate
  when they didn't before.

* Previously we generated "derived shadow" constraints from
  Wanteds, but we could (and sometimes did; Trac #xxxx) repeatedly
  generate a derived shadow from the same Wanted.

  A big change in this patch is to have two kinds of Wanteds:
     [WD] behaves like a pair of a Wanted and a Derived
     [W]  behaves like a Wanted only
  See CtFlavour and ShadowInfo in TcRnTypes, and the ctev_nosh
  field of a Wanted.

  This turned out to be a lot simpler.  A [WD] gets split into a
  [W] and a [D] in TcSMonad.maybeEmitShaodow.

  See TcSMonad Note [The improvement story and derived shadows]

* Rather than have a separate inert_model in the InertCans, I've
  put the derived equalities back into inert_eqs.  We weren't
  gaining anything from a separate field.

* Previously we had a mode for the constraint solver in which it
  would more aggressively solve Derived constraints; it was used
  for simplifying the context of a 'deriving' clause, or a 'default'
  delcaration, for example.

  But the complexity wasn't worth it; now I just make proper Wanted
  constraints.  See TcMType.cloneWC

* Don't generate injectivity improvement for Givens; see
  Note [No FunEq improvement for Givens] in TcInteract

* solveSimpleWanteds leaves the insolubles in-place rather than
  returning them.  Simpler.

I also did lots of work on comments, including fixing Trac #12821.

2 years agoAdd elemDVarEnv
Simon Peyton Jones [Wed, 23 Nov 2016 09:05:33 +0000 (09:05 +0000)] 
Add elemDVarEnv

I need this in a later patch

2 years agoComments only in TcType
Simon Peyton Jones [Tue, 25 Oct 2016 14:25:03 +0000 (15:25 +0100)] 
Comments only in TcType

2 years agoFix a bug in mk_superclasses_of
Simon Peyton Jones [Tue, 25 Oct 2016 14:22:17 +0000 (15:22 +0100)] 
Fix a bug in mk_superclasses_of

This bug meant that we were less eager about expanding
tuple superclasses than we should have been; i.e. we stopped
too soon.  That's not fatal, beause we expand more superclasses
later, but it's less efficient.

2 years agoMake a panic into an ASSERT
Simon Peyton Jones [Tue, 25 Oct 2016 14:21:31 +0000 (15:21 +0100)] 
Make a panic into an ASSERT

2 years agoMake quoting and reification return the same types
Dominik Bollmann [Thu, 24 Nov 2016 19:14:09 +0000 (06:14 +1100)] 
Make quoting and reification return the same types

Previously TH was incorrectly returning a `Dec` using a `ConT` instead
of `PromotedT`.

Test Plan: validate

Reviewers: mainland, jstolarek, osa1, goldfire, thomie, bollmann,
bgamari, RyanGlScott, austin

Reviewed By: RyanGlScott

Subscribers: erikd

Differential Revision:

GHC Trac Issues: #11629

2 years agoCollect wildcards in sum types during renaming (#12711)
Ömer Sinan Ağacan [Thu, 24 Nov 2016 01:12:17 +0000 (04:12 +0300)] 
Collect wildcards in sum types during renaming (#12711)

This patch also removes the "catch all" pattern in the function and
explicitly lists constructors to get a warning in the future if a new
`HsType` was added.

Reviewers: bgamari, austin, simonpj

Reviewed By: simonpj

Subscribers: simonpj, thomie

Differential Revision:

GHC Trac Issues: #12711

2 years agoAllow to unregister threadWaitReadSTM action.
Alexander Vershilov [Wed, 23 Nov 2016 01:57:08 +0000 (20:57 -0500)] 
Allow to unregister threadWaitReadSTM action.

Allow to unregister threadWaitReadSTM/threadWaitWriteSTM on
a non-threaded runtime. Previosly noop action was returned,
as a result it was not possible to unregister action, unless
data arrives to Fd or it's closed.

Fixes #12852.

Reviewers: simonmar, hvr, austin, bgamari, trofi

Reviewed By: bgamari, trofi

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12852

2 years agoghc/hschooks.c: Fix include path of Rts.h
Ben Gamari [Tue, 22 Nov 2016 05:43:19 +0000 (00:43 -0500)] 
ghc/hschooks.c: Fix include path of Rts.h

We need to ensure that we don't include Rts.h from bootstrap compiler.
See #12796.

Test Plan: Validate

Reviewers: austin

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12796

2 years agoMake transformers upstream repository location consistent with others
Demi Obenour [Mon, 21 Nov 2016 22:09:27 +0000 (17:09 -0500)] 
Make transformers upstream repository location consistent with others

Reviewers: bgamari, austin

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

2 years agoIgnore Hadrian build products.
Edward Z. Yang [Mon, 21 Nov 2016 22:09:02 +0000 (17:09 -0500)] 
Ignore Hadrian build products.

Test Plan: none

Reviewers: austin, snowleopard, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

2 years agoImplement fine-grained `-Werror=...` facility
Maciej Bielecki [Mon, 21 Nov 2016 22:08:45 +0000 (17:08 -0500)] 
Implement fine-grained `-Werror=...` facility

This patch add new options `-Werror=...`, `-Wwarn=...` and
`-Wno-error=...` (synonym for `-Wwarn=...`).


  - `-Werror` marks all warnings as fatal, including those that don't
    have a warning flag, and CPP warnings.
  - `-Werror=...` enables a warning and marks it as fatal
  - `-Wwarn=...` marks a warning as non-fatal, but doesn't disable it

Test Plan: validate

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: mpickering, svenpanne, RyanGlScott, thomie

Differential Revision:

GHC Trac Issues: #11219

2 years agoadd ieee754 next* functions to math_funs
Ben Gamari [Mon, 21 Nov 2016 22:08:38 +0000 (17:08 -0500)] 
add ieee754 next* functions to math_funs

Reviewers: austin, simonmar, trofi, bgamari

Reviewed By: bgamari

Subscribers: mpickering, thomie

Differential Revision:

GHC Trac Issues: #12802

2 years agotestsuite: Add (still failing) testcase for #12550
Ben Gamari [Mon, 21 Nov 2016 18:44:21 +0000 (13:44 -0500)] 
testsuite: Add (still failing) testcase for #12550

I thought that this would naturally resolve itself with the elimination
of the Type pretty-printer but somehow all of the stars in result
position of an arrow are still rendered in non-Unicode syntax. Quite

Test Plan: Validate

Reviewers: austin

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12550

2 years agotestsuite: Add (still broken) testcase for #12447
Ben Gamari [Mon, 21 Nov 2016 18:43:48 +0000 (13:43 -0500)] 
testsuite: Add (still broken) testcase for #12447

Test Plan: Validate

Reviewers: austin

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12447

2 years agotestsuite: Add test for #12024
Ben Gamari [Mon, 21 Nov 2016 18:43:35 +0000 (13:43 -0500)] 
testsuite: Add test for #12024

Test Plan: Validate

Reviewers: austin

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12024

2 years agotestsuite: Add test for #12855
Ben Gamari [Mon, 21 Nov 2016 18:42:15 +0000 (13:42 -0500)] 
testsuite: Add test for #12855

Test Plan: Validate

Reviewers: austin

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12855

2 years agoA few typos in comments
Gabor Greif [Mon, 21 Nov 2016 10:11:09 +0000 (11:11 +0100)] 
A few typos in comments

2 years agoUpdated code comment regarding EquationInfo. Trac #12856
Andreas Klebinger [Sun, 20 Nov 2016 00:03:51 +0000 (00:03 +0000)] 
Updated code comment regarding EquationInfo. Trac #12856

Summary: Updated code comment regarding EquationInfo. Fixes T12856

Reviewers: austin, bgamari, mpickering

Reviewed By: mpickering

Subscribers: mpickering, thomie

Differential Revision:

GHC Trac Issues: #12856

2 years agoOptimise whole module exports
Matthew Pickering [Fri, 18 Nov 2016 16:28:30 +0000 (16:28 +0000)] 
Optimise whole module exports

We directly build up the correct AvailInfos rather than generating
lots of singleton instances and combining them with expensive calls to

There are two other small changes.

* Pushed the nubAvails call into the explicit export list
  branch as we construct them correctly and uniquely ourselves.
* fix_faminst only needs to check the first element of the export
  list as we maintain the (yucky) invariant that the parent is the
  first thing in it.

Reviewers: simonpj, austin, bgamari

Reviewed By: simonpj, bgamari

Subscribers: simonpj, thomie, niteria

Differential Revision:

GHC Trac Issues: #12754

2 years agoAdd Data instance for Const
Ryan Scott [Fri, 18 Nov 2016 14:33:01 +0000 (09:33 -0500)] 
Add Data instance for Const

Fixes #12438. As discussed on the Haskell libraries mailing list here:

Reviewers: hvr, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12438

2 years agoSpelling in comment only
Gabor Greif [Fri, 18 Nov 2016 09:57:46 +0000 (10:57 +0100)] 
Spelling in comment only

2 years agoAdd missing SMP symbols to RT linker.
Tamar Christina [Fri, 18 Nov 2016 08:50:11 +0000 (08:50 +0000)] 
Add missing SMP symbols to RT linker.

Add some missing symbols that we
export from the public headers but forgot to include
in the runtime linker's symbol table.

This is a bit of a unsatifactory patch, since we have a bit of a
cat and mouse game going. We should find a way to automate this.

But I know of no good solutions at the moment that won't add all
rts symbols (including those we don't have an extern declaration for.).

So for now, just add the ones reported missing.

Test Plan: inplace/bin/ghc-stage2.exe --interactive

Reviewers: RyanGlScott, austin, erikd, simonmar, bgamari

Reviewed By: bgamari

Subscribers: thomie, #ghc_windows_task_force

Differential Revision:

GHC Trac Issues: #12846

2 years agoSwitch to LLVM version 3.9
Erik de Castro Lopo [Fri, 18 Nov 2016 08:14:42 +0000 (19:14 +1100)] 
Switch to LLVM version 3.9

Test Plan:
Build and test on x86_64/linux (perf-llvm) and armhf/linux.

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: RyanGlScott, thomie

Differential Revision:

2 years agoHave reify work for local variables with functional dependencies.
Facundo Domínguez [Thu, 17 Nov 2016 15:04:13 +0000 (10:04 -0500)] 
Have reify work for local variables with functional dependencies.

It turned out that finalizers were run too early and information
resulting from simplifying constraints was not available.

This patch runs finalizers after a first call to simplifyTop, and
then calls simplifyTop a second time to deal with constraints
that could result from running the finalizers.

Fixes T12777

Test Plan: ./validate

Reviewers: goldfire, simonpj, bgamari, austin

Reviewed By: simonpj

Subscribers: mpickering, mboes, thomie

Differential Revision:

GHC Trac Issues: #12777

2 years agoGHCi: Unconditionally import System.Directory
Ben Gamari [Thu, 17 Nov 2016 15:03:25 +0000 (10:03 -0500)] 
GHCi: Unconditionally import System.Directory

Both Windows and POSIX codepaths use System.Directory.canonicalizePath.

2 years agotestsuite: Rip out hack for #12554
Ben Gamari [Thu, 17 Nov 2016 03:17:26 +0000 (22:17 -0500)] 
testsuite: Rip out hack for #12554

@Phyx is working on correctly fixing (pun intended) the underlying issue
that prompted this hack. It turns out that `timeout` it the culprit.
Moreover, this hack breaks on msys python builds, which don't export

Test Plan: Validate on Windows with `msys` python.

Reviewers: Phyx, austin

Subscribers: thomie, Phyx

Differential Revision:

GHC Trac Issues: #12554

2 years agoLLVM generate llvm.expect for conditional branches
Alex Biehl [Wed, 16 Nov 2016 23:16:39 +0000 (18:16 -0500)] 
LLVM generate llvm.expect for conditional branches

This patch adds likeliness annotations to heap and and stack checks and
modifies the llvm codegen to recognize those to help it generate better

So with this patch

if ((Sp + 8) - 24 < SpLim) (likely: False) goto c23c; else goto c23d;

roughly generates:

  %ln23k = icmp ult i64 %ln23j, %SpLim_Arg
  %ln23m = call ccc i1 (i1, i1) @llvm.expect.i1( i1 %ln23k, i1 0 )
  br i1 %ln23m, label %c23c, label %c23d

Note the call to `llvm.expect` which denotes the expected result for
the comparison.

Test Plan: Look at assembler code with and without this patch. If the
heap-checks moved out of the way we are happy.

Reviewers: austin, simonmar, bgamari

Reviewed By: bgamari

Subscribers: michalt, thomie

Differential Revision:

GHC Trac Issues: #8321

2 years agoPass autoconf triplets to sub-project configures
Shea Levy [Wed, 16 Nov 2016 23:15:52 +0000 (18:15 -0500)] 
Pass autoconf triplets to sub-project configures

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: thomie, erikd

Differential Revision:

GHC Trac Issues: #12840

2 years agoRevert "Add Data instance for Const"
Ryan Scott [Thu, 17 Nov 2016 14:58:19 +0000 (09:58 -0500)] 
Revert "Add Data instance for Const"

This reverts commit 07e40e905357db805e6dbb557b35d6bdf76eaec6.

This was meant for a local branch, but accidentally wound up in master. Oops.

2 years agoAdd Data instance for Const
Ryan Scott [Thu, 17 Nov 2016 14:55:55 +0000 (09:55 -0500)] 
Add Data instance for Const

2 years agoCorrect name of Note in comment
Richard Eisenberg [Thu, 17 Nov 2016 14:08:04 +0000 (09:08 -0500)] 
Correct name of Note in comment

2 years agoCorrect spelling of command-line option in comment
Gabor Greif [Thu, 17 Nov 2016 09:13:46 +0000 (10:13 +0100)] 
Correct spelling of command-line option in comment

2 years agoTest for type synonym loops on TyCon.
Edward Z. Yang [Sat, 29 Oct 2016 00:54:36 +0000 (17:54 -0700)] 
Test for type synonym loops on TyCon.

Previously, we tested for type synonym loops by doing
a syntactic test on the literal type synonym declarations.
However, in some cases, loops could go through hs-boot
files, leading to an infinite loop (#12042); a similar
situation can occur when signature merging.

This commit replaces the syntactic test with a test on
TyCon, simply by walking down all type synonyms until
we bottom out, or find we've looped back.  It's a lot

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

Reviewers: simonpj, austin, bgamari

Subscribers: goldfire, thomie

Differential Revision:

GHC Trac Issues: #12042

2 years agoFix windows validate
Tamar Christina [Thu, 17 Nov 2016 00:45:17 +0000 (00:45 +0000)] 
Fix windows validate

mark myindex as inline only and hide it from profilers.
Also prevent this function from being used any other way
than just for inlining.

Test Plan: ./validate

Reviewers: austin, erikd, simonmar, bgamari

Reviewed By: bgamari

Subscribers: thomie, #ghc_windows_task_force

Differential Revision:

2 years agoInline compiler/NOTES into X86/Ppr.hs
Matthew Pickering [Wed, 16 Nov 2016 15:59:32 +0000 (15:59 +0000)] 
Inline compiler/NOTES into X86/Ppr.hs

Reviewers: austin, bgamari

Subscribers: thomie

Differential Revision:

2 years agoGeneralise the implicit prelude import
Simon Marlow [Wed, 16 Nov 2016 12:47:36 +0000 (12:47 +0000)] 
Generalise the implicit prelude import

Now it's possible to have two lists of imports:
* extra_imports are imports that are always added to the context
* prelude_imports are imports that are added if we don't have
  any open modules in scope.

No UI changes or new commands are added for now.  This was functionality
that we needed in our customized GHCi at Facebook, so I wanted to get it
upstream to reduce the differences between our version and the upstream

2 years agoAvoid calling newDynFlags when there are no changes
Simon Marlow [Tue, 15 Nov 2016 17:19:04 +0000 (17:19 +0000)] 
Avoid calling newDynFlags when there are no changes

This is a small optimisation for :set and :unset

2 years agoFix -fobject-code with -fexternal-interpreter
Simon Marlow [Tue, 15 Nov 2016 16:49:33 +0000 (16:49 +0000)] 
Fix -fobject-code with -fexternal-interpreter

If the user does :cd in GHCi with -fexternal-interpreter, then we can
fail to find the object files.

2 years agoStorage.c: Pass a size to sys_icache_invalidate
Shea Levy [Wed, 16 Nov 2016 03:01:56 +0000 (22:01 -0500)] 
Storage.c: Pass a size to sys_icache_invalidate

The previous code passed an end pointer, but the interface takes a size

Fixes #12838.

Reviewers: austin, erikd, simonmar, bgamari

Reviewed By: simonmar, bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12838

2 years agoDon't use mmap symbols when !RTS_LINKER_USE_MMAP
Shea Levy [Wed, 16 Nov 2016 03:01:20 +0000 (22:01 -0500)] 
Don't use mmap symbols when !RTS_LINKER_USE_MMAP

Some usages of symbols from sys/mman.h are guarded by
RTS_LINKER_USE_MMAP by C conditionals, not CPP conditionals. Since those
branches are dead anyway when !RTS_LINKER_USE_MMAP, we just stub out the
relevant symbols rather than increasing CPP branching.

Fixes #12839.

Reviewers: simonmar, austin, bgamari, erikd

Reviewed By: simonmar, bgamari, erikd

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12839

2 years agoUpdate xhtml submodule
Erik de Castro Lopo [Wed, 16 Nov 2016 03:00:13 +0000 (22:00 -0500)] 
Update xhtml submodule

Test Plan: validate

Reviewers: hvr, austin, Phyx, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

2 years agoTest for unnecessary register spills
Thomas Jakway [Wed, 16 Nov 2016 02:59:28 +0000 (21:59 -0500)] 
Test for unnecessary register spills

Reviewers: mainland, simonmar, michalt, bgamari, austin

Reviewed By: bgamari

Subscribers: simonpj, mpickering, thomie

Differential Revision:

GHC Trac Issues: #12744, #12745

2 years agofixup! Stop the simplifier from removing StaticPtr binds.
Facundo Domínguez [Wed, 16 Nov 2016 00:39:40 +0000 (21:39 -0300)] 
fixup! Stop the simplifier from removing StaticPtr binds.

2 years agoTypos in comments, notes and manual
Gabor Greif [Mon, 14 Nov 2016 16:57:09 +0000 (17:57 +0100)] 
Typos in comments, notes and manual

2 years agoMark T12041 as expect_broken with -DDEBUG (#12826)
Simon Marlow [Tue, 15 Nov 2016 10:40:24 +0000 (10:40 +0000)] 
Mark T12041 as expect_broken with -DDEBUG (#12826)

2 years agoHopefully fix build on OS X
Simon Marlow [Mon, 14 Nov 2016 15:36:38 +0000 (15:36 +0000)] 
Hopefully fix build on OS X

It looks like I broke the OS X build with 55d535da10dd, hopefully this
should fix it.

Test Plan: Harbourmaster

Reviewers: austin, bgamari, erikd

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12455

2 years agoSkip 64-bit symbol tables
Sylvain HENRY [Mon, 14 Nov 2016 22:16:27 +0000 (17:16 -0500)] 
Skip 64-bit symbol tables

This patch makes the RTS linker skip 64-bit symbol table entries.  See

Test Plan: validate

Reviewers: austin, erikd, simonmar, bgamari

Reviewed By: bgamari

Subscribers: osa1, thomie

Differential Revision:

GHC Trac Issues: #12827

2 years agoconfigure: Verify that GCC recognizes -no-pie flag
Ben Gamari [Mon, 14 Nov 2016 19:13:30 +0000 (14:13 -0500)] 
configure: Verify that GCC recognizes -no-pie flag

It seems like GCC versions prior to 4.8 exit with code 0 when faced with
an unrecognized flag. Silly compilers.

Test Plan: Validate

Reviewers: hvr, austin, ggreif

Reviewed By: ggreif

Subscribers: thomie, erikd

Differential Revision:

GHC Trac Issues: #12759

2 years agotestsuite: Fix creep of T4029
Ben Gamari [Mon, 14 Nov 2016 14:20:14 +0000 (09:20 -0500)] 
testsuite: Fix creep of T4029

Ostensibly due to IfaceType rework, but I have my doubts.

2 years agoFix numa001 failure with "too many NUMA nodes"
Simon Marlow [Wed, 9 Nov 2016 11:02:12 +0000 (11:02 +0000)] 
Fix numa001 failure with "too many NUMA nodes"

It seems that recent versions of the Linux kernel are using larger NUMA
bitmasks; I see 1024 on my laptop running a 4.6.5 kernel.  This causes
the NUMA tests to fail.  I'm fixing it to only fail if we have that many
actual *nodes*, rather than failing if the size of the mask is too big.

2 years agoAccept output for scc003
Simon Marlow [Wed, 9 Nov 2016 10:58:57 +0000 (10:58 +0000)] 
Accept output for scc003

Looks like e3f341f334d89c88f388d8e864ed8762d0890a64 broke it, but we
wouldn't have noticed because the test isn't run in validate.

I think the change is OK.  We don't get a tick for x' any more, because
it is converted directly to a case instead of a let-binding, but we
still get a tick for the "pattern binding" (!x').  This could be better
- f.(...) isn't all that intuitive - but it's not strictly wrong.

2 years agoRemove CONSTR_STATIC
Simon Marlow [Wed, 9 Nov 2016 09:20:02 +0000 (09:20 +0000)] 

We currently have two info tables for a constructor

* XXX_con_info: the info table for a heap-resident instance of the
  constructor, It has type CONSTR, or one of the specialised types like

* XXX_static_info: the info table for a static instance of this
  constructor, which has type CONSTR_STATIC or CONSTR_STATIC_NOCAF.

I'm getting rid of the latter, and using the `con_info` info table for
both static and dynamic constructors.  For rationale and more details
see Note [static constructors] in SMRep.hs.

I also removed these macros: `isSTATIC()`, `ip_STATIC()`,
`closure_STATIC()`, since they relied on the CONSTR/CONSTR_STATIC
distinction, and anyway HEAP_ALLOCED() does the same job.

Test Plan: validate

Reviewers: bgamari, simonpj, austin, gcampax, hvr, niteria, erikd

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12455

2 years agoKill Type pretty-printer
Ben Gamari [Sun, 13 Nov 2016 21:17:37 +0000 (16:17 -0500)] 
Kill Type pretty-printer

Here we consolidate the pretty-printing logic for types in IfaceType. We
need IfaceType regardless and the printer for Type can be implemented in
terms of that for IfaceType. See #11660.

Note that this is very much a work-in-progress. Namely I still have yet
to ponder how to ease the hs-boot file situation, still need to rip out
more dead code, need to move some of the special cases for, e.g., `*` to
the IfaceType printer, and need to get it to validate. That being said,
it comes close to validating as-is.

Test Plan: Validate

Reviewers: goldfire, austin

Subscribers: goldfire, thomie, simonpj

Differential Revision:

GHC Trac Issues: #11660

2 years agorts: Fix references to UChar
Ben Gamari [Sun, 13 Nov 2016 21:07:59 +0000 (16:07 -0500)] 
rts: Fix references to UChar

Test Plan: Validate on Windows.

Reviewers: erikd, austin, simonmar

Reviewed By: erikd

Subscribers: Phyx, thomie

Differential Revision:

2 years agoghc: Fix ghc's template-haskell bound
Ben Gamari [Sat, 12 Nov 2016 16:54:45 +0000 (11:54 -0500)] 
ghc: Fix ghc's template-haskell bound

2 years agotemplate-haskell: Version bump
Ben Gamari [Sat, 12 Nov 2016 16:37:36 +0000 (11:37 -0500)] 
template-haskell: Version bump

2 years agoMake default output less verbose (source/object paths)
Sylvain HENRY [Sat, 12 Nov 2016 03:54:05 +0000 (22:54 -0500)] 
Make default output less verbose (source/object paths)

Reviewers: simonmar, mpickering, austin, bgamari

Reviewed By: bgamari

Subscribers: mpickering, nomeata, thomie

Differential Revision:

GHC Trac Issues: #12807

2 years agorts: Fix #include of <linker/PEi386.h>
Ben Gamari [Sat, 12 Nov 2016 03:04:45 +0000 (22:04 -0500)] 
rts: Fix #include of <linker/PEi386.h>

Test Plan: Validate on Windows

Reviewers: austin, erikd, simonmar

Subscribers: thomie

Differential Revision:

2 years agorts: Fix build when linked with gold
Ben Gamari [Sat, 12 Nov 2016 03:04:32 +0000 (22:04 -0500)] 
rts: Fix build when linked with gold

As reported in #12812, the runtime system fails to build when linked
with gold due to a missing dependency on libpthread.

Additionally, rts/ uses the WORD_SIZE_IN_BITS macro
defined by MachDeps.h, which it does not #include. Fix this.

Test Plan: Validate with gold linker

Reviewers: hsyl20, austin, erikd, simonmar

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12816

2 years agoghc-pkg: Munge dynamic library directories
Ben Gamari [Fri, 11 Nov 2016 20:53:36 +0000 (15:53 -0500)] 
ghc-pkg: Munge dynamic library directories

Otherwise we end up looking in the wrong place for dynamic libraries on
Windows. This addresses a regression introduced by D2611. See #12479.

Test Plan: validate across platforms

Reviewers: austin

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12479

2 years agotestsuite: Lower allocations for T876
Ben Gamari [Sat, 12 Nov 2016 01:26:13 +0000 (20:26 -0500)] 
testsuite: Lower allocations for T876

If only we knew why...


2 years agoPass -no-pie to GCC
Ben Gamari [Fri, 11 Nov 2016 17:05:21 +0000 (12:05 -0500)] 
Pass -no-pie to GCC

Certain distributions (e.g. Debian and Ubuntu) have enabled PIE be
default in their GCC packaging. This breaks our abuse of GCC as a linker
which requires that we pass -Wl,-r, which is incompatible with
PIE (since the former implies that we are generating a relocatable
object file and the latter an executable).

This is a second attempt at D2691. This attempt constrasts with D2691 in that
it preserves the "does gcc support -no-pie" flag in settings, allowing this to
be reconfigured by `configure` during installation of a binary distribution.
Thanks for @rwbarton for drawing attention to this issue.

Test Plan: Validate

Reviewers: austin, hvr, erikd

Reviewed By: erikd

Subscribers: thomie, rwbarton, erikd

Differential Revision:

GHC Trac Issues: #12759

2 years agorts: Fix LoadArchive on OS X
Ben Gamari [Fri, 11 Nov 2016 15:58:08 +0000 (10:58 -0500)] 
rts: Fix LoadArchive on OS X

2 years agoRevert "Refactor CallStack defaulting slightly"
Simon Peyton Jones [Fri, 11 Nov 2016 15:31:56 +0000 (15:31 +0000)] 
Revert "Refactor CallStack defaulting slightly"

This reverts commit 317236db308d9bd497a11fa4c455428fc7477405.

I totally missed that in simplifyInfer for local functions
we must NOT default call stacks.  So I'm reverting this.

Fortunately caught by T10845, which sadly isn't run by
validate --fast

2 years agoRevert "Pass -no-pie to GCC"
Ben Gamari [Fri, 11 Nov 2016 04:48:27 +0000 (23:48 -0500)] 
Revert "Pass -no-pie to GCC"

This reverts commit bae4a55b1fb403f610b4b55a1b6fb3f03e9c2026.

This will be superceded by D2693.

2 years agoPrevent GND from inferring an instance context for method-less classes
Ryan Scott [Thu, 10 Nov 2016 20:22:48 +0000 (15:22 -0500)] 
Prevent GND from inferring an instance context for method-less classes

When `GeneralizedNewtypeDeriving` is used with a type class that has no
methods, it will generate a redundant context, and as a result, it can
trigger warnings when compiled with `-Wredundant-constraints`. This is a
simple change in behavior to check beforehand if a class has methods
when deriving it with GND, and if it has no methods, avoid inferring the
redundant context.

Beware that the test for #6088, which used to be expected to fail, now
compiles without issue since it doesn't infer a problematic instance

Thanks to Simon Peyton Jones for doing the necessary refactoring in

Fixes #12814.

Test Plan: ./validate

Reviewers: goldfire, rwbarton, simonpj, austin, bgamari

Reviewed By: simonpj

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12814

2 years agoUpdate user's guide after D2490
Thomas Winant [Thu, 10 Nov 2016 20:22:14 +0000 (15:22 -0500)] 
Update user's guide after D2490

D2490 added support for type wildcards in TH pattern splices. The user's
guide still said that they were not supported, this patch fixes this.

Test Plan: build documentation

Reviewers: goldfire, austin, mvv, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12164