ghc.git
3 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: https://phabricator.haskell.org/D2721

3 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
version.

3 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

3 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.

3 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
instead.

Fixes #12838.

Reviewers: austin, erikd, simonmar, bgamari

Reviewed By: simonmar, bgamari

Subscribers: thomie

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

GHC Trac Issues: #12838

3 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: https://phabricator.haskell.org/D2710

GHC Trac Issues: #12839

3 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: https://phabricator.haskell.org/D2701

3 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: https://phabricator.haskell.org/D2638

GHC Trac Issues: #12744, #12745

3 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.

3 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

3 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)

3 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

Summary:
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: https://phabricator.haskell.org/D2705

GHC Trac Issues: #12455

3 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
https://mail.haskell.org/pipermail/ghc-devs/2016-November/013210.html

Test Plan: validate

Reviewers: austin, erikd, simonmar, bgamari

Reviewed By: bgamari

Subscribers: osa1, thomie

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

GHC Trac Issues: #12827

3 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: https://phabricator.haskell.org/D2707

GHC Trac Issues: #12759

3 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.

3 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.

3 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.

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

Summary:
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
  CONSTR_1_0

* 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: https://phabricator.haskell.org/D2690

GHC Trac Issues: #12455

3 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: https://phabricator.haskell.org/D2528

GHC Trac Issues: #11660

3 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: https://phabricator.haskell.org/D2700

3 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

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

3 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: https://phabricator.haskell.org/D2679

GHC Trac Issues: #12807

3 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: https://phabricator.haskell.org/D2696

3 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/package.conf.in 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: https://phabricator.haskell.org/D2695

GHC Trac Issues: #12816

3 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: https://phabricator.haskell.org/D2640

GHC Trac Issues: #12479

3 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...

[skip-ci]

3 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: https://phabricator.haskell.org/D2693

GHC Trac Issues: #12759

3 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

3 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

3 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.

3 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
context.

Thanks to Simon Peyton Jones for doing the necessary refactoring in
f05d685ae05ec293083f2fa7ec7ba057fbe64869.

Fixes #12814.

Test Plan: ./validate

Reviewers: goldfire, rwbarton, simonpj, austin, bgamari

Reviewed By: simonpj

Subscribers: thomie

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

GHC Trac Issues: #12814

3 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: https://phabricator.haskell.org/D2686

GHC Trac Issues: #12164

3 years agorts/linker: Move loadArchive to new source file
Ben Gamari [Thu, 10 Nov 2016 20:21:38 +0000 (15:21 -0500)] 
rts/linker: Move loadArchive to new source file

Test Plan: Validate

Reviewers: DemiMarie, austin, simonmar, erikd

Reviewed By: DemiMarie

Subscribers: Phyx, thomie, hvr

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

GHC Trac Issues: #12388

3 years agorts: Add api to pin a thread to a numa node but without fixing a capability
Darshan Kapashi [Thu, 10 Nov 2016 20:21:08 +0000 (15:21 -0500)] 
rts: Add api to pin a thread to a numa node but without fixing a capability

`rts_setInCallCapability` sets the thread affinity as well as pins the
numa node. We should also have the ability to set the numa node without
setting the capability affinity. `rts_pinNumaNodeForCapability` function
is added and exported via `RtsAPI.h`.

Previous callers of `rts_setInCallCapability` should now also call
`rts_pinNumaNodeForCapability` to get the same effect as before.

Test Plan:
  ./validate

Reviewers: austin, simonmar, bgamari

Reviewed By: simonmar, bgamari

Subscribers: thomie, niteria

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

GHC Trac Issues: #12764

3 years agoRead parentheses better
David Feuer [Thu, 10 Nov 2016 20:20:15 +0000 (15:20 -0500)] 
Read parentheses better

Instead of pulling a token and looking for `'('` or `')'`,
just look for the character itself. This prevents us from
lexing every single item twice, once to see if it's a
left parenthesis and once to actually parse it.

Partially fixes #12665

Make parens faster more aggressively

