ghc.git
2 years agoImplement deriving strategies
Ryan Scott [Sat, 1 Oct 2016 00:15:25 +0000 (20:15 -0400)] 
Implement deriving strategies

Allows users to explicitly request which approach to `deriving` to use
via keywords, e.g.,

```
newtype Foo = Foo Bar
  deriving Eq
  deriving stock    Ord
  deriving newtype Show
```

Fixes #10598. Updates haddock submodule.

Test Plan: ./validate

Reviewers: hvr, kosmikus, goldfire, alanz, bgamari, simonpj, austin,
erikd, simonmar

Reviewed By: alanz, bgamari, simonpj

Subscribers: thomie, mpickering, oerjan

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

GHC Trac Issues: #10598

2 years agoDocument Safe Haskell restrictions on Generic instances
Ryan Scott [Fri, 30 Sep 2016 19:52:02 +0000 (15:52 -0400)] 
Document Safe Haskell restrictions on Generic instances

Commit 578fbeca31dd3d755e24e910c3a7327f92bc4ee3 disallowed hand-written
`Generic` instances in Safe Haskell, but this wasn't documented anywhere.

2 years agoCorrect spelling in note references
Gabor Greif [Fri, 30 Sep 2016 14:37:53 +0000 (16:37 +0200)] 
Correct spelling in note references

2 years agoMake tcrun042 fail
Simon Peyton Jones [Fri, 30 Sep 2016 13:33:19 +0000 (14:33 +0100)] 
Make tcrun042 fail

This test uses wholesale impredicative polymorphism, and now fails.
That's ok.

2 years agoAdd missing stderr file
Simon Peyton Jones [Fri, 30 Sep 2016 12:32:51 +0000 (13:32 +0100)] 
Add missing stderr file

..accidentally omitted from previous commit.

2 years agoComments only
Simon Peyton Jones [Tue, 27 Sep 2016 16:16:57 +0000 (17:16 +0100)] 
Comments only

2 years agoFix impredicativity (again)
Simon Peyton Jones [Sun, 25 Sep 2016 14:50:18 +0000 (15:50 +0100)] 
Fix impredicativity (again)

This patch fixes Trac #12616.

Dignosis.  In TcUnify.tc_sub_type_ds we were going to some trouble to
support co- and contra-variance even for impredicative types.  With
-XImpredicativeTYpes, this allowed a unification variable to be
unified with a polytype (probably wrongly) and that caused later
trouble in the constraint solver, where -XImpredicativeTypes was /not/
on.  In effect, -XImpredicativeTypes can't be switched on locally.

Why did we want ImpredicativeTypes locally?  Because the program
generated by GND for a higher-rank method involved impredicative
instantation of 'coerce':
      op = coerce op   -- where op has a higher rank type
See Note [Newtype-deriving instances] in TcGenDeriv.

Cure.

1.  It is ghastly to rely on ImpredicativeTypes (a 100% flaky
    feature) to instantiate coerce polymorphically.  Happily we
    now have Visible Type Application, so I've used that instead
    which should be solid and reliable.

2.  I deleted the code in tc_sub_type_ds that allows the constraint
    solver to "look through" a unification variable to find a
    polytype.  That used to be essential in the days of ReturnTv,
    but it's utterly unreliable and should be consigned to the dustbin
    of history.  (We have ExpType now for the essential uses.)

Tests involving ImpredicativeTypes are affected, but I'm not worried
about them... it's advertised as a feature you can't rely on, and
I want to reform it outright.

2 years agoAdd Outputable Report in TcErrors
Simon Peyton Jones [Sun, 25 Sep 2016 14:48:29 +0000 (15:48 +0100)] 
Add Outputable Report in TcErrors

...just for debug output

2 years agoFix a bug in occurs checking
Simon Peyton Jones [Thu, 22 Sep 2016 21:18:22 +0000 (22:18 +0100)] 
Fix a bug in occurs checking

1. Trac #12593 exposed a long-standing bug in the occurs
   checking machinery.  When unifying two type variables
          a ~ b
   where a /= b, we were assuming that there could be
   no occurs-check error.  But there can: 'a' can occur
   in b's kind!  When the RHS was a non-tyvar we used
   occurCheckExpand, which /did/ look in kinds, but not
   when the RHS was a tyvar.

   This bug has been lurking ever since TypeInType, maybe
   longer.  And it was present both in TcUnify (the on-the-fly
   unifier), and in TcInteract.

   I ended up refactoring both so that the tyvar/tyvar
   path naturally goes through the same occurs-check as
   non-tyvar rhss.  It's simpler and more robust now.

   One good thing is that both unifiers now share
       TcType.swapOverVars
       TcType.canSolveByUnification
   previously they had different logic for the same goals

2. Fixing this bug exposed another!  In T11635 we end
   up unifying
   (alpha :: forall k. k->*) ~ (beta :: forall k. k->*)
   Now that the occurs check is done for tyvars too, we
   look inside beta's kind.  And then reject the program
   becuase of the forall inside there.  But in fact that
   forall is fine -- it does not count as impredicative
   polymoprhism.   See Note [Checking for foralls]
   in TcType.

3. All this fuss around occurrence checking forced me
   to look at TcUnify.checkTauTvUpdate
          and TcType.occurCheckExpand
   There's a lot of duplication there, and I managed
   to elminate quite a bit of it. For example,
   checkTauTvUpdate called a local 'defer_me'; and then
   called occurCheckExpand, which then used a very
   similar 'fast_check'.

   Things are better, but there is more to do.

2 years agoFix desugaring of pattern bindings (again)
Simon Peyton Jones [Fri, 16 Sep 2016 21:33:20 +0000 (22:33 +0100)] 
Fix desugaring of pattern bindings (again)

This patch fixes Trac #12595.  The problem was with a
pattern binding like
     !x = e
