2 years agoCaret diag.: Avoid decoding whole module if only specific line is needed
alexbiehl [Mon, 17 Apr 2017 16:51:10 +0000 (12:51 -0400)] 
Caret diag.: Avoid decoding whole module if only specific line is needed

Before we were decoding the whole file to get to the desired line. This
patch introduces a fast function which searches a StringBuffer for the
desired line so we only need to utf8 decode a little portion.

This is especially interesting if we have big modules with lots of

Reviewers: austin, bgamari, Rufflewind, trofi

Reviewed By: Rufflewind, trofi

Subscribers: rwbarton, thomie

Differential Revision:

2 years agoUse intersect and minus instead of filter
Bartosz Nitka [Mon, 17 Apr 2017 16:50:10 +0000 (12:50 -0400)] 
Use intersect and minus instead of filter

These are asymptotically better and convey the intent
a bit better.

Test Plan: ./validate

Reviewers: simonpj, bgamari, austin, goldfire

Reviewed By: bgamari

Subscribers: rwbarton, thomie, simonmar

Differential Revision:

2 years agoFix "Glasgow Haskell Compiler <release> Users Guide"
Bartosz Nitka [Mon, 17 Apr 2017 16:49:34 +0000 (12:49 -0400)] 
Fix "Glasgow Haskell Compiler <release> Users Guide"

If you go to
the window title has `<release>` in it.  I don't understand how it all
works, but inspired by the line below which produces a correct string in
the docs I just blindly changed it in the same way.  Cabal appears to
have the same problem.

Test Plan:
it'd be nice if I could check the result
on harbormaster, can I?

Reviewers: thomie, bgamari, austin

Reviewed By: bgamari

Subscribers: rwbarton, simonmar

Differential Revision:

