ghc.git
23 months agoAdd hadrian as a submodule
Ben Gamari [Fri, 8 Dec 2017 18:02:06 +0000 (13:02 -0500)] 
Add hadrian as a submodule

It will remain a submodule until we are ready to merge Hadrian into the
tree.

23 months agoRip out hadrian subtree
Ben Gamari [Fri, 8 Dec 2017 17:42:35 +0000 (12:42 -0500)] 
Rip out hadrian subtree

Sadly subtrees haven't worked quite as well as we would have liked for
developers. See Hadrian #440.

23 months agoOccurrrence analysis improvements for NOINLINE functions
Simon Peyton Jones [Fri, 8 Dec 2017 15:39:05 +0000 (15:39 +0000)] 
Occurrrence analysis improvements for NOINLINE functions

This patch fixes #14567.  The idea is simple: if a function
is marked NOINLINE then it makes a great candidate for a loop
breaker.

Implementation is easy too, but it needs a little extra plubming,
notably the occ_unf_act field in OccEnv

23 months agoImprove LiberateCase
Simon Peyton Jones [Fri, 8 Dec 2017 15:31:36 +0000 (15:31 +0000)] 
Improve LiberateCase

This patch, which fixes Trac #14566, makes LiberateCase a little
more conservative.  In particular:

* In libCaseBind, treat a recursive group as a whole, rather than
  binding-by-binding, allowing the group to be duplicated only if
    - the bindings /considered together/ are smaller than the
      liberate-case threshold (which is large by default)
    - none of them are thunks
    - none of them are guaranteed-diverging

  The latter condidtion is new, and happens to apply in the
  case of Data/Typeable/Internal.mkTrApp

23 months agoRefactor kcHsTyVarBndrs
Simon Peyton Jones [Thu, 7 Dec 2017 14:31:53 +0000 (14:31 +0000)] 
Refactor kcHsTyVarBndrs

This refactoring

* Renames kcHsTyVarBndrs to kcLHsQTyVars,
  which is more truthful. It is only used in getInitialKind.

* Pulls out bind_telescope from that function, and calls it
  kcLHsTyVarBndrs, again to reflect its argument

* Uses the new kcLHsTyVarBndrs in kcConDecl, where the old
  function was wild overkill.

There should not be any change in behaviour

23 months agoRevert accidental hsc2hs submodule downgrade
Herbert Valerio Riedel [Thu, 7 Dec 2017 19:05:56 +0000 (20:05 +0100)] 
Revert accidental hsc2hs submodule downgrade

This submodule update was committed unintentionally in
fa29df02a1b0b926afb2525a258172dcbf0ea460

23 months agoRefactor ConDecl: Trac #14529
Simon Peyton Jones [Tue, 28 Nov 2017 11:33:37 +0000 (11:33 +0000)] 
Refactor ConDecl: Trac #14529

This patch refactors HsDecls.ConDecl.  Specifically

* ConDeclGADT was horrible, with all the information hidden
  inside con_res_ty.  Now it's kept separate, as it should be.

* ConDeclH98: use [LHsTyVarBndr] instead of LHsQTyVars for the
  existentials. There is no implicit binding here.

* Add a field con_forall to both ConDeclGADT and ConDeclH98
  which says if there is an explicit user-written forall.

* Field renamings in ConDecl
     con_cxt     to con_mb_cxt
     con_details to con_args

There is an accompanying submodule update to Haddock.

Also the following change turned out to remove a lot of clutter:

* add a smart constructor for HsAppsTy, namely mkHsAppsTy,
  and use it consistently. This avoids a lot of painful pattern
  matching for the common singleton case.

Two api-annotation tests (T10278, and T10399) are broken, hence marking
them as expect_broken(14529).  Alan is going to fix them, probably by
changing the con_forall field to
   con_forall :: Maybe SrcSpan
instead of Bool

23 months agoForward-port changes from GHC 8.2 branch
Herbert Valerio Riedel [Thu, 7 Dec 2017 08:58:00 +0000 (09:58 +0100)] 
Forward-port changes from GHC 8.2 branch

(cherry picked from commit 3fa061a647d2fdc182eff9296eea02d6a7d516cd)

23 months agoutils/hsc2hs: update submodule
Sergei Trofimovich [Tue, 5 Dec 2017 07:51:16 +0000 (07:51 +0000)] 
utils/hsc2hs: update submodule

This pulls single change to fix building of cross-compilers:
* ghc.mk: Use the same conditional install logic from unlit

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

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

23 months agorts: fix filename case for mingw32 target
Sergei Trofimovich [Tue, 5 Dec 2017 07:49:24 +0000 (07:49 +0000)] 
rts: fix filename case for mingw32 target

The failure is visible when we build a cross-compiler
from linux to mingw32 as:

```
    $ ./configure --host=x86_64-pc-linux-gnu \
                  --target=x86_64-w64-mingw32
    $ make
    rts/linker/PEi386.c:159:10: error:
         fatal error: Psapi.h: No such file or directory
         #include <Psapi.h>
                  ^~~~~~~~~
        |
    159 | #include <Psapi.h>
        |          ^
```