For a start it's silly to match that pattern and build
a unit tuple (the General Case of mkSelectorBinds); but
that's what was happening because the bang fell through
to the general case.  But for a variable pattern building
any auxiliary bindings is stupid.  So the patch
introduces a new case in mkSelectorBinds for variable
patterns.

Then it turned out that if 'e' was a plain variable, and
moreover was imported GlobalId, then matchSinglePat made
it a /bound/ variable, which should never happen.  That
ultimately caused a linker error, but the original bug
was much earlier.

2 years agoA bit of tracing about flattening
Simon Peyton Jones [Sat, 24 Sep 2016 03:42:18 +0000 (04:42 +0100)] 
A bit of tracing about flattening

2 years agoCheck.hs: Use actual import lists instead of comments
Ömer Sinan Ağacan [Thu, 29 Sep 2016 15:03:24 +0000 (11:03 -0400)] 
Check.hs: Use actual import lists instead of comments

2 years agoTest Trac #12634
Simon Peyton Jones [Thu, 29 Sep 2016 08:23:11 +0000 (09:23 +0100)] 
Test Trac #12634

2 years agoComments and manual only: spelling
Gabor Greif [Wed, 28 Sep 2016 13:28:38 +0000 (15:28 +0200)] 
Comments and manual only: spelling

2 years agoTH: Use atomicModifyIORef' for fresh names
Erik de Castro Lopo [Tue, 27 Sep 2016 21:37:33 +0000 (07:37 +1000)] 
TH: Use atomicModifyIORef' for fresh names

This prevents the possibility of race conditions when creating fresh
names.

Test Plan: validate

Reviewers: goldfire, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

