ghc.git
3 years agoghc/Main.hs: Add import list to DynamicLoading
Ömer Sinan Ağacan [Tue, 18 Oct 2016 19:24:23 +0000 (15:24 -0400)] 
ghc/Main.hs: Add import list to DynamicLoading

3 years agoDynamicLoading: Replace map + zip with zipWith
Ömer Sinan Ağacan [Tue, 18 Oct 2016 19:05:16 +0000 (15:05 -0400)] 
DynamicLoading: Replace map + zip with zipWith

3 years agofixup! Add option to not retain CAFs to the linker API
Simon Marlow [Tue, 18 Oct 2016 14:18:28 +0000 (15:18 +0100)] 
fixup! Add option to not retain CAFs to the linker API

3 years agoremove unnecessary ifdef
Simon Marlow [Tue, 18 Oct 2016 10:35:12 +0000 (11:35 +0100)] 
remove unnecessary ifdef

3 years agoAdd option to not retain CAFs to the linker API
Simon Marlow [Thu, 13 Oct 2016 11:51:33 +0000 (12:51 +0100)] 
Add option to not retain CAFs to the linker API

3 years agoTrack dep_finsts in exports hash, as it affects downstream deps.
Edward Z. Yang [Mon, 17 Oct 2016 21:06:18 +0000 (14:06 -0700)] 
Track dep_finsts in exports hash, as it affects downstream deps.

Summary:
I also added some more comments about the orphan and family instance
hashing business.

Fixes #12723.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate

Reviewers: bgamari, austin

Subscribers: thomie

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

GHC Trac Issues: #12723

3 years agoBump parallel submodule
Ben Gamari [Mon, 17 Oct 2016 18:34:25 +0000 (14:34 -0400)] 
Bump parallel submodule

Includes testsuite fix for Python 3.

3 years agotestsuite: Mark T7037 as broken on Windows
Ben Gamari [Mon, 17 Oct 2016 12:57:12 +0000 (08:57 -0400)] 
testsuite: Mark T7037 as broken on Windows

Due to #12725.

3 years agotestsuite/driver: Allow threading on Windows
Ben Gamari [Mon, 17 Oct 2016 00:49:57 +0000 (20:49 -0400)] 
testsuite/driver: Allow threading on Windows