2 years agoRemove redundant flag (-O) registration (fixes #13392)
Santiago Munin [Mon, 17 Apr 2017 16:44:52 +0000 (12:44 -0400)] 
Remove redundant flag (-O) registration (fixes #13392)

Reviewers: austin, bgamari, dfeuer

Reviewed By: bgamari, dfeuer

Subscribers: rwbarton, thomie

GHC Trac Issues: #13392

Differential Revision:

2 years ago[iserv] drop cryptonite dependency.
Moritz Angermann [Mon, 17 Apr 2017 16:28:22 +0000 (12:28 -0400)] 
[iserv] drop cryptonite dependency.

Reviewers: bgamari, austin

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision:

2 years agoutils: Lazily decode UTF8 strings
Ben Gamari [Mon, 17 Apr 2017 16:26:56 +0000 (12:26 -0400)] 
utils: Lazily decode UTF8 strings

Reviewers: austin, hvr

Subscribers: rwbarton, thomie

GHC Trac Issues: #13527

Differential Revision:

2 years agoFix space leak in sortBy
Gregory [Mon, 17 Apr 2017 15:24:31 +0000 (11:24 -0400)] 
Fix space leak in sortBy

This makes yields a small improvement in sort performance: around 3.5% in
runtime on random Ints.

Reviewers: austin, hvr, mpickering

Subscribers: siddhanathan, rwbarton, thomie

Differential Revision:

2 years agobase: Track timer PSQ timeouts as Word64 instead of Double
Ben Gamari [Mon, 17 Apr 2017 15:17:00 +0000 (11:17 -0400)] 
base: Track timer PSQ timeouts as Word64 instead of Double

Test Plan: Validate on all the platforms

Reviewers: nh2, hvr, austin

Subscribers: Phyx, nh2, rwbarton, thomie

Differential Revision:

2 years agoaclocal.m4: respect user's --with-ar= choice
Sergei Trofimovich [Mon, 17 Apr 2017 08:41:49 +0000 (09:41 +0100)] 
aclocal.m4: respect user's --with-ar= choice

'FP_PROG_AR' macro has a minor bug: it ignores
already existing value stored in '$fp_prog_ar'.

I've noticed it when tried to built UNREG ghc using thin LTO:

  $ ./configure --enable-unregisterised \
                --with-nm=gcc-nm \
                --with-ar=gcc-ar \
                --with-ranlib=gcc-ranlib \

./configure refused to use 'gcc-ar' (LTO-aware variant of 'ar')
and kept using 'ar'.

'$fp_prog_ar' is initialized (in a complex manner) in '' as:

    FP_ARG_WITH_PATH_GNU_PROG([AR], [ar], [ar])

The change keeps that value.

Signed-off-by: Sergei Trofimovich <>
2 years print resolved 'ar' and 'ranlib' tools
Sergei Trofimovich [Mon, 17 Apr 2017 08:40:17 +0000 (09:40 +0100)] print resolved 'ar' and 'ranlib' tools

Signed-off-by: Sergei Trofimovich <>
2 years agohs_add_root() RTS API removal
Sergei Trofimovich [Mon, 17 Apr 2017 11:56:20 +0000 (12:56 +0100)] 
hs_add_root() RTS API removal

Before ghc-7.2 hs_add_root() had to be used to initialize haskell
modules when haskell was called from FFI.

commit a52ff7619e8b7d74a9d933d922eeea49f580bca8
("Change the way module initialisation is done (#3252, #4417)")
removed needs for hs_add_root() and made function a no-op.
For backward compatibility '__stginit_<module>' symbol was
not removed.

This change removes no-op hs_add_root() function and unused
'__stginit_<module>' symbol from each haskell module.

Signed-off-by: Sergei Trofimovich <>
Test Plan: ./validate

Reviewers: simonmar, austin, bgamari, erikd

Reviewed By: simonmar

Subscribers: rwbarton, thomie

Differential Revision:

2 years agoUNREG: fix spelling of '-split-objs' in warning
Sergei Trofimovich [Sun, 16 Apr 2017 16:56:35 +0000 (17:56 +0100)] 
UNREG: fix spelling of '-split-objs' in warning

Spelling if warning message slightly mismathed passed commandline:

  $ ghc-stage2 -split-objs -C N.hs
  on the commandline: warning: ignoring -fsplit-objs

Signed-off-by: Sergei Trofimovich <>
2 years agoUNREG: remove dead code around -split-objs
Sergei Trofimovich [Sun, 16 Apr 2017 16:20:54 +0000 (17:20 +0100)] 
UNREG: remove dead code around -split-objs

Signed-off-by: Sergei Trofimovich <>
2 years agorts/RtsUtils.c: drop stale comments
Sergei Trofimovich [Sun, 16 Apr 2017 09:45:00 +0000 (10:45 +0100)] 
rts/RtsUtils.c: drop stale comments

Signed-off-by: Sergei Trofimovich <>
2 years agolinker/mach-o: Catch the case where there is no symCmd
Moritz Angermann [Sun, 16 Apr 2017 01:30:10 +0000 (21:30 -0400)] 
linker/mach-o: Catch the case where there is no symCmd

We do check for symCmd, to set the info->nlist value, but
forgot to do the same check for info->names.  Thus when trying to
extract stroff from symCmd, we hit a segfault.

Reviewers: bgamari, adinapoli, austin, erikd, simonmar

Reviewed By: bgamari, adinapoli

Subscribers: rwbarton, thomie

Differential Revision:

2 years agolinters/cpp: Catch #ifndef
Ben Gamari [Fri, 14 Apr 2017 02:04:48 +0000 (22:04 -0400)] 
linters/cpp: Catch #ifndef

2 years agoFix typo in TcErrors.hs
Matthías Páll Gissurarson [Fri, 17 Mar 2017 00:46:58 +0000 (01:46 +0100)] 
Fix typo in TcErrors.hs

This fixes a very simple typo in TcErrors.hs. I hope this is small
enough in scope to be accepted through GitHub.

2 years agoDoc typo
Alex Biehl [Wed, 22 Mar 2017 09:25:24 +0000 (10:25 +0100)] 
Doc typo

2 years agoComments only in Type.isPredTy
Simon Peyton Jones [Thu, 13 Apr 2017 08:23:39 +0000 (09:23 +0100)] 
Comments only in Type.isPredTy

2 years agoRemove dead quantifyTyVars
Simon Peyton Jones [Wed, 12 Apr 2017 15:20:13 +0000 (16:20 +0100)] 
Remove dead quantifyTyVars

This patch

* removes a function TcMType.quantifyTyVars
  that was never called

* renames quantifyZonkedTyVars to quantifyTyVars

Plus a few comments.  No functional change at all

2 years agoYet more work on TcSimplify.simplifyInfer
Simon Peyton Jones [Wed, 12 Apr 2017 14:09:37 +0000 (15:09 +0100)] 
Yet more work on TcSimplify.simplifyInfer

The proximate cause for this patch is Trac #13482, which pointed out
further subtle interactions between
   - Inferring the most general type of a function
   - A partial type signature for that function

That led me into /further/ changes to the shiny new stuff in
TcSimplify.simplifyInfer, decideQuantification, decideMonoTyVars,
and related functions.

Happily, I was able to make some of it quite a bit simpler,
notably the bit about promoting free tyvars.  I'm happy with
the result.

Moreover I fixed Trac #13524 at the same time.  Happy days.

2 years agoFix a couple of user-manual typos
Simon Peyton Jones [Tue, 11 Apr 2017 14:24:42 +0000 (15:24 +0100)] 
Fix a couple of user-manual typos

2 years agoSplit up RnEnv into 4 modules, RnUnbound, RnUtils and RnFixity
Matthew Pickering [Sat, 8 Apr 2017 15:42:32 +0000 (16:42 +0100)] 
Split up RnEnv into 4 modules, RnUnbound, RnUtils and RnFixity

RnEnv contains functions which convertn RdrNames into Names.

RnUnbound contains helper functions for reporting and creating
unbound variables.

RnFixity contains code which maintains the fixity environent
whilst renaming.

RnUtils contains the other stuff in RnEnv.

Reviewers: austin, goldfire, bgamari

Subscribers: goldfire, rwbarton, thomie, snowleopard

Differential Revision:

2 years agoDrop special handling of iOS
Moritz Angermann [Wed, 12 Apr 2017 18:12:33 +0000 (14:12 -0400)] 
Drop special handling of iOS

iOS at least since iOS8 (we are currently at iOS10.3), allows for
dynamic libaries, hence any artificail restriction on dyanmic
libraries should be lifted.

Please ping me with any iOS related issues that should potentially
resurface.  The iOS toolchain has considerably changed over the
years, and I'm willing to drop work arounds in good faith.

Reviewers: bgamari, austin

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13559, #7722

Differential Revision:

2 years agoFix typo in ReadP (succeds -> succeeds)
Chris Martin [Wed, 12 Apr 2017 18:12:05 +0000 (14:12 -0400)] 
Fix typo in ReadP (succeds -> succeeds)

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision:

2 years ago[linker] Remove dead code (ELF_FUNCTION_DESC)
Moritz Angermann [Wed, 12 Apr 2017 18:11:41 +0000 (14:11 -0400)] 
[linker] Remove dead code (ELF_FUNCTION_DESC)

Reviewers: bgamari, austin, erikd, simonmar, rwbarton

Reviewed By: bgamari, rwbarton

Subscribers: rwbarton, thomie

Differential Revision:

2 years agoAllow qualified names to be children in export lists
Matthew Pickering [Wed, 12 Apr 2017 18:10:54 +0000 (14:10 -0400)] 
Allow qualified names to be children in export lists

When doing this I noticed a horrible amount of duplication between
lookupSubBndrOcc and lookupExportChild (which I am responsible for).
I opened #13545 to keep track of this.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13528

Differential Revision:

2 years agoSuggest correct replacement flag name for -dppr-ticks
Reid Barton [Wed, 12 Apr 2017 18:10:39 +0000 (14:10 -0400)] 
Suggest correct replacement flag name for -dppr-ticks

It told me to use -fno-suppress-ticks, but it should have been

Test Plan: tested -dppr-ticks and -frewrite-rules manually

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

2 years agoRemove GhcDynamic (in favor of DYNAMIC_GHC_PROGRAMS)
Reid Barton [Wed, 12 Apr 2017 18:10:12 +0000 (14:10 -0400)] 
Remove GhcDynamic (in favor of DYNAMIC_GHC_PROGRAMS)

DYNAMIC_GHC_PROGRAMS and GhcDynamic both tried to control whether
the ghc binary was built as a dynamic executable, with confusing
results. In particular, setting GhcDynamic=NO has no effect on
systems where DYNAMIC_GHC_PROGRAMS defaults to YES.

DYNAMIC_GHC_PROGRAMS is more fully-featured (it ensures that the
correct flavor of the libraries is built, for example) so let's
keep it and remove GhcDynamic to reduce confusion.

This effectively reverts commit 3c6190b0.

Test Plan: tested locally; harbormaster

Reviewers: simonmar, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie, snowleopard

Differential Revision:

2 years agoarc-linters: Add linting of #ifdef x and #if defined x
Ben Gamari [Wed, 12 Apr 2017 18:10:01 +0000 (14:10 -0400)] 
arc-linters: Add linting of #ifdef x and #if defined x

Reviewers: austin, erikd

Reviewed By: erikd

Subscribers: rwbarton, thomie, erikd

Differential Revision:

2 years agobase: Implement bit casts between word and float types
Erik de Castro Lopo [Wed, 12 Apr 2017 18:09:49 +0000 (14:09 -0400)] 
base: Implement bit casts between word and float types

Test Plan: Test on x86 and x86_64

Reviewers: duncan, trofi, simonmar, tibbe, hvr, austin, rwbarton,

Reviewed By: duncan

Subscribers: Phyx, DemiMarie, rwbarton, thomie

Differential Revision:

2 years agoRnEnv cleanup
Matthew Pickering [Wed, 12 Apr 2017 18:06:15 +0000 (14:06 -0400)] 
RnEnv cleanup

unless (not ..) -> when

Remove unused getLookupOccRn

Remove lookupGreRn2

It was only called in one place in a very strange way. It is easier
to just use lookupGreRn which has nearly the same implementation and
then directly call `unboundName`.

Remove unused function mapFvRnCPS

Remove unused functions bindLocatedLocalsRn and bindLocatedLocalsFV

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision:

2 years agoUse -G1 for reliable peak mem usage
Simon Peyton Jones [Tue, 11 Apr 2017 15:09:42 +0000 (16:09 +0100)] 
Use -G1 for reliable peak mem usage

2 years agoMake let and app consistent in exprIsCheapX
Simon Peyton Jones [Tue, 11 Apr 2017 14:39:09 +0000 (15:39 +0100)] 
Make let and app consistent in exprIsCheapX

This fixes Trac #13558, by making App and Let behave
consistently; see Note [Arguments and let-bindings exprIsCheapX]

I renamed the mysterious exprIsOk to exprIsCheapX.  (The "X"
is because it is parameterised over a CheapAppFun.)

2 years agoAdd Outputable instance for ArityType
Simon Peyton Jones [Tue, 11 Apr 2017 14:36:30 +0000 (15:36 +0100)] 
Add Outputable instance for ArityType

2 years agoFix another literal-string buglet
Simon Peyton Jones [Tue, 11 Apr 2017 14:34:12 +0000 (15:34 +0100)] 
Fix another literal-string buglet

We were failing to float a nested binding
   x :: Addr# = "foo"#
to top level, even though we /were/ floating string
literals themselves.  A small oversight, easily fixed.

2 years agoImprove demand analysis for join points
Simon Peyton Jones [Mon, 10 Apr 2017 07:51:49 +0000 (08:51 +0100)] 
Improve demand analysis for join points

I realised (Trac #13543) that we can improve demand analysis for
join point quite straightforwardly.

The idea is explained in
    Note [Demand analysis for join points]
in DmdAnal

2 years agoKill off complications in CoreFVs
Simon Peyton Jones [Fri, 7 Apr 2017 16:10:07 +0000 (17:10 +0100)] 
Kill off complications in CoreFVs

When doing type-in-type, Richard introduce some substantial
complications in CoreFVs, gathering types and free variables
of type.  In Trac #13160 we decided that this complication was
unnecessary, so this patch removes it.

Unfortnately I then fell down a twisty rabbit hole.  Roughly:

* An apparently-innocuous change in the AnnApp case of
  fiExpr made the fuction a little bit stricter, so we ended
  up peering into the arguments when we didn't before (namely
  when there are no bindings being floated inwards).  I've
  rejigged it so that it's not fragile any more.

* Peering into the arguments was sometimes expensive, becuase
  exprIsExpandable can be expensive because it looks deeply into
  the expression.

* The combination of the two led to a non-linear explosion
  of work when the argument of a function is a deeep nest
  of constructors.  This bug has been lurking for ages.

  I solved it by replacing exprIsExpandable with exprIsHNF
  + exprIsTrivial; see Note [noFloatInto considerations]

* The code around floating case-expressions turned out to be
  very delicate, because can_fail primops (which we want to
  float inwards) can't be floated outwards; so we have to be
  careful never to float them too far. Note [Floating primops]
  has the details

* I ended up refactoring some rather opaque code in

Working all this out meant that I rewrote quite a bit of
code, so it's now a reasonably substantial patch.  But it's
a net improvement.

2 years agoTypos in comments [ci skip]
Gabor Greif [Thu, 6 Apr 2017 13:13:55 +0000 (15:13 +0200)] 
Typos in comments [ci skip]

2 years ago[Elf/arm] Thumb indicator bit only for STT_FUNC
Moritz Angermann [Tue, 11 Apr 2017 01:39:19 +0000 (21:39 -0400)] 
[Elf/arm] Thumb indicator bit only for STT_FUNC

Reviewers: rwbarton, bgamari, austin, erikd, simonmar, trofi

Reviewed By: trofi

Subscribers: trofi, thomie

Differential Revision:

2 years ago[MachO] Use OBJFORMAT_MACHO.
Moritz Angermann [Tue, 11 Apr 2017 01:39:02 +0000 (21:39 -0400)] 

Reviewers: bgamari, austin, erikd, simonmar, rwbarton

Reviewed By: rwbarton

Subscribers: rwbarton, thomie

Differential Revision:

2 years agoEnter iserv-proxy
Moritz Angermann [Tue, 11 Apr 2017 01:38:45 +0000 (21:38 -0400)] 
Enter iserv-proxy

With the introduction of -fexternal-interpreter we are
now able to compile template haskell via an extern iserv process.

This however is restricted to the same host, and can therefore
not be used with crosscompilers where the iserv slave process
needs to run on a different machine than the cross compiling
haskell compiler.

This diff breaks up iserv into a library and the iserv-bin binary.
It also introduces the iserv-proxy, a proxy instance that the
haskell compiler can talk to, and which forwards the calls
to the iserv slave on a different machine, as well as providing
some extra functionarily (sending files that are not available
on the machine the slave runs on), as well as forwarding from
the slave to the haskell compiler, when the slave needs to
interrogate the haskell compiler.

The iserv library now also exports the startSlave function to be
called by the application that implements the slave on the target.

The simplest such app would probably look something like:

extern void startServ(bool, const char *);

int main(int argc, char * argv[]) {
  hs_init(NULL, NULL);

Special thanks to Shea Levy for the first draft of the iserv-remote,
from which I took some inspiration.

The `Buildable` flags are due to ghc-cabal not being able to build
more than a single target.  Please note that only the stock iserv-bin
is supposed to be built *with* ghc.  The library and proxy are supposed
to be built outside of ghc.  Yet I believe that this code should live
together with iserv.

Reviewers: simonmar, ezyang, goldfire, austin, rwbarton, bgamari

Reviewed By: simonmar

Subscribers: luite, ryantrinkle, shlevy, thomie

Differential Revision:

2 years agoFix form of note
Ben Gamari [Tue, 11 Apr 2017 01:35:06 +0000 (21:35 -0400)] 
Fix form of note

2 years agobase: Fix erroneous reference to Data.Reflection in documentation
Ben Gamari [Mon, 10 Apr 2017 18:07:42 +0000 (14:07 -0400)] 
base: Fix erroneous reference to Data.Reflection in documentation

2 years agoImprove `readChan` documentation:
Ömer Sinan Ağacan [Mon, 10 Apr 2017 17:36:45 +0000 (20:36 +0300)] 
Improve `readChan` documentation:

- Mention that the read end is an `MVar`, so fairness guarantees are

- Mention that it can throw `BlockedIndefinitelyOnMVar` exception.

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #5466

Differential Revision:

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