* Strip spaces before parsing, so we never have to strip
the same spaces twice.

* String parsers together manually, to try to avoid unnecessary closure
creation.

Test Plan: Validate

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

GHC Trac Issues: #12665

3 years agoAdd Richard Eisenberg's new email to mailmap
Ben Gamari [Thu, 10 Nov 2016 20:19:10 +0000 (15:19 -0500)] 
Add Richard Eisenberg's new email to mailmap

Reviewers: austin, mpickering

Reviewed By: mpickering

Subscribers: thomie

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

3 years agotestsuite: Update allocation numbers for T5631
Ben Gamari [Thu, 10 Nov 2016 20:25:08 +0000 (15:25 -0500)] 
testsuite: Update allocation numbers for T5631

3 years agoPass -no-pie to GCC
Ben Gamari [Thu, 10 Nov 2016 18:18:09 +0000 (13:18 -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).

Test Plan: Validate

Reviewers: hvr, austin

Subscribers: rwbarton, thomie, erikd

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

GHC Trac Issues: #12759

3 years agoconfigure: Pass HC_OPTS_STAGEx to build system
Ben Gamari [Fri, 4 Nov 2016 19:03:55 +0000 (15:03 -0400)] 
configure: Pass HC_OPTS_STAGEx to build system

Test Plan: Try `./configure HC_OPTS_STAGE0=-foobar` and watch it fail

Reviewers: austin, hvr

Subscribers: thomie, erikd

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

3 years agobuild system: Include CONF_LD_LINKER_OPTS in ALL_LD_OPTS
Ben Gamari [Fri, 4 Nov 2016 19:03:44 +0000 (15:03 -0400)] 
build system: Include CONF_LD_LINKER_OPTS in ALL_LD_OPTS

This ensures that artifacts built with build-prog see these options.
Also spruce up comments.

Test Plan: Carefully read it.

Reviewers: austin, hvr, erikd

Reviewed By: erikd

Subscribers: thomie, erikd

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

3 years agoghc-cabal: Use correct name of linker flags env variable
Ben Gamari [Fri, 4 Nov 2016 19:03:33 +0000 (15:03 -0400)] 
ghc-cabal: Use correct name of linker flags env variable

Currently passing the `CONF_LD_LINKER_OPTS_STAGE0` environment
variable to `configure` is broken due to this naming inconsistency.

Test Plan: Try passing `CONF_LD_LINKER_OPTS_STAGE0` to `configure`.
Look at resulting stage0 ghc invocation.

Reviewers: austin

Subscribers: thomie

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

3 years agoRefactor CallStack defaulting slightly
Simon Peyton Jones [Thu, 10 Nov 2016 16:02:42 +0000 (16:02 +0000)] 
Refactor CallStack defaulting slightly

This moves call-stack defaulting from simpl_top to solveWanteds,
for reasons described in Note [CallStack defaulting].

No change in visible behaviour.

3 years agoRefactoring of mkNewTypeEqn
Simon Peyton Jones [Thu, 10 Nov 2016 15:52:31 +0000 (15:52 +0000)] 
Refactoring of mkNewTypeEqn

The refactoring here is very small.  I did it while studying
Trac #12814.

To implement the change in #12814, we can just un-comment the
lines at line 1275.  It's ready to go but I didn't want to pull
the trigger in this commit

3 years agoAdapt the (commented out) pprTrace in OccurAnal
Simon Peyton Jones [Thu, 10 Nov 2016 15:50:57 +0000 (15:50 +0000)] 
Adapt the (commented out) pprTrace in OccurAnal

I did this while investigating Trac #12776

3 years agoFix comment about pointer tagging
Alex Biehl [Thu, 10 Nov 2016 12:12:30 +0000 (13:12 +0100)] 
Fix comment about pointer tagging

`Lcall` enters the closure. If it has tags we jump directly to `Lret`.

Confirmed with some generated cmm code:

```
           R1 = _s2pP::P64;
           Sp = Sp - 8;
           if (R1 & 7 != 0) goto c2x0; else goto c2x1;
       c2x1:
           call (I64[R1])(R1) returns to c2x0, args: 8, res: 8, upd: 8;
       c2x0:
           _s2pQ::P64 = R1;
```

3 years agoUpdate 8.0.2 release notes for #12784
Ryan Scott [Mon, 7 Nov 2016 13:56:22 +0000 (08:56 -0500)] 
Update 8.0.2 release notes for #12784

Summary:
The fix for #12220 exposed some ill-typed programs which passed the typechecker
in GHC 8.0.1 but now fail to typecheck in GHC 8.0.2. It's a bit difficult to
characterize what exactly triggers this bug, but we at least have a minimal
example and a simple fix to illustrate the problem and solution, so let's
add that the the 8.0.2 release notes to advertise this change.

Resolves #12784.

Reviewers: rwbarton, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

GHC Trac Issues: #12784

3 years agoFix hs_try_putmvar003 (#12800)
Simon Marlow [Fri, 4 Nov 2016 21:10:39 +0000 (14:10 -0700)] 
Fix hs_try_putmvar003 (#12800)

Summary:
There was a race condition on some shared data when creating the
callback thread.

I couldn't repro the issue without inserting a dummy usleep(100), but
it's definitely a bug.

Test Plan: validate

Reviewers: bgamari, austin, erikd

Subscribers: thomie

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

GHC Trac Issues: #12800

3 years agoFix broken validate build.
Tamar Christina [Sun, 6 Nov 2016 22:04:40 +0000 (22:04 +0000)] 
Fix broken validate build.

3 years agoSome minor linker cleanups.
Tamar Christina [Sun, 6 Nov 2016 19:08:40 +0000 (19:08 +0000)] 
Some minor linker cleanups.

Summary:
Just some cleanups to some oddities I've noticed
while investigating a linker issue.

Particularly the dll name returned by `findSysDll`
was decorated. So foo.dll is returned. We make it
`foo.dll.dll` and later drop one `.dll` when passed to
`addDll` which expects it without extension, but still
tries the name *as is* which is why it worked.

This should be slightly faster, since we don't try 4 loads
before we succeed.

Test Plan: ./validate

Reviewers: austin, hvr, erikd, simonmar, bgamari

Reviewed By: bgamari

Subscribers: thomie, #ghc_windows_task_force

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

3 years agoDescribe symptoms of (and the cure for) #12768 in 8.0.2 release notes
Ryan Scott [Sun, 6 Nov 2016 14:40:48 +0000 (09:40 -0500)] 
Describe symptoms of (and the cure for) #12768 in 8.0.2 release notes

GHC 8.0.2 introduced a bugfix involving GeneralizedNewtypeDeriving in
96d451450923a80b043b5314c5eaaa9d0eab7c56. This made typechecking of
GND-produced code a bit stricter, and an unfortunate side effect of this was
that there were a couple of corner-case programs that stopped compiling
when transitioning from GHC 8.0.1 to 8.0.2.

Since the number of affected programs seems quite small, and since the fix
is so straightforward, we opt to simply note this discrepancy in the 8.0.2
release notes.

Resolves #12768.

3 years agoAllow GeneralizedNewtypeDeriving for classes with associated type families
Ryan Scott [Sun, 6 Nov 2016 14:09:36 +0000 (09:09 -0500)] 
Allow GeneralizedNewtypeDeriving for classes with associated type families

Summary:
This implements the ability to derive associated type family instances
for newtypes automatically using `GeneralizedNewtypeDeriving`. Refer to the
users' guide additions for how this works; I essentially follow the pattern
laid out in https://ghc.haskell.org/trac/ghc/ticket/8165#comment:18.

Fixes #2721 and #8165.

Test Plan: ./validate

Reviewers: simonpj, goldfire, austin, bgamari

Reviewed By: simonpj

Subscribers: mpickering, thomie

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

GHC Trac Issues: #2721, #8165

3 years agoAdd tracing infrastructure to pattern match checker
Matthew Pickering [Sun, 6 Nov 2016 12:47:48 +0000 (12:47 +0000)] 
Add tracing infrastructure to pattern match checker

Summary:
This is the start of some tracing infrastructure which I found useful
when working through how the pattern match checker worked.

It adds the flag -ddump-ec-trace in order to turn on the trace.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

3 years agoStop -dno-debug-output suppressing -ddump-tc-trace
Matthew Pickering [Sun, 6 Nov 2016 12:46:40 +0000 (12:46 +0000)] 
Stop -dno-debug-output suppressing -ddump-tc-trace

Summary:
The user manual states that -dno-debug-output should suppress
*unsolicited* debugging output which essentially amounts to calls
to `pprTrace`. Before I unified the interface of `traceTc` and
`traceRn`, the flag suppressed calls to `traceTc` but not to `traceRn`
or any other tracing function already controlled by a flag.

Thus, in order to make the behaviour more uniform, it seemed best to
remove this one special case.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

GHC Trac Issues: #12691

3 years agoUpdate release notes for type sigs in TH patterns patch
Matthew Pickering [Sat, 5 Nov 2016 22:15:14 +0000 (22:15 +0000)] 
Update release notes for type sigs in TH patterns patch

[skip ci]

3 years agoHandle types w/ type variables in signatures inside patterns (DsMeta)
Mikhail Vorozhtsov [Sat, 5 Nov 2016 22:06:39 +0000 (22:06 +0000)] 
Handle types w/ type variables in signatures inside patterns (DsMeta)

The comment indicated that scoping of type variables was a large problem
but Simon fixed it in e21e13fb52b99b14770cc5857df57bbcc9c85102.

Thus, we can implement repP for signatures very easily in the usual way
now.

Reviewers: goldfire, simonpj, austin, bgamari

Reviewed By: simonpj

Subscribers: mpickering, simonpj, thomie

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

GHC Trac Issues: #12164

3 years agoTake account of injectivity when doing fundeps
Simon Peyton Jones [Fri, 4 Nov 2016 10:43:36 +0000 (10:43 +0000)] 
Take account of injectivity when doing fundeps

This fixes Trac #12803. Yikes!

See Note [Care with type functions].

3 years agoRemove a debug trace
Simon Peyton Jones [Thu, 3 Nov 2016 14:54:45 +0000 (14:54 +0000)] 
Remove a debug trace

I added this when debugging something else, but in general it doesn't
work (with -ddump-tc-trace) because of typecking recursive groups of
TyCons.  So removing it again.

3 years agoAdd comments from Trac #12768
Simon Peyton Jones [Thu, 3 Nov 2016 14:54:01 +0000 (14:54 +0000)] 
Add comments from Trac #12768

3 years agoOmit unnecessary linker flags
Simon Marlow [Thu, 27 Oct 2016 11:52:00 +0000 (12:52 +0100)] 
Omit unnecessary linker flags

Summary:
This omits -L and -l flags from the linker command line that shouldn't
be necessary because GHC will already add them via the -package-id
flags we pass.

This also reverts part of 90538d86af579595987826cd893828d6f379f35a
that rearranges the linker command line and causes some knock-on
problems (see D2618).

Test Plan: validate (need to validate on Windows too)

Reviewers: Phyx, bgamari, niteria, austin, erikd

Subscribers: thomie

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

GHC Trac Issues: #12738

3 years agoAPI Annotations: make all ModuleName Located
Alan Zimmerman [Thu, 3 Nov 2016 12:40:12 +0000 (14:40 +0200)] 
API Annotations: make all ModuleName Located

Summary:
This also changes the backpack Renaming type to use a Maybe for the
renameTo field, to more accurately reflect the parsed source.

Updates haddock submodule to match AST changes

Test Plan: ./validate

Reviewers: ezyang, bgamari, austin

Reviewed By: bgamari

Subscribers: thomie, mpickering

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

3 years agoAdd test for #12788
Ryan Scott [Thu, 3 Nov 2016 18:01:54 +0000 (14:01 -0400)] 
Add test for #12788

Commit bce99086e9f54909f51ff5a74cb8c666083bb021 (#12584) fixed #12788. Let's
add a test to make sure it stays fixed.

3 years agotestsuite: Update T10858 allocations
Ben Gamari [Thu, 3 Nov 2016 02:41:56 +0000 (22:41 -0400)] 
testsuite: Update T10858 allocations

3 years agoMerge cpe_ExprIsTrivial and exprIsTrivial
Ben Gamari [Wed, 2 Nov 2016 21:03:05 +0000 (17:03 -0400)] 
Merge cpe_ExprIsTrivial and exprIsTrivial

Strangely my previous attempts at resolving this all seemed to end in
perplexing segmentation faults in the GHC testsuite (including some
rather recent attempts). Somehow this attempt miraculously works.

However, there was one wrinkle that I still need to work out fully: we
need to consider Lits as non-trivial in cpeArg. Failure to do this means
that we would transform something like,

    $trModule = TrModule "HelloWorld"#

into

    $trModule = case "HelloWorld"# of x { __DEFAULT -> TrModule x }

Which then fails the consistentStgInfo check in CoreToStg for reasons
that I am still trying to work out.

Mark T12757 as fixed

Reviewers: simonmar, simonpj, austin

Reviewed By: simonpj

Subscribers: thomie

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

GHC Trac Issues: #11158

3 years agoAdd testcase for #12757
Ben Gamari [Wed, 2 Nov 2016 21:02:14 +0000 (17:02 -0400)] 
Add testcase for #12757

Test Plan: Validate, expected to fail

Reviewers: austin

Subscribers: thomie

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

GHC Trac Issues: #12757

3 years agoAdd notes describing SRT concepts
Ben Gamari [Wed, 2 Nov 2016 19:06:31 +0000 (15:06 -0400)] 
Add notes describing SRT concepts

Test Plan: Read it

Reviewers: austin, erikd, simonmar

Reviewed By: simonmar

Subscribers: thomie

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

3 years agoHoopl/Dataflow: make the module more self-contained
Michal Terepeta [Wed, 2 Nov 2016 19:05:19 +0000 (15:05 -0400)] 
Hoopl/Dataflow: make the module more self-contained

This makes the GHC's Dataflow module more self-contained by also
forking the `DataflowLattice` (instead of only the analysis
algorithm). Effects/benefits:
- We no longer need to use the deprecated Hoopl functions (and can
  remove `-fno-warn-warnings-deprecations` from two modules).
- We can remove the unnecessary `Label` parameter of `JoinFun` (already
  ignored in all our implementations).
- We no longer mix Hoopl's `Dataflow` module and GHC's one.
- We can replace some calls to lazy folds in Hoopl with the strict ones
  (see `joinOutFacts` and `mkFactBase`).

Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>
Test Plan: validate

Reviewers: austin, simonmar, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

3 years agolinker: Move ARM interworking note to SymbolExtras.c
Ben Gamari [Fri, 28 Oct 2016 13:26:08 +0000 (09:26 -0400)] 
linker: Move ARM interworking note to SymbolExtras.c

3 years agolinker: Split ELF implementation into separate source file
Ben Gamari [Wed, 2 Nov 2016 19:02:36 +0000 (15:02 -0400)] 
linker: Split ELF implementation into separate source file

Test Plan: Validate

Reviewers: erikd, austin, simonmar

Reviewed By: simonmar

Subscribers: thomie

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

3 years agolinker: Split MachO implementation into new source file
Ben Gamari [Wed, 2 Nov 2016 19:02:25 +0000 (15:02 -0400)] 
linker: Split MachO implementation into new source file

Test Plan: Validate

Reviewers: erikd, austin, simonmar

Reviewed By: simonmar

Subscribers: thomie

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

3 years agolinker: Split PEi386 implementation into new source file
Ben Gamari [Wed, 2 Nov 2016 19:02:13 +0000 (15:02 -0400)] 
linker: Split PEi386 implementation into new source file

Test Plan: Validate

Reviewers: erikd, austin, simonmar

Reviewed By: simonmar

Subscribers: thomie

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

3 years agoShuffle declarations into LinkerInternals.h
Ben Gamari [Wed, 2 Nov 2016 19:01:27 +0000 (15:01 -0400)] 
Shuffle declarations into LinkerInternals.h

Summary: These will be needed across source files shortly.

Test Plan: Validate

Reviewers: erikd, austin, simonmar

Reviewed By: simonmar

Subscribers: thomie

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

3 years agolinker: Split symbol extras logic into new source file
Ben Gamari [Wed, 2 Nov 2016 19:01:15 +0000 (15:01 -0400)] 
linker: Split symbol extras logic into new source file

Test Plan: Validate

Reviewers: erikd, austin, simonmar

Reviewed By: simonmar

Subscribers: thomie

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

3 years agolinker: Move mmapForLinker declaration into LinkerInternals.h
Ben Gamari [Wed, 2 Nov 2016 19:01:03 +0000 (15:01 -0400)] 
linker: Move mmapForLinker declaration into LinkerInternals.h

Test Plan: Validate

Reviewers: simonmar, erikd, austin

Reviewed By: simonmar

Subscribers: thomie

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

3 years agolinker: Shuffle configuration into LinkerInternals.h
Ben Gamari [Wed, 2 Nov 2016 19:00:44 +0000 (15:00 -0400)] 
linker: Shuffle configuration into LinkerInternals.h

Test Plan: Validate

Reviewers: erikd, austin, simonmar

Reviewed By: simonmar

Subscribers: thomie

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

3 years agolinker: Split out CacheFlush logic
Ben Gamari [Wed, 2 Nov 2016 18:58:59 +0000 (14:58 -0400)] 
linker: Split out CacheFlush logic

Test Plan: Validate

Reviewers: erikd, austin, simonmar

Reviewed By: erikd

Subscribers: thomie

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

3 years agotestsuite: Simplify kernel32 glue logic
Ben Gamari [Wed, 2 Nov 2016 18:58:30 +0000 (14:58 -0400)] 
testsuite: Simplify kernel32 glue logic

On Windows the testsuite driver calls kernel32 to set the current
terminal codepage. The previous implementation of this was significantly
more complex than necessary, and was wrong in the case of MSYS2, which
requires that we explicitly load the library using the name of its
DLL, including its file extension.

Test Plan: Validate on Windows

Reviewers: austin, RyanGlScott, Phyx

Reviewed By: RyanGlScott, Phyx

Subscribers: thomie

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

GHC Trac Issues: #12661

3 years agoUninstall signal handlers
Sylvain HENRY [Wed, 2 Nov 2016 18:55:06 +0000 (14:55 -0400)] 
Uninstall signal handlers

GHC installs signal handlers in runGhc/runGhcT to handle ^C but it
never uninstalls them.
It can be an issue, especially when using GHC as a library.

Test Plan: validate

Reviewers: bgamari, erikd, austin, simonmar

Reviewed By: bgamari, simonmar

Subscribers: thomie

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

GHC Trac Issues: #4162

3 years agoRenaming and comments in CorePrep
Simon Peyton Jones [Wed, 2 Nov 2016 16:48:38 +0000 (16:48 +0000)] 
Renaming and comments in CorePrep

In particular I renamed
  'triv' to 'arg'
  CpeTriv to CpeArg
in Note [CorePrep invariants], with knock on consequences.

This is groundwork for the fix to Trac #11158

3 years agoFix Trac #12797: approximateWC
Simon Peyton Jones [Wed, 2 Nov 2016 11:53:21 +0000 (11:53 +0000)] 
Fix Trac #12797: approximateWC

This patch makes approximateWC a bit more gung-ho when called
from the defaulting code.  See Note [ApproximateWC], item (1).

3 years agoUse substTyUnchecked in TcMType.new_meta_tv_x
Simon Peyton Jones [Wed, 2 Nov 2016 11:50:10 +0000 (11:50 +0000)] 
Use substTyUnchecked in TcMType.new_meta_tv_x

Sadly, one of the indirect callers of this function doesn't yet
enforce the in-scope set.  It's in the TcHsType.tc_infer_args swamp,
so I'm not going to wade in there today.

The assertion tripped when investigating Trac #12785; but this patch
does NOT fix the actual bug reported there.

3 years agoSimplify the API for TcHsType.kcHsTyVarBndrs
Simon Peyton Jones [Wed, 2 Nov 2016 11:48:51 +0000 (11:48 +0000)] 
Simplify the API for TcHsType.kcHsTyVarBndrs

Pass in a Bool rather than return a funcion!

No change in behaviour.

3 years agoGet rid of TcTyVars more assiduously
Simon Peyton Jones [Wed, 2 Nov 2016 11:42:37 +0000 (11:42 +0000)] 
Get rid of TcTyVars more assiduously

* I found a bug in 'generalize' in TcTyClsDecls.kcTyClGroup, where
  the kind variables weren't being turned into proper TyVars, so
  we got (skolem) TcTyVars in TyCons, which shouldn't happen.  Fix
  was easy.

* Similarly TcHsType.kindGeneralizeType wasn't turning the forall'd
  TcTyVars into TyVars.  To achieve this I defined TcHsTyn.zonkSigType.

* All this allowed me to remove awkward and ill-explained bit of
  footwork on DFunIds in Inst.newClsInst

This is just refactoring, but it does make the printout from
-ddump-deriv make a bit more sense by not grautuitiously cloning
type variables.  In the display I was seeing

   instance C [a_df4] where
      f x = ...a_dx5...

where actually the d_df4 and a_dx5 were the same.

3 years agoTiny refactor
Simon Peyton Jones [Tue, 1 Nov 2016 14:03:57 +0000 (14:03 +0000)] 
Tiny refactor

Swap order of calls in genInst just to make
the two cases the same

Plus some alpha-renaming

3 years agoSparc*: Prevent GHC from doing unaligned accesses
Erik de Castro Lopo [Tue, 1 Nov 2016 19:26:22 +0000 (06:26 +1100)] 
Sparc*: Prevent GHC from doing unaligned accesses

This is specifically for the C backend on Sparc64 (which has
no native backend) but is also required for Sparc when building
un-registerised.

Bug reported via Debian (patch included):

    https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=842780

Test Plan: validate

Reviewers: hvr, Phyx, bgamari, austin, simonmar

Reviewed By: Phyx

Subscribers: jrtc27, thomie

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

GHC Trac Issues: #12793

3 years agoHave static pointers work with -fno-full-laziness.
Facundo Domínguez [Fri, 28 Oct 2016 22:25:05 +0000 (19:25 -0300)] 
Have static pointers work with -fno-full-laziness.

Summary:
Before this patch, static pointers wouldn't be floated to
the top-level.

Test Plan: ./validate

Reviewers: simonpj, bgamari, austin

Subscribers: mboes, thomie

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

GHC Trac Issues: #11656

3 years agoAlign GHCi's library search order more closely with LDs
Tamar Christina [Mon, 31 Oct 2016 21:03:14 +0000 (21:03 +0000)] 
Align GHCi's library search order more closely with LDs

Summary:
Given a static library and an import library in the same folder. e.g.

```
libfoo.a
libfoo.dll.a
```

running `ghci -lfoo` we should prefer the import library `libfoo.dll.a`
over `libfoo.a` because we prefer having to just load the DLL.
And not having to do any linking.

This also more closely emulated the behaviour of LD, which has a search order of

```
libxxx.dll.a
xxx.dll.a
libxxx.a
cygxxx.dll (*)
libxxx.dll
xxx.dll
```

Test Plan: ./validate

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

Reviewed By: RyanGlScott

Subscribers: thomie, #ghc_windows_task_force

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

GHC Trac Issues: #12771

3 years agoTypos in comments
Gabor Greif [Mon, 31 Oct 2016 11:08:50 +0000 (12:08 +0100)] 
Typos in comments

3 years agoZap redundant imports
Gabor Greif [Sun, 30 Oct 2016 18:02:33 +0000 (19:02 +0100)] 
Zap redundant imports

3 years agoFix a bug in parallel GC synchronisation
Simon Marlow [Fri, 28 Oct 2016 15:30:14 +0000 (08:30 -0700)] 
Fix a bug in parallel GC synchronisation

Summary:
The problem boils down to global variables: in particular gc_threads[],
which was being modified by a subsequent GC before the previous GC had
finished with it.  The fix is to not use global variables.

This was causing setnumcapabilities001 to fail (again!).  It's an old
bug though.

Test Plan:
Ran setnumcapabilities001 in a loop for a couple of hours.  Before this
patch it had been failing after a few minutes.  Not a very scientific
test, but it's the best I have.

Reviewers: bgamari, austin, fryguybob, niteria, erikd

Subscribers: thomie

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

3 years agoMinor refactoring in stg_unpackClosurezh
Ömer Sinan Ağacan [Fri, 28 Oct 2016 19:39:11 +0000 (15:39 -0400)] 
Minor refactoring in stg_unpackClosurezh

- Reuse `clos` local variable
- Rename labels for clarity

3 years agoDocument unpackClosure# primop
Ömer Sinan Ağacan [Fri, 28 Oct 2016 19:36:55 +0000 (15:36 -0400)] 
Document unpackClosure# primop

3 years agoAdd test for #12732
Ryan Scott [Fri, 28 Oct 2016 21:00:29 +0000 (17:00 -0400)] 
Add test for #12732

3 years agoMake it possible to use +RTS -qn without -N
Simon Marlow [Fri, 28 Oct 2016 15:34:44 +0000 (16:34 +0100)] 
Make it possible to use +RTS -qn without -N

It's entirely reasonable to set +RTS -qn without setting -N, because the
program might later call setNumCapabilities.  If we disallow it, there's
no way to use -qn on programs that use setNumCapabilities.

3 years agoClarify comments on kinds (Trac #12536)
Simon Peyton Jones [Fri, 28 Oct 2016 11:08:49 +0000 (12:08 +0100)] 
Clarify comments on kinds (Trac #12536)

- Remove misleading comments from TyCoRep.
- Remove 'check_lifted' calls (which were no-ops) from TcValidity.

3 years agoMinor doc addition as requested in #12774.
Edward Z. Yang [Fri, 28 Oct 2016 01:09:40 +0000 (18:09 -0700)] 
Minor doc addition as requested in #12774.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
3 years agoRevert "rts/linker: Move loadArchive to new source file"
Matthew Pickering [Thu, 27 Oct 2016 08:47:55 +0000 (09:47 +0100)] 
Revert "rts/linker: Move loadArchive to new source file"

This reverts commit 488a9ed3440fe882ae043ba7f44fed4e84e679ce.

3 years agoFix typo in comment
Simon Peyton Jones [Thu, 27 Oct 2016 07:33:06 +0000 (08:33 +0100)] 
Fix typo in comment

3 years agoAllow levity-polymorpic arrows
Simon Peyton Jones [Wed, 26 Oct 2016 14:34:56 +0000 (15:34 +0100)] 
Allow levity-polymorpic arrows

This cures Trac #12668 (and cures the Lint errors you get from
Trac #12718).

The idea is explained in Note [Levity polymorphism], in Kind.hs

3 years agoCollect coercion variables, not type variables
Simon Peyton Jones [Wed, 26 Oct 2016 13:58:59 +0000 (14:58 +0100)] 
Collect coercion variables, not type variables

...when tracking which constraints are used.

Previously we were gathering type variables too, which meant that the
ics_need field was (stupidly) non-empty, which meant that we kept hold
of solved implications for no purpose.  Better just to get rid of them,
which setImplicationStatus is all ste up to to do.

No change in behaviour; a bit more efficient.