It seems that threading now works fine. The only caveat here is that it
makes some race conditions more likely (e.g. #12554), although these
also appear to affect single-threaded runs.

Test Plan: Validate on Windows

Reviewers: austin, Phyx

Subscribers: thomie

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

GHC Trac Issues: #10510

3 years agotestsuite: Eliminate unnecessary compile_timeout_multiplier
Ben Gamari [Mon, 17 Oct 2016 00:49:46 +0000 (20:49 -0400)] 
testsuite: Eliminate unnecessary compile_timeout_multiplier

tc266 was failing intermittently on Windows due to a very small
compile_timeout_multiplier. This test was added in
e907e1f12f4dedc0ec13c7a501c8810bcfc03583 which doesn't appear to have
any timng dependence, so I see no reason to retain the multiplier at
all.

Test Plan: Validate

Reviewers: ezyang, austin

Subscribers: thomie

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

3 years agotestsuite/driver: More Unicode awareness
Ben Gamari [Mon, 17 Oct 2016 00:49:36 +0000 (20:49 -0400)] 
testsuite/driver: More Unicode awareness

Explicitly specify utf8 encoding in a few spots which were failing on
Windows with Python 3.

Test Plan: Validate

Reviewers: austin, thomie

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

GHC Trac Issues: #9184

3 years agovalidate: Allow user to override Python interpreter
Ben Gamari [Mon, 17 Oct 2016 00:49:26 +0000 (20:49 -0400)] 
validate: Allow user to override Python interpreter

Due to #12554 and #12661 we must be quite picky about our choice of
Python interpreter on Windows. Allow the user to override it.

Test Plan: `PYTHON=/usr/bin/python2 ./validate` on Windows

Reviewers: austin, Phyx

Subscribers: thomie

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

GHC Trac Issues: #12554, #12661

3 years agotestsuite/timeout: Ensure that processes are cleaned up on Windows
Ben Gamari [Mon, 17 Oct 2016 00:49:15 +0000 (20:49 -0400)] 
testsuite/timeout: Ensure that processes are cleaned up on Windows

Previously if the test is interrupted (e.g. with Ctrl-C) any processes
which it spawned may not be properly terminated. Here we catch any
exception and ensure that we job is terminated.

Test Plan: Validate on Windows

Reviewers: Phyx, austin

Subscribers: thomie

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

3 years agotestsuite/driver: Never symlink on Windows
Ben Gamari [Mon, 17 Oct 2016 00:49:00 +0000 (20:49 -0400)] 
testsuite/driver: Never symlink on Windows

While msys' mingw Python 3 does indeed export `os.symlink`, it is
unusable since creating symbolic links on Windows requires permissions
that essentially no one has.

Test Plan: Validate on Windows

Reviewers: austin, Phyx, thomie

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

3 years agotestsuite: Mark T9405 as broken on Windows
Ben Gamari [Sun, 16 Oct 2016 02:53:06 +0000 (02:53 +0000)] 
testsuite: Mark T9405 as broken on Windows

There seems to be a runtime system bug here, as described in #12714.

3 years agotestsuite: Mark T10858 as broken on Windows
Ben Gamari [Sun, 16 Oct 2016 02:25:50 +0000 (02:25 +0000)] 
testsuite: Mark T10858 as broken on Windows

Strangely the allocation numbers on Windows differ significantly from
those on Linux. Usually I would just update the number, but I would
really like to understand why this is the case. This is a rather large
deviation in the compilation of a program which really shouldn't have
any appreciable platform dependence.

3 years agotestsuite: Mark break011 as broken
Ben Gamari [Sun, 16 Oct 2016 02:05:50 +0000 (02:05 +0000)] 
testsuite: Mark break011 as broken

See #12712.

3 years agotestsuite: Work around #12554
Ben Gamari [Sat, 15 Oct 2016 18:18:14 +0000 (18:18 +0000)] 
testsuite: Work around #12554

It seems that Python 2.7.11 and "recent" msys2 releases are broken,
holding open file locks unexpected. This causes rmtree to intermittently
fail. Even worse, it would fail silently (since we pass
ignore_errors=True), causing makedirs to fail later.

We now explicitly check for the existence of the test directory before
attempting to delete it and disable ignore_errors. Moreover, on Windows
we now try multiple times to rmtree the testdir, working around the
apparently msys bug.

This is all just terrible, but Phyx and I spent several hours trying to
track down the issue to no available. The workaround is better than
nothing.

3 years agoRe-add accidentally-deleted line
Simon Peyton Jones [Mon, 17 Oct 2016 08:23:50 +0000 (09:23 +0100)] 
Re-add accidentally-deleted line

This adds a line I deleted by mistake in

  commit db71d971379c74dd1d2b958c11dc6c9e718a3e61
  Author: Simon Peyton Jones <simonpj@microsoft.com>
  Date:   Fri Oct 14 17:40:51 2016 +0100

      Reduce trace output slightly

Sorry about that!

3 years agoTypos in comments
Gabor Greif [Mon, 17 Oct 2016 08:05:45 +0000 (10:05 +0200)] 
Typos in comments

3 years agoComments only
Simon Peyton Jones [Fri, 14 Oct 2016 16:50:28 +0000 (17:50 +0100)] 
Comments only

3 years agoAdd more variants of T3064 (in comments)
Simon Peyton Jones [Fri, 14 Oct 2016 16:42:00 +0000 (17:42 +0100)] 
Add more variants of T3064 (in comments)

3 years agoReduce trace output slightly
Simon Peyton Jones [Fri, 14 Oct 2016 16:40:51 +0000 (17:40 +0100)] 
Reduce trace output slightly

3 years agoTest Trac #12681
Simon Peyton Jones [Mon, 17 Oct 2016 07:40:16 +0000 (08:40 +0100)] 
Test Trac #12681

3 years agoFix wrapping order in matchExpectedConTy
Simon Peyton Jones [Fri, 14 Oct 2016 16:13:43 +0000 (17:13 +0100)] 
Fix wrapping order in matchExpectedConTy

The wrappers in matchExpectedConTy were being composed back
to front, resulting in a Core Lint error.  Yikes!  This has
been here a long time.

Fixes Trac #12676.

3 years agoCorrect order of existentials in pattern synonyms
Simon Peyton Jones [Fri, 14 Oct 2016 14:54:14 +0000 (15:54 +0100)] 
Correct order of existentials in pattern synonyms

Trac #12698 exposed a nasty bug in the typechecking for
pattern synonmys: the existential type variables weren't
being put in properly-scoped order.

For some reason TcPatSyn.tcCollectEx was colleting them as a
set, not as a list!  Easily fixed.

3 years agoTypo in comment
Simon Peyton Jones [Fri, 14 Oct 2016 14:52:15 +0000 (15:52 +0100)] 
Typo in comment

3 years agoFix shadowing in mkWwBodies
Simon Peyton Jones [Fri, 14 Oct 2016 11:05:46 +0000 (12:05 +0100)] 
Fix shadowing in mkWwBodies

This bug, exposed by Trac #12562 was very obscure, and has been
lurking for a long time.  What happened was that, in the
worker/wrapper split

  a tyvar binder for a worker function
  accidentally shadowed an in-scope term variable
  that was mentioned in the body of the function

It's jolly hard to provoke, so I have not even attempted to make
a test case.  There's a Note [Freshen WW arguments] to explain.

Interestingly, fixing the bug (which meant fresher type variables)
revealed a second lurking bug: I'd failed to apply the substitution to
the coercion in the second last case of mkWWArgs, which introduces a
Cast.

3 years agoFix comment typo
Simon Peyton Jones [Fri, 14 Oct 2016 09:41:45 +0000 (10:41 +0100)] 
Fix comment typo

3 years agoComments about -Wredundant-constraints
Simon Peyton Jones [Fri, 14 Oct 2016 09:41:14 +0000 (10:41 +0100)] 
Comments about -Wredundant-constraints

3 years agoCorrect name of makeStableName in haddock
Reid Barton [Sun, 16 Oct 2016 17:40:11 +0000 (13:40 -0400)] 
Correct name of makeStableName in haddock

3 years agoAdd a forward reference for a Note
Ryan Scott [Sat, 15 Oct 2016 22:33:06 +0000 (18:33 -0400)] 
Add a forward reference for a Note

And fix a typo within said Note.

[ci skip]

3 years agoFix Show derivation in the presence of RebindableSyntax/OverloadedStrings
Ryan Scott [Sat, 15 Oct 2016 15:11:20 +0000 (11:11 -0400)] 
Fix Show derivation in the presence of RebindableSyntax/OverloadedStrings

Summary:
To fix this issue, we simply disable `RebindableSyntax` whenever we rename
the code generated from a deriving clause.

Fixes #12688.

Test Plan: make test TEST=T12688

Reviewers: simonpj, austin, bgamari

Reviewed By: simonpj, bgamari

Subscribers: thomie

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

GHC Trac Issues: #12688

3 years agoFix Windows build following D2588
Ryan Scott [Sat, 15 Oct 2016 02:28:29 +0000 (22:28 -0400)] 
Fix Windows build following D2588

Commit 8c6a3d68c0301bb985aa2a462936bbcf7584ae9c inadvertently broke the build
on Windows. This restores Windows compatibility.

3 years agoDisable T-signals-child test on single-threaded runtime
Michael Snoyman [Fri, 14 Oct 2016 14:53:40 +0000 (10:53 -0400)] 
Disable T-signals-child test on single-threaded runtime

As identified by Joachim, this test broke the Travis build. It appears
that this is due to the usage of the single-threaded runtime there. I've
confirmed that this fix causes the Travis build to pass:
https://travis-ci.org/snoyberg/ghc/builds/167368988.

Test Plan: Confirm tests now pass

Reviewers: austin, nomeata, bgamari

Reviewed By: nomeata, bgamari

Subscribers: thomie

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

3 years agoCheck for empty entity string in "prim" foreign imports
Sylvain HENRY [Fri, 14 Oct 2016 14:43:30 +0000 (10:43 -0400)] 
Check for empty entity string in "prim" foreign imports

Foreign imports with "prim" convention require a valid symbol identifier
(see linked issue). We check this.

Fix line too long

Test Plan: Validate

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

GHC Trac Issues: #12355

3 years agoBuild ghc-iserv with --export-dynamic
Simon Marlow [Fri, 14 Oct 2016 14:43:10 +0000 (10:43 -0400)] 
Build ghc-iserv with --export-dynamic

This enables loading dynamic libraries that refer to the RTS.  I just
came across somewhere I needed to do that, and without
`--export-dynamic` it's impossible.

For now we'll only support that when using `-fexternal-interpreter`,
because the dynamic symbol table for GHC itself is much bigger.

Test Plan: validate

Reviewers: niteria, austin, erikd, bgamari

Reviewed By: bgamari

Subscribers: Phyx, thomie

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

3 years agoMake error when deriving an instance for a typeclass less misleading
Ryan Scott [Fri, 14 Oct 2016 14:40:56 +0000 (10:40 -0400)] 
Make error when deriving an instance for a typeclass less misleading

Before, when you attempted to derive an instance for a typeclass,
e.g.,

```
class C1 (a :: Constraint) where
class C2 where

deriving instance C1 C2
```

GHC would complain that `C2`'s data constructors aren't in scope. But
that
makes no sense, since typeclasses don't have constructors! By refining
the
checks that GHC performs when deriving, we can make the error message a
little more sensible.

This also cleans up a related `DeriveAnyClass` infelicity. Before, you
wouldn't have been able to compile code like this:

```
import System.IO (Handle)
class C a
deriving instance C Handle
```

Since GHC was requiring that all data constructors of `Handle` be in
scope. But `DeriveAnyClass` doesn't even generate code that mentions
any data constructors, so this requirement is silly!

Fixes #11509.

Test Plan: make test TEST=T11509

Reviewers: simonpj, austin, bgamari

Reviewed By: simonpj, bgamari

Subscribers: thomie, simonpj

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

GHC Trac Issues: #11509

3 years agoAdd missing Semigroup instances for Monoidal datatypes in base
Ryan Scott [Fri, 14 Oct 2016 14:30:54 +0000 (10:30 -0400)] 
Add missing Semigroup instances for Monoidal datatypes in base

Summary:
There are currently three datatypes that are exposed in `base` that have
`Monoid` instances, but no `Semigroup` instances:

* `IO`
* `Event` (from `GHC.Event`)
* `Lifetime` (from `GHC.Event`)

(There is also `EventLifetime` in `GHC.Event.Internal`, but it is not exported
directly, so I didn't bother with it.)

Adding the `Semigroup` instances for these types directly in the modules in
which they're defined resulted in some horrific import cycles, so I opted to
take the easy approach of defining all of these instances in `Data.Semigroup`.
(When `Semigroup` becomes a superclass of `Monoid`, these instances will have
to be moved somehow.)

Fixes #12464.

Test Plan: It compiles

Reviewers: hvr, ekmett, austin, bgamari

Reviewed By: ekmett

Subscribers: thomie

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

GHC Trac Issues: #12464

3 years agoPrelInfo: Fix style
Ben Gamari [Fri, 14 Oct 2016 00:42:59 +0000 (20:42 -0400)] 
PrelInfo: Fix style

3 years agoImprove find_lbl panic message
Ben Gamari [Thu, 13 Oct 2016 23:42:21 +0000 (19:42 -0400)] 
Improve find_lbl panic message

3 years agoMkIface: Turn a foldr into a foldl'
Ben Gamari [Tue, 23 Aug 2016 03:18:02 +0000 (23:18 -0400)] 
MkIface: Turn a foldr into a foldl'

There is no reason why this should be a foldr considering we are
building a map.

3 years agoClean up handling of known-key Names in interface files
Ben Gamari [Fri, 14 Oct 2016 01:53:13 +0000 (21:53 -0400)] 
Clean up handling of known-key Names in interface files

Previously BinIface had some dedicated logic for handling tuple names in
the symbol table. As it turns out, this logic was essentially dead code
as it was superceded by the special handling of known-key things. Here
we cull the tuple code-path and use the known-key codepath for all
tuple-ish things.

This had a surprising number of knock-on effects,

 * constraint tuple datacons had to be made known-key (previously they
   were not)

 * IfaceTopBndr was changed from being a synonym of OccName to a
   synonym of Name (since we now need to be able to deserialize Names
   directly from interface files)

 * the change to IfaceTopBndr complicated fingerprinting, since we need
   to ensure that we don't go looking for the fingerprint of the thing
   we are currently fingerprinting in the fingerprint environment (see
   notes in MkIface). Handling this required distinguishing between
   binding and non-binding Name occurrences in the Binary serializers.

 * the original name cache logic which previously lived in IfaceEnv has
   been moved to a new NameCache module

 * I ripped tuples and sums out of knownKeyNames since they introduce a
   very large number of entries. During interface file deserialization
   we use static functions (defined in the new KnownUniques module) to
   map from a Unique to a known-key Name (the Unique better correspond
   to a known-key name!) When we need to do an original name cache
   lookup we rely on the parser implemented in isBuiltInOcc_maybe.

 * HscMain.allKnownKeyNames was folded into PrelInfo.knownKeyNames.

 * Lots of comments were sprinkled about describing the new scheme.

Updates haddock submodule.

Test Plan: Validate

Reviewers: niteria, simonpj, austin, hvr

Reviewed By: simonpj

Subscribers: simonmar, niteria, thomie

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

GHC Trac Issues: #12532, #12415

3 years agoUnique: Simplify encoding of sum uniques
Ben Gamari [Fri, 14 Oct 2016 01:52:57 +0000 (21:52 -0400)] 
Unique: Simplify encoding of sum uniques

The previous encoding was entropically a bit better, but harder to
encode and decode. Now we just split up the integer part of the unique
into a bitfield.

Test Plan: Validate

Reviewers: austin

Subscribers: thomie

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

3 years agoCabal submodule update.
Edward Z. Yang [Thu, 13 Oct 2016 07:52:20 +0000 (00:52 -0700)] 
Cabal submodule update.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
3 years agoFurther improve error handling in TcRn monad
Simon Peyton Jones [Thu, 13 Oct 2016 11:24:53 +0000 (12:24 +0100)] 
Further improve error handling in TcRn monad

This patch builds on the one for Trac #12124, by dealing properly
with out-of-scope "hole" errors.

This fixes Trac #12529. The hard error coming from visible type application
is still there, but the out-of-scope error is no longer suppressed.

(Arguably the VTA message should be suppressed somehow, but that's a
battle for another day.)

3 years agoAdd missing @since annotations
Ryan Scott [Thu, 13 Oct 2016 02:22:43 +0000 (22:22 -0400)] 
Add missing @since annotations

3 years agoAdd test for #12456
Ryan Scott [Thu, 13 Oct 2016 01:06:48 +0000 (21:06 -0400)] 
Add test for #12456

Commit f352e5cd7bb629fe0ca3b913bfbe7bee43d62f3a fixed #12456. Let's add a test
to make sure it stays fixed.

3 years agoAdd test for #12589
Ryan Scott [Wed, 12 Oct 2016 23:16:46 +0000 (19:16 -0400)] 
Add test for #12589

Commit af21e38855f7d517774542b360178b05045ecb08 fixed #12598. Let's add a test
to make sure it stays fixed.

3 years agoAdd test for #12411
Ryan Scott [Wed, 12 Oct 2016 18:57:32 +0000 (14:57 -0400)] 
Add test for #12411

The fix for #12584 also fixed the problem in #12411. Let's add a test to ensure
that it stays fixed.

3 years agotestsuite: Bump T1969 allocations
Ben Gamari [Wed, 12 Oct 2016 15:49:55 +0000 (11:49 -0400)] 
testsuite: Bump T1969 allocations

3 years agoRnExpr: Actually fail if patterns found in expression
Ben Gamari [Tue, 11 Oct 2016 13:26:46 +0000 (09:26 -0400)] 
RnExpr: Actually fail if patterns found in expression

This fixes #12584, where wildcard patterns were snuck into an
expression, which then crashed the typechecker in TcExpr since EWildPats
aren't supposed to appear in the AST after renaming.

The problem was that `rnTopSpliceDecl` failed to check for errors from
`rnSplice` (as done by other callers to `rnSplice`).

Thanks to Shayan for reporting this!

Reviewers: simonpj, austin

Reviewed By: simonpj

Subscribers: simonpj, thomie

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

GHC Trac Issues: #12584

3 years agoComments and equation ordering only
Simon Peyton Jones [Wed, 12 Oct 2016 14:26:24 +0000 (15:26 +0100)] 
Comments and equation ordering only

3 years agoAdd derived shadows only for Wanted constraints
Simon Peyton Jones [Wed, 12 Oct 2016 11:02:04 +0000 (12:02 +0100)] 
Add derived shadows only for Wanted constraints

This patch implements choice (3) of comment:14 on Trac #12660.
It cures an infinite loop (caused by the creation of an infinite
type) in in compiling the 'singletons' package.

See Note [Add derived shadows only for Wanteds] in TcSMonad.

3 years agoAdd a broken test case for #12689
Joachim Breitner [Tue, 11 Oct 2016 20:50:25 +0000 (16:50 -0400)] 
Add a broken test case for #12689

A rule with a phase specification trying to match on a constructor with
a wrapper will fail to match, as the wrapper will be inlined by then.
The fact that it works in the other case is also mostly by accident.
(Split into two test cases so that regressions with regard what works so
far are caught.)

3 years agoAdd test case for #12689
Joachim Breitner [Tue, 11 Oct 2016 20:25:05 +0000 (16:25 -0400)] 
Add test case for #12689

which test a few variants of rules involving constructors, including
nullary constructors, constructors with wrappers, and unsaturated of
constructors.

At the moment, all the rules work as expected, despite GHC’s compile
time warnings when called with -Wall.

3 years agoMore tests for Trac #12522
Simon Peyton Jones [Mon, 10 Oct 2016 12:57:01 +0000 (13:57 +0100)] 
More tests for Trac #12522

These ones test the variations in coment:15 of the ticket

3 years agoImproved stats for Trac #1969
Simon Peyton Jones [Mon, 10 Oct 2016 12:45:42 +0000 (13:45 +0100)] 
Improved stats for Trac #1969

With my latest commits

  76a5477 Move zonking out of tcFamTyPats
  b255ae7 Orient improvement constraints better

perf has improved slightly for T1969:

allocs:    733M -> 26M
residency: 43M  -> 41M

I don't know exactly why, but hey, it's good

3 years agoMove zonking out of tcFamTyPats
Simon Peyton Jones [Fri, 7 Oct 2016 23:03:53 +0000 (00:03 +0100)] 
Move zonking out of tcFamTyPats

In tcFamTyPats we were zonking from the TcType world to the
Type world, ready to build the results into a CoAxiom (which
should have no TcType stuff.  But the 'thing_inside' for
tcFamTyPats also must be zonked, and that zonking must have
the ZonkEnv from the binders zonked tcFamTyPats.

Ugh.  This caused an assertion failure (with DEBUG on) in
RaeBlobPost and TypeLevelVec, both in tests/dependent, as
shown in Trac #12682.  Why it hasn't shown up before now
is obscure to me.

So I moved the zonking stuff out of tcFamTyPats to its
three call sites, where we can do it all together. Very
slightly longer, but much more robust.

3 years agoDelete orphan where clause
Simon Peyton Jones [Fri, 7 Oct 2016 22:57:29 +0000 (23:57 +0100)] 
Delete orphan where clause

3 years agoRename a parameter; trivial refactor
Simon Peyton Jones [Fri, 7 Oct 2016 22:55:54 +0000 (23:55 +0100)] 
Rename a parameter; trivial refactor

3 years agoOrient improvement constraints better
Simon Peyton Jones [Fri, 7 Oct 2016 22:51:44 +0000 (23:51 +0100)] 
Orient improvement constraints better

This patch fixes an infinite loop in the constraint solver,
shown up by Trac #12522.

The solution is /very/ simple: just reverse the orientation of the
derived constraints arising from improvement using type-family
injectivity.  I'm not very proud of the fix --- it seems fragile
--- but it has the very great merit of simplicity, and it works
fine.

See Note [Improvement orientation] in TcInteract, and some
discussion on the Trac ticket.

3 years agoEscape lambda.
Vaibhav Sagar [Sun, 9 Oct 2016 22:21:58 +0000 (18:21 -0400)] 
Escape lambda.

Test Plan: View updated documentation?

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

GHC Trac Issues: #12672

3 years agoTurn on -n4m with -A16m or greater
Simon Marlow [Sun, 9 Oct 2016 22:21:35 +0000 (18:21 -0400)] 
Turn on -n4m with -A16m or greater

Nursery chunks help reduce the cost of GC when capabilities are unevenly
loaded, by ensuring that we use more of the available nursery.

The rationale for enabling this at -A16m is that any negative effects
due to loss of cache locality are less likely to be an issue at -A16m
and above.  It's a conservative guess.  If we had a lot of benchmark
data we could probably do better.

Results for nofib/parallel at -N4 -A32m with and without -n4m:

```
------------------------------------------------------------------------
        Program           Size    Allocs   Runtime   Elapsed  TotalMem
------------------------------------------------------------------------
   blackscholes           0.0%     -9.5%     -9.0%    -15.0%     -2.2%
          coins           0.0%     -4.7%     -3.6%     -0.6%    -13.6%
         mandel           0.0%     -0.3%     +7.7%    +13.1%     +0.1%
        matmult           0.0%     +1.5%    +10.0%     +7.7%     +0.1%
          nbody           0.0%     -4.1%     -2.9%     0.085      0.0%
         parfib           0.0%     -1.4%     +1.0%     +1.5%     +0.2%
        partree           0.0%     -0.3%     +0.8%     +2.9%     -0.8%
           prsa           0.0%     -0.5%     -2.1%     -7.6%      0.0%
         queens           0.0%     -3.2%     -1.4%     +2.2%     +1.3%
            ray           0.0%     -5.6%    -14.5%     -7.6%     +0.8%
       sumeuler           0.0%     -0.4%     +2.4%     +1.1%      0.0%
------------------------------------------------------------------------
            Min           0.0%     -9.5%    -14.5%    -15.0%    -13.6%
            Max           0.0%     +1.5%    +10.0%    +13.1%     +1.3%
 Geometric Mean          +0.0%     -2.6%     -1.3%     -0.5%     -1.4%
```

Not conclusive, but slightly better.  This matters a lot more when you
have more cores.

Test Plan: validate, nofib/paralel

Reviewers: niteria, ezyang, nh2, trofi, austin, erikd, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

GHC Trac Issues: #9221

3 years agoDefault +RTS -qn to the number of cores
Simon Marlow [Sun, 9 Oct 2016 22:20:53 +0000 (18:20 -0400)] 
Default +RTS -qn to the number of cores

Setting a -N value that is too large has a dramatic negative effect on
performance, but the new -qn flag can mitigate the worst of the effects
by limiting the number of GC threads.

So now, if you don't explcitly set +RTS -qn, and you set -N larger than
the number of cores (or use setNumCapabilities to do the same), we'll
default -qn to the number of cores.

These are the results from nofib/parallel on my 4-core (2 cores x 2
threads) i7 laptop, comparing -N8 before and after this change.

```
------------------------------------------------------------------------
        Program           Size    Allocs   Runtime   Elapsed  TotalMem
------------------------------------------------------------------------
   blackscholes          +0.0%     +0.0%    -72.5%    -72.0%     +9.5%
          coins          +0.0%     -0.0%    -73.7%    -72.2%     -0.8%
         mandel          +0.0%     +0.0%    -76.4%    -75.4%     +3.3%
        matmult          +0.0%    +15.5%    -26.8%    -33.4%     +1.0%
          nbody          +0.0%     +2.4%     +0.7%     0.076      0.0%
         parfib          +0.0%     -8.5%    -33.2%    -31.5%     +2.0%
        partree          +0.0%     -0.0%    -60.4%    -56.8%     +5.7%
           prsa          +0.0%     -0.0%    -65.4%    -60.4%      0.0%
         queens          +0.0%     +0.2%    -58.8%    -58.8%     -1.5%
            ray          +0.0%     -1.5%    -88.7%    -85.6%     -3.6%
       sumeuler          +0.0%     -0.0%    -47.8%    -46.9%      0.0%
------------------------------------------------------------------------
            Min          +0.0%     -8.5%    -88.7%    -85.6%     -3.6%
            Max          +0.0%    +15.5%     +0.7%    -31.5%     +9.5%
 Geometric Mean          +0.0%     +0.6%    -61.4%    -63.1%     +1.4%
```

Test Plan: validate, nofib/parallel benchmarks

Reviewers: niteria, ezyang, nh2, austin, erikd, trofi, bgamari

Reviewed By: trofi, bgamari

Subscribers: thomie

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

GHC Trac Issues: #9221

3 years agoCleanup PosixSource.h
Moritz Angermann [Sun, 9 Oct 2016 22:19:26 +0000 (18:19 -0400)] 
Cleanup PosixSource.h

When trying to build arm64-apple-iso, the build fell over `strdup`, as
the arm64-apple-ios build did not fall into `darwin_HOST_OS`, and would
need `ios_HOST_OS`.

This diff tries to clean up PosixSource.h, instead of layering another
define on top.

As we use `strnlen` in sources that include PosixSource.h, and `strnlen`
is defined in POSIX.1-2008, the `_POSIX_C_SOURCE` and `_XOPEN_SOURCE`
are increased accordingly.

Furthermore the `_DARWIN_C_SOURCE` (required for `u_char`, etc. used in
sysctl.h) define is moved into `OSThreads.h` alongside a similar ifdef
for freebsd.

Test Plan: Build on all supported platforms.

Reviewers: austin, simonmar, erikd, kgardas, bgamari

Reviewed By: simonmar, erikd, kgardas, bgamari

Subscribers: Phyx, hvr, thomie

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

GHC Trac Issues: #12624

3 years agoDo not segfault if no common root can be found
Moritz Angermann [Sun, 9 Oct 2016 22:17:46 +0000 (18:17 -0400)] 
Do not segfault if no common root can be found

When trying to profile a plugin, ghc mysteriously segfaulted.  Upon
closer examination the segfault happend due to a `->prevStack` lookup
on a NULL pointer.

A new CostCentre: Unknown is introduced that is set, if ccsapp and
ccsfn are of equal depth (e.g. 0), and do not have a common CostCentre
in their stacks.

Reviewers: bgamari, simonmar, austin, erikd

Reviewed By: simonmar

Subscribers: Phyx, thomie

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

3 years agoGenerate a unique symbol for signature object stub files, fixes #12673
Edward Z. Yang [Sun, 9 Oct 2016 22:17:32 +0000 (18:17 -0400)] 
Generate a unique symbol for signature object stub files, fixes #12673

Test Plan: validate

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

GHC Trac Issues: #12673

3 years agoFix build
Csongor Kiss [Sat, 8 Oct 2016 10:28:22 +0000 (11:28 +0100)] 
Fix build

- interaction between backpack and export list refactoring
  introduced a few syntax errors, and constructor arity mismatches
- CPP macro used in backpack was not accepted by clang because of
  extraneous whitespace

Signed-off-by: Csongor Kiss <kiss.csongor.kiss@gmail.com>
Reviewers: austin, bgamari, mpickering

Reviewed By: mpickering

Subscribers: thomie

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

3 years agoAdd trailing comma to fix the build.
Matthew Pickering [Sat, 8 Oct 2016 09:28:47 +0000 (10:28 +0100)] 
Add trailing comma to fix the build.

3 years agoRework renaming of children in export lists.
Matthew Pickering [Sat, 8 Oct 2016 09:06:01 +0000 (10:06 +0100)] 
Rework renaming of children in export lists.

The target of this patch is exports such as:

```
module Foo ( T(A, B, C) ) where
```

Essentially this patch makes sure that we use the correct lookup functions in order
to lookup the names in parent-children export lists. This change
highlighted the complexity of this small part of GHC which accounts for
the scale.

This change was motivated by wanting to
remove the `PatternSynonym` constructor from `Parent`. As with all these
things, it quickly spiraled out of control into a much larger refactor.

Reviewers: simonpj, goldfire, bgamari, austin

Subscribers: adamgundry, thomie

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

GHC Trac Issues: #11970

3 years agoCabal submodule update.
Edward Z. Yang [Fri, 7 Oct 2016 06:20:38 +0000 (23:20 -0700)] 
Cabal submodule update.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
3 years agoReport that we support Backpack in --info.
Edward Z. Yang [Fri, 7 Oct 2016 06:20:19 +0000 (23:20 -0700)] 
Report that we support Backpack in --info.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
3 years agoUpdate haddock.Cabal perf for Cabal update.
Edward Z. Yang [Fri, 7 Oct 2016 01:19:22 +0000 (18:19 -0700)] 
Update haddock.Cabal perf for Cabal update.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
3 years agoMake InstalledUnitId be ONLY a FastString.
Edward Z. Yang [Thu, 6 Oct 2016 20:40:10 +0000 (13:40 -0700)] 
Make InstalledUnitId be ONLY a FastString.

It turns out that we don't really need to be able to
extract a ComponentId from UnitId, except in one case.
So compress UnitId into a single FastString.

The one case where we do need the ComponentId is when
we are compiling an instantiated version of a package;
we need the ComponentId to look up the indefinite
version of this package from the database.  So now we
just pass it in as an argument -this-component-id.

Also: ghc-pkg now no longer will unregister a package if
you register one with the same package name, if the
instantiations don't match.

Cabal submodule update which tracks the same data type
change.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
3 years agoDistinguish between UnitId and InstalledUnitId.
Edward Z. Yang [Thu, 6 Oct 2016 07:17:15 +0000 (00:17 -0700)] 
Distinguish between UnitId and InstalledUnitId.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
3 years agoThe Backpack patch.
Edward Z. Yang [Sat, 10 Oct 2015 19:01:14 +0000 (12:01 -0700)] 
The Backpack patch.

Summary:
This patch implements Backpack for GHC.  It's a big patch but I've tried quite
hard to keep things, by-in-large, self-contained.

The user facing specification for Backpack can be found at:

    https://github.com/ezyang/ghc-proposals/blob/backpack/proposals/0000-backpack.rst

A guide to the implementation can be found at:

    https://github.com/ezyang/ghc-proposals/blob/backpack-impl/proposals/0000-backpack-impl.rst

Has a submodule update for Cabal, as well as a submodule update
for filepath to handle more strict checking of cabal-version.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate

Reviewers: simonpj, austin, simonmar, bgamari, goldfire

Subscribers: thomie, mpickering

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

3 years agoExclude Cabal PackageTests from gen_contents_index.
Edward Z. Yang [Thu, 6 Oct 2016 23:20:24 +0000 (16:20 -0700)] 
Exclude Cabal PackageTests from gen_contents_index.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
3 years agoRemove reexports from ghc-boot, help bootstrap with GHC 8.
Edward Z. Yang [Sun, 2 Oct 2016 19:59:44 +0000 (12:59 -0700)] 
Remove reexports from ghc-boot, help bootstrap with GHC 8.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
3 years agoNote about external interface changes.
Edward Z. Yang [Tue, 30 Aug 2016 04:20:58 +0000 (21:20 -0700)] 
Note about external interface changes.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
3 years agoTc267, tests what happens if you forgot to knot-tie.
Edward Z. Yang [Thu, 25 Aug 2016 05:11:07 +0000 (22:11 -0700)] 
Tc267, tests what happens if you forgot to knot-tie.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
3 years agoSimplify implementation of wWarningFlags
Matthew Pickering [Fri, 7 Oct 2016 14:19:56 +0000 (15:19 +0100)] 
Simplify implementation of wWarningFlags

3 years agoDon't suggest deprecated flags in error messages
Martin Ceresa [Fri, 7 Oct 2016 12:54:10 +0000 (13:54 +0100)] 
Don't suggest deprecated flags in error messages

When looking up flags, we make sure to lookup the non-deprecated flags first
by ordering the list of flags.

Reviewers: bgamari, austin, mpickering

Reviewed By: mpickering

Subscribers: mpickering, thomie

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

GHC Trac Issues: #12574

3 years agoFix memory leak from #12664
Bartosz Nitka [Thu, 6 Oct 2016 12:40:24 +0000 (05:40 -0700)] 
Fix memory leak from #12664

This fixes the leak with `setProgArgv`. The problem was
that `setProgArgv` would not free the objects pointed
to by `prog_argc`, `prog_argv` when the globals were
changed resulting in a leak.

The only strictly necessary change is in `rts/RtsFlags.c`, but
the code in `System.Environment` was a bit confusing and not
exception safe, so I refactored it.

Test Plan: ./validate

Reviewers: simonmar, ezyang, austin, hvr, bgamari, erikd

Subscribers: thomie

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

GHC Trac Issues: #12664

3 years agoAdd compact to packages so it gets cleaned on make clean.
Edward Z. Yang [Thu, 6 Oct 2016 23:48:56 +0000 (16:48 -0700)] 
Add compact to packages so it gets cleaned on make clean.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
3 years agoRemove dead code “mkHsConApp”
Joachim Breitner [Wed, 5 Oct 2016 20:14:59 +0000 (16:14 -0400)] 
Remove dead code “mkHsConApp”

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

3 years agoRegAlloc: Make some pattern matched complete
Joachim Breitner [Thu, 6 Oct 2016 03:37:03 +0000 (23:37 -0400)] 
RegAlloc: Make some pattern matched complete

these actually are complete, but due to the use of pattern guards, the
compiler does not see that. Refactor the code that it does.

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

3 years agoRefactor TcDeriv and TcGenDeriv
Ryan Scott [Thu, 6 Oct 2016 13:14:49 +0000 (09:14 -0400)] 
Refactor TcDeriv and TcGenDeriv

Summary:
Keeping a promise I made to Simon to clean up these modules.

This change splits up the massive `TcDeriv` and `TcGenDeriv` modules into
somewhat more manageable pieces. The new modules are:

* `TcGenFunctor`: This contains the deriving machinery for `Functor`,
  `Foldable`, and `Traversable` (which all use the same underlying algorithm).
* `TcDerivInfer`: This is the new home for `inferConstraints`,
  `simplifyInstanceContexts`, and related functions, whose role is to come up
  with the derived instance context and subsequently simplify it.
* `TcDerivUtils`: This is a grab-bag module that contains several
  error-checking utilities originally in `TcDeriv`, as well as some functions
  that `TcDeriv` and `TcDerivInfer` both need.

The end result is that `TcDeriv` is now less than 1,600 SLOC (originally 2,686
SLOC), and `TcGenDeriv` is now about 2,000 SLOC (originally 2,964).

In addition, this also implements a couple of tiny refactorings:

* I transformed `type Condition = (DynFlags, TyCon) -> Validity` into
  `type Condition = DynFlags -> TyCon -> Validity`
* I killed the `DerivSpecGeneric` constructor for `DerivSpecMechanism`, and
  merged its functionality into `DerivSpecStock`. In addition,
  `hasStockDeriving` now contains key-value pairs for `Generic` and `Generic1`,
  so they're no longer treated as an awkward special case in `TcDeriv`.

Test Plan: ./validate

Reviewers: simonpj, austin, bgamari

Reviewed By: simonpj

Subscribers: thomie, mpickering

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

3 years agoRemove unused T12124.srderr
Ryan Scott [Thu, 6 Oct 2016 13:12:05 +0000 (09:12 -0400)] 
Remove unused T12124.srderr

This was (accidentally?) introduced in 465c6c5d15f8fb54afb78408f3a79e75e74d2cd4

3 years agoImprove error handling in TcRnMonad
Simon Peyton Jones [Wed, 5 Oct 2016 21:00:02 +0000 (22:00 +0100)] 
Improve error handling in TcRnMonad

See Note [Constraints and errors] in TcRnMonad.  This
patch fixes Trac #12124 in quite a neat way.

3 years agoBring Note in TcDeriv up to date
Ryan Scott [Wed, 5 Oct 2016 20:13:29 +0000 (16:13 -0400)] 
Bring Note in TcDeriv up to date

Comments only.

[ci skip]

3 years agoMark zipWithAndUnzipM as INLINABLE rather than INLINE
Matthew Pickering [Tue, 4 Oct 2016 21:36:55 +0000 (22:36 +0100)] 
Mark zipWithAndUnzipM as INLINABLE rather than INLINE

It is a self-recursive function and hence a loop-breaker.

3 years agogenapply: update source file in autogenerated text
Sergei Trofimovich [Tue, 4 Oct 2016 20:13:51 +0000 (21:13 +0100)] 
genapply: update source file in autogenerated text

Signed-off-by: Sergei Trofimovich <siarheit@google.com>
3 years agorunghc: Fix import of System.Process on Windows
Ben Gamari [Sun, 2 Oct 2016 23:40:56 +0000 (19:40 -0400)] 
runghc: Fix import of System.Process on Windows

This apparently should have been an import of rawSystem instead of
runProcess. Oops.

Fixes D2538.

Test Plan: Validate on Linux and Windows.

Reviewers: austin, snowleopard

Reviewed By: snowleopard

Subscribers: thomie

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

3 years agoUpdate Cabal submodule to latest version.
Edward Z. Yang [Fri, 30 Sep 2016 23:50:52 +0000 (16:50 -0700)] 
Update Cabal submodule to latest version.

Summary:
Note that Cabal needs one more bugfix which is in PR to
fix GHC bootstrapping. But the rest of the patch is
ready for review.

Needs a filepath submodule update because cabal check
became more strict.

This patch handles the abstract-ification of Version and
PackageName.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate

Reviewers: bgamari, austin

Subscribers: thomie

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

3 years agotestsuite: Mark test for #12355 as unbroken on Darwin.
Ben Gamari [Sun, 2 Oct 2016 17:47:03 +0000 (13:47 -0400)] 
testsuite: Mark test for #12355 as unbroken on Darwin.

Somehow this testcase works on Darwin but not on Linux. This deserves
further investigation.

3 years agoDynFlags: Fix absolute import path to generated header
Ben Gamari [Sun, 2 Oct 2016 17:46:12 +0000 (13:46 -0400)] 
DynFlags: Fix absolute import path to generated header

Test Plan: Validate

Reviewers: austin, snowleopard

Reviewed By: snowleopard

Subscribers: thomie

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

GHC Trac Issues: #8040.

3 years agoIgnore output from derefnull and divbyzero on Darwin
Ben Gamari [Sun, 2 Oct 2016 16:01:21 +0000 (12:01 -0400)] 
Ignore output from derefnull and divbyzero on Darwin

The output contains the pid and executable path of the bash process
which spawned the failing process. It doesn't seem worth the effort to
cleanse this output; just ignore it.

3 years agoMark #6132 as broken on OS X
Ben Gamari [Sun, 2 Oct 2016 15:53:54 +0000 (11:53 -0400)] 
Mark #6132 as broken on OS X

It currently fails with,

    =====> T6132(normal) 1 of 1 [0, 0, 0]
    cd "./runghc/T6132.run" && "/Users/bgamari/ghc/inplace/test
    spaces/ghc-stage2" -c T6132.hs -dcore-lint -dcmm-lint
    -no-user-package-db -rtsopts -fno-warn-missed-specialisations
    -fshow-warning-groups -dno-debug-output
    Compile failed (exit code 1) errors were:

    T6132.hs:1:2: error: parse error on input ‘#!/’

    *** unexpected failure for T6132(normal)

3 years agorunghc: use executeFile to run ghc process on POSIX
Michael Snoyman [Sun, 2 Oct 2016 01:24:05 +0000 (21:24 -0400)] 
runghc: use executeFile to run ghc process on POSIX

This means that, on POSIX systems, there will be only one ghc process
used for running scripts, as opposed to the current situation of a
runghc process and a ghc process. Beyond minor performance benefits of
not having an extra fork and resident process, the more important impact
of this is automatically getting proper signal handling. I noticed this
problem myself when running runghc as PID1 inside a Docker container.

I attempted to create a shim library for executeFile that would work for
both POSIX and Windows, but unfortunately I ran into issues with exit
codes being propagated correctly (see
https://github.com/fpco/replace-process/issues/2). Therefore, this patch
leaves the Windows behavior unchanged. Given that signals are a POSIX
issue, this isn't too bad a trade-off. If someone has suggestions for
better Windows _exec support, please let me know.

Reviewers: erikd, austin, bgamari

Reviewed By: bgamari

Subscribers: Phyx, thomie

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