The problem here is case-sensitive linux filesystem. On windows
it does not matter what case is used for includes and libraries.

mingw32 provides all libraries and headers lowercase. This change
fixes case for <dbghelp.h>, <psapi.h>, -ldbghelp, -lpsapi.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Reviewers: bgamari, erikd, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

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

23 months agoBump version to 8.5 ghc-8.5-start
Ben Gamari [Wed, 29 Nov 2017 14:54:14 +0000 (09:54 -0500)] 
Bump version to 8.5

The ghc-8.4 branch has now been cut. Updates the haddock submodule.

23 months agoFix ghc_packages
Ben Gamari [Mon, 4 Dec 2017 21:15:52 +0000 (16:15 -0500)] 
Fix ghc_packages

The LaTeX produced by this previously failed to compile. Changing the first cell
of the row from an inline to a paragraph fixes this. Then I noticed that the
table overflowed the page. This is fixed by applying the longtable class.

23 months agotemplate-haskell: Rip out FamFlavour
Ben Gamari [Mon, 4 Dec 2017 18:50:36 +0000 (13:50 -0500)] 
template-haskell: Rip out FamFlavour

This was scheduled to happen for 8.2, it looks like it will actually
happen in 8.4.

23 months agoMake the Con and Con' patterns produce evidence
David Feuer [Mon, 4 Dec 2017 13:27:18 +0000 (08:27 -0500)] 
Make the Con and Con' patterns produce evidence

Matching with the `Con` and `Con'` patterns can reveal evidence
that the type in question is *not* an application. This can help
the pattern checker.

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: carter, rwbarton, thomie

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

23 months agoCache TypeRep kinds aggressively
David Feuer [Fri, 1 Dec 2017 22:00:24 +0000 (17:00 -0500)] 
Cache TypeRep kinds aggressively

Cache `TypeRep k` in each `TrApp` or `TrTyCon` constructor of
`TypeRep (a :: k)`. This makes `typeRepKind` cheap.

With this change, we won't need any special effort to deserialize
typereps efficiently. The downside, of course, is that we make
`TypeRep`s slightly larger.

Reviewers: austin, hvr, bgamari, simonpj

Reviewed By: bgamari, simonpj

Subscribers: carter, simonpj, rwbarton, thomie

GHC Trac Issues: #14254

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

23 months agoAdd trace injection
David Feuer [Fri, 1 Dec 2017 20:59:24 +0000 (15:59 -0500)] 
Add trace injection

Add support for injecting runtime calls to `trace` in `DsM`. This
allows the desugarer to add compile-time information to a runtime
trace.

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: carter, thomie, rwbarton

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

23 months agoHandle CPP properly in Backpack
Edward Z. Yang [Sat, 25 Nov 2017 02:12:05 +0000 (10:12 +0800)] 
Handle CPP properly in Backpack

Summary:
Previously, we attempted to lookup 'hole' packages for
include directories; this obviously is not going to work.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Test Plan: validate

Reviewers: ekmett, bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #14525

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

23 months agoMake use of boot TyThings during typechecking.
Edward Z. Yang [Mon, 30 Oct 2017 00:15:07 +0000 (20:15 -0400)] 
Make use of boot TyThings during typechecking.

Summary:
Suppose that you are typechecking A.hs, which transitively imports,
via B.hs, A.hs-boot.  When we poke on B.hs and discover that it
has a reference to a type from A, what TyThing should we wire
it up with?  Clearly, if we have already typechecked A, we
should use the most up-to-date TyThing: the one we freshly
generated when we typechecked A.  But what if we haven't typechecked
it yet?

For the longest time, GHC adopted the policy that this was
*an error condition*; that you MUST NEVER poke on B.hs's reference
to a thing defined in A.hs until A.hs has gotten around to checking
this.  However, actually ensuring this is the case has proven
to be a bug farm.  The problem was especially poignant with
type family consistency checks, which eagerly happen before
any typechecking takes place.

This patch takes a different strategy: if we ever try to access
an entity from A which doesn't exist, we just fall back on the
definition of A from the hs-boot file.  This means that you may
end up with a mix of A.hs and A.hs-boot TyThings during the
course of typechecking.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Test Plan: validate

Reviewers: simonpj, bgamari, austin, goldfire

Subscribers: thomie, rwbarton

GHC Trac Issues: #14396

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

23 months agoDarwin: Use gmp from homebrew
Ben Gamari [Wed, 29 Nov 2017 22:02:17 +0000 (17:02 -0500)] 
Darwin: Use gmp from homebrew

As discussed on ghc-devs, OS X appears to ship an old or otherwise broken gmp.

https://mail.haskell.org/pipermail/ghc-devs/2017-June/014321.html

23 months agoDarwin: Set deployment target
Ben Gamari [Wed, 29 Nov 2017 22:01:07 +0000 (17:01 -0500)] 
Darwin: Set deployment target

23 months agoBump unix submodule
Ben Gamari [Wed, 29 Nov 2017 20:23:41 +0000 (15:23 -0500)] 
Bump unix submodule

Fixes FreeBSD build.

23 months agoComments only: Trac #14511
Simon Peyton Jones [Tue, 28 Nov 2017 16:02:18 +0000 (16:02 +0000)] 
Comments only: Trac #14511

23 months agoMinor tweaks to codegens.rst
Steven Shaw [Wed, 29 Nov 2017 07:16:14 +0000 (17:16 +1000)] 
Minor tweaks to codegens.rst

A couple of nits involving the letter 'C'.

23 months agoCircleCI: Freeze all packages at fixed index state
Ben Gamari [Wed, 29 Nov 2017 15:22:50 +0000 (10:22 -0500)] 
CircleCI: Freeze all packages at fixed index state

We will periodically bump this as necessary.

23 months agoCircleCI: Disallow hscolour 1.24.3
Ben Gamari [Wed, 29 Nov 2017 14:58:42 +0000 (09:58 -0500)] 
CircleCI: Disallow hscolour 1.24.3

This release does not build.

23 months agoCLabel: A bit of documentation
Ben Gamari [Tue, 28 Nov 2017 20:35:32 +0000 (15:35 -0500)] 
CLabel: A bit of documentation

23 months agoCmm: Add missing cases for BlockInfoTable
Ben Gamari [Tue, 28 Nov 2017 19:32:34 +0000 (14:32 -0500)] 
Cmm: Add missing cases for BlockInfoTable

Silly rabbit, BlockInfoTables are data. This fixes the unregisterised build,
finally fixing #14454.

23 months agoCLabel: More specific debug output from CLabel
Ben Gamari [Tue, 28 Nov 2017 19:23:02 +0000 (14:23 -0500)] 
CLabel: More specific debug output from CLabel

23 months agonativeGen: Use foldl' instead of foldl
Ben Gamari [Tue, 28 Nov 2017 01:02:55 +0000 (20:02 -0500)] 
nativeGen: Use foldl' instead of foldl

23 months agonativeGen: Use plusUFMList instead of foldr
Ben Gamari [Tue, 28 Nov 2017 01:02:25 +0000 (20:02 -0500)] 
nativeGen: Use plusUFMList instead of foldr

23 months agoCLabel: Refactor pprDynamicLinkerAsmLabel
Ben Gamari [Tue, 14 Nov 2017 19:58:40 +0000 (14:58 -0500)] 
CLabel: Refactor pprDynamicLinkerAsmLabel

23 months agocmm: Use LocalBlockLabel instead of AsmTempLabel to represent blocks
Ben Gamari [Mon, 13 Nov 2017 17:34:54 +0000 (12:34 -0500)] 
cmm: Use LocalBlockLabel instead of AsmTempLabel to represent blocks

blockLbl was originally changed in 8b007abbeb3045900a11529d907a835080129176 to
use mkTempAsmLabel to fix an inconsistency resulting in #14221. However, this
breaks the C code generator, which doesn't support AsmTempLabels (#14454).

Instead let's try going the other direction: use a new CLabel variety,
LocalBlockLabel. Then we can teach the C code generator to deal with
these as well.

23 months agoCLabel.labelType: Make catch-all case explicit
Ben Gamari [Tue, 14 Nov 2017 22:34:36 +0000 (17:34 -0500)] 
CLabel.labelType: Make catch-all case explicit

23 months agobase: Rip out old RTS statistics interface
Ben Gamari [Mon, 27 Nov 2017 19:02:56 +0000 (14:02 -0500)] 
base: Rip out old RTS statistics interface

Test Plan: Validate

Reviewers: simonmar, hvr

Subscribers: rwbarton, thomie

GHC Trac Issues: #14516

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

23 months agorelnotes: Rework treatment of included package list
Ben Gamari [Mon, 27 Nov 2017 19:01:02 +0000 (14:01 -0500)] 
relnotes: Rework treatment of included package list

Previously the included package lists took a disproportionate amount of
space in the resulting document and were difficult to maintain. Turn it
into a table.

Subscribers: rwbarton, thomie

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

23 months agoDon't call alex for Cabal lib during GHC build
Tobias Dammers [Mon, 27 Nov 2017 19:00:50 +0000 (14:00 -0500)] 
Don't call alex for Cabal lib during GHC build

The Cabal library now commits `Lexer.hs` directly to the source tree,
so the build step where we'd call alex ourselves to generate that file
is no longer necessary, nor will it work.

See also: https://ghc.haskell.org/trac/ghc/ticket/14459

Reviewers: bgamari, hvr

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14459

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

23 months agotypecheck: Consistently use pretty quotes in error messages
Ben Gamari [Mon, 27 Nov 2017 19:00:06 +0000 (14:00 -0500)] 
typecheck: Consistently use pretty quotes in error messages

Subscribers: rwbarton, thomie, carter

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

23 months agoCheck quantification for partial type signatues
Simon Peyton Jones [Tue, 14 Nov 2017 15:26:19 +0000 (15:26 +0000)] 
Check quantification for partial type signatues

Trac #14449 showed that we were failing to check that the
quantified type variables of a partial type signature remained
distinct.

See Note [Quantified variables in partial type signatures]
in TcBinds.

A little refactoring along the way.

23 months agoboot: Eliminate superfluous output
Ben Gamari [Mon, 27 Nov 2017 15:20:59 +0000 (10:20 -0500)] 
boot: Eliminate superfluous output

23 months agoRtsFlags: allow +RTS -K0
Ben Gamari [Mon, 27 Nov 2017 14:46:55 +0000 (09:46 -0500)] 
RtsFlags: allow +RTS -K0

Reviewers: erikd, simonmar, hvr

Reviewed By: hvr

Subscribers: hvr, rwbarton, thomie

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

23 months agoAdd obvious Outputable Integer instance.
klebinger.andreas@gmx.at [Mon, 27 Nov 2017 14:46:32 +0000 (09:46 -0500)] 
Add obvious Outputable Integer instance.

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

23 months agoFollow symlinks in the Win32 code for System.Environment.getExecutablePath
Alp Mestanogullari [Mon, 27 Nov 2017 14:45:52 +0000 (09:45 -0500)] 
Follow symlinks in the Win32 code for System.Environment.getExecutablePath

This partially addresses #14483 by fixing the Windows implementation of
System.Environment.getExecutablePath. This is achieved by using
GetFinalPathNameByHandleW to resolve potential symlinks, while making
sure we do not get back a UNC path (see #14460).

Test Plan: Validate

Reviewers: Phyx, bgamari, angerman, hvr, goldfire

Reviewed By: Phyx, bgamari

GHC Trac Issues: #14483

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

23 months agoDon't complain about UNPACK in -fno-code.
Edward Z. Yang [Mon, 27 Nov 2017 14:45:23 +0000 (09:45 -0500)] 
Don't complain about UNPACK in -fno-code.

Test Plan: validate

Reviewers: ekmett, austin, bgamari

Reviewed By: bgamari

Subscribers: duog, goldfire, rwbarton, thomie

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

23 months agoCircleCI: Reenable artifact collection on Darwin
Ben Gamari [Thu, 23 Nov 2017 20:03:18 +0000 (15:03 -0500)] 
CircleCI: Reenable artifact collection on Darwin

Supposedly the original issue has been fixed.

23 months agobase: fdReady(): Fix timeouts > ~49 days overflowing. Fixes #14262.
Niklas Hambüchen [Thu, 23 Nov 2017 18:17:24 +0000 (13:17 -0500)] 
base: fdReady(): Fix timeouts > ~49 days overflowing. Fixes #14262.

On 64-bit UNIX and Windows, Haskell `Int` has 64 bits
but C `int msecs` has 32 bits, resulting in an overflow.

This commit fixes it by switching fdReady() to take int64_t,
into which a Haskell `Int` will always fit.

(Note we could not switch to `long long` because that is
32 bit on 64-bit Windows machines.)

Further, to be able to actually wait longer than ~49 days,
we put loops around the waiting syscalls (they all accept only
32-bit integers).

Note the timer signal would typically interrupt the syscalls
before the ~49 days are over, but you can run Haskell programs
without the timer signal, an we want it to be correct in all
cases.

Reviewers: bgamari, austin, hvr, NicolasT, Phyx

Reviewed By: bgamari, Phyx

Subscribers: syd, Phyx, rwbarton, thomie

GHC Trac Issues: #14262

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

23 months agousers-guide: Fix :default: placement
Ben Gamari [Thu, 23 Nov 2017 18:14:33 +0000 (13:14 -0500)] 
users-guide: Fix :default: placement

23 months agoDynFlags: Expand $topdir in --info output
Ben Gamari [Thu, 23 Nov 2017 18:05:30 +0000 (13:05 -0500)] 
DynFlags: Expand $topdir in --info output

Test Plan: Try running nofib on Windows

Reviewers: Phyx

Subscribers: rwbarton, thomie

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

23 months agoSysTools: Split up TopDir logic into new module
Ben Gamari [Thu, 23 Nov 2017 18:05:05 +0000 (13:05 -0500)] 
SysTools: Split up TopDir logic into new module

Test Plan: Validate on Linux and Windows

Reviewers: erikd

Subscribers: rwbarton, thomie

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

23 months agoSysTools: Expand occurrences of $topdir anywhere in a Settings path
Ben Gamari [Thu, 23 Nov 2017 18:04:55 +0000 (13:04 -0500)] 
SysTools: Expand occurrences of $topdir anywhere in a Settings path

Subscribers: rwbarton, thomie, Phyx

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

23 months agorts/Printer: add closure name entries for small arrays (Fixes #14513)
Takano Akio [Thu, 23 Nov 2017 17:17:24 +0000 (12:17 -0500)] 
rts/Printer: add closure name entries for small arrays (Fixes #14513)

Test Plan: ./validate

Reviewers: bgamari, erikd, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #14513

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

23 months agoCircleCI: Install lbzip2 and patch
Ben Gamari [Wed, 22 Nov 2017 17:07:29 +0000 (12:07 -0500)] 
CircleCI: Install lbzip2 and patch

tar needs lbzip2 to extract the GMP tarball. Patch is needed to, well, patch.

23 months agocircleci: Build with Hadrian
Ben Gamari [Sat, 18 Nov 2017 19:50:24 +0000 (14:50 -0500)] 
circleci: Build with Hadrian

23 months agoCircleCI: Try validating LLVM as well
Ben Gamari [Sun, 12 Nov 2017 00:04:42 +0000 (19:04 -0500)] 
CircleCI: Try validating LLVM as well

23 months agoCircleCI: Perform nightly validation of unregisterised build
Ben Gamari [Sat, 11 Nov 2017 23:53:56 +0000 (18:53 -0500)] 
CircleCI: Perform nightly validation of unregisterised build

23 months agoFix README
Ben Gamari [Thu, 23 Nov 2017 14:53:30 +0000 (09:53 -0500)] 
Fix README

This was unfortunately overwritten by the Hadrian README in a previous
Hadrian merge.

23 months agoRevert "Add new mbmi and mbmi2 compiler flags"
Ben Gamari [Wed, 22 Nov 2017 19:27:55 +0000 (14:27 -0500)] 
Revert "Add new mbmi and mbmi2 compiler flags"

This broke the 32-bit build.

This reverts commit f5dc8ccc29429d0a1d011f62b6b430f6ae50290c.

23 months agoUpdate Hadrian
Ben Gamari [Wed, 22 Nov 2017 13:50:45 +0000 (08:50 -0500)] 
Update Hadrian

23 months agoSquashed 'hadrian/' changes from fa3771fe6b..4499b294e4
Ben Gamari [Wed, 22 Nov 2017 13:47:55 +0000 (08:47 -0500)] 
Squashed 'hadrian/' changes from fa3771fe6b..4499b294e4

4499b294e4 Follow GHC changes
8fd68186b2 Add ways to build hadrian using nix
e5c7a29c23 Do not depend on the in-tree filepath library
9dd7ad2acc Fix dependencies
497184390e Bring mtl dependency back
6c5f5c9bd9 Minor clean up of Hadrian dependencies
9aff81d424 Fix Windows build
fa95caa8df Unbreak `cabal new-build`

git-subtree-dir: hadrian
git-subtree-split: 4499b294e4a53f71f8808d6eb55a7dd0b341cfb8

2 years agoErrUtils: Ensure timing dumps are always output on one line
Ben Gamari [Wed, 22 Nov 2017 03:59:28 +0000 (22:59 -0500)] 
ErrUtils: Ensure timing dumps are always output on one line

This output is supposed to be machine-readable; having random line-breaks
defeats this.

2 years agoErrUtils: Refactor dump file logic
Ben Gamari [Wed, 22 Nov 2017 03:57:27 +0000 (22:57 -0500)] 
ErrUtils: Refactor dump file logic

This refactors the dump file setup path, separating concerns a bit. It also
fixes an exception-unsafe usage of openFile.

2 years agoBump stm submodule
Ben Gamari [Wed, 22 Nov 2017 04:00:13 +0000 (23:00 -0500)] 
Bump stm submodule

2 years agobase: Remove redundant subtraction in (^) and stimes
Ben Gamari [Wed, 22 Nov 2017 02:15:29 +0000 (21:15 -0500)] 
base: Remove redundant subtraction in (^) and stimes

Subtraction `y - 1` is redundant. The value of y is guaranteed to be
positive and odd, so
```
(y - 1) `quot` 2` = `y `quot` 2
```

Test Plan: validate

Reviewers: hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #14439

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

2 years agocmm: Optimise remainders by powers of two
Ben Gamari [Wed, 22 Nov 2017 02:14:31 +0000 (21:14 -0500)] 
cmm: Optimise remainders by powers of two

Test Plan: validate

Reviewers: bgamari, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #14437

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

2 years agotestsuite: Add test for #14257
Ben Gamari [Tue, 21 Nov 2017 23:30:17 +0000 (18:30 -0500)] 
testsuite: Add test for #14257

Subscribers: rwbarton, thomie, duog

GHC Trac Issues: #14257

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

2 years agoTest Trac #14488
Vladislav Zavialov [Tue, 21 Nov 2017 23:28:21 +0000 (18:28 -0500)] 
Test Trac #14488

Summary:
The refactoring in 3f5673f34a2f761423027bf46f64f7499708725f also fixed a
previously unreported issue in the typechecker that prevented defining a
lens to a record field with a constraint. This patch adds a regression
test.

Test Plan: make test TEST=14488

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: int-e, rwbarton, thomie

GHC Trac Issues: #14488

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

2 years agoRemove hadrian sub-dir from .gitignore
Matthew Pickering [Tue, 21 Nov 2017 23:26:16 +0000 (18:26 -0500)] 
Remove hadrian sub-dir from .gitignore

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

2 years agoUpdate leftover reference to refer to [FunBind vs PatBind]
klebinger.andreas@gmx.at [Tue, 21 Nov 2017 23:25:57 +0000 (18:25 -0500)] 
Update leftover reference to refer to [FunBind vs PatBind]

Reviewers: bgamari, mpickering

Reviewed By: mpickering

Subscribers: rwbarton, thomie, mpickering

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

2 years agoAdd warn-missing-export-lists
Evan Rutledge Borden [Tue, 21 Nov 2017 23:06:01 +0000 (18:06 -0500)] 
Add warn-missing-export-lists

Many industrial users have aligned around the idea that implicit exports
are an anti-pattern. They lead to namespace pollution and byzantine
naming schemes. They also prevent GHC's dead code analysis and create
more obstacles to optimization. This warning allows teams/projects to
warn on or enforce via -Werror explicit export lists.

This warning also serves as a complement to warn-missing-import-lists.

This was originally discussed here:
https://github.com/ghc-proposals/ghc-proposals/pull/93

Test Plan: Three new minimal tests have been added to the type checker.

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

2 years agorts: Fix inconsistencies in how retainer and heap censuses are timed.
Douglas Wilson [Tue, 21 Nov 2017 23:05:22 +0000 (18:05 -0500)] 
rts: Fix inconsistencies in how retainer and heap censuses are timed.

mut_elapsed should deduct retainer profiling and heap censuses, just as
mut_cpu does.

mutator_cpu_ns should not deduct retainer profiling or heap censuses,
since those times are included in stats.gc_cpu_ns.

Reviewers: bgamari, erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, thomie

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

2 years agorts: Move libdwPrintBacktrace to public interface
Ben Gamari [Tue, 21 Nov 2017 23:04:34 +0000 (18:04 -0500)] 
rts: Move libdwPrintBacktrace to public interface

Reviewers: erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, thomie

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

2 years agoUpdate ANNOUNCE
Ben Gamari [Tue, 21 Nov 2017 22:23:49 +0000 (17:23 -0500)] 
Update ANNOUNCE

2 years agoCircleCI: Add webhook for Harbormaster builds
Ben Gamari [Wed, 22 Nov 2017 00:20:49 +0000 (19:20 -0500)] 
CircleCI: Add webhook for Harbormaster builds

2 years agoRevert "trees that grow" work
Ben Gamari [Tue, 21 Nov 2017 19:28:58 +0000 (14:28 -0500)] 
Revert "trees that grow" work

As documented in #14490, the Data instances currently blow up
compilation time by too much to stomach. Alan will continue working on
this in a branch and we will perhaps merge to 8.2 before 8.2.1 to avoid
having to perform painful cherry-picks in 8.2 minor releases.

Reverts haddock submodule.

This reverts commit 47ad6578ea460999b53eb4293c3a3b3017a56d65.
This reverts commit e3ec2e7ae94524ebd111963faf34b84d942265b4.
This reverts commit 438dd1cbba13d35f3452b4dcef3f94ce9a216905.
This reverts commit 0ff152c9e633accca48815e26e59d1af1fe44ceb.

2 years agobase: Document GHC.Stack.CCS internals
Ben Gamari [Tue, 21 Nov 2017 19:27:51 +0000 (14:27 -0500)] 
base: Document GHC.Stack.CCS internals

Reviewers: hvr

Subscribers: rwbarton, thomie

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

2 years agoconfigure: Fix ar probed flags
Ben Gamari [Tue, 21 Nov 2017 19:27:11 +0000 (14:27 -0500)] 
configure: Fix ar probed flags

FP_PROG_AR_ARGS appears to be probing for what flags to use to build an
archive with an index. However, none of the flags that it probed
previously were valid as they all started with `c`, which isn't a mode
character. This went unnoticed until someone attempted to use LLVM ar
since we have a special case for gnu ar.

Additionally, we work around a bug in llvm-ar 5.0 where ar will exit
with code 0 even if it fails to parse the command line. Silliness.

I believe these should rather all be mode `q` however I'll need to test
this on a few platforms to be certain.

Test Plan: Validate on OS X, BSD, and Linux with binutils and llvm ar

Reviewers: hvr

Subscribers: rwbarton, thomie, erikd

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

2 years agoCircleCI: Disable artifact collection on OS X
Ben Gamari [Tue, 21 Nov 2017 19:22:22 +0000 (14:22 -0500)] 
CircleCI: Disable artifact collection on OS X

The storeartifacts step inexplicably hangs on OS X. I am currently be working
with CircleCI support to resolve this.

2 years agorel-notes: Fix up formatting in release notes
Ben Gamari [Mon, 20 Nov 2017 22:14:03 +0000 (17:14 -0500)] 
rel-notes: Fix up formatting in release notes

2 years agoghc-pkg: Add missing newlines to usage message
Ben Gamari [Mon, 20 Nov 2017 22:13:16 +0000 (17:13 -0500)] 
ghc-pkg: Add missing newlines to usage message

2 years agoBump haddock submodule
Ben Gamari [Mon, 20 Nov 2017 13:12:15 +0000 (08:12 -0500)] 
Bump haddock submodule

2 years agoBump hsc2hs submodule
Ben Gamari [Mon, 20 Nov 2017 03:13:07 +0000 (22:13 -0500)] 
Bump hsc2hs submodule

2 years agoStop generating make files when using hadrian.
Moritz Angermann [Mon, 20 Nov 2017 03:12:09 +0000 (22:12 -0500)] 
Stop generating make files when using hadrian.

The boot script generates lots of .mk files
for the make based build system. This change adds
a `--hadrian` flag to `boot`, which skips the `.mk`
file generation.

Reviewers: bgamari

Subscribers: rwbarton, thomie

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

2 years agoRename ghc-version -> ghcversion-file
Moritz Angermann [Mon, 20 Nov 2017 03:11:43 +0000 (22:11 -0500)] 
Rename ghc-version -> ghcversion-file

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

2 years agoFix #elfi -> #elif; unbreak -Werror.
Moritz Angermann [Sun, 19 Nov 2017 23:46:01 +0000 (18:46 -0500)] 
Fix #elfi -> #elif; unbreak -Werror.

Reviewers: bgamari, erikd

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

2 years agobase: Make documentation of atomically more accurate
Andrew Martin [Sat, 18 Nov 2017 19:43:20 +0000 (14:43 -0500)] 
base: Make documentation of atomically more accurate

2 years agoFix T4437
Bartosz Nitka [Sat, 18 Nov 2017 14:11:38 +0000 (14:11 +0000)] 
Fix T4437

This test tests if the flags are in sync between GHC and
Cabal.
After b0b80e9 'Implement the basics of hex floating point
literals' landed, the Cabal side had to be updated. That
has been done, and 835d8dd 'GHC.Prim use virtual-modules'
brought the Cabal submodule up to date.

2 years agoFix rts.cabal.in
Moritz Angermann [Sat, 18 Nov 2017 07:05:31 +0000 (15:05 +0800)] 
Fix rts.cabal.in

Overlap with commit 2f463873, resulted in `hooks/LongGCSync.c`
missing from the `rts.cabal.in` file.  As the `rts.cabal` file is only
used by hadrian, this did not trigger with the make base build
system which can do globbing.

Also ignore the `rts.cabal` file, as it's generated by configure
from the `rts.cabal.in`.

2 years agoRelocatable GHC
Moritz Angermann [Fri, 17 Nov 2017 07:04:50 +0000 (15:04 +0800)] 
Relocatable GHC

GHC and the binary distribution that's produced is
not relocatable outside of Windows.  This diff tries to
address this for at least Linux and macOS.

Reviewers: austin, hvr, bgamari, erikd, goldfire, Phyx

Reviewed By: bgamari

Subscribers: duog, rwbarton, thomie, erikd

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

2 years agoGHC.Prim use virtual-modules
Moritz Angermann [Thu, 16 Nov 2017 14:54:11 +0000 (22:54 +0800)] 
GHC.Prim use virtual-modules

Stop the GHC.Prim madness with `virtual-module` support from cabal.
Needs https://github.com/haskell/cabal/pull/4875.

Bumps submodule libraries/Cabal to include the necessary logic for `virtual-module`.

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

2 years agoAdds -ghc-version flag to ghc.
Moritz Angermann [Fri, 17 Nov 2017 11:29:25 +0000 (19:29 +0800)] 
Adds -ghc-version flag to ghc.

Summary:
When building the rts with ghc (e.g. using ghc as a c compiler), ghc's
"Value Add"[1] is, it includes adding `-include /path/to/ghcversion.h`.  For
this it looksup the rts package in the package database, which--if
empty--fails.  Thus to allow compiling C files with GHC, we add the
`-ghc-version` flag, which takes the path to the `ghcversion.h` file.

A `-no-ghc-version` flag was omitted, as at that point it becomes
questionable why one would use ghc to compile c if one doesn't
any of the added value.

--

[1] from `compiler/main/DriverPipeline.hs`
>        -- add package include paths even if we're just compiling .c
>        -- files; this is the Value Add(TM) that using ghc instead of
>        -- gcc gives you :)

Reviewers: bgamari, geekosaur, austin

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

2 years agoconfigure: Fix incorrect quoting
Ben Gamari [Thu, 16 Nov 2017 20:07:33 +0000 (15:07 -0500)] 
configure: Fix incorrect quoting

This is a regression affecting Windows introduced by
3bed4aa703c41ccbd310496420fbb71afdfd99e7.

2 years agoDocument -ddump-timings
Ben Gamari [Wed, 15 Nov 2017 22:28:48 +0000 (17:28 -0500)] 
Document -ddump-timings

2 years agoDetect overly long GC sync
Simon Marlow [Wed, 11 Feb 2015 14:19:21 +0000 (14:19 +0000)] 
Detect overly long GC sync

Summary:
GC sync is the time between a GC being intiated and all the mutator
threads finally stopping so that the GC can start. Problems that cause
the GC sync to be delayed are hard to find and can cause dramatic
slowdowns for heavily parallel programs.

The new flag --long-gc-sync=<time> helps by emitting a warning and
calling a user-overridable hook when the GC sync time exceeds the
specified threshold. A debugger can be used to set a breakpoint when
this happens and inspect the stacks of threads to find the culprit.

Test Plan:
```
$ ./inplace/bin/ghc-stage2 +RTS --long-gc-sync=0.0000001 -S
    Alloc    Copied     Live     GC     GC      TOT      TOT  Page Flts
    bytes     bytes     bytes   user   elap     user     elap
  1135856     51144    153736  0.000  0.000    0.002    0.002    0    0  (Gen:  0)
  1034760     94704    188752  0.000  0.000    0.002    0.002    0    0  (Gen:  0)
  1038888    134832    228888  0.009  0.009    0.011    0.011    0    0  (Gen:  1)
  1025288     90128    235184  0.000  0.000    0.012    0.012    0    0  (Gen:  0)
  1049088    130080    333984  0.000  0.000    0.013    0.013    0    0  (Gen:  0)
Warning: waited 0us for GC sync
  1034424     73360    331976  0.000  0.000    0.013    0.013    0    0  (Gen:  0)
```

Also tested on a real production problem.

Reviewers: niteria, bgamari, erikd

Subscribers: rwbarton, thomie

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

2 years agoPull recent Hadrian changes from upstream
Andrey Mokhov [Wed, 15 Nov 2017 21:58:19 +0000 (21:58 +0000)] 
Pull recent Hadrian changes from upstream

Merge commit 'c1fcd9b3f60e8420dd228cd4e3efeb9cfa793aa5'

2 years agoSquashed 'hadrian/' changes from 5ebb69a..fa3771f
Andrey Mokhov [Wed, 15 Nov 2017 21:58:18 +0000 (21:58 +0000)] 
Squashed 'hadrian/' changes from 5ebb69a..fa3771f

fa3771f hadrian: Disable -Wno-undef in files which include ffi.h (#459)
f15e851 Do not run configure by default (#458)
5baa8db Fix AppVeyor cache failure (#456)
94dbe9d Fix ghc-cabal build (#455)
a679764 Fix CI scripts (#454)
06ec241 Widen bounds on Cabal (#452)

git-subtree-dir: hadrian
git-subtree-split: fa3771fe6baf5008a8506fec48220f8347ac59af

2 years agousers_guide: Fix "CancelSynchronousIo" casing
Niklas Hambüchen [Wed, 15 Nov 2017 16:43:04 +0000 (11:43 -0500)] 
users_guide: Fix "CancelSynchronousIo" casing

Reviewers: bgamari, angerman

Reviewed By: angerman

Subscribers: angerman, rwbarton, thomie

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

2 years agoAdjust AltCon Ord instance to match Core linter requirements.
klebinger.andreas@gmx.at [Wed, 15 Nov 2017 16:42:48 +0000 (11:42 -0500)] 
Adjust AltCon Ord instance to match Core linter requirements.

When sorting by the Ord instance put DEFAULT before other constructors.

This is in line with what the core linter requests allowing the use of
the instance for putting alternatives in the correct order.
This implements #14464.

Reviewers: bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, thomie

GHC Trac Issues: #14464

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

2 years agoCabalify all the things
Moritz Angermann [Wed, 15 Nov 2017 16:41:34 +0000 (11:41 -0500)] 
Cabalify all the things

Adding cabal files to `unlit`, `touchy` and `hp2ps`, allows us to treat
them uniformally across the build system. In particular Hadrian will use
these.

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

2 years agoAllow the rts lib to be called rts-1.0
Moritz Angermann [Wed, 15 Nov 2017 16:41:15 +0000 (11:41 -0500)] 
Allow the rts lib to be called rts-1.0

Reviewers: bgamari, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

2 years agorts: Fix gc timing
Douglas Wilson [Wed, 15 Nov 2017 16:40:54 +0000 (11:40 -0500)] 
rts: Fix gc timing

We were accumulating the gc times of the previous gc.
`stats.gc.{cpu,elappsed}_ns` were being accumulated into
`stats.gc_{cpu,elapsed}_ns` before they were set.

There is also a change in that heap profiling will no longer cause gc
events to
be emitted.

Reviewers: bgamari, erikd, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #14257, #14445

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

2 years agoAdd dump flag for timing output
Ben Gamari [Wed, 15 Nov 2017 16:40:16 +0000 (11:40 -0500)] 
Add dump flag for timing output

This allows you to use `-ddump-to-file -ddump-timings` for more useful
dump output.

Test Plan: Try it

Subscribers: rwbarton, thomie

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