2 years agoFix layout of MultiWayIf expressions (#10807)
Ömer Sinan Ağacan [Mon, 26 Sep 2016 21:09:01 +0000 (17:09 -0400)] 
Fix layout of MultiWayIf expressions (#10807)

With this patch we stop generating virtual semicolons in MultiWayIf
guards. Fixes #10807.

Test Plan:

Reviewers: simonmar, austin, bgamari

Reviewed By: simonmar

Subscribers: mpickering, thomie

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

GHC Trac Issues: #10807

2 years agoRemove #ifdef with never fulfilled condition
Joachim Breitner [Mon, 26 Sep 2016 17:49:42 +0000 (13:49 -0400)] 
Remove #ifdef with never fulfilled condition

__GLASGOW_HASKELL is a typo (should be __GLASGOW_HASKELL__), obviously,
but nobody noticed.

2 years agoPrint foralls in user format
Simon Peyton Jones [Mon, 26 Sep 2016 07:37:47 +0000 (08:37 +0100)] 
Print foralls in user format

This fixes Trac #12597: in RnNames.warnMissingSignatures,
use pprSigmaType not pprType

2 years agoPattern Synonyms documentation update
Matthew Pickering [Sat, 24 Sep 2016 15:28:02 +0000 (16:28 +0100)] 
Pattern Synonyms documentation update

2 years agoUpdate test output
Joachim Breitner [Sat, 24 Sep 2016 01:20:18 +0000 (10:20 +0900)] 
Update test output

2 years agoReplace INLINEABLE by INLINABLE (#12613)
Joachim Breitner [Sat, 24 Sep 2016 00:16:59 +0000 (09:16 +0900)] 
Replace INLINEABLE by INLINABLE (#12613)

as the latter is the official, correct spelling, and the former just a
misspelling accepted by GHC.

Also document in the user’s guide that the alternative spelling is
accepted

This commit was brough to you by HIW 2016.

2 years agoMark mapUnionFV as INLINABLE rather than INLINE
Matthew Pickering [Fri, 23 Sep 2016 22:25:43 +0000 (23:25 +0100)] 
Mark mapUnionFV as INLINABLE rather than INLINE

It is a self-recursive function so will always be the loop-breaker
and hence never able to be inlined. It is dubious whether the INLINABLE
pragma will ever help as it is not a very polymorphic function
but some specialisation could occur.

2 years agoFix #12442.
Richard Eisenberg [Wed, 27 Jul 2016 20:41:50 +0000 (16:41 -0400)] 
Fix #12442.

The problem is described in the ticket.

This patch adds new variants of the access points to the pure
unifier that allow unification of types only when the caller
wants this behavior. (The unifier used to also unify kinds.)
This behavior is appropriate when the kinds are either already
known to be the same, or the list of types provided are a
list of well-typed arguments to some type constructor. In the
latter case, unifying earlier types in the list will unify the
kinds of any later (dependent) types.

At use sites, I went through and chose the unification function
according to the criteria above.

This patch includes some modest performance improvements as we
are now doing less work.

2 years agoImproved documentation for Foreign.Concurrent (#12547)
Simon Marlow [Fri, 16 Sep 2016 13:48:57 +0000 (14:48 +0100)] 
Improved documentation for Foreign.Concurrent (#12547)

We had better docs for the underlying functions in GHC.ForeignPtr, but
this wasn't propagated to the re-exported versions in
Foreign.Concurrent.

2 years agoExpose hs_exit_(rtsFalse) as hs_exit_nowait()
Simon Marlow [Fri, 16 Sep 2016 10:04:44 +0000 (11:04 +0100)] 
Expose hs_exit_(rtsFalse) as hs_exit_nowait()

Summary: And document it.  See the docmentation for the reason I want this.

Test Plan: It's an existing API, just exposing it.

Reviewers: bgamari, niteria, austin, erikd

Subscribers: thomie

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

2 years agoshutdownHaskellAndExit: just do a normal hs_exit() (#5402)
Simon Marlow [Thu, 15 Sep 2016 14:53:00 +0000 (15:53 +0100)] 
shutdownHaskellAndExit: just do a normal hs_exit() (#5402)

If we want to keep the RTS alive a bit longer by having another
hs_init()/hs_exit() pair in a library that will destruct itself after
main() has exited, then the forced shutdown here thwarts that.

I think we just "fixed" #5402 in the wrong way before, this should be
better.

2 years agoFix failing test T12504
Tamar Christina [Wed, 21 Sep 2016 00:51:47 +0000 (01:51 +0100)] 
Fix failing test T12504

Summary:
Test T12504 does it's checking in the Makefile using grep but still specified an stdout.
the stdout has the old output and would always fail.

Since the stdout isn't needed, let's not check it.

Test Plan: make test TEST=T12504

Reviewers: bgamari, austin, erikd, rcook

Reviewed By: rcook

Subscribers: thomie, #ghc_windows_task_force

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

GHC Trac Issues: #12504

2 years agoBump Haddock submodule to fix rendering of class methods
Matthew Pickering [Tue, 20 Sep 2016 18:48:01 +0000 (19:48 +0100)] 
Bump Haddock submodule to fix rendering of class methods

Fixes #12519

2 years agoCodegen for case: Remove redundant void id checks
Ömer Sinan Ağacan [Tue, 20 Sep 2016 04:19:15 +0000 (00:19 -0400)] 
Codegen for case: Remove redundant void id checks

New unarise (714bebf) eliminates void binders in patterns already, so no
need to eliminate them here. I leave assertions to make sure this is the
case.

Assertion failure -> bug in unarise

Reviewers: bgamari, simonpj, austin, simonmar, hvr

Reviewed By: simonpj

Subscribers: thomie

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

2 years agoRemove directories from include paths
Ben Gamari [Fri, 16 Sep 2016 15:49:24 +0000 (11:49 -0400)] 
Remove directories from include paths

Previously this was a relative path which worked in the GHC tree, but
failed elsewhere. This caused trouble for out-of-tree users as well as
Hadrian, which wants to move build artifacts out of the working
directory. Fixes #8040.

Test Plan: Validate

Reviewers: thomie, austin, snowleopard, hvr

Reviewed By: snowleopard, hvr

Subscribers: thomie

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

GHC Trac Issues: #8040

2 years agoAdd test case for #7611
Joachim Breitner [Thu, 15 Sep 2016 21:06:16 +0000 (17:06 -0400)] 
Add test case for #7611

basically using the machinery from the test case of #2110.

2 years agoComments in TH.Syntax (Trac #12596)
Simon Peyton Jones [Wed, 14 Sep 2016 07:38:33 +0000 (08:38 +0100)] 
Comments in TH.Syntax (Trac #12596)

See Note [Data for non-algebraic types]

2 years agoComments only
Simon Peyton Jones [Thu, 15 Sep 2016 16:07:12 +0000 (17:07 +0100)] 
Comments only

3 years agoUnify CallStack handling in ghc
Ben Gamari [Mon, 12 Sep 2016 18:54:30 +0000 (14:54 -0400)] 
Unify CallStack handling in ghc

Here we introduce compatibility wrappers for HasCallStack constraints.
This is necessary as we must support GHC 7.10.1 which lacks sane call
stack support. We also introduce another constraint synonym,
HasDebugCallStack, which only provides a call stack when DEBUG is set.

3 years agotryGrabCapability should be using TRY_ACQUIRE_LOCK
Simon Marlow [Thu, 15 Sep 2016 10:34:05 +0000 (11:34 +0100)] 
tryGrabCapability should be using TRY_ACQUIRE_LOCK

3 years agoFix codegen bug in PIC version of genSwitch (#12433)
Simon Marlow [Thu, 15 Sep 2016 09:11:34 +0000 (10:11 +0100)] 
Fix codegen bug in PIC version of genSwitch (#12433)

Summary:
* getNonClobberedReg instead of getSomeReg, because the reg needs to
  survive across t_code
* Use a new reg for the table offset calculation instead of clobbering
  the reg returned by expr (this was the bug affecting #12433)

Test Plan: New unit test; validate

Reviewers: rwbarton, bgamari, austin, erikd

Subscribers: thomie

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

GHC Trac Issues: #12433

3 years agoComments and white space
Simon Peyton Jones [Mon, 5 Sep 2016 15:52:35 +0000 (16:52 +0100)] 
Comments and white space

3 years agoComments and white space only
Simon Peyton Jones [Mon, 5 Sep 2016 08:28:19 +0000 (09:28 +0100)] 
Comments and white space only

3 years agoComments and white space only
Simon Peyton Jones [Mon, 29 Aug 2016 08:04:24 +0000 (09:04 +0100)] 
Comments and white space only

3 years agoTestsuite wibbles, to the same files
Simon Peyton Jones [Mon, 12 Sep 2016 23:00:21 +0000 (00:00 +0100)] 
Testsuite wibbles, to the same files

Sigh.  I added some comments to the source files,
and failed to revalidate.  But the comments change the
line number in the error messages.  Doh.

3 years agoTest wibbles for commit 03541cba
Simon Peyton Jones [Mon, 12 Sep 2016 21:21:15 +0000 (22:21 +0100)] 
Test wibbles for commit 03541cba

I must have failed to validate properly, sorry.
These testsuite wibbles belong with

  commit 03541cbae50f0d1cdf99120ab88698f29a278159
  Author: Simon Peyton Jones <simonpj@microsoft.com>
  Date:   Fri Sep 9 17:42:42 2016 +0100

      Be less picky about reporing inaccessible code

3 years agorts: Disable -hb with multiple capabilities
Ben Gamari [Mon, 12 Sep 2016 12:44:24 +0000 (08:44 -0400)] 
rts: Disable -hb with multiple capabilities

Biographical profiling is not thread-safe as documented in #12019. Throw
an error when it is used in this way.

Test Plan: Validate

Reviewers: simonmar, austin, erikd

Reviewed By: erikd

Subscribers: thomie

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

GHC Trac Issues: #12019

3 years agousers_guide: TH now partially supports typed holes
Ben Gamari [Thu, 8 Sep 2016 15:34:11 +0000 (11:34 -0400)] 
users_guide: TH now partially supports typed holes

As requested in #10267. However we still lack support in typed splices.
See #10945 and #10946.

3 years agousers_guide: #8761 is now fixed
Ben Gamari [Thu, 8 Sep 2016 15:31:44 +0000 (11:31 -0400)] 
users_guide: #8761 is now fixed

Remove a leftover note in the users guide claiming that TH doesn't
support pattern synonyms.

3 years agousers_guide: Fix Docbook remnant
Ben Gamari [Thu, 8 Sep 2016 15:30:40 +0000 (11:30 -0400)] 
users_guide: Fix Docbook remnant

Not sure how this snuck through but it seems to be the only one.

3 years agoRemove unused exports
Simon Peyton Jones [Sun, 4 Sep 2016 20:58:20 +0000 (21:58 +0100)] 
Remove unused exports

3 years agoBe less picky about reporing inaccessible code
Simon Peyton Jones [Fri, 9 Sep 2016 16:42:42 +0000 (17:42 +0100)] 
Be less picky about reporing inaccessible code

Triggered by the discussion on Trac #12466, this patch
makes GHC less aggressive about reporting an error when
there are insoluble Givens.

Being so agressive was making some libraries fail to
compile, and is arguably wrong in at least some cases.
See the discussion on the ticket.

Several test now pass when they failed before; see
the files-modified list for this patch.

3 years agoAdd hs_try_putmvar()
Simon Marlow [Tue, 30 Aug 2016 19:55:10 +0000 (20:55 +0100)] 
Add hs_try_putmvar()

Summary:
This is a fast, non-blocking, asynchronous, interface to tryPutMVar that
can be called from C/C++.

It's useful for callback-based C/C++ APIs: the idea is that the callback
invokes hs_try_putmvar(), and the Haskell code waits for the callback to
run by blocking in takeMVar.

The callback doesn't block - this is often a requirement of
callback-based APIs.  The callback wakes up the Haskell thread with
minimal overhead and no unnecessary context-switches.

There are a couple of benchmarks in
testsuite/tests/concurrent/should_run.  Some example results comparing
hs_try_putmvar() with using a standard foreign export:

    ./hs_try_putmvar003 1 64 16 100 +RTS -s -N4     0.49s
    ./hs_try_putmvar003 2 64 16 100 +RTS -s -N4     2.30s

hs_try_putmvar() is 4x faster for this workload (see the source for
hs_try_putmvar003.hs for details of the workload).

An alternative solution is to use the IO Manager for this.  We've tried
it, but there are problems with that approach:
* Need to create a new file descriptor for each callback
* The IO Manger thread(s) become a bottleneck
* More potential for things to go wrong, e.g. throwing an exception in
  an IO Manager callback kills the IO Manager thread.

Test Plan: validate; new unit tests

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

Subscribers: thomie

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

3 years agoFix TH ppr output for list comprehensions with only one Stmt
Ryan Scott [Sun, 11 Sep 2016 15:10:36 +0000 (11:10 -0400)] 
Fix TH ppr output for list comprehensions with only one Stmt

A folow-up to D2521 (which addressed #12583), where the `Outputable` `ppr`
output was tweaked to display a list comprehension with only one `Stmt` as
`[Foo]` instead of `[Foo|]` (which isn't valid Haskell). I forgot to update
the corresponding code in `Language.Haskell.TH.Ppr` which pretty-prints
`CompE`, however, so this commit takes care of that.

3 years agoFix derived Ix instances for one-constructor GADTs
Ryan Scott [Sun, 11 Sep 2016 14:27:36 +0000 (10:27 -0400)] 
Fix derived Ix instances for one-constructor GADTs

Summary:
Standalone-derived `Ix` instances would panic on GADTs with exactly
one constructor, since the list of fields was being passed to a function that
uses `foldl1` in order to generate an implementation for `inRange`. This adds a
simple check that makes `inRange` be `True` whenever a product type has no
fields.

Fixes #12583.

Test Plan: make test TEST=12583

Reviewers: simonpj, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

GHC Trac Issues: #12583

3 years agoRemove uses of mkMatchGroupName
Matthew Pickering [Sun, 11 Sep 2016 13:35:27 +0000 (14:35 +0100)] 
Remove uses of mkMatchGroupName

You can now just use `mkMatchGroup`.

3 years agoGeneralise type of mkMatchGroup to unify with mkMatchGroupName
Matthew Pickering [Sun, 11 Sep 2016 13:33:14 +0000 (14:33 +0100)] 
Generalise type of mkMatchGroup to unify with mkMatchGroupName

3 years agoAdd platform warning to Foreign.C.Types
Tamar Christina [Sat, 10 Sep 2016 12:04:19 +0000 (13:04 +0100)] 
Add platform warning to Foreign.C.Types

Summary:
The generated documentation for thhe Foreign.C.Types
module is generated based on the platform which ran Haddock.

This is generating incorrect types for e.g. Windows.

Add a disclaimer to the top of the page to ask people to
keep this in mind.

Test Plan: make documentation and inspect Haddock

Reviewers: erikd, austin, hvr, bgamari

Reviewed By: erikd

Subscribers: RyanGlScott, #ghc_windows_task_force, thomie

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

GHC Trac Issues: #12586

3 years agoRemove -flocal-ghci-history from default flags
Ryan Scott [Sat, 10 Sep 2016 17:51:23 +0000 (13:51 -0400)] 
Remove -flocal-ghci-history from default flags

Summary:
D2461 seemed to (inadvertently, I think) add the
`-flocal-ghci-history` flag to the list of `defaultFlags` that are enabled
automatically. As a result, every invocation of `ghci` caused a local GHCi
history to be saved to the current directory, which probably shouldn't be the
default.

Test Plan:
Run `ghci`, observe the lack of a `.ghci_history` file in your
working directory

Reviewers: austin, thomie, bgamari

Reviewed By: bgamari

Subscribers: ak3n

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

GHC Trac Issues: #9089

3 years agoMake start address of `osReserveHeapMemory` tunable via command line -xb
Francesco Mazzoli [Fri, 9 Sep 2016 17:15:49 +0000 (18:15 +0100)] 
Make start address of `osReserveHeapMemory` tunable via command line -xb

Summary:
We stumbled upon a case where an external library (OpenCL) does not work
if a specific address (0x200000000) is taken.

It so happens that `osReserveHeapMemory` starts trying to mmap at 0x200000000:

```
        void *hint = (void*)((W_)8 * (1 << 30) + attempt * BLOCK_SIZE);
        at = osTryReserveHeapMemory(*len, hint);
```

This makes it impossible to use Haskell programs compiled with GHC 8
with C functions that use OpenCL.

See this example ​https://github.com/chpatrick/oclwtf for a repro.

This patch allows the user to work around this kind of behavior outside
our control by letting the user override the starting address through an
RTS command line flag.

Reviewers: bgamari, Phyx, simonmar, erikd, austin

Reviewed By: Phyx, simonmar

Subscribers: rwbarton, thomie

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

3 years agoAdd hook for creating ghci external interpreter
Alan Zimmerman [Thu, 8 Sep 2016 06:59:48 +0000 (08:59 +0200)] 
Add hook for creating ghci external interpreter

Summary:
The external interpreter is launched by calling
'System.Process.createProcess' with a 'CreateProcess' parameter.

The current value for this has the 'std_in', 'std_out' and 'std_err'
fields use the default of 'Inherit', meaning that the remote interpreter
shares the stdio with the original ghc/ghci process.

This patch introduces a new hook to the DynFlags, which has an
opportunity to override the 'CreateProcess' fields, launch the process,
and retrieve the stdio handles actually used.

So if a ghci external interpreter session is launched from the GHC API
the stdio can be redirected if required, which is useful for tooling/IDE
integration.

Test Plan: ./validate

Reviewers: austin, hvr, simonmar, bgamari

Reviewed By: simonmar, bgamari

Subscribers: thomie

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

3 years agoUpdate unix submodule to latest HEAD.
Edward Z. Yang [Thu, 8 Sep 2016 19:05:30 +0000 (12:05 -0700)] 
Update unix submodule to latest HEAD.

Fixes readdir validation error (fixes #12572).

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
3 years agoDocument meaning of order of --package-db flags, fixes #12485.
Edward Z. Yang [Mon, 5 Sep 2016 23:19:57 +0000 (19:19 -0400)] 
Document meaning of order of --package-db flags, fixes #12485.

Test Plan: none

Reviewers: austin, niteria, bgamari

Reviewed By: niteria

Subscribers: thomie

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

GHC Trac Issues: #12485

3 years agoRemove references to -XRelaxedPolyRec
Ben Gamari [Mon, 5 Sep 2016 23:19:23 +0000 (19:19 -0400)] 
Remove references to -XRelaxedPolyRec

Test Plan: Read it

Reviewers: dfeuer, austin

Subscribers: thomie

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

GHC Trac Issues: #11691

3 years agoAdd failing testcase for #12433
Ben Gamari [Mon, 5 Sep 2016 23:19:10 +0000 (19:19 -0400)] 
Add failing testcase for #12433

Test Plan: Validate

Reviewers: austin

Subscribers: thomie

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

GHC Trac Issues: #11433

3 years agoMake the test for #11108 less fragile
Takano Akio [Mon, 5 Sep 2016 19:52:37 +0000 (15:52 -0400)] 
Make the test for #11108 less fragile

This change should close #11108 by fixing the test case.

This commit fixes two issues:

* Make sure that each weak pointer we allocate has a constructor as the
  key, not a thunk. A failure to do so meant these weak pointers died
  prematurely on the 'ghci' WAY.

* Don't print anything in the finalizer, because they are not guaranteed
  to run.

Test Plan: validate

Reviewers: austin, simonmar, erikd, bgamari

Reviewed By: erikd, bgamari

Subscribers: thomie

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

GHC Trac Issues: #11108

3 years agodistrib: Fix libdw bindist check
Ben Gamari [Sun, 4 Sep 2016 17:23:35 +0000 (13:23 -0400)] 
distrib: Fix libdw bindist check

As reported in #12555 this code was terribly broken. Sadly, Autoconf was
none-the-wiser. Thanks to @rwbarton for pointing this out.

Test Plan: Test with libdw version newer and older and 0.158

Reviewers: hvr, austin, rwbarton

Reviewed By: rwbarton

Subscribers: thomie, rwbarton, erikd

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

GHC Trac Issues: #12555

3 years agoDerive the Generic instance in perf/compiler/T5642
Ryan Scott [Mon, 5 Sep 2016 19:45:38 +0000 (15:45 -0400)] 
Derive the Generic instance in perf/compiler/T5642

Summary:
For some inexplicable reason, the `Generic` instance in
`perf/compiler/T5642` is written out entirely by hand. This is not only
strange, since Trac #5642 is about derived `Generic` instances, but it also
annoying to maintain, since it requires manually changing a bunch of code
whenever the algorithm behind `deriving Generic` changes. (See D2304 for a
recent example of this.)

It seems more sensible to just derive the `Generic` instance. It shifts the
goalposts of what allocations we're measuring a bit, since we no longer have
to parse a large amount of code (and as a knock-on effect, the allocations go
down a bit). But I think this program is morally equivalent to what we were
benchmarking before, so it's not too unreasonable to change.

Test Plan: make test TEST=T5642

Reviewers: austin, thomie, bgamari

Reviewed By: bgamari

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

GHC Trac Issues: #5642

3 years agoMake generated Ord instances smaller (per #10858).
Petr Prokhorenkov [Sun, 4 Sep 2016 17:23:19 +0000 (13:23 -0400)] 
Make generated Ord instances smaller (per #10858).

Reviewers: simonpj, bgamari, RyanGlScott, austin

Reviewed By: simonpj

Subscribers: nomeata, simonpj, thomie

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

GHC Trac Issues: #10858

3 years agoLess scary arity mismatch error message when deriving
mniip [Sun, 4 Sep 2016 17:23:03 +0000 (13:23 -0400)] 
Less scary arity mismatch error message when deriving

Test Plan: Corrected a few tests to include the new message.

Reviewers: goldfire, austin, bgamari

Reviewed By: bgamari

Subscribers: goldfire, thomie

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

GHC Trac Issues: #12546

3 years agoTurn divInt# and modInt# into bitwise operations when possible
Takano Akio [Sun, 4 Sep 2016 17:22:22 +0000 (13:22 -0400)] 
Turn divInt# and modInt# into bitwise operations when possible

This implements #5615 for divInt# and modInt#.

I also included rules to do constant-folding when the both arguments
are known.

Test Plan: validate

Reviewers: austin, simonmar, bgamari

Reviewed By: bgamari

Subscribers: hvr, thomie

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

GHC Trac Issues: #5615

3 years agoDon't ignore addTopDecls in module finalizers.
Facundo Domínguez [Thu, 1 Sep 2016 14:00:08 +0000 (11:00 -0300)] 
Don't ignore addTopDecls in module finalizers.

Summary:
Module finalizer could call addTopDecls, however, the declarations
added in this fashion were ignored. This patch makes sure to rename,
type check and incorporate this declarations.

Because a declaration may include a splice which calls addModFinalizer,
the list of finalizers is repeteadly checked after adding declarations
until no more finalizers remain.

Test Plan: ./validate

Reviewers: bgamari, goldfire, simonpj, austin

Reviewed By: bgamari, simonpj

Subscribers: simonmar, mboes, thomie

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

GHC Trac Issues: #12559

3 years agocleanup: drop 11 years old performance hack
Sergei Trofimovich [Sun, 4 Sep 2016 21:08:27 +0000 (22:08 +0100)] 
cleanup: drop 11 years old performance hack

The 'return () >>' hack was added in commit
    commit ac88f113abdec1edbffb6d2f97323e81f82908e7
    Date:   Tue Jul 26 12:14:03 2005 +0000

Nowadays it has no effect on generated Core on -O1/-O2
and slightly bloats Core on -O0.

Signed-off-by: Sergei Trofimovich <siarheit@google.com>
3 years agoaccept current (problematic) output
Gabor Greif [Sun, 4 Sep 2016 10:38:40 +0000 (12:38 +0200)] 
accept current (problematic) output

3 years agotest #12567: add new testcase with expected plugin behaviour
Gabor Greif [Sun, 4 Sep 2016 10:13:54 +0000 (12:13 +0200)] 
test #12567: add new testcase with expected plugin behaviour

3 years agoFix comment about result
Gabor Greif [Sat, 3 Sep 2016 15:10:49 +0000 (17:10 +0200)] 
Fix comment about result

3 years agoTypo in comment
Gabor Greif [Sat, 3 Sep 2016 12:44:48 +0000 (14:44 +0200)] 
Typo in comment

3 years agoextend '-fmax-worker-args' limit to specialiser (Trac #11565)
Sergei Trofimovich [Fri, 2 Sep 2016 17:47:56 +0000 (18:47 +0100)] 
extend '-fmax-worker-args' limit to specialiser (Trac #11565)

It's a complementary change to
    a48de37dcca98e7d477040b0ed298bcd1b3ab303
    restore -fmax-worker-args handling (Trac #11565)

I don't have a small example but I've noticed another
discrepancy when was profiling GHC for performance

    cmmExprNative :: ReferenceKind -> CmmExpr -> CmmOptM CmmExpr

was specialised by 'spec_one' down to a function with arity 159.
As a result 'perf record' pointed at it as at slowest
function in whole ghc library.

I've extended -fmax-worker-args effect to 'spec_one'
as it does the same worker/wrapper split to push
arguments to the heap.

The change decreases heap usage on a synth.bash benchmark
(Trac #9221) from 67G down to 64G (-4%). Benchmark runtime
decreased from 14.5 s down to 14.s (-7%).

Signed-off-by: Sergei Trofimovich <siarheit@google.com>
Reviewers: ezyang, simonpj, austin, goldfire, bgamari

Subscribers: thomie

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

GHC Trac Issues: #11565

3 years agoghc-cabal: accept EXTRA_HC_OPTS make variable
Sergei Trofimovich [Fri, 2 Sep 2016 17:04:03 +0000 (18:04 +0100)] 
ghc-cabal: accept EXTRA_HC_OPTS make variable

Signed-off-by: Sergei Trofimovich <siarheit@google.com>
3 years agoProtect StablPtr dereference with the StaticPtr table lock.
Facundo Domínguez [Thu, 1 Sep 2016 19:31:26 +0000 (16:31 -0300)] 
Protect StablPtr dereference with the StaticPtr table lock.

Summary: Also comment on the need to use stgMallocBytes in StaticPtrTable.c.

Test Plan: ./validate

Reviewers: erikd, austin, bgamari, simonmar

Reviewed By: simonmar

Subscribers: thomie

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

3 years agoTypos in notes
ggreif [Mon, 15 Jun 2015 16:10:24 +0000 (18:10 +0200)] 
Typos in notes

3 years agoFix #10923 by fingerprinting optimization level.
Edward Z. Yang [Thu, 1 Sep 2016 22:28:07 +0000 (15:28 -0700)] 
Fix #10923 by fingerprinting optimization level.

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

Reviewers: simonmar, austin, bgamari, thomie, rwbarton

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

GHC Trac Issues: #10923

3 years agoconfigure.ac: fix --host= handling
Sergei Trofimovich [Fri, 2 Sep 2016 07:35:25 +0000 (08:35 +0100)] 
configure.ac: fix --host= handling

The following command fails as:
    $ ./configure --prefix=/usr \
        --build=x86_64-pc-linux-gnu \
        --host=x86_64-pc-linux-gnu \
        --target=x86_64-pc-linux-gnu
    configure: error:
    You've selected:

      BUILD:  x86_64-unknown-linux
      HOST:   x86_64-unknown-linux
      TARGET: x86_64-unknown-linux

    BUILD must equal HOST;

18f06878ed5d8cb0cf366a876f2bfea29647e5f0 changed native
configure $build/$host/$target checks to ghc-mangled ones,
but not completely.

Signed-off-by: Sergei Trofimovich <siarheit@google.com>
Reviewers: rwbarton, erikd, austin, hvr, bgamari, Phyx

Reviewed By: Phyx

Subscribers: thomie

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

GHC Trac Issues: #12487

3 years agoAdded support for deprecated POSIX functions on Windows.
Tamar Christina [Thu, 1 Sep 2016 20:30:07 +0000 (21:30 +0100)] 
Added support for deprecated POSIX functions on Windows.

Summary:
With the introduction of 8.0.1 We've stopped supporting in GHCi
the use of POSIX functions under their deprecated names on Windows.

This to be compatible with object and libraries from the most
popular compilers on the platform (Microsoft and Intel compilers).

However this brings a confusing disparity between the compiled and
interpreted behavior since MingW-W64 does support the deprecated names.

Also It seems clear that package writers won't update their packages to
properly support Windows. As such I have added redirects in the RTS
for the deprecated functions as listed on

https://msdn.microsoft.com/en-us/library/ms235384.aspx.

This won't export the functions (as in, they won't be in the symbol table
of compiled code for the RTS.) but we inject them into the symbol table
of the dynamic linker at startup.

Test Plan:
./validate
and

make test TEST="ffi017 ffi021"

Reviewers: thomie, simonmar, RyanGlScott, bgamari, austin, hvr, erikd

Reviewed By: simonmar, bgamari

Subscribers: RyanGlScott, #ghc_windows_task_force

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

GHC Trac Issues: #12209, #12497, #12496

3 years agoFix startsVarSym and refactor operator predicates (fixes #4239)
Malo Jaffré [Thu, 1 Sep 2016 18:13:47 +0000 (14:13 -0400)] 
Fix startsVarSym and refactor operator predicates (fixes #4239)

startsVarSym used isSymbol which does not recognize valid operators
beginning with OtherPunctuation generalCategory (e. g. (·)).
Move it to ghc-boot-th for reducing duplication.

This patch fixes template-haskell pretty printer, which is used by
-ddump-minimal-imports.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

GHC Trac Issues: #4239

3 years agoRevert "Fix startsVarSym and refactor operator predicates (fixes #4239)"
Ben Gamari [Thu, 1 Sep 2016 19:03:46 +0000 (15:03 -0400)] 
Revert "Fix startsVarSym and refactor operator predicates (fixes #4239)"

This reverts commit 8d35e18d885e60f998a9dddb6db19762fe4c6d92.
arc butchered the authorship on this.

3 years agoFix startsVarSym and refactor operator predicates (fixes #4239)
Ben Gamari [Thu, 1 Sep 2016 18:13:47 +0000 (14:13 -0400)] 
Fix startsVarSym and refactor operator predicates (fixes #4239)

startsVarSym used isSymbol which does not recognize valid operators
beginning with OtherPunctuation generalCategory (e. g. (·)).
Move it to ghc-boot-th for reducing duplication.

This patch fixes template-haskell pretty printer, which is used by
-ddump-minimal-imports.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

GHC Trac Issues: #4239

3 years agoKill vestiages of DEFAULT_TMPDIR
Ben Gamari [Thu, 1 Sep 2016 16:13:18 +0000 (12:13 -0400)] 
Kill vestiages of DEFAULT_TMPDIR

It was removed long ago in cf403b50900648063d99afa160d2091a7d6f58c1.
Thanks for @rwbarton for catching this.

Updates nofib submodule.

Test Plan: Validate

Reviewers: austin, rwbarton

Subscribers: thomie, rwbarton

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

GHC Trac Issues: #12443

3 years agorestore -fmax-worker-args handling (Trac #11565)
Sergei Trofimovich [Thu, 1 Sep 2016 16:34:58 +0000 (17:34 +0100)] 
restore -fmax-worker-args handling (Trac #11565)

maxWorkerArgs handling was accidentally lost 3 years ago
in a major update of demand analysis
    commit 0831a12ea2fc73c33652eeec1adc79fa19700578

Old regression is noticeable as:
- code bloat (requires stack reshuffling)
- compilation slowdown (more code to optimise/generate)
- and increased heap usage (DynFlags unboxing/reboxing?)

On a simple compile benchmark this change causes heap
allocation drop from 70G don to 67G (ghc perf build).

Signed-off-by: Sergei Trofimovich <siarheit@google.com>
Reviewers: simonpj, ezyang, goldfire, austin, bgamari

Reviewed By: simonpj, ezyang

Subscribers: thomie

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

GHC Trac Issues: #11565

3 years agousers_guide: Move initGhcMonad note to 8.0.2 relnotes
Ben Gamari [Thu, 1 Sep 2016 05:06:25 +0000 (01:06 -0400)] 
users_guide: Move initGhcMonad note to 8.0.2 relnotes

3 years agousers_guide: Move -fdefer-out-of-scope-variables note to 8.0.2 relnotes
Ben Gamari [Wed, 31 Aug 2016 21:14:42 +0000 (17:14 -0400)] 
users_guide: Move -fdefer-out-of-scope-variables note to 8.0.2 relnotes

It will be included in 8.0.2

3 years agousers_guide: Move addModFinalizer mention to 8.0.2 release notes
Ben Gamari [Wed, 31 Aug 2016 21:03:46 +0000 (17:03 -0400)] 
users_guide: Move addModFinalizer mention to 8.0.2 release notes

3 years agousers_guide: Document removal of -Wredundant-constraints from -Wall
Ben Gamari [Wed, 31 Aug 2016 20:42:53 +0000 (16:42 -0400)] 
users_guide: Document removal of -Wredundant-constraints from -Wall

3 years agoRevert "testsuite: Update bytes allocated of parsing001"
Ben Gamari [Thu, 1 Sep 2016 14:23:20 +0000 (10:23 -0400)] 
Revert "testsuite: Update bytes allocated of parsing001"

This reverts commit ca6d0eb0f7d28b0245abc2b0783141101e51945f.

I'm really not sure what happened with the test build that lead me to
believe that this was necessary. Mysterious.

3 years agoLoadIFace: Show known names on inconsistent interface file
Ben Gamari [Wed, 31 Aug 2016 20:04:11 +0000 (16:04 -0400)] 
LoadIFace: Show known names on inconsistent interface file

Reviewers: austin

Subscribers: simonpj, ezyang, thomie

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

3 years agoRnExpr: Fix ApplicativeDo desugaring with RebindableSyntax
Ben Gamari [Wed, 31 Aug 2016 20:03:33 +0000 (16:03 -0400)] 
RnExpr: Fix ApplicativeDo desugaring with RebindableSyntax

We need to compare against the local return and pure, not returnMName
and pureAName.

Fixes #12490.

Test Plan: Validate, add testcase

Reviewers: austin, simonmar

Reviewed By: simonmar

Subscribers: thomie

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

GHC Trac Issues: #12490

3 years agoRemove redundant-constraints from -Wall (#10635)
Adam C. Foltzer [Wed, 31 Aug 2016 20:02:53 +0000 (16:02 -0400)] 
Remove redundant-constraints from -Wall (#10635)

Removes -Wredundant-constraints from -Wall, as per the
discussion in #10635.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

GHC Trac Issues: #10635

3 years agoAdd -fdefer-out-of-scope-variables flag (#12170).
Eugene Akentyev [Wed, 31 Aug 2016 20:02:10 +0000 (16:02 -0400)] 
Add -fdefer-out-of-scope-variables flag (#12170).

Reviewers: simonpj, thomie, austin, bgamari

Reviewed By: simonpj, thomie, bgamari

Subscribers: simonpj, thomie

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

GHC Trac Issues: #12170

3 years agotestsuite: Update bytes allocated of parsing001
Ben Gamari [Wed, 31 Aug 2016 20:16:25 +0000 (16:16 -0400)] 
testsuite: Update bytes allocated of parsing001

Sadly I don't know precisely which commit regressed this, but it was
quite recent. I'm not sure how this wasn't caught by my test builds.

3 years agoPPC NCG: Implement minimal stack frame header.
Peter Trommler [Wed, 31 Aug 2016 19:18:06 +0000 (15:18 -0400)] 
PPC NCG: Implement minimal stack frame header.

According to the ABI specifications a minimal stack frame consists
of a header and a minimum size parameter save area. We reserve the
minimal size for each ABI.

On PowerPC 64-bil Linux and AIX the parameter save area can accomodate
up to eight parameters. So calls with eight parameters and fewer
can be done without allocating a new stack frame and deallocating
that stack frame after the call. On AIX one additional spill slot
is available on the stack.

Code size for all nofib benchmarks is 0.3 % smaller on powerpc64.

Test Plan: validate on AIX

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

Reviewed By: bgamari

Subscribers: thomie

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

3 years agoAdd -flocal-ghci-history flag (#9089).
Eugene Akentyev [Wed, 31 Aug 2016 18:31:39 +0000 (14:31 -0400)] 
Add -flocal-ghci-history flag (#9089).

Reviewers: thomie, bgamari, austin

Reviewed By: thomie, bgamari

Subscribers: thomie

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

GHC Trac Issues: #9089

3 years agoAdd Read1/Read2 methods defined in terms of ReadPrec
Ryan Scott [Wed, 31 Aug 2016 18:30:57 +0000 (14:30 -0400)] 
Add Read1/Read2 methods defined in terms of ReadPrec

This adds new methods `liftReadList(2)` and `liftReadListPrec(2)` to the
`Read1`/`Read2` classes which are defined in terms of `ReadPrec` instead
of `ReadS`. This also adds related combinators and changes existing
`Read1` and `Read2` instances to be defined in terms of the new methods.

Reviewers: hvr, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

GHC Trac Issues: #12358

3 years agoTysWiredIn: Use dataConWorkerUnique instead of incrUnique
Ben Gamari [Wed, 31 Aug 2016 17:53:04 +0000 (13:53 -0400)] 
TysWiredIn: Use dataConWorkerUnique instead of incrUnique

Test Plan: Validate

Reviewers: austin

Subscribers: thomie

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

3 years agoA failing testcase for T12485
Bartosz Nitka [Wed, 31 Aug 2016 17:52:35 +0000 (13:52 -0400)] 
A failing testcase for T12485

Test Plan: it's just a testcase

Reviewers: ezyang, simonmar, bgamari, austin

Subscribers: thomie

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

GHC Trac Issues: #12485

3 years agoErrUtils: Expose accessors of ErrDoc and ErrMsg
Ben Gamari [Wed, 31 Aug 2016 17:50:30 +0000 (13:50 -0400)] 
ErrUtils: Expose accessors of ErrDoc and ErrMsg

Test Plan: Validate

Reviewers: austin

Subscribers: thomie

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

GHC Trac Issues: #12206