4 years agoImprove documentation of comprehensions
Simon Peyton Jones [Fri, 11 Sep 2015 16:02:58 +0000 (17:02 +0100)] 
Improve documentation of comprehensions

Suggestion from Jeremy Gibbons

4 years agoFix broken links in documentation
Simon Peyton Jones [Fri, 11 Sep 2015 16:01:33 +0000 (17:01 +0100)] 
Fix broken links in documentation

4 years agoImprove documentation for transform list-comps
Simon Peyton Jones [Fri, 11 Sep 2015 15:23:35 +0000 (16:23 +0100)] 
Improve documentation for transform list-comps

Thanks to Jeremy Gibbons for spotting the infelictity

4 years agoA CFunEqCan can be Derived
Simon Peyton Jones [Fri, 11 Sep 2015 15:23:06 +0000 (16:23 +0100)] 
A CFunEqCan can be Derived

This fixes the ASSERTION failures in
when GHC is compiled with -DDEBUG

See Phab:D202 attached to Trac #6018

4 years agoAdd a test for Trac #10806
Simon Peyton Jones [Fri, 11 Sep 2015 14:55:29 +0000 (15:55 +0100)] 
Add a test for Trac #10806

4 years agoImprove rejigConRes (again)
Simon Peyton Jones [Fri, 11 Sep 2015 14:54:39 +0000 (15:54 +0100)] 
Improve rejigConRes (again)

I think this patch finally works around the delicacy in the strictness
of TcTyClsDecls.rejigConRes.   See the notes with that function and
Note [Checking GADT return types].

As a result, we fix Trac #10836, and improve Trac #7175

4 years agoComments on oneShot
Simon Peyton Jones [Thu, 27 Aug 2015 15:23:46 +0000 (16:23 +0100)] 
Comments on oneShot

4 years agoDon't check in autogenerated hs files for recomp013.
Edward Z. Yang [Thu, 10 Sep 2015 05:02:48 +0000 (22:02 -0700)] 
Don't check in autogenerated hs files for recomp013.

