2 years agoTypos in bang patterns user manual [skip ci]
Ömer Sinan Ağacan [Mon, 10 Apr 2017 15:38:31 +0000 (18:38 +0300)] 
Typos in bang patterns user manual [skip ci]

2 years agoAdd a second regression test for #13536
Joachim Breitner [Mon, 10 Apr 2017 15:21:52 +0000 (11:21 -0400)] 
Add a second regression test for #13536

which counts allocations instead of observing recomputation directly.

2 years agoStgCse: Do not re-use trivial case scrutinees
Joachim Breitner [Sun, 9 Apr 2017 23:40:02 +0000 (19:40 -0400)] 
StgCse: Do not re-use trivial case scrutinees

as they might be marked as one-shot, and suddenly we’d evaluate them
multiple times. This came up in #13536 (test cases included).

The solution was layed out by SPJ in ticket:13536#comment:12.

Differential Revision:

2 years agoAdd a Note [Call Arity and Join Points]
Joachim Breitner [Sun, 9 Apr 2017 17:41:40 +0000 (13:41 -0400)] 
Add a Note [Call Arity and Join Points]

as discussed in #13479.

2 years agoParenthesize type/data families correctly for -ddump-splices
Alan Zimmerman [Sun, 9 Apr 2017 19:06:06 +0000 (21:06 +0200)] 
Parenthesize type/data families correctly for -ddump-splices

Fix a regression in the pretty-printed code for -ddump-splices, which regressed
since 8.0.

Closes trac issue #13550

2 years agocross-build 'unlit' and 'hp2ps' for stage2 install
Sergei Trofimovich [Sat, 8 Apr 2017 09:02:34 +0000 (10:02 +0100)] 
cross-build 'unlit' and 'hp2ps' for stage2 install

In navive build case it does not matter much if we build
'unlit' and 'hp2ps' tools with ghc-stage0 or ghc-stage1:
both GHCs are native compilers and both tools are written
in C (have no haskell code).

But in cross-case the difference is substantial:
In Stag1Only=YES case we need to install native tools built
by ghc-stage0/${host}-cc.
In Stag1Only=NO  case we need to install cross-built tools
built by ghc-stage1/${target}-cc.

Before this change GHC did not have a rule to build cross-built
'unlit' and 'hp2ps'.

The change adds cross-built 'unlit' and 'hp2ps' as 'dist-install'

'inplace/lib/bin/unlit.bin' target is unchanged and still contains
native binary.

As a result this change allows cross-building and packaging whole
GHC for target platform!

Signed-off-by: Sergei Trofimovich <>
2 years agofix 'make install' for cross-stage2
Sergei Trofimovich [Fri, 7 Apr 2017 09:08:58 +0000 (10:08 +0100)] 
fix 'make install' for cross-stage2

When cross-built GHC is being installed one of
latest steps is to register installed libraries
with 'ghc-pkg'.

GHC uses freshly installed 'ghc-pkg' and 'ghc-stage2'
for that.

Tested as:
    ./configure --target=aarch64-unknown-linux-gnu
    make install DESTDIR=$(pwd)/__s2 STRIP_CMD=:

Before the change install failed on ghc-pkg execution phase:

    ".../ghc-cross/__s2/usr/local/lib/ghc-8.3.20170406/bin/ghc-pkg" \
        --force \
        --global-package-db \
        ".../ghc-cross/__s2/usr/local/lib/ghc-8.3.20170406/package.conf.d" \
        update rts/dist/package.conf.install
    /bin/sh: .../ghc-cross/__s2/usr/local/lib/ghc-8.3.20170406/bin/ghc-pkg: \
        No such file or directory

To avoid breakage we use 'ghc' and 'ghc-pkg' built by stage0.

Signed-off-by: Sergei Trofimovich <>
Test Plan: run 'make install' on stage2 crosscompiler

Reviewers: rwbarton, austin, bgamari

Subscribers: thomie, snowleopard

Differential Revision:

2 years agoDo Note [Improving seq] always
Simon Peyton Jones [Fri, 7 Apr 2017 15:19:56 +0000 (16:19 +0100)] 
Do Note [Improving seq] always

This patch fixes Trac #13468, and at the same time makes the
code simpler and more uniform.  In particular, I've eliminated
the awkward conflict between the old built-in rule for seq
(which elimianted a cast), and the desire to make case scrutinse
a data type by doing type-family reduction (which adds a cast).


2 years agoadd $(CrossCompilePrefix) to 'runghc' and 'ghci'
Sergei Trofimovich [Thu, 6 Apr 2017 21:48:13 +0000 (22:48 +0100)] 
add $(CrossCompilePrefix) to 'runghc' and 'ghci'

When Stage1Only=YES install mode is used one of rare tools
that lack $(CrossCompilePrefix) prefix are 'runghc' and 'ghci'.

This causes file collisions when multiple GHC crosscompilers
are installed in system.

Signed-off-by: Sergei Trofimovich <>
2 years agoMore changes to fix a space leak in the simplifier (#13426)
Reid Barton [Thu, 6 Apr 2017 21:44:08 +0000 (17:44 -0400)] 
More changes to fix a space leak in the simplifier (#13426)

Part of e13419c55 was accidentally lost during a rebase. This commit
adds the missing change, along with some more improvements
regarding where we do and don't use `seqType`.

Also include a comment about where the space leak showed up
and a Note explaining the strategy being used here.

Test Plan: harbormaster, plus local testing on DynFlags

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

2 years agotestsuite: Update expected performance numbers on 32-bit Linux
Ben Gamari [Thu, 6 Apr 2017 21:22:28 +0000 (17:22 -0400)] 
testsuite: Update expected performance numbers on 32-bit Linux

The Harbormaster build seems to slightly disagree with my local build machine on
a few of these. In the case of `haddock.compiler` the difference is nearly an
order of magnitude. Odd.

2 years agobase: Run num009 with -msse2 on i386
Ben Gamari [Thu, 6 Apr 2017 21:14:47 +0000 (17:14 -0400)] 
base: Run num009 with -msse2 on i386

x87's transcendental instructions are terribly imprecise and fail this test.
Moreover, we really ouch to enable -mse2 on i386 by default as it is nearly
universally supported at this point. See #13540.

2 years agoAdd regression test for #13538
Ryan Scott [Thu, 6 Apr 2017 20:42:39 +0000 (16:42 -0400)] 
Add regression test for #13538

Commit 2b64e926a628fb2a3710b0360123ea73331166fe (#13135) ended
up fixing #13538 as well. Let's add a regression test so that it stays

Test Plan: make test TEST=T13538

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13538

Differential Revision:

2 years agoEnable lint checking of levity polymorphic coercions
Ben Gamari [Thu, 6 Apr 2017 20:38:45 +0000 (16:38 -0400)] 
Enable lint checking of levity polymorphic coercions

This reverts commit 03c7dd0941fb4974be54026ef3e4bb97451c3b1f and fixes
the coercions.

2 years agoFix name of Note
Ben Gamari [Thu, 6 Apr 2017 19:58:08 +0000 (15:58 -0400)] 
Fix name of Note

2 years agoBe less aggressive about fragile-context warrnings
Simon Peyton Jones [Thu, 6 Apr 2017 11:27:43 +0000 (12:27 +0100)] 
Be less aggressive about fragile-context warrnings

In the implementation of WarnSimplifiableClassConstraints, be
less aggressive about reporting a problem. We were complaining
about a "fragile" case that in fact was not fragile.

See Note [Simplifiable given constraints] in TcValidity.

This fixes Trac #13526.

2 years agoComments only
Simon Peyton Jones [Thu, 6 Apr 2017 07:26:18 +0000 (08:26 +0100)] 
Comments only

2 years agoYet another attempt at inferring the right quantification
Simon Peyton Jones [Wed, 5 Apr 2017 12:46:03 +0000 (13:46 +0100)] 
Yet another attempt at inferring the right quantification

TcSimplify.decideQuantification is truly a tricky function!
Trac #13509 showed that we were being over-eager with defaulting
of runtime-rep variables (levity polymorphism), which meant that
a program was wrongly rejected, and with a very odd error message
(c.f. Trac #13530)

I spent an unreasonably long time figuring out how to fix this
in a decent way, and ended up with a major refactoring of
decideQuantification, with a kock-on effect in simplifyInfer.

It is at least a bit more comprehensible now; but I still
can't say I like it.

2 years agoComments and eta expand only
Simon Peyton Jones [Wed, 5 Apr 2017 12:45:30 +0000 (13:45 +0100)] 
Comments and eta expand only

2 years agoAdd a missing addDeferredBinding
Simon Peyton Jones [Wed, 5 Apr 2017 12:39:51 +0000 (13:39 +0100)] 
Add a missing addDeferredBinding

I'd forgotten to add deferred bindings for user type
errors.  Fixes Trac #13487.

2 years agoDon't report fundep wanted/wanted errors
Simon Peyton Jones [Wed, 5 Apr 2017 12:37:28 +0000 (13:37 +0100)] 
Don't report fundep wanted/wanted errors

This makes GHC drop derived FunDep errors when they
are come from wanted/wanted interactions.  Much along
the lines of "don't rewrite wanteds with wanteds".

See TcRnTypes Note [Dropping derived constraints]
and the new code in isDroppableDerivedLoc.

Fixes Trac #13506.

2 years agoAdd comments on DmdAnal space leak fix
Simon Peyton Jones [Mon, 3 Apr 2017 07:48:28 +0000 (08:48 +0100)] 
Add comments on DmdAnal space leak fix

2 years agoFix markup
Gabor Greif [Thu, 6 Apr 2017 10:52:29 +0000 (12:52 +0200)] 
Fix markup

2 years agoUpdate .mailmap [skip ci]
Erik de Castro Lopo [Thu, 6 Apr 2017 11:09:55 +0000 (21:09 +1000)] 
Update .mailmap [skip ci]

2 years removed stray HaveLibDL assignment
Sergei Trofimovich [Thu, 6 Apr 2017 08:57:36 +0000 (09:57 +0100)] removed stray HaveLibDL assignment

HaveLibDL substitution was removed from in 2014
with 9692393d7ba91a091c1e61b6754d79ad17c5f193 commit.

Noticed when scrolled through '' which contained
unsunstituted assignment after './configure' run:
    HaveLibDL = @HaveLibDL@

Signed-off-by: Sergei Trofimovich <>
2 years agoavoid $(CrossCompilerPrefix) for stage2 install
Sergei Trofimovich [Wed, 5 Apr 2017 21:31:37 +0000 (22:31 +0100)] 
avoid $(CrossCompilerPrefix) for stage2 install

Suppose we are crossbuilding ghc (when ghc-stage2
is a normal compiler for $target):

For this case 'make install' should install unprefixed
stage2 'ghc' and not '$(CorssCompilePrefix)-ghc'.

That way cross-built ghc is installable and
usable on target as if it would be built natively
on a target.

Signed-off-by: Sergei Trofimovich <>
2 years remove phase=0 hack for CrossCompilePrefix
Sergei Trofimovich [Thu, 6 Apr 2017 07:55:56 +0000 (08:55 +0100)] remove phase=0 hack for CrossCompilePrefix

$(CrossCompilePrefix) is used only in 'make install'
target filenames in $(DESTDIR). None of inplace (or boot)
files contain $(CrossCompilePrefix).

Thus we don't need to worry about phases.

Signed-off-by: Sergei Trofimovich <>
2 years agoUse non-canocalized triple as cross-compiler prefix
Sergei Trofimovich [Thu, 6 Apr 2017 07:51:22 +0000 (08:51 +0100)] 
Use non-canocalized triple as cross-compiler prefix

I've noticed the problem when tried to install
cross-compiler using following configuration:

    $ ./configure --target=s390x-unknown-linux-gnu
    make install Stage1Only=YES

Instead of expected tool prefix
Result was:

It's problematic as installed binaries appear in
unpredictable location.

The problem is caused by use of ${target} autoconf variable.
${target} contains a canocalized triplet.

Luckily we already have non-canonucalized target triplet
in ${TargetPlatformFull} variable. The change uses that

Signed-off-by: Sergei Trofimovich <>
2 years agoRevert "Enable new warning for fragile/incorrect CPP #if usage"
Ben Gamari [Wed, 5 Apr 2017 16:01:12 +0000 (12:01 -0400)] 
Revert "Enable new warning for fragile/incorrect CPP #if usage"

This is causing too much platform dependent breakage at the moment. We
will need a more rigorous testing strategy before this can be
merged again.

This reverts commit 7e340c2bbf4a56959bd1e95cdd1cfdb2b7e537c2.

2 years agotest for HAVE_CLOCK_GETTIME definedness
Gabor Greif [Wed, 5 Apr 2017 15:37:53 +0000 (17:37 +0200)] 
test for HAVE_CLOCK_GETTIME definedness

2 years agoTypos in comments [ci skip]
Gabor Greif [Tue, 4 Apr 2017 08:49:51 +0000 (10:49 +0200)] 
Typos in comments [ci skip]

2 years agobase: Mark unfold as deprecated
Ben Gamari [Wed, 5 Apr 2017 01:48:49 +0000 (21:48 -0400)] 
base: Mark unfold as deprecated

Test Plan: Read it

Reviewers: austin, hvr, RyanGlScott

Reviewed By: RyanGlScott

Subscribers: rwbarton, thomie, ekmett

Differential Revision:

2 years agoAdd Alternative instance for ZipList (fix #13520).
Edvard Hübinette [Wed, 5 Apr 2017 01:48:37 +0000 (21:48 -0400)] 
Add Alternative instance for ZipList (fix #13520).

Reviewers: austin, hvr, bgamari, RyanGlScott

Reviewed By: RyanGlScott

Subscribers: adamse, RyanGlScott, rwbarton, thomie

Differential Revision:

2 years agoReplace Digraph's Node type synonym with a data type
Matthew Pickering [Wed, 5 Apr 2017 01:47:29 +0000 (21:47 -0400)] 
Replace Digraph's Node type synonym with a data type

This refactoring makes it more obvious when we are constructing
a Node for the digraph rather than a less useful 3-tuple.

Reviewers: austin, goldfire, bgamari, simonmar, dfeuer

Reviewed By: dfeuer

Subscribers: rwbarton, thomie

Differential Revision:

2 years agovalidate: Clean GMP trees
Ben Gamari [Wed, 5 Apr 2017 01:47:05 +0000 (21:47 -0400)] 
validate: Clean GMP trees

For reasons unknown `validate` passed `NO_CLEAN_GMP=YES` to
`maintainer-clean`, leaving a stale `gmp.h` which causes the build to
fail in the event that the uses a tree for validating for two different
target platforms. This is quite unexpected, don't do it.

Reviewers: hvr, austin, rwbarton, dfeuer

Reviewed By: dfeuer

Subscribers: thomie

Differential Revision:

2 years agoAdd regression test for #7944
Ryan Scott [Wed, 5 Apr 2017 01:46:55 +0000 (21:46 -0400)] 
Add regression test for #7944

Commit b8b3e30a6eedf9f213b8a718573c4827cfa230ba happened to fix the bug
reported in #7944. Let's add a regression test so that it stays that

Fixes #7944.

Test Plan: make test TEST=T7944

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision:

2 years agoUse strict types and folds in CoreStats
Reid Barton [Wed, 5 Apr 2017 01:46:45 +0000 (21:46 -0400)] 
Use strict types and folds in CoreStats

This only has a significant effect when compiling with -v
(or -dshow-passes), but still there's no reason not to do it.

Test Plan: harbormaster

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

2 years agobase: Add test for #8684
Ben Gamari [Wed, 5 Apr 2017 00:48:35 +0000 (20:48 -0400)] 
base: Add test for #8684

Reviewers: austin, hvr

Subscribers: rwbarton, thomie

Differential Revision:

2 years agobase: Add test for #13525
Ben Gamari [Wed, 5 Apr 2017 00:48:20 +0000 (20:48 -0400)] 
base: Add test for #13525

Reviewers: austin, hvr

Subscribers: rwbarton, thomie

Differential Revision:

2 years agotestsuite: Add test for #13524
Ben Gamari [Wed, 5 Apr 2017 00:47:20 +0000 (20:47 -0400)] 
testsuite: Add test for #13524

Reviewers: austin

Subscribers: rwbarton, thomie

Differential Revision:

2 years agotestsuite: Bump up timeout multiplier on T11195
Ben Gamari [Tue, 4 Apr 2017 22:04:07 +0000 (18:04 -0400)] 
testsuite: Bump up timeout multiplier on T11195

This has been failing a bit too often (on CI machines under load).

2 years agorts: Fix lingering #ifs
Ben Gamari [Tue, 4 Apr 2017 20:15:32 +0000 (16:15 -0400)] 
rts: Fix lingering #ifs

These were missed in D3278.

2 years agoEnable new warning for fragile/incorrect CPP #if usage
Erik de Castro Lopo [Tue, 4 Apr 2017 19:53:46 +0000 (05:53 +1000)] 
Enable new warning for fragile/incorrect CPP #if usage

The C code in the RTS now gets built with `-Wundef` and the Haskell code
(stages 1 and 2 only) with `-Wcpp-undef`. We now get warnings whereever
`#if` is used on undefined identifiers.

Test Plan: Validate on Linux and Windows

Reviewers: austin, angerman, simonmar, bgamari, Phyx

Reviewed By: bgamari

Subscribers: thomie, snowleopard

Differential Revision:

2 years agoHACKING: Update for Phabricator patch workflow
Ben Gamari [Tue, 4 Apr 2017 16:07:25 +0000 (12:07 -0400)] 
HACKING: Update for Phabricator patch workflow

2 years agoRevert "Make raiseIO# produce topRes"
David Feuer [Tue, 4 Apr 2017 02:25:55 +0000 (22:25 -0400)] 
Revert "Make raiseIO# produce topRes"

This reverts commit da4687f63ffe5a6162e3d7856aa53de048dd0f42.

It's not entirely trivial to clean up the dead code this patch
introduced. In particular, when we see

case raiseIO# m s of
  s' -> e

we want to know that `e` is dead. For scrutinees that are properly
bottom (which we don't want to consider `raiseIO# m s` to be, this
is handled by rewriting `bot` to `case bot of {}`. But if we do
that for `raiseIO#`, we end up with

case raiseIO# m s of {}

which looks a lot like bottom and could confuse demand analysis.
I think we need to wait with this change until we have a more
complete story.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision:

2 years agocompact: Clarify mutability restriction
Ben Gamari [Mon, 3 Apr 2017 23:27:59 +0000 (19:27 -0400)] 
compact: Clarify mutability restriction

Fixes #13508.

[skip ci]

Test Plan: Read it

Reviewers: austin

Subscribers: rwbarton, thomie

Differential Revision:

2 years agoBump Win32 submodule
Ben Gamari [Mon, 3 Apr 2017 23:00:33 +0000 (19:00 -0400)] 
Bump Win32 submodule

Fixes #13514.

2 years agohp2ps: install shell wrapper
Sergei Trofimovich [Mon, 3 Apr 2017 07:55:04 +0000 (08:55 +0100)] 
hp2ps: install shell wrapper

Before this change we installed hp2ps both
to inplace/bin/ and ${prefix}/bin/

In both cases we added $(CrossCompilePrefix) as
a binary prefix. It's incorrect for inplace install
as none of inplace binaries are prefixed.

The change it to track 'hp2ps' as unprefixed binary.
$(CrossCompilePrefix) prefix is only added to the
installed shell wrapper.

Now 'hp2ps' is handled in a similar way to 'hpc' and

Signed-off-by: Sergei Trofimovich <>
2 years agoFix validate.
Edward Z. Yang [Mon, 3 Apr 2017 09:21:09 +0000 (02:21 -0700)] 
Fix validate.

Signed-off-by: Edward Z. Yang <>
2 years agotestsuite: Classify missing expected perf numbers as merely warnings
Ben Gamari [Sun, 2 Apr 2017 21:20:34 +0000 (17:20 -0400)] 
testsuite: Classify missing expected perf numbers as merely warnings

Previously these were considered to be framework failures, meaning that validate
would fail. For better or worse, Windows lacks a good number of metrics and I
don't see this changing any time soon. Let's consider these to be non-fatal.

2 years agoVarious testsuite fixes for 32-bit Windows
Ben Gamari [Sun, 2 Apr 2017 21:10:48 +0000 (17:10 -0400)] 
Various testsuite fixes for 32-bit Windows

2 years agorts: Make out-of-memory errors more consistent
Ben Gamari [Sun, 2 Apr 2017 23:15:45 +0000 (19:15 -0400)] 
rts: Make out-of-memory errors more consistent

This will make it a bit easier to maintain consistent output in the testsuite.

2 years agoarray: Clear up inconsistency in T9220 output
Ben Gamari [Sun, 2 Apr 2017 17:04:26 +0000 (13:04 -0400)] 
array: Clear up inconsistency in T9220 output

ghc-8.2 and master disagreed on the order of the instances. Normalise this
difference away.

Updates array submodule.

2 years agoCorrectly handle wired in unit IDs in -instantiated-with
Edward Z. Yang [Sun, 26 Mar 2017 21:06:12 +0000 (14:06 -0700)] 
Correctly handle wired in unit IDs in -instantiated-with

To handle wired in packages, we must rewrite all occurrences
of unit ids like base- to base.  However, I forgot
to do this on unit ids that occurred in unit identifiers
passed via -instantiated-with.  This patch handles that case,
plus a test.

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

Reviewers: bgamari, austin

Subscribers: rwbarton, thomie

Differential Revision:

2 years agoBetter test coverage for module reexports in signatures.
Edward Z. Yang [Tue, 28 Mar 2017 17:21:15 +0000 (10:21 -0700)] 
Better test coverage for module reexports in signatures.

Signed-off-by: Edward Z. Yang <>
2 years agoExtra docs on tcg_imports.
Edward Z. Yang [Tue, 28 Mar 2017 17:20:44 +0000 (10:20 -0700)] 
Extra docs on tcg_imports.

Signed-off-by: Edward Z. Yang <>
2 years agoExtra docs on exports_from_avail.
Edward Z. Yang [Tue, 28 Mar 2017 17:20:19 +0000 (10:20 -0700)] 
Extra docs on exports_from_avail.

Signed-off-by: Edward Z. Yang <>
2 years agoAdd more documentation on mergeSignatures.
Edward Z. Yang [Tue, 28 Mar 2017 03:00:53 +0000 (20:00 -0700)] 
Add more documentation on mergeSignatures.

Signed-off-by: Edward Z. Yang <>
2 years agomk/ defines STAGE1_GHC, not GHC_STAGE1.
Edward Z. Yang [Sun, 26 Mar 2017 21:40:29 +0000 (14:40 -0700)] 
mk/ defines STAGE1_GHC, not GHC_STAGE1.

Signed-off-by: Edward Z. Yang <>
2 years agoFix recompilation avoidance bug for implementor of hsig.
Edward Z. Yang [Sun, 26 Mar 2017 05:50:55 +0000 (22:50 -0700)] 
Fix recompilation avoidance bug for implementor of hsig.

I observed a bug where if I modified the module which implemented
an hsig in another package, GHC would not recompile the signature
in this situation.

The root cause was that we were conflating modules from user
imports, and "system" module dependencies (from signature
merging and instantiation.) So this patch handles them separately.

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

Reviewers: simonpj, bgamari, austin

Subscribers: rwbarton, thomie, snowleopard

Differential Revision:

2 years agoMinor comment updates on CSE.
Edward Z. Yang [Thu, 23 Mar 2017 02:22:02 +0000 (19:22 -0700)] 
Minor comment updates on CSE.

Signed-off-by: Edward Z. Yang <>
2 years agoDerive the definition of null
David Feuer [Sun, 2 Apr 2017 20:20:20 +0000 (16:20 -0400)] 
Derive the definition of null

We can sometimes produce much better code by deriving the
definition of `null` rather than using the default. For example,

    data SnocList a = Lin | Snoc (SnocList a) a

the default definition of `null` will walk the whole list, but of
course we can stop as soon as we see `Snoc`. Similarly, if a
constructor contains some other `Foldable` type, we want to use its
`null` rather than folding over the structure.

Partially fixes Trac #13280

Reviewers: austin, bgamari, RyanGlScott

Reviewed By: RyanGlScott

Subscribers: rwbarton, thomie

Differential Revision:

2 years add aarch64 to list of registerised
Sergei Trofimovich [Sun, 2 Apr 2017 19:56:40 +0000 (20:56 +0100)] add aarch64 to list of registerised

Similar to 'arm' 'aarch64' has working llvm codegen,
no need to fallback to unregisterised buld by default.

Signed-off-by: Sergei Trofimovich <>
2 years fix NCG support in --target=
Sergei Trofimovich [Sun, 2 Apr 2017 18:38:23 +0000 (19:38 +0100)] fix NCG support in --target=

Before this change attempt to build a crosscompiler
on registerised platform (--host=x86_64-pc-linux-gnu)
targeting UNREG platform failed:
    $ ./configure --target=ia64-unknown-linux-gnu

  utils/genapply/../../includes/stg/MachRegs.h:608:2: error:
     #error Cannot find platform to give register info for

The change is to check --target= for NCG availability,
not --host=.

Signed-off-by: Sergei Trofimovich <>
2 years agoUpdate containers submodule to official
David Feuer [Sun, 2 Apr 2017 18:39:15 +0000 (14:39 -0400)] 
Update containers submodule to official

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision:

2 years agoAdd a perf test for deriving null
David Feuer [Sun, 2 Apr 2017 16:44:07 +0000 (12:44 -0400)] 
Add a perf test for deriving null

Deriving null even helps for a simple list-like type,
presumably because we don't perform the static argument
transformation. Adding this test before the null deriving
patch should give a proper baseline.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision:

2 years agotestsuite: Fix GhciCurDir test
Ben Gamari [Sun, 2 Apr 2017 16:05:09 +0000 (12:05 -0400)] 
testsuite: Fix GhciCurDir test

This was horribly, horribly wrong.

2 years ago:cd affects the iserv process too
Simon Marlow [Sun, 2 Apr 2017 14:43:32 +0000 (10:43 -0400)] 
:cd affects the iserv process too

Test Plan: validate

Reviewers: angerman, austin, bgamari, erikd

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision:

2 years agoReport heap overflow in the same way as stack overflow
Simon Marlow [Sat, 1 Apr 2017 23:52:40 +0000 (19:52 -0400)] 
Report heap overflow in the same way as stack overflow

Now that we throw an exception for heap overflow, we should only print
the heap overflow message in the main thread when the HeapOverflow
exception is caught, rather than as a side effect in the GC.

Stack overflows were already done this way, I just made heap overflow
consistent with stack overflow, and did some related cleanup.

Fixes broken T2592(profasm) which was reporting the heap overflow
message twice (you would only notice when building with profiling
libs enabled).

Test Plan: validate

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

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision:

2 years agoFastMutInt: fix Int and Ptr sizes when crosscompiling
Sergei Trofimovich [Sun, 2 Apr 2017 15:12:18 +0000 (16:12 +0100)] 
FastMutInt: fix Int and Ptr sizes when crosscompiling

Similar to

target platform. These values are usually
not correct when stage1 is built.

It means the code

  newFastMutInt = IO $ \s ->
   case newByteArray# size s of { (# s, arr #) ->
   (# s, FastMutInt arr #) }
   where !(I# size) = SIZEOF_HSINT
would try to allocate only 4 bytes on 64-bit-host
targeting 32-bit system.

It does not matter in practice as newByteArray#
implementation rounds up passed value to host's
word size. But one day it might not.

To prevent this class of problems in compiler/
directory 'MachDeps.h' contents is hidden when
ghc-stage1 (-DSTAGE=1) is built.

Signed-off-by: Sergei Trofimovich <>
Reviewers: austin, rwbarton, simonmar, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

2 years agocompiler/ fix GhcWithInterpreter=NO build failure
Sergei Trofimovich [Sun, 2 Apr 2017 13:01:19 +0000 (14:01 +0100)] 
compiler/ fix GhcWithInterpreter=NO build failure

When GhcWithInterpreter=NO is set in mk/ build
fails as:

    $ inplace/bin/dll-split compiler/stage2/build/.depend-v-dyn.haskell "DynFlags" ...
    Reachable modules from DynFlags out of date
    Please fix compiler/, or building DLLs on Windows may break (#7780)
    Extra modules: ByteCodeTypes InteractiveEvalTypes

Signed-off-by: Sergei Trofimovich <>
2 years agoStamp out space leaks from demand analysis
Reid Barton [Sat, 1 Apr 2017 15:51:59 +0000 (11:51 -0400)] 
Stamp out space leaks from demand analysis

This reduces peak memory usage by ~30% on my test case (DynFlags),
and (probably as a result of reduced GC work) decreases compilation
time by a few percent as well.

Also fix a bug in seqStrDmd so that demeand info is fully evaluated.

Reviewers: simonpj, austin, bgamari

Reviewed By: bgamari

Subscribers: dfeuer, thomie

Differential Revision:

2 years agoOptimise common cases of GHC.setProgramDynFlags
Simon Marlow [Sat, 1 Apr 2017 15:51:43 +0000 (11:51 -0400)] 
Optimise common cases of GHC.setProgramDynFlags

* If the package flags haven't changed, don't do initPackages (which
  might take multiple seconds in extreme cases)

* Provide a way to change the log_action without invalidating the
  summary cache.

Test Plan: validate

Reviewers: niteria, bgamari, austin, erikd, ezyang

Reviewed By: bgamari

Subscribers: mpickering, rwbarton, thomie

Differential Revision:

2 years agoDon't derive showList
David Feuer [Sat, 1 Apr 2017 15:12:31 +0000 (11:12 -0400)] 
Don't derive showList

There's no obvious reason to derive the definition of `showList`,
manually inlining the default definition. Let's just use
the default definition in the usual manner.

Garbage collect a few unused `RdrNames` from `PrelNames`:
`showList`, `showList__`, and `/=`.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: RyanGlScott, rwbarton, thomie

Differential Revision:

2 years agotestsuite: Add regression test for #13474
Ben Gamari [Sat, 1 Apr 2017 14:59:53 +0000 (10:59 -0400)] 
testsuite: Add regression test for #13474

2 years agorts: print incorrect prev_what_next
Sergei Trofimovich [Sat, 1 Apr 2017 10:58:55 +0000 (11:58 +0100)] 
rts: print incorrect prev_what_next

Moritz Angermann reports mysterious rts crash:
  A: link: internal error: schedule: invalid what_next field
  A:     (GHC version 8.3.20170321 for arm_none_linux_android)

This change prints actual prev_what_next value.

Signed-off-by: Sergei Trofimovich <>
2 years agoUNREG: ignore -fllvm (Trac #13495)
Sergei Trofimovich [Sat, 1 Apr 2017 09:35:52 +0000 (10:35 +0100)] 
UNREG: ignore -fllvm (Trac #13495)

Unregisterised GHC can only use C as a target backend
(option used to be called -fvia-C). -fasm option was
ignored with a warhing, but not -fllvm.

jms noticed the failure when tried to use quick-cross
build flavour. quick-cross enables -fllvm in makefile.

  "inplace/bin/ghc-stage1" ... -fllvm
  ghc-stage1: panic! (the 'impossible' happened)
    (GHC version 8.0.2 for powerpc-unknown-linux):
          LlvmCodeGen.Ppr: Cross compiling without valid target info.

This change ignores -fllvm as well.

Signed-off-by: Sergei Trofimovich <>
2 years agoRemove Core Lint pass on occurrence analysis output (#13220)
Reid Barton [Sat, 1 Apr 2017 02:48:14 +0000 (22:48 -0400)] 
Remove Core Lint pass on occurrence analysis output (#13220)

It was expensive, as the simplifier runs for many iterations,
and probably not very useful.

Test Plan: harbormaster

Reviewers: austin, bgamari, dfeuer

Reviewed By: dfeuer

Subscribers: dfeuer, thomie

Differential Revision:

2 years agoaskCc should be using the linker, not the compiler
Simon Marlow [Sat, 1 Apr 2017 02:47:47 +0000 (22:47 -0400)] 
askCc should be using the linker, not the compiler

When GHCi tries to find a shared lib, it calls "gcc --print-file-name"
to ask gcc where to find it.  But since we're looking for libraries,
we're really using the linker here, not the C compiler, so we should be
respecting the values of -pgml and -optl rather than -pgmc and -optc.

Test Plan: validate

Reviewers: bgamari, niteria, austin, hvr, erikd

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision:

2 years agotestsuite: Update Windows allocations for T12234
Ben Gamari [Sat, 1 Apr 2017 02:32:21 +0000 (22:32 -0400)] 
testsuite: Update Windows allocations for T12234

2 years agoFix space leaks in simplifier (#13426)
Reid Barton [Fri, 31 Mar 2017 15:37:38 +0000 (11:37 -0400)] 
Fix space leaks in simplifier (#13426)

The Join points commit (8d5cf8bf) introduced a space leak
somewhere in the simplifier. The extra strictness added in this commit
fixes the leak. Unfortunately I don't really understand the details.

Unfortunately, the extra strictness appears to result in more overall
allocations in some cases, even while the peak heap size decreases in others.

Test Plan: harbormaster

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

2 years agoClean up coreView/tcView.
Ben Gamari [Mon, 27 Mar 2017 17:17:00 +0000 (13:17 -0400)] 
Clean up coreView/tcView.

In Core, Constraint should be considered fully equal to
TYPE LiftedRep, in all ways. Accordingly, coreView should
unwrap Constraint to become TYPE LiftedRep. Of course, this
would be a disaster in the type checker.

So, where previously we used coreView in both the type checker
and in Core, we now have coreView and tcView, which differ only
in their treatment of Constraint.

Historical note: once upon a past, we had tcView distinct from
coreView. Back then, it was because newtypes were unwrapped in
Core but not in the type checker. The distinction is back, but
for a different reason than before.

This had a few knock-on effects:

 * The Typeable solver must explicitly handle Constraint to ensure
   that we produce the correct evidence.

 * TypeMap now respects the Constraint/Type distinction

Finished by: bgamari

Test Plan: ./validate

Reviewers: simonpj, austin, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, thomie

Differential Revision:

2 years agoRefactor simplExpr (Type ty)
Simon Peyton Jones [Fri, 31 Mar 2017 16:48:10 +0000 (17:48 +0100)] 
Refactor simplExpr (Type ty)

This small refactoring, provoked by comment:18 on Trac #13426,
makes it so that simplExprF never gets a (Type ty) expression to
simplify, which in turn means that calls to exprType on its argument
will always succeed.

No change in behaviour.

2 years agoDisable bogus lint checks about levity polimorphic coerions
Joachim Breitner [Fri, 31 Mar 2017 13:47:06 +0000 (09:47 -0400)] 
Disable bogus lint checks about levity polimorphic coerions

These checks, introduced in cea7141851ce653cb20207da3591d09e73fa396d
hugely inflated build logs, which incapitated

According to Richard, the checks are useless and wrong, and that Ben
plans to investigate.

Until that happens, I remove them from the code.

2 years agoDeriving for phantom and empty types
David Feuer [Thu, 30 Mar 2017 17:30:52 +0000 (13:30 -0400)] 
Deriving for phantom and empty types

Make `Functor`, `Foldable`, and `Traversable` take advantage
of the case where the type parameter is phantom. In this case,

* `fmap _ = coerce`
* `foldMap _ _ = mempty`
* `traverse _ x = pure (coerce x)`

For the sake of consistency and especially simplicity, make other types
with no data constructors behave the same:

* `fmap _ x = case x of`
* `foldMap _ _ = mempty`
* `traverse _ x = pure (case x of)`

Similarly, for `Generic`,

* `to x = case x of`
* `from x = case x of`

Give all derived methods for types without constructors appropriate
arities. For example,

    compare _ _ = error ...

rather than

    compare = error ...

Fixes #13117 and #13328

Reviewers: austin, bgamari, RyanGlScott

Reviewed By: RyanGlScott

Subscribers: ekmett, RyanGlScott, rwbarton, thomie

Differential Revision:

2 years agoTypos in comments [ci skip]
Gabor Greif [Wed, 29 Mar 2017 13:34:32 +0000 (15:34 +0200)] 
Typos in comments [ci skip]

2 years agounique: fix UNIQUE_BITS crosscompilation (Trac #13491)
Sergei Trofimovich [Wed, 29 Mar 2017 21:30:50 +0000 (17:30 -0400)] 
unique: fix UNIQUE_BITS crosscompilation (Trac #13491)

The #13491 manifests best when we try to crosscompile
from 32-bit (i386-linux) to 64-bit (powerpc64-linux)
    ./configure --target=powerpc64-unknown-linux-gnu

The build fails at assembly time:
  "inplace/bin/ghc-stage1" ...  -c rts/StgStartup.cmm
    /tmp/ghc19687_0/ghc_4.s: Assembler messages:

    /tmp/ghc19687_0/ghc_4.s:11:0: error:
         Error: unknown pseudo-op: `.l'
    11 | .L<\x00>4:
       | ^

That happens because UNIQUE_BITS is defined in terms

WORD_SIZE_IN_BITS is 64 bits (equals to target value)
while ghc-stage1 is still running on i386-linux

The fix is to stop relying on target macros and use
host's 'sizeof (HsInt)' and 'finiteBitSize' way to
determine unique layout.

Signed-off-by: Sergei Trofimovich <>
Test Plan: build i386-to-powerpc64 crosscompiler

Reviewers: rwbarton, austin, bgamari

Reviewed By: bgamari

Subscribers: RyanGlScott, thomie

Differential Revision:

2 years agoShow valid substitutions for typed holes
Matthías Páll Gissurarson [Wed, 29 Mar 2017 21:30:28 +0000 (17:30 -0400)] 
Show valid substitutions for typed holes

The idea is to implement a mechanism similar to PureScript, where they
suggest which identifiers in scope would fit the given hole. In
PureScript, they use subsumption (which is what we would like here as
well). For subsumption, we would have to check each type in scope
whether the hole is a subtype of the given type, but that would require
`tcSubType` and constraint satisfiability checking. Currently,
`TcSimplify` uses a lot of functions from `TcErrors`, so that would
require more of a rewrite, I will hold on with that for now, and submit
the more simpler type equality version.

As an example, consider

ps :: String -> IO ()
ps = putStrLn

ps2 :: a -> IO ()
ps2 _ = putStrLn "hello, world"

main :: IO ()
main = _ "hello, world"

The results would be something like

    • Found hole: _ :: [Char] -> IO ()
    • In the expression: _
      In a stmt of a 'do' block: _ "hello, world"
      In the expression:
        do _ "hello, world"
    • Relevant bindings include
        main :: IO () (bound at test.hs:13:1)
        ps :: String -> IO () (bound at test.hs:7:1)
        ps2 :: forall a. a  -> IO () (bound at test.hs:10:1)
      Valid substitutions include
        putStrLn :: String
                    -> IO () (imported from ‘Prelude’ at
                              (and originally defined in
        putStr :: String
                  -> IO () (imported from ‘Prelude’ at
                            (and originally defined in ‘System.IO’))

We'd like here for ps2 to be suggested as well, but for that we require

Reviewers: austin, bgamari, dfeuer, mpickering

Reviewed By: dfeuer, mpickering

Subscribers: mpickering, Wizek, dfeuer, rwbarton, thomie

Differential Revision:

2 years agoVarious patches to support android cross compilation
Moritz Angermann [Wed, 29 Mar 2017 21:29:58 +0000 (17:29 -0400)] 
Various patches to support android cross compilation

- Better test for SHT_INIT_ARRAY than openbsd_HOST_OS
  This is actually bens patch:
- linux-android defines.
- No need for -lpthread on OSAndroid
  However, I’m confused why we do not use the AC NEED_PTHREAD_LIB
  value here?
- Use mmap on android
- Support `none` vendor.

Reviewers: austin, hvr, bgamari, erikd, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie, erikd

Differential Revision:

2 years agoCheck TargetPlatform instead of HostPlatform for leading underscore
Moritz Angermann [Wed, 29 Mar 2017 21:28:16 +0000 (17:28 -0400)] 
Check TargetPlatform instead of HostPlatform for leading underscore

Reviewers: austin, hvr, rwbarton, bgamari

Reviewed By: rwbarton, bgamari

Subscribers: rwbarton, thomie, erikd

Differential Revision:

2 years agoAllow operators as record pattern synonym fields
Matthew Pickering [Wed, 29 Mar 2017 20:09:08 +0000 (16:09 -0400)] 
Allow operators as record pattern synonym fields

Fixes #13454

Reviewers: austin, bgamari, dfeuer

Reviewed By: dfeuer

Subscribers: RyanGlScott, rwbarton, thomie

Differential Revision:

2 years agoPrint module when dumping rules
Matthew Pickering [Wed, 29 Mar 2017 20:08:40 +0000 (16:08 -0400)] 
Print module when dumping rules

It is sometimes hard to find where a rule is defined. Printing the
module where it comes from will make it much easier to find.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision:

2 years agoFixed error messages for RecursiveDo (#8501)
Rupert Horlick [Wed, 29 Mar 2017 19:26:11 +0000 (15:26 -0400)] 
Fixed error messages for RecursiveDo (#8501)

Changes in a few different places to catch several different
types of error related to RecursiveDo

Signed-off-by: Rupert Horlick <>
Test Plan: Three test cases, with further tests in comments

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

2 years agobase: Check for path separators chars in openTempFile' template string
Ben Gamari [Mon, 27 Mar 2017 16:40:42 +0000 (12:40 -0400)] 
base: Check for path separators chars in openTempFile' template string

This fixes #13489.

2 years agotestsuite: More 32-bit performance changes
Ben Gamari [Mon, 27 Mar 2017 12:16:18 +0000 (08:16 -0400)] 
testsuite: More 32-bit performance changes

2 years agoFix scc001
Simon Marlow [Wed, 29 Mar 2017 13:17:38 +0000 (06:17 -0700)] 
Fix scc001

2 years agocg057: accept output
Simon Marlow [Wed, 29 Mar 2017 13:25:05 +0000 (06:25 -0700)] 
cg057: accept output

2 years agoFix ASSERT failure in TcErrors
Simon Peyton Jones [Wed, 29 Mar 2017 13:57:21 +0000 (14:57 +0100)] 
Fix ASSERT failure in TcErrors

This fixes Trac #13494, by improving

   commit e0ad55f894a8d85dcc099c33c63cfe3d4515d464
   Author: Simon Peyton Jones <>
   Date:   Mon Mar 27 10:32:08 2017 +0100

   Fix error-message suppress on given equalities

which in turn was a fix to #13446

2 years agoAdd a couple of HasDebugCallStack contexts
Simon Peyton Jones [Wed, 29 Mar 2017 08:01:58 +0000 (09:01 +0100)] 
Add a couple of HasDebugCallStack contexts

Just for future (and past) debugging...

2 years agoAllow unbound Refl binders in a RULE
Simon Peyton Jones [Wed, 29 Mar 2017 08:00:02 +0000 (09:00 +0100)] 
Allow unbound Refl binders in a RULE

Trac #13410 was failing because we had a RULE with a binder
   (c :: t~t)
and the /occurrences/ of c on the LHS were being optimised to Refl,
leaving a binder that would not be filled in by matching the LHS
of the rule.

I flirted with trying to ensure that occurrences (c :: t~t) are
not optimised to Relf, but that turned out to be fragile; it was
being done, for good reasons, in multiple places, including
  - TyCoRep.substCoVarBndr
  - Simplify.simplCast
  - Corecion.mkCoVarCo

So I fixed it in one place by making Rules.matchN deal happily
with an unbound binder (c :: t~t).  Quite easy.  See "Coercion
variables" in Note [Unbound RULE binders] in Rules.

In addition, I needed to make CoreLint be happy with an bound
RULE binder that is a Relf coercion variable

In debugging this, I was perplexed that occurrences of a variable
(c :: t~t) mysteriously turned into Refl.  I found out how it
was happening, and decided to move it:

* In TyCoRep.substCoVarBndr, do not substitute Refl for a
  binder (c :: t~t).

* In mkCoVarCo do not optimise (c :: t~t) to Refl.

Instead, we do this optimisation in optCoercion (specifically
opt_co4) where, surprisingly, the optimisation was /not/
being done.  This has no effect on what programs compile;
it just moves a relatively-expensive optimisation to optCoercion,
where it seems more properly to belong.  It's actually not clear
to me which is really "better", but this way round is less

One small simplifying refactoring

* Eliminate TyCoRep.substCoVarBndrCallback, which was only
  called locally.