Signed-off-by: Edward Z. Yang <>
4 years agoTestsuite: comment out `setnumcapabilities001` (#10860)
Thomas Miedema [Wed, 9 Sep 2015 11:56:53 +0000 (13:56 +0200)] 
Testsuite: comment out `setnumcapabilities001` (#10860)

Don't mark it expect_broken, because it fails only sometimes.

4 years agoForbid annotations when Safe Haskell safe mode is enabled.
David Kraeutmann [Tue, 8 Sep 2015 16:35:33 +0000 (11:35 -0500)] 
Forbid annotations when Safe Haskell safe mode is enabled.

For now, this fails compliation immediately with an error. If desired, this
can be a warning that annotations in Safe Haskell are ignored.

Signed-off-by: David Kraeutmann <>
Reviewed By: goldfire, austin

Differential Revision:

GHC Trac Issues: #10826

4 years agoHeapStackCheck: Small refactoring
Ben Gamari [Tue, 8 Sep 2015 16:30:43 +0000 (11:30 -0500)] 
HeapStackCheck: Small refactoring

Use modern Cmm argument syntax in stg_block_blackhole definition.

Reviewed By: simonmar, austin

Differential Revision:

4 years agoBuild system: check for inconsistent settings (#10157)
Thomas Miedema [Tue, 8 Sep 2015 11:51:44 +0000 (13:51 +0200)] 
Build system: check for inconsistent settings (#10157)

`configure` currently detects when the docbook and hscolour tools aren't
available, and instead of failing outright (as it does for missing alex
and happy), sets some variables in mk/ to tell `make` not to
build the documentation.

Sometimes, however, you want to really make sure all documentation gets
built, fully colourized. For example when making a release. To do so,
you can override the mentioned variables from mk/ in
mk/ (e.g. set HSCOLOUR_SRCS=YES).

This patch adds some error checking to make sure that doing so will not
result in weird build failures when those tools are still missing.

Test Plan: ran `make` a couple of times, with different mk/ settings.

Reviewed by: austin

Differential Revision:

4 years agoMove GeneralCategory et al to GHC.Unicode
Ben Gamari [Tue, 8 Sep 2015 13:38:40 +0000 (08:38 -0500)] 
Move GeneralCategory et al to GHC.Unicode

This allows these to be used from Text.Read.Lex import cycles.

Reviewed By: thomie, austin

Differential Revision:

GHC Trac Issues: #10444

4 years agoBuild system: cleanup BUILD_DIRS + add lots of Notes
Thomas Miedema [Fri, 10 Jul 2015 22:50:58 +0000 (00:50 +0200)] 
Build system: cleanup BUILD_DIRS + add lots of Notes

See Note [CrossCompiling vs Stage1Only] in mk/
See Note [Stage1Only vs stage=1] in mk/
See Note [No stage2 packages when CrossCompiling or Stage1Only].

  * use stage2 to build mkUserGuidePart, as was probably intended.
    Now the following represent the same set of packages:
    - packages that we build with ghc-stage2
    - packages that depend on the ghc library
    Those packages are: haddock, mkUserGuidePart and ghctags.
  * don't let utils that don't depend on the ghc library depend on its file. Instead, let those utils directly depend on
    the files of the stage1 packages. Not sure if it
    improves anything, but I found it easier to explain what's going on
    this way.

(partially) reviewed by: austin

Differential Revision:

4 years agoBuild system: make *-cross BuildFlavours consistent (#10223)
Thomas Miedema [Tue, 25 Aug 2015 17:20:39 +0000 (19:20 +0200)] 
Build system: make *-cross BuildFlavours consistent (#10223)

This is a follow up to 841924c9587c10488a18e307b573720977bf4f13,
where `-fllvm` was explicitly removed from GhcStage1HcOpts for

After removing -fllvm from GhcStage1HcOpts, it should be removed from
SRC_HC_OPTS as well, because SRC_HC_OPTS are added to every Haskell
compilation. That's what this patch does.

BuildFlavour bench-cross (added in ddf79ebf69fe4a6e69d69d451a6040a53b1ea12c),
is probably never used. But for consistency, also use -fllvm here, for
building stage2 and the libraries.

Reviewed by: austin

Differential Revision:

4 years agoBuild system: delete the InstallExtraPackages variable
Thomas Miedema [Tue, 25 Aug 2015 15:30:18 +0000 (17:30 +0200)] 
Build system: delete the InstallExtraPackages variable

Just install all packages that are built. Don't make an exception for
the dph and extra packages.

You can control whether the dph and extra packages should be build using
the variables BUILD_DPH and BUILD_EXTRA_PKGS. These variables didn't
exist before. But now that they do, InstallExtraPackages isn't really
needed anymore.

Reviewed by: austin

Differential Revision:

4 years agoBuild system: remove hack for Mac OSX in (#10476)
Thomas Miedema [Mon, 7 Sep 2015 13:58:33 +0000 (15:58 +0200)] 
Build system: remove hack for Mac OSX in (#10476)

Cross-compilation on Mac OSX currently doesn't work. While building
stage 1, the build system uses the `ar` for the target architecture
instead of the `ar` for build/host architecture.

The cause is a hack added in 24746fe78024a1edab843bc710c79c55998ab134
(2010), to supporting bootstrap compilers built with older versions of
Xcode. Xcode 4.3 started installing command line tools in a different
location. Assuming this all behind us now, and the paths didn't change
again (you never now), we can delete the hack.

Deleting the hack fixes the cross compilation issue. Tested by Trac user

Reviewed by: austin

Differential Revision:

4 years agoBuild system: detect when user cloned from GitHub
Thomas Miedema [Mon, 7 Sep 2015 13:28:30 +0000 (15:28 +0200)] 
Build system: detect when user cloned from GitHub

Cloning the ghc repository from GitHub doesn't work out of the box. It
requires installing some special url rewrites into ~/.gitconfig. The
build fails mysteriously if you forget. This patch tries to detect when
you cloned from GitHub, and warns you if you didn't set those url

This hopefully lowers to barrier to contribute to GHC by a tiny bit. At
least one /r/haskell user ran into this recently.

Test Plan:
cloned from github, ran ./boot, saw the message. Installed url
rewrites, and ran ./boot again, didn't see the message.

Reviewed by: austin

Differential Revision:

4 years agoFurther simplify the story around minimum/maximum
Joachim Breitner [Mon, 7 Sep 2015 11:48:10 +0000 (13:48 +0200)] 
Further simplify the story around minimum/maximum

After I have found out that I should look at -ddump-prep and not
-ddump-core, I noticed that these days, GHC is perfectly capeable of
turning (the equivalent) of foldl to (the equivalent) of foldl' if the
operation in question is strict. So instead of using rewrite rules to
rewrite maximum to a strictMaximum for certain types, we simply use

This also marks maximum/minimum as INLINEABLE, so that client code can
get similar specializations, hopefully even automatically. And inded,
minimum applied to [Double] produces good code (although due to
inlineing, not due to specialization, it seems).

I checked (by looking at the core) that this still fixes #10788.

Differential revision:

4 years agoSPECIALIZE strictMinimum for Int and Integer
Joachim Breitner [Mon, 7 Sep 2015 11:19:50 +0000 (13:19 +0200)] 
SPECIALIZE strictMinimum for Int and Integer

This fixes a regression reported in #10788, where due to less inlining
compared to earlier versions, we’d get worse code. With the SPECIALIZE,
we get the good code, and moreover, the good code is in List.hs and
_not_ inlined to the use site, so smaller code size and less compilation

4 years agoBuild system: cleanup utils/ghc-pkg/
Thomas Miedema [Thu, 9 Jul 2015 23:02:31 +0000 (01:02 +0200)] 
Build system: cleanup utils/ghc-pkg/

There used to be a lot of custom make code to build ghc-pkg with the
stage0 compiler. Commit ac5a314504554ddef0e855ef9e2fcf51e961f4a6
thankfully cleaned this up, by using the build settings from the
ghc-pkg.cabal file.

This commit removes some remains of the old way of installing ghc-pkg
when Stage1Only=YES. Notably, we called both `build-prog` as
`shell-wrapper`. This is surely wrong, because `build-prog` already
calls `shell-wrapper`. It isn't needed to set WANT_INSTALLED_WRAPPER
either; build-prog does that for us.

This prevents the following warnings when Stage1Only=YES:
  utils/ghc-pkg/ warning:
    overriding commands for target `install_utils/ghc-pkg_dist_wrapper'
  utils/ghc-pkg/ warning:
    ignoring old commands for target `install_utils/ghc-pkg_dist_wrapper'

Also add more comments and restructure a bit.

Reviewed by: austin

Differential Revision:

4 years agoBuild system: simplify *-llvm BuildFlavours (#10223)
Thomas Miedema [Tue, 25 Aug 2015 15:49:32 +0000 (17:49 +0200)] 
Build system: simplify *-llvm BuildFlavours (#10223)

Note that SRC_HC_OPTS are added to every Haskell compilation. So
there isn't any need to also add `-fllvm` to GhcStage1HcOpts,
GhcStage2HcOpts and GhcLibHcOpts.

Small bug fix: make sure we test for -fllvm in SRC_HC_OPTS, to check
whether the bootstrap compiler is affected by bug #9439.

Reviewed by: austin

Differential Revision:

4 years agoBuild system: put each BuildFlavour in a separate file (#10223)
Thomas Miedema [Mon, 31 Aug 2015 12:39:47 +0000 (14:39 +0200)] 
Build system: put each BuildFlavour in a separate file (#10223)

This allows easier diffing of different BuildFlavours, including

Reviewed By: bgamari, austin

Differential Revision:

4 years agotracing: Kill EVENT_STARTUP
Ben Gamari [Mon, 31 Aug 2015 20:39:13 +0000 (22:39 +0200)] 
tracing: Kill EVENT_STARTUP

This has been unnecessary for quite some time due to the create/delete
capability events.

4 years agoEventLog: Factor out ensureRoomFor*Event
Ben Gamari [Mon, 31 Aug 2015 20:00:10 +0000 (22:00 +0200)] 
EventLog: Factor out ensureRoomFor*Event

4 years agouser-guide: Add missing <para> tags around <listitem> body
Ben Gamari [Fri, 4 Sep 2015 16:49:23 +0000 (18:49 +0200)] 
user-guide: Add missing <para> tags around <listitem> body

Otherwise this is ill-formed DocBook

4 years agoghc-pkg: don't print ignored errors when verbosity=0
Thomas Miedema [Fri, 4 Sep 2015 14:59:44 +0000 (16:59 +0200)] 
ghc-pkg: don't print ignored errors when verbosity=0

Lines like the following are filling up the build logs:

  binary- cannot find any of
  ["Data/Binary.hi","Data/Binary.p_hi","Data/Binary.dyn_hi"] (ignoring)

4 years agoBuild system: implement `make install-strip` (#1851)
Thomas Miedema [Sat, 15 Aug 2015 15:45:57 +0000 (17:45 +0200)] 
Build system: implement `make install-strip` (#1851)

Reviewed by: bgamari

Differential Revision:

4 years agoFix T6018th test failure
Jan Stolarek [Fri, 4 Sep 2015 03:15:06 +0000 (05:15 +0200)] 
Fix T6018th test failure

4 years agoMake Data.List.foldr1 inline
Joachim Breitner [Wed, 2 Sep 2015 22:58:38 +0000 (15:58 -0700)] 
Make Data.List.foldr1 inline

Previously, foldr1 would be defiend recursively and thus not inline.
This is bad, for example, when maximumBy has a strict comparison
function: Before the BBP, it was implemented via foldl1, which inlined
and yielded good code. With BBP, it goes via foldr1, so we better inline
this as well. Fixes #10830.

Differential Revision:

4 years agoTestsuite: ignore line number differences in call stacks (#10834)
Thomas Miedema [Thu, 3 Sep 2015 12:56:50 +0000 (14:56 +0200)] 
Testsuite: ignore line number differences in call stacks (#10834)

Differential Revision:

4 years agoTestsuite: only print msg when timeout kills process unexpectedly
Thomas Miedema [Thu, 3 Sep 2015 14:13:42 +0000 (16:13 +0200)] 
Testsuite: only print msg when timeout kills process unexpectedly

Differential Revision:

4 years agoTestsuite: fix tcfail220 - Maybe is wired-in now
Thomas Miedema [Thu, 3 Sep 2015 15:01:10 +0000 (17:01 +0200)] 
Testsuite: fix tcfail220 - Maybe is wired-in now

This fixes validate.

374457809de343f409fbeea0a885877947a133a2 (D202) mentions: "This patch
also wires-in Maybe data type".

A conflicting definition of a wired-in type in a .hsig file doesn't seem
to cause compilation to fail. This is probably a bug, but a small one.
Since SPJ in ffc21506894c7887d3620423aaf86bc6113a1071 swept this under
the rug, by removing `data Bool a b c d = False` from tcfail220.hsig,
I'm going to do the same here.

D1098 touches these files, so ezyang can decide whether this problem
warrants fixing when doing a rebase.

Differential Revision:

4 years agoAccept underscores in the module parser. (Thanks spinda for the fix.)
Edward Z. Yang [Thu, 3 Sep 2015 21:16:03 +0000 (14:16 -0700)] 
Accept underscores in the module parser. (Thanks spinda for the fix.)

Signed-off-by: Edward Z. Yang <>
4 years agoAdd test for T10836 (expected broken)
Jan Stolarek [Thu, 3 Sep 2015 17:28:44 +0000 (19:28 +0200)] 
Add test for T10836 (expected broken)

4 years agoInjective type families
Jan Stolarek [Fri, 11 Jul 2014 11:54:45 +0000 (13:54 +0200)] 
Injective type families

For details see #6018, Phab:D202 and the wiki page:

This patch also wires-in Maybe data type and updates haddock submodule.

Test Plan: ./validate

Reviewers: simonpj, goldfire, austin, bgamari

Subscribers: mpickering, bgamari, alanz, thomie, goldfire, simonmar,

Differential Revision:

GHC Trac Issues: #6018

4 years agoTestsuite: delete dead code
Thomas Miedema [Thu, 27 Aug 2015 23:00:31 +0000 (01:00 +0200)] 
Testsuite: delete dead code

4 years agoTestsuite: by default run all tests for a single way
Thomas Miedema [Thu, 27 Aug 2015 10:44:15 +0000 (12:44 +0200)] 
Testsuite: by default run all tests for a single way

`make test` now runs all tests for a single way only. Use `make slowtest` to
get the previous behaviour (i.e. run all tests for all ways).

The intention is to use this new `make test` setting for Phabricator, as
a reasonable compromise between `make fasttest` (what it previously
used) and a fullblown `make slowtest` (which runs all tests for all

See Note [validate and testsuite speed] in toplevel Makefile.

Differential Revision:

4 years agoFix some tests that were broken by D861
Eric Seidel [Wed, 2 Sep 2015 18:17:01 +0000 (20:17 +0200)] 
Fix some tests that were broken by D861

I didn't realize that `./validate` does not run every test :(

Test Plan: ./validate --slow

Update submodule hpc.

Differential Revision:

4 years agoTestsuite: mark 4 tests expect_broken_for(#10712, opt_ways)
Thomas Miedema [Wed, 2 Sep 2015 16:49:25 +0000 (18:49 +0200)] 
Testsuite: mark 4 tests expect_broken_for(#10712, opt_ways)

Please revert when #10712 is fixed.

4 years agoTestsuite: update expected output
Thomas Miedema [Wed, 2 Sep 2015 16:30:07 +0000 (18:30 +0200)] 
Testsuite: update expected output

4 years agoTestsuite: don't warn about missing specialisations
Thomas Miedema [Wed, 2 Sep 2015 13:45:57 +0000 (15:45 +0200)] 
Testsuite: don't warn about missing specialisations

They can only occur with `-O`, but we want tests to produce the same
output for all test ways.

This brings us closer to passing the complete testsuite.

Differential Revision:

4 years agostm: Fix test case
Ben Gamari [Wed, 2 Sep 2015 13:34:56 +0000 (09:34 -0400)] 
stm: Fix test case

Updates stm submodule.

4 years agoImprove the error messages for class instance errors
Simon Peyton Jones [Wed, 2 Sep 2015 12:05:36 +0000 (14:05 +0200)] 
Improve the error messages for class instance errors

Summary: See Note [Displaying potential instances].

Reviewers: austin

Subscribers: KaneTW, thomie

Differential Revision:

4 years agoExpand declaration QQs first (#10047)
Michael Smith [Wed, 2 Sep 2015 11:57:44 +0000 (13:57 +0200)] 
Expand declaration QQs first (#10047)

Declaration QuasiQuoters do not cause a group split like $(...)
splices, and are run and expanded before other declarations in
the group.

Resolves the lingering issue with #10047, and fixes broken tests
qq007 and qq008.

Test Plan: validate

Reviewers: goldfire, austin, bgamari

Reviewed By: bgamari

Subscribers: goldfire, simonpj, thomie, spinda

Differential Revision:

GHC Trac Issues: #10047

4 years agoAllow annotations though addTopDecls (#10486)
Michael Smith [Wed, 2 Sep 2015 11:56:27 +0000 (13:56 +0200)] 
Allow annotations though addTopDecls (#10486)

addTopDecls restricts what declarations it can be used to add. Adding
annotations via this method works fine with no special changes apart
from adding AnnD to the declaration whitelist.

Test Plan: validate

Reviewers: austin, goldfire, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #10486

4 years agoUse a response file for linker command line arguments #10777
Michael Snoyman [Wed, 2 Sep 2015 11:31:25 +0000 (13:31 +0200)] 
Use a response file for linker command line arguments #10777

On Windows, we're constrained to 32k bytes total for command line
arguments.  When building large projects, this limit can be exceeded.
This patch changes GHC to always use response files for linker
arguments, a feature first used by Microsoft compilers and added to GCC
(over a decade ago).

Alternatives here include:

* Only use this method on Windows systems
* Check the length of the command line arguments and use that to decide
  whether to use this method

I did not pursue either of these, as I believe it would make the patch
more likely to break in less tested situations.

Test Plan:
Confirm that linking still works in general. Ideally: compile a very
large project on Windows with this patch. (I am attempting to do that
myself now, but having trouble getting the Windows build tool chain up
and running.)

Reviewers: goldfire, hvr, rwbarton, austin, thomie, bgamari, Phyx

Reviewed By: thomie, bgamari, Phyx

Subscribers: erikd, awson, #ghc_windows_task_force, thomie

Differential Revision:

GHC Trac Issues: #8596, #10777

4 years agoAdd test for updating a record with existentially quantified fields.
Matthew Pickering [Wed, 2 Sep 2015 11:28:34 +0000 (13:28 +0200)] 
Add test for updating a record with existentially quantified fields.

Test Plan: ./validate

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

4 years agoFix trac #10413
Ben Gamari [Wed, 2 Sep 2015 11:26:22 +0000 (13:26 +0200)] 
Fix trac #10413

Test Plan: Validate.

Reviewers: austin, tibbe, bgamari

Reviewed By: tibbe, bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #10413

4 years agoUse IP based CallStack in error and undefined
Eric Seidel [Wed, 2 Sep 2015 08:22:01 +0000 (10:22 +0200)] 
Use IP based CallStack in error and undefined

This patch modifies `error`, `undefined`, and `assertError` to use
implicit call-stacks to provide better error messages to users.

There are a few knock-on effects:

- `GHC.Classes.IP` is now wired-in so it can be used in the wired-in
  types for `error` and `undefined`.

- `TysPrim.tyVarList` has been replaced with a new function
  `TysPrim.mkTemplateTyVars`. `tyVarList` made it easy to introduce
  subtle bugs when you need tyvars of different kinds. The naive

  tv1 = head $ tyVarList kind1
  tv2 = head $ tyVarList kind2

  would result in `tv1` and `tv2` sharing a `Unique`, thus substitutions
  would be applied incorrectly, treating `tv1` and `tv2` as the same
  tyvar. `mkTemplateTyVars` avoids this pitfall by taking a list of kinds
  and producing a single tyvar of each kind.

- The types `GHC.SrcLoc.SrcLoc` and `GHC.Stack.CallStack` now live in

- The type `GHC.Exception.ErrorCall` has a new constructor
  `ErrorCallWithLocation` that takes two `String`s instead of one, the
  2nd one being arbitrary metadata about the error (but usually the
  call-stack). A bi-directional pattern synonym `ErrorCall` continues to
  provide the old API.

Updates Cabal, array, and haddock submodules.

Reviewers: nh2, goldfire, simonpj, hvr, rwbarton, austin, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, rodlogic, goldfire, maoe, simonmar, carter,
liyang, bgamari, thomie

Differential Revision:

GHC Trac Issues: #5273

4 years agoTestsuite: refactoring only
Thomas Miedema [Fri, 28 Aug 2015 10:03:30 +0000 (12:03 +0200)] 
Testsuite: refactoring only

* Rename `platform_wordsize_qualify` to `find_expected_file`, and make
  it return a filename instead of an (absolute) filepath.

* Replace most usages of `qualify` by `in_testdir`. Others usage sites
  will be deleted in a later commit.

These changes will be useful in a later commit, when we'll distinguish
between files in the source directory and those in a (newly created)
test directory.

Reviewed by: austin, bgamari

Differential Revision:

4 years agoAnchor type family instances deterministically
Bartosz Nitka [Mon, 31 Aug 2015 15:10:34 +0000 (16:10 +0100)] 
Anchor type family instances deterministically

This is very similar to D1073. It makes type family instances to be
attached to a binding with a least `OccName`, therefore not depending on `Unique` ordering.

Test Plan:
* this makes `Language.Haskell.Exts.SrcLoc` deterministic
* ./validate

Reviewers: simonmar, austin, bgamari, simonpj

Reviewed By: simonpj

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #4012

4 years agoFix typo in pattern synonym documentation.
Matthew Pickering [Sun, 30 Aug 2015 16:31:01 +0000 (18:31 +0200)] 
Fix typo in pattern synonym documentation.

`MkT` is the name of the constructor whilst `T` is the name of
the type.

Reviewers: bgamari, austin

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #10787

4 years agoFix 7.10 validate
Matthew Pickering [Sun, 30 Aug 2015 16:30:51 +0000 (18:30 +0200)] 
Fix 7.10 validate

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

4 years agoStgCmmHeap: Re-add check for large static allocations
Ben Gamari [Thu, 27 Aug 2015 12:08:01 +0000 (14:08 +0200)] 
StgCmmHeap: Re-add check for large static allocations

This should at least help alleviate the annoyance of #4505. This
reintroduces a compile-time check originally added in
a278f3f02d09bc32b0a75d4a04d710090cde250f but dropped with the new code

4 years agointeger-gmp: optimise bitBigNat
Herbert Valerio Riedel [Sat, 29 Aug 2015 10:25:45 +0000 (12:25 +0200)] 
integer-gmp: optimise bitBigNat

This is a somewhat minor optimisation exploiting the static knowledge
of the operands involved allowing to save a few allocations.

Reviewers: austin, rwbarton, goldfire, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

4 years agoghc-pkg --enable-multi-instance should not complain about case sensitivity.
Edward Z. Yang [Sat, 29 Aug 2015 10:25:28 +0000 (12:25 +0200)] 
ghc-pkg --enable-multi-instance should not complain about case sensitivity.

Test Plan: validate

Reviewers: simonmar, bgamari, austin

Reviewed By: bgamari, austin

Subscribers: thomie

Differential Revision:

4 years agoFix identifier parsing in hp2ps
Yuras Shumovich [Sat, 29 Aug 2015 10:25:14 +0000 (12:25 +0200)] 
Fix identifier parsing in hp2ps

Now identifiers can start with a package key, which is a hash, so they
may also start with a digit. Identifiers always appear at the beginning
of a line, and numbers never appear here, soit's safe to allow
identifiers to start with a digit.

Test Plan: `concprog002` passes under `threaded2_hT` way

Reviewers: austin, bgamari, thomie

Reviewed By: austin, bgamari, thomie

Differential Revision:

GHC Trac Issues: #10661

4 years agoDwarf: Produce .dwarf_aranges section
Ben Gamari [Sat, 29 Aug 2015 10:25:04 +0000 (12:25 +0200)] 
Dwarf: Produce .dwarf_aranges section

Test Plan: Check with `readelf --debug-dump=ranges`

Reviewers: scpmw, austin

Subscribers: thomie

Differential Revision:

4 years agoDwarf: Produce {low,high}_pc attributes for compilation units
Ben Gamari [Sat, 29 Aug 2015 10:24:54 +0000 (12:24 +0200)] 
Dwarf: Produce {low,high}_pc attributes for compilation units

Some libraries (e.g. elfutils) need these otherwise they ignore our
DWARF annotations.

Test Plan: Test with elfutils' `readelf --debug-dump=cu_index`

Reviewers: scpmw, austin

Subscribers: thomie

Differential Revision:

4 years agoDwarf: Fix DW_AT_use_UTF8 attribute
Ben Gamari [Sat, 29 Aug 2015 10:24:14 +0000 (12:24 +0200)] 
Dwarf: Fix DW_AT_use_UTF8 attribute

Previously this was given in the body but not in the abbreviation table.
Who knows what sort of havoc this was wrecking.

Test Plan: Verify against DWARF4 specification

Reviewers: scpmw, austin

Subscribers: Tarrasch, thomie

Differential Revision:

4 years agoRespect GHC_CHARENC environment variable #10762
Michael Snoyman [Sat, 29 Aug 2015 10:23:48 +0000 (12:23 +0200)] 
Respect GHC_CHARENC environment variable #10762

Only supports UTF-8 as a value right now. I expect some discussion to go
on around the naming of this variable and whether it's valid to backport
it to GHC 7.10 (which would be my preference). The motivation here is
that, when capturing the output of GHC to a file, we often want to
ensure that the output is UTF-8, regardless of the actual character
encoding of the terminal/console.

On the other hand, we don't want to necessary change the
terminal/console encoding. The reason being:

* On Windows, this requires a global-esque change to the console
  codepage, which adversely affects other processes in the same console

* On all OSes, this can break features like smart quote auto-detection.

Test Plan:
Set LANG to C, GHC_CHARENC to UTF-8, and compile a Haskell source
file with a non-ASCII warning produced. The output who include the UTF-8
sequence instead of replacing it with ?.

Reviewers: austin, rwbarton, bgamari

Reviewed By: bgamari

Subscribers: hsyl20, thomie

Differential Revision:

GHC Trac Issues: #10762

4 years agoMake Generic (Proxy t) instance poly-kinded (fixes #10775)
RyanGlScott [Sat, 29 Aug 2015 10:23:31 +0000 (12:23 +0200)] 
Make Generic (Proxy t) instance poly-kinded (fixes #10775)

This amounts to enabling PolyKinds in GHC.Generics. However, explicit
kind signatures must be applied to the datatypes and typeclasses in
GHC.Generics to ensure that the Core which TcGenGenerics generates
is properly kinded.

Several of the typeclasses in GHC.Generics could be poly-kinded, but
this differential does not attempt to address this, since D493 already
addresses this.

Test Plan: ./validate

Reviewers: hvr, austin, dreixel, bgamari

Reviewed By: austin, dreixel, bgamari

Subscribers: goldfire, thomie

Differential Revision:

GHC Trac Issues: #10775

4 years agoAdd testcase for #7411
Ben Gamari [Thu, 27 Aug 2015 13:04:29 +0000 (15:04 +0200)] 
Add testcase for #7411

4 years agoRTS: Reduce MBLOCK_SPACE_SIZE on AArch64
Erik de Castro Lopo [Tue, 25 Aug 2015 02:07:45 +0000 (02:07 +0000)] 

Commit 0d1a8d09f4 added a two step allocator for 64 bit systems. This
allocator mmaps a huge (1 TB) chunk of memory out of which it does
smaller allocations. On AArch64/Arm64 linux, this mmap was failing
due to the Arm64 Linux kernel parameter CONFIG_ARM64_VA_BITS
defaulting to 39 bits.

Therefore reducing the AArch64 value for MBLOCK_SPACE_SIZE to make
this allocation 1/4 TB while remaining 1 TB for other archs.

Reviewers: ezyang, austin, bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #10682

4 years agobase: Remove a redundant 'return'
Simon Peyton Jones [Thu, 26 Mar 2015 11:06:12 +0000 (11:06 +0000)] 
base: Remove a redundant 'return'

4 years agoTysWiredIn: Shuffle code around
Ben Gamari [Wed, 26 Aug 2015 16:19:31 +0000 (18:19 +0200)] 
TysWiredIn: Shuffle code around

4 years agoMkIface: Introduce PatSynId, ReflectionId, DefMethId
Ben Gamari [Wed, 26 Aug 2015 16:14:31 +0000 (18:14 +0200)] 
MkIface: Introduce PatSynId, ReflectionId, DefMethId

Currently we don't persist these three "advisory" IdInfos through
interface files.  We easily could if needed.

4 years agoIfaceEnv: Clean up updNameCache a bit
Ben Gamari [Wed, 26 Aug 2015 16:10:21 +0000 (18:10 +0200)] 
IfaceEnv: Clean up updNameCache a bit

4 years agoMove newImplicitBinder to from IfaceEnv to BuildTyCl
Ben Gamari [Thu, 27 Aug 2015 06:01:21 +0000 (08:01 +0200)] 
Move newImplicitBinder to from IfaceEnv to BuildTyCl

4 years agoPrelNames: introduce dcQual in place of conName
Ben Gamari [Wed, 26 Aug 2015 16:03:00 +0000 (18:03 +0200)] 
PrelNames: introduce dcQual in place of conName

4 years agoRevert "Clean up handling of knownKeyNames"
Ben Gamari [Wed, 26 Aug 2015 23:00:52 +0000 (01:00 +0200)] 
Revert "Clean up handling of knownKeyNames"

This reverts commit 792446906c718a08f0870b58acbdf2cfdeb77770.

This commit was a failed part of an effort to split up D757. I'll need
to try again and make sure I build-test next time.

4 years agoClean up handling of knownKeyNames
Ben Gamari [Wed, 26 Aug 2015 15:58:25 +0000 (17:58 +0200)] 
Clean up handling of knownKeyNames

4 years agoBinIface: Clean up whitespace
Ben Gamari [Wed, 26 Aug 2015 15:56:06 +0000 (17:56 +0200)] 
BinIface: Clean up whitespace

4 years agoPrelNames: Clean up list a bit
Ben Gamari [Wed, 26 Aug 2015 15:50:33 +0000 (17:50 +0200)] 
PrelNames: Clean up list a bit

4 years agoTcDeriv: Kill dead code
Ben Gamari [Wed, 26 Aug 2015 15:46:22 +0000 (17:46 +0200)] 
TcDeriv: Kill dead code

4 years agotcRnDeclsi can use tcRnSrcDecls
Simon Peyton Jones [Mon, 23 Mar 2015 14:32:31 +0000 (14:32 +0000)] 
tcRnDeclsi can use tcRnSrcDecls

I'm not sure why tcRnDeclsi didn't call tcRnSrcDecls before, but now it
does.  About 20 lines of code vanish. Hooray.

4 years agoImplement lookupGlobal in TcEnv, and use it
Simon Peyton Jones [Fri, 20 Mar 2015 12:38:42 +0000 (12:38 +0000)] 
Implement lookupGlobal in TcEnv, and use it

This localises the (revolting) initTcForLookup function, exposing
instead the more civilised interface for lookupGlobal

4 years agoComments and white space
Simon Peyton Jones [Fri, 20 Mar 2015 12:36:22 +0000 (12:36 +0000)] 
Comments and white space

4 years agoFix algorithm.tex build and update with some new info.
Edward Z. Yang [Wed, 26 Aug 2015 17:16:05 +0000 (10:16 -0700)] 
Fix algorithm.tex build and update with some new info.

Signed-off-by: Edward Z. Yang <>
4 years Allow disabling of large-address-space
Erik de Castro Lopo [Tue, 25 Aug 2015 01:33:32 +0000 (11:33 +1000)] Allow disabling of large-address-space

Recent changes (commit 0d1a8d09f4) for 64 bit platforms allowed GHC
to mmap one huge (currently 1 terrabyte) memory region from which to
do its own allocations. This is enabled by default, but it would be
nice (even just from the point of view of testing) to be able to
disable this at configure time.

Test Plan: configure and grep mk/config.h for USE_LARGE_ADDRESS_SPACE

Reviewers: austin, ezyang, bgamari, rwbarton

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #10791

4 years agofix 64bit two-stage allocator on Solaris/AMD64 platform (#10790)
Karel Gardas [Tue, 25 Aug 2015 12:06:29 +0000 (14:06 +0200)] 
fix 64bit two-stage allocator on Solaris/AMD64 platform (#10790)

Test Plan: tested on Solaris 11/AMD64 when previous build failed

Reviewers: bgamari, austin, simonmar, gcampax, ezyang

Subscribers: thomie

Differential Revision:

4 years agoDelete ExtsCompat46 (#8330)
Thomas Miedema [Tue, 21 Jul 2015 12:59:55 +0000 (14:59 +0200)] 
Delete ExtsCompat46 (#8330)

We require ghc-7.8 to build HEAD (ghc-7.11).

Differential Revision:

4 years agoCheck options before warning about source imports.
Alex Rozenshteyn [Fri, 21 Aug 2015 19:42:16 +0000 (21:42 +0200)] 
Check options before warning about source imports.

Summary: Fixes T10637

Reviewers: austin, bgamari, thomie

Subscribers: dfordivam, simonpj, thomie

Differential Revision:

GHC Trac Issues: #10637

4 years agoBuild system: delete unused distrib/Makefile
Thomas Miedema [Sat, 15 Aug 2015 17:07:52 +0000 (19:07 +0200)] 
Build system: delete unused distrib/Makefile

4 years agoBuild system: simplify
Thomas Miedema [Sat, 15 Aug 2015 12:18:07 +0000 (14:18 +0200)] 
Build system: simplify

This will allow fixing #1851 more easily
("make install-strip" should work).

This reverts 57e2a81c589103b50da80a9e378b1a11285bd521:
  "On Cygwin, use a Cygwin-style path for /bin/install's destination"

Update submodule haddock and hsc2hs.

4 years agoRefactor: delete most of the module FastTypes
Thomas Miedema [Fri, 21 Aug 2015 08:44:54 +0000 (10:44 +0200)] 
Refactor: delete most of the module FastTypes

This reverses some of the work done in #1405, and goes back to the
assumption that the bootstrap compiler understands GHC-haskell.

In particular:
  * use MagicHash instead of _ILIT and _CLIT
  * pattern matching on I# if possible, instead of using iUnbox
  * use Int#/Char#/Addr# instead of the following type synonyms:
    - type FastInt   = Int#
    - type FastChar  = Char#
    - type FastPtr a = Addr#
  * inline the following functions:
    - iBox           = I#
    - cBox           = C#
    - fastChr        = chr#
    - fastOrd        = ord#
    - eqFastChar     = eqChar#
    - shiftLFastInt  = uncheckedIShiftL#
    - shiftR_FastInt = uncheckedIShiftRL#
    - shiftRLFastInt = uncheckedIShiftRL#
  * delete the following unused functions:
    - minFastInt
    - maxFastInt
    - uncheckedIShiftRA#
    - castFastPtr
    - panicDocFastInt and pprPanicFastInt
  * rename panicFastInt back to panic#

These functions remain, since they actually do something:
  * iUnbox
  * bitAndFastInt
  * bitOrFastInt

Test Plan: validate

Reviewers: austin, bgamari

Subscribers: rwbarton

Differential Revision:

GHC Trac Issues: #1405

4 years agoDelete FastBool
Thomas Miedema [Fri, 21 Aug 2015 08:38:06 +0000 (10:38 +0200)] 
Delete FastBool

This reverses some of the work done in Trac #1405, and assumes GHC is
smart enough to do its own unboxing of booleans now.

I would like to do some more performance measurements, but the code
changes can be reviewed already.

Test Plan:
With a perf build:
./inplace/bin/ghc-stage2 nofib/spectral/simple/Main.hs -fforce-recomp
+RTS -t --machine-readable

  [("bytes allocated", "1300744864")
  ,("num_GCs", "302")
  ,("average_bytes_used", "8811118")
  ,("max_bytes_used", "24477464")
  ,("num_byte_usage_samples", "9")
  ,("peak_megabytes_allocated", "64")
  ,("init_cpu_seconds", "0.001")
  ,("init_wall_seconds", "0.001")
  ,("mutator_cpu_seconds", "2.833")
  ,("mutator_wall_seconds", "4.283")
  ,("GC_cpu_seconds", "0.960")
  ,("GC_wall_seconds", "0.961")

  [("bytes allocated", "1301088064")
  ,("num_GCs", "310")
  ,("average_bytes_used", "8820253")
  ,("max_bytes_used", "24539904")
  ,("num_byte_usage_samples", "9")
  ,("peak_megabytes_allocated", "64")
  ,("init_cpu_seconds", "0.001")
  ,("init_wall_seconds", "0.001")
  ,("mutator_cpu_seconds", "2.876")
  ,("mutator_wall_seconds", "4.474")
  ,("GC_cpu_seconds", "0.965")
  ,("GC_wall_seconds", "0.979")

CPU time seems to be up a bit, but I'm not sure. Unfortunately CPU time
measurements are rather noisy.

Reviewers: austin, bgamari, rwbarton

Subscribers: nomeata

Differential Revision:

GHC Trac Issues: #1405

4 years agoImplement getSizeofMutableByteArrayOp primop
Ben Gamari [Fri, 21 Aug 2015 08:37:39 +0000 (10:37 +0200)] 
Implement getSizeofMutableByteArrayOp primop

Now since ByteArrays are mutable we need to be more explicit about when
the size is queried.

Test Plan: Add testcase and validate

Reviewers: goldfire, hvr, austin

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #9447

4 years agoBag: Add Foldable instance
Ben Gamari [Tue, 18 Aug 2015 17:17:50 +0000 (19:17 +0200)] 
Bag: Add Foldable instance

4 years agoGhcMake: Fix spelling in comment
Ben Gamari [Tue, 18 Aug 2015 17:17:22 +0000 (19:17 +0200)] 
GhcMake: Fix spelling in comment

4 years agoDelete sync-all
Thomas Miedema [Thu, 20 Aug 2015 22:47:16 +0000 (00:47 +0200)] 
Delete sync-all

4 years agoBuild system: delete half-baked Cygwin support
Thomas Miedema [Sat, 15 Aug 2015 09:36:44 +0000 (11:36 +0200)] 
Build system: delete half-baked Cygwin support

We only support building GHC on mys2 nowadays, see

This (partially) reverts various commits from a few years ago, among which:
  * 5775d5142da227d65fb86994d363eb16841ee642
    "Add OSTYPE build-system variable, and use it"
  * 3fb8c431824aa2f3bd979e35d1a283546fcfbe74
    "Fix building libgmp on cygwin"
  * cdbb4720c424500adb57cbbef69721d0b039fa46
    "Fix cmd invocation by libffi cuild system on Windows 7 cygwin"
  * e8121501ee3549a35e954726ccfd871ac9d51f83
    "Fix dblatex and xml* tool detection on Windows"

Reviewed by: austin, Phyx

Differential Revision:

4 years agoComments reformating/corrections
Divam [Tue, 18 Aug 2015 16:08:26 +0000 (18:08 +0200)] 
Comments reformating/corrections

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

4 years agoAdd selectors for common fields (DataCon/PatSyn) to ConLike
Matthew Pickering [Tue, 18 Aug 2015 16:07:18 +0000 (18:07 +0200)] 
Add selectors for common fields (DataCon/PatSyn) to ConLike

When pattern synonyms were introduced a new sum type was used
in places where DataCon used to be used. PatSyn and DataCon share many
of the same fields, this patch adds selectors to ConLike for these

Reviewers: austin, goldfire, bgamari

Subscribers: thomie

Differential Revision:

4 years agorts/Printer.c: speed up '-Da' printer for 'LIBBFD' build
Sergei Trofimovich [Tue, 18 Aug 2015 16:06:41 +0000 (18:06 +0200)] 
rts/Printer.c: speed up '-Da' printer for 'LIBBFD' build

Patch switches from linear lookup in unordered array
to a hash table lookup.

When debugging GHC array contains 658_445 elements.

Found performance gap when tried to debug blackholes.

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

Subscribers: thomie

Differential Revision:

4 years agoFix rdynamic flag and test on Windows
Tamar Christina [Tue, 18 Aug 2015 15:59:04 +0000 (17:59 +0200)] 
Fix rdynamic flag and test on Windows

The rdynamic tests and feature are marked broken on windows.
This is because the flag used doesn't exist and the symbol lookup
in the test did not account for platform differences in name mangling.

This commit fixes the flag and tests for rdynamic on windows.

Test Plan:
make TEST="rdynamic"

on both x86 and x86_64

Reviewers: austin, thomie, bgamari

Reviewed By: thomie, bgamari

Subscribers: #ghc_windows_task_force

Differential Revision:

GHC Trac Issues: #9381

4 years agoDump files always use UTF8 encoding #10762
Michael Snoyman [Tue, 18 Aug 2015 15:58:36 +0000 (17:58 +0200)] 
Dump files always use UTF8 encoding #10762

When the Windows codepage or *nix LANG variable is something besides
UTF-8, dumping to file can cause GHC to exit currently. This changes the
output encoding for files to match the defined input encoding for
Haskell source code (UTF-8), making it easier for users and build tools
to capture this output.

Test Plan:
Create a Haskell source file with non-Latin characters for identifier
names and
compile with:

LANG=C ghc -ddump-to-file -ddump-hi filename.hs -fforce-recomp

Without this patch, it will fail. With this patch, it succeeds

Reviewers: austin, rwbarton, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #10762

4 years agoTransliterate unknown characters at output
Michael Snoyman [Tue, 18 Aug 2015 15:58:02 +0000 (17:58 +0200)] 
Transliterate unknown characters at output

This avoids the compiler from crashing when, for example, a warning
contains a non-Latin identifier and the LANG variable is set to C.
Fixes #6037.

Test Plan:
Create a Haskell source file containing an identifier with non-Latin
characters and no type signature. Compile with `LANG=C ghc -Wall
foo.hs`, and it should fail. With this patch, it will succeed.

Reviewers: austin, rwbarton, bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #6037, #10762

4 years agoMake rts/ThreadLabels.c threadsafe for debug runtime.
Sergei Trofimovich [Mon, 17 Aug 2015 22:14:42 +0000 (23:14 +0100)] 
Make rts/ThreadLabels.c threadsafe for debug runtime.

rts/ThreadLabels.c has a global hashtable for each
running haskell thread. It's not synchronized across
OS threads.

Was discovered when ran -debug build of ghc itself as:

    $ ghc-stage2 -j8 +RTS -A256M -l

and glibc detected double-free corruption:

    #2  in __libc_message (do_abort=do_abort@entry=2,
        fmt=fmt@entry=0x7fe0bcebf368 "*** Error in `%s': %s: 0x%s ***\n")
    #3  in malloc_printerr (action=3, str=0x7fe0bcebf4c0 "double free or corruption (fasttop)",
        ptr=<optimized out>)
    #4  in _int_free (av=<optimized out>, p=<optimized out>, have_lock=0)
    #5  in stgFree (p=0x7fe060001820) at rts/RtsUtils.c:108
    #6  in freeHashTable (table=0x5929320, freeDataFun=0x36374df <stgFree>) at rts/Hash.c:360
    #7  in freeThreadLabelTable () at rts/ThreadLabels.c:37
    #8  in hs_exit_ (wait_foreign=rtsFalse) at rts/RtsStartup.c:403
    #9  in shutdownHaskellAndExit (n=0, fastExit=0) at rts/RtsStartup.c:481
    #10 in hs_main (...) at rts/RtsMain.c:91
    #11 in main (...) at ghc/hschooks.c:63

Exposed itself after commit:

> commit f6866824ce5cdf5359f0cad78c49d65f6d43af12
> Author: Sergei Trofimovich <>
> Date:   Mon Aug 4 08:10:33 2014 -0500
>     ghc --make: add nicer names to RTS threads (threaded IO manager, make workers)

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

Reviewed By: ezyang, bgamari

Subscribers: thomie

Differential Revision: