ghc.git
11 days agoBump parsec submodule to 3.1.14.0 wip/ghc-8.8-merges
Ben Gamari [Wed, 3 Jul 2019 05:45:50 +0000 (01:45 -0400)] 
Bump parsec submodule to 3.1.14.0

2 weeks agoDisable fragile test cases: T14697 T5559 T3424
Vladislav Zavialov [Sat, 23 Feb 2019 22:03:35 +0000 (01:03 +0300)] 
Disable fragile test cases: T14697 T5559 T3424

See Trac #15072, Trac #16349, Trac #16350

(cherry picked from commit 14586f5d737ec5dc828633267b50dcf0d47e1696)

2 weeks agoInitial commit of dump-interfaces
Ben Gamari [Mon, 1 Jul 2019 15:52:47 +0000 (11:52 -0400)] 
Initial commit of dump-interfaces

This is the initial commit of a utility that I have been using to
compare the user-facing interfaces exposed by GHC across releases

2 weeks agoCorrect closure observation, construction, and mutation on weak memory machines.
Travis Whitaker [Wed, 3 Apr 2019 22:26:16 +0000 (15:26 -0700)] 
Correct closure observation, construction, and mutation on weak memory machines.

Here the following changes are introduced:
    - A read barrier machine op is added to Cmm.
    - The order in which a closure's fields are read and written is changed.
    - Memory barriers are added to RTS code to ensure correctness on
      out-or-order machines with weak memory ordering.

Cmm has a new CallishMachOp called MO_ReadBarrier. On weak memory machines, this
is lowered to an instruction that ensures memory reads that occur after said
instruction in program order are not performed before reads coming before said
instruction in program order. On machines with strong memory ordering properties
(e.g. X86, SPARC in TSO mode) no such instruction is necessary, so
MO_ReadBarrier is simply erased. However, such an instruction is necessary on
weakly ordered machines, e.g. ARM and PowerPC.

Weam memory ordering has consequences for how closures are observed and mutated.
For example, consider a closure that needs to be updated to an indirection. In
order for the indirection to be safe for concurrent observers to enter, said
observers must read the indirection's info table before they read the
indirectee. Furthermore, the entering observer makes assumptions about the
closure based on its info table contents, e.g. an INFO_TYPE of IND imples the
closure has an indirectee pointer that is safe to follow.

When a closure is updated with an indirection, both its info table and its
indirectee must be written. With weak memory ordering, these two writes can be
arbitrarily reordered, and perhaps even interleaved with other threads' reads
and writes (in the absence of memory barrier instructions). Consider this
example of a bad reordering:

- An updater writes to a closure's info table (INFO_TYPE is now IND).
- A concurrent observer branches upon reading the closure's INFO_TYPE as IND.
- A concurrent observer reads the closure's indirectee and enters it. (!!!)
- An updater writes the closure's indirectee.

Here the update to the indirectee comes too late and the concurrent observer has
jumped off into the abyss. Speculative execution can also cause us issues,
consider:

- An observer is about to case on a value in closure's info table.
- The observer speculatively reads one or more of closure's fields.
- An updater writes to closure's info table.
- The observer takes a branch based on the new info table value, but with the
  old closure fields!
- The updater writes to the closure's other fields, but its too late.

Because of these effects, reads and writes to a closure's info table must be
ordered carefully with respect to reads and writes to the closure's other
fields, and memory barriers must be placed to ensure that reads and writes occur
in program order. Specifically, updates to a closure must follow the following
pattern:

- Update the closure's (non-info table) fields.
- Write barrier.
- Update the closure's info table.

Observing a closure's fields must follow the following pattern:

- Read the closure's info pointer.
- Read barrier.
- Read the closure's (non-info table) fields.

This patch updates RTS code to obey this pattern. This should fix long-standing
SMP bugs on ARM (specifically newer aarch64 microarchitectures supporting
out-of-order execution) and PowerPC. This fixes issue #15449.

Co-Authored-By: Ben Gamari <ben@well-typed.com>
(cherry picked from commit 11bac11545b19a63f5cec3c5bbd5c3f9a7dae0b2)

2 weeks agoFix GCC warnings with __clear_cache builtin (#16867)
Sylvain Henry [Tue, 25 Jun 2019 16:53:22 +0000 (18:53 +0200)] 
Fix GCC warnings with __clear_cache builtin (#16867)

(cherry picked from commit 4ec233ecfc7f061c19d0c5ef98ad05719b1161e7)

2 weeks agoFix Happy deps for Stack (#16825)
Sylvain Henry [Mon, 24 Jun 2019 16:36:07 +0000 (18:36 +0200)] 
Fix Happy deps for Stack (#16825)

(cherry picked from commit 90e0ab7d80d88463df97bc3514fc89d2ab9fcfca)

2 weeks agogetExecutablePath: get path from sysctl on FreeBSD
Fraser Tweedale [Tue, 25 Jun 2019 02:17:30 +0000 (12:17 +1000)] 
getExecutablePath: get path from sysctl on FreeBSD

(cherry picked from commit d35cec7a9c07a0fc3b40e45d64e5794c3567a523)

2 weeks agotypo in the docs for DynFlags.hs
Artem Pelenitsyn [Wed, 26 Jun 2019 08:33:17 +0000 (04:33 -0400)] 
typo in the docs for DynFlags.hs

(cherry picked from commit ef6d9a50db115e296d2d9bec3e94c7369f1d504c)

2 weeks agoDisable automatic use of -fobject-code due to #16876
Ben Gamari [Thu, 27 Jun 2019 03:14:32 +0000 (23:14 -0400)] 
Disable automatic use of -fobject-code due to #16876

2 weeks agotestsuite: Unbreak T16608 tests
Ben Gamari [Tue, 25 Jun 2019 03:31:44 +0000 (23:31 -0400)] 
testsuite: Unbreak T16608 tests

Sleep to avoid non-determinism due to Darwin's poor mtime resolution.
Fixes #16855.

(cherry picked from commit b90437d8b5c2727450cf45b12fd65cc87a8ab80e)

2 weeks agotestsuite: Add testcase for #16111
Ben Gamari [Fri, 29 Mar 2019 21:26:05 +0000 (17:26 -0400)] 
testsuite: Add testcase for #16111

(cherry picked from commit 3acdc9a8844a5f9bddf27379b3e74c2bb94bff5f)

2 weeks agorts: Reset STATIC_LINK field of reverted CAFs
Ben Gamari [Tue, 18 Jun 2019 16:07:50 +0000 (12:07 -0400)] 
rts: Reset STATIC_LINK field of reverted CAFs

When we revert a CAF we must reset the STATIC_LINK field lest the GC
might ignore the CAF (e.g. as it carries the STATIC_FLAG_LIST flag) and
will consequently overlook references to object code that we are trying
to unload. This would result in the reachable object code being
unloaded. See Note [CAF lists] and Note [STATIC_LINK fields].

This fixes #16842.

Idea-due-to: Phuong Trinh <lolotp@fb.com>
(cherry picked from commit 2a960c3a04afcfcdb25a13e9a6e65c94c22a169f)

2 weeks agoDon't eta-expand unsaturated primops
Ben Gamari [Fri, 21 Jun 2019 16:42:53 +0000 (12:42 -0400)] 
Don't eta-expand unsaturated primops

Previously, as described in Note [Primop wrappers], `hasNoBinding` would
return False in the case of `PrimOpId`s. This would result in eta
expansion of unsaturated primop applications during CorePrep. Not only
did this expansion result in unnecessary allocations, but it also meant
lead to rather nasty inconsistencies between the CAFfy-ness
determinations made by TidyPgm and CorePrep.

This fixes #16846.

(cherry picked from commit 4ae71eba8c1f680f3163fa27fd83cc5a5214770a)

2 weeks agoCoreToStg: Enable CAFfyness checking with -dstg-lint
Ben Gamari [Fri, 21 Jun 2019 15:24:50 +0000 (11:24 -0400)] 
CoreToStg: Enable CAFfyness checking with -dstg-lint

The debugging involved in finding #16846 wouldn't have been necessary
had the consistentCafInfo check been enabled. However, :wq

(cherry picked from commit cd753410da64bc1c2b1e8a9dc0331e96f4990004)

2 weeks agotestsuite: Add test for #16846
Ben Gamari [Thu, 20 Jun 2019 17:40:13 +0000 (13:40 -0400)] 
testsuite: Add test for #16846

(cherry picked from commit 1faf4982e26dc89d5e9d68810e0d764596587fdd)

2 weeks agoBump containers submodule to v0.6.2.1
Ben Gamari [Wed, 12 Jun 2019 15:53:57 +0000 (11:53 -0400)] 
Bump containers submodule to v0.6.2.1

(cherry picked from commit 4c2127c4837d7e2588399c06b56b45b2d4c2f9b0)

2 weeks agoBump Cabal submodule to what will become 3.0.0.0
Ben Gamari [Tue, 25 Jun 2019 03:44:01 +0000 (23:44 -0400)] 
Bump Cabal submodule to what will become 3.0.0.0

Metric Increase:
    haddock.Cabal

(cherry picked from commit 5c3f20801c4149d6a950cfb36c7a841dd32d17e0)

2 weeks agoAdd MonadFail instance for ParserM
Erik de Castro Lopo [Sat, 22 Jun 2019 03:50:14 +0000 (13:50 +1000)] 
Add MonadFail instance for ParserM

(cherry picked from commit 581cbc28e143a4ed8e7f794ed1618161222a5646)

2 weeks agoFixes for LLVM 7
Erik de Castro Lopo [Sat, 22 Jun 2019 00:13:51 +0000 (10:13 +1000)] 
Fixes for LLVM 7

LLVM version numberinf changed recently. Previously, releases were numbered
4.0, 5.0 and 6.0 but with version 7, they dropped the redundant ".0".

Fix requires for Llvm detection and some code.

(cherry picked from commit 71aca77c780dad8496054a06a7fe65704a13a742)

2 weeks agoghci: Load static objects in batches
Ben Gamari [Fri, 14 Jun 2019 20:53:12 +0000 (16:53 -0400)] 
ghci: Load static objects in batches

Previously in the case where GHC was dynamically linked we would load
static objects one-by-one by linking each into its own shared object and
dlopen'ing each in order. However, this meant that the link would fail
in the event that the objects had cyclic symbol dependencies.

Here we fix this by merging each "run" of static objects into a single
shared object and loading this.

Fixes #13786 for the case where GHC is dynamically linked.

(cherry picked from commit cd177b44695382878eca7800fb2493b72b20c1e7)

2 weeks agotestsuite: Test for #13786
Ben Gamari [Fri, 14 Jun 2019 21:38:04 +0000 (17:38 -0400)] 
testsuite: Test for #13786

(cherry picked from commit 652b83be7a13f35deefc778d89fd11c9dd46cfa3)

2 weeks agotestsuite: Add test for #16563
Ben Gamari [Sun, 16 Jun 2019 21:13:15 +0000 (17:13 -0400)] 
testsuite: Add test for #16563

(cherry picked from commit 22743f728a55e851bd079511df0812a1275d1fee)

2 weeks agoghci: Don't rely on resolution of System.IO to base module
Ben Gamari [Sun, 16 Jun 2019 15:15:11 +0000 (11:15 -0400)] 
ghci: Don't rely on resolution of System.IO to base module

Previously we would hackily evaluate a textual code snippet to compute
actions to disable I/O buffering and flush the stdout/stderr handles.
This broke in a number of ways (#15336, #16563).

Instead we now ship a module (`GHC.GHCi.Helpers`) with `base` containing
the needed actions. We can then easily refer to these via `Orig` names.

(cherry picked from commit abee907f20ec9b8465be6587b3c74df9a1d1b1a6)

2 weeks agoGHCi support for levity-polymorphic join points
Richard Eisenberg [Tue, 4 Jun 2019 18:31:08 +0000 (14:31 -0400)] 
GHCi support for levity-polymorphic join points

Fixes #16509.

See Note [Levity-polymorphic join points] in ByteCodeGen,
which tells the full story.

This commit also adds some comments and cleans some code
in the byte-code generator, as I was exploring around trying
to understand it.

test case: ghci/scripts/T16509

(cherry picked from commit 392210bf8a27b3604f8642d76c39e391c2d4b5e0)

3 weeks agoFix the ghci063 test on Darwin (Trac #16201)
Vladislav Zavialov [Sun, 24 Feb 2019 22:23:42 +0000 (01:23 +0300)] 
Fix the ghci063 test on Darwin (Trac #16201)

We use "touch -r" to set modification timestamps, which leads to precision loss
on Darwin. For example,

   before: 2019-02-25 01:11:23.807627350 +0300
   after:  2019-02-25 01:11:23.807627000 +0300
                                     ^^^
This means we can't trick GHCi into thinking the file hasn't been changed by
restoring its old timestamp, as we cannot faithfully restore all digits.

The solution is to nullify the insignificant digits before the first :load

(cherry picked from commit f320f3b2f2f421af41b8f7588529ed46bbe6ccf3)

3 weeks agotestsuite: Drop constraint in kind from T15862
Ben Gamari [Mon, 24 Jun 2019 22:47:39 +0000 (18:47 -0400)] 
testsuite: Drop constraint in kind from T15862

We only started allowing constraints in kinds in
6cce36f83aec33d33545e0ef2135894d22dff5ca, which is not present in 8.8.

3 weeks agoProperly trim IdInfos of DFunIds and PatSyns in TidyPgm
Ömer Sinan Ağacan [Fri, 3 May 2019 08:45:33 +0000 (11:45 +0300)] 
Properly trim IdInfos of DFunIds and PatSyns in TidyPgm

Not doing this right caused #16608. We now properly trim IdInfos of
DFunIds and PatSyns.

Some further refactoring done by SPJ.

Two regression tests T16608_1 and T16608_2 added.

Fixes #16608

(cherry picked from commit 9d58554f7b19c52896796e8c3b6de20c154a67b2)

3 weeks agoSynchronize ClsInst.doTyConApp with TcTypeable validity checks (#15862)
Ryan Scott [Fri, 14 Jun 2019 15:07:46 +0000 (11:07 -0400)] 
Synchronize ClsInst.doTyConApp with TcTypeable validity checks (#15862)

Issue #15862 demonstrated examples of type constructors on which
`TcTypeable.tyConIsTypeable` would return `False`, but the `Typeable`
constraint solver in `ClsInst` (in particular, `doTyConApp`) would
try to generate `Typeable` evidence for anyway, resulting in
disaster. This incongruity was caused by the fact that `doTyConApp`
was using a weaker validity check than `tyConIsTypeable` to determine
if a type constructor warrants `Typeable` evidence or not. The
solution, perhaps unsurprisingly, is to use `tyConIsTypeable` in
`doTyConApp` instead.

To avoid import cycles between `ClsInst` and `TcTypeable`, I factored
out `tyConIsTypeable` into its own module, `TcTypeableValidity`.

Fixes #15862.

(cherry picked from commit 25ee60cdae6ddedaf6b4677c6327c0f31c81073a)

3 weeks agoSafeHaskell: Don't throw -Wsafe warning if module is declared Safe
Ben Gamari [Fri, 14 Jun 2019 03:51:24 +0000 (23:51 -0400)] 
SafeHaskell: Don't throw -Wsafe warning if module is declared Safe

Fixes #16689.

(cherry picked from commit 29ec33cd3ee390e8006a88d34f5ea0ac236663d0)

3 weeks agoFix #16525: ObjectCode freed wrongly because of lack of info header check
Phuong Trinh [Thu, 25 Apr 2019 17:44:02 +0000 (18:44 +0100)] 
Fix #16525: ObjectCode freed wrongly because of lack of info header check

`checkUnload` currently doesn't check the info header of static objects.
Thus, it may free an `ObjectCode` struct wrongly even if there's still a
live static object whose info header lies in a mapped section of that
`ObjectCode`. This fixes the issue by adding an appropriate check.

(cherry picked from commit fc6b23be509e290f8d27775a1c637284a335ed81)

3 weeks agoFix typo in error message
Aiken Cairncross [Fri, 14 Jun 2019 13:21:37 +0000 (14:21 +0100)] 
Fix typo in error message

(cherry picked from commit ca721193fc71c065036deecfb9d4274fbfc6850d)

3 weeks agoFix missing unboxed tuple RuntimeReps (#16565)
Krzysztof Gogolewski [Sun, 5 May 2019 18:37:31 +0000 (20:37 +0200)] 
Fix missing unboxed tuple RuntimeReps (#16565)

Unboxed tuples and sums take extra RuntimeRep arguments,
which must be manually passed in a few places.
This was not done in deSugar/Check.

This error was hidden because zipping functions in TyCoRep
ignored lists with mismatching length. This is now fixed;
the lengths are now checked by calling zipEqual.

As suggested in #16565, I moved checking for isTyVar and
isCoVar to zipTyEnv and zipCoEnv.

(cherry picked from commit 69b1633104a43d5654e65f2c05fa6b73775936e2)

3 weeks agopowerpc32: fix stack allocation code generation
Sergei Trofimovich [Wed, 20 Mar 2019 22:46:33 +0000 (22:46 +0000)] 
powerpc32: fix stack allocation code generation

When ghc was built for powerpc32 built failed as:

It's a fallout of commit 3f46cffcc2850e68405a1
("PPC NCG: Refactor stack allocation code") where
word size used to be
    II32/II64
and changed to
    II8/panic "no width for given number of bytes"
    widthFromBytes ((platformWordSize platform) `quot` 8)

The change restores initial behaviour by removing extra division.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
(cherry picked from commit bb2ee86a4cf47eb56d4b8b4a552537449d492f88)

3 weeks agopowerpc32: fix 64-bit comparison (#16465)
Sergei Trofimovich [Wed, 20 Mar 2019 22:40:28 +0000 (22:40 +0000)] 
powerpc32: fix 64-bit comparison (#16465)

On powerpc32 64-bit comparison code generated dangling
target labels. This caused ghc build failure as:

    $ ./configure --target=powerpc-unknown-linux-gnu && make
    ...
    SCCs aren't in reverse dependent order
    bad blockId n3U

This happened because condIntCode' in PPC codegen generated
label name but did not place the label into `cmp_lo` code block.

The change adds the `cmp_lo` label into the case of negative
comparison.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
(cherry picked from commit 973077ac63c79988f2d5f25d13b60dce82f9e8dd)

3 weeks agollvm-targets: Add x86_64 android layout
Moritz Angermann [Sat, 9 Dec 2017 23:36:20 +0000 (07:36 +0800)] 
llvm-targets: Add x86_64 android layout

(cherry picked from commit e87b9f8731460a7d8c0b45507be2d83935683d56)

3 weeks agoFix T16737
Ben Gamari [Mon, 24 Jun 2019 13:37:58 +0000 (09:37 -0400)] 
Fix T16737

* Disable in profasm way when GHC is dynamically linked
* Drop -optcxx as fix for #16477 is not present in 8.8

3 weeks agoPass preprocessor options to C compiler when building foreign C files (#16737)
Zejun Wu [Tue, 4 Jun 2019 22:25:10 +0000 (15:25 -0700)] 
Pass preprocessor options to C compiler when building foreign C files (#16737)

(cherry picked from commit cfd3e0f1cfd16c8f35cae139d2a871a32eb4d2e1)

3 weeks agotestsuite: Add test for #16514
Ben Gamari [Tue, 2 Apr 2019 15:59:06 +0000 (11:59 -0400)] 
testsuite: Add test for #16514

(cherry picked from commit 41bf4045c5a85651db8ceb631a1b67edec0c1216)

3 weeks agoAdd a `NOINLINE` pragma on `someNatVal` (#16586)
Iavor Diatchki [Tue, 7 May 2019 20:02:27 +0000 (13:02 -0700)] 
Add a `NOINLINE` pragma on `someNatVal` (#16586)

This fixes #16586, see `Note [NOINLINE someNatVal]` for details.

(cherry picked from commit 59f4cb6fb73ade6f9b0bdc85380dfddba93bf14b)

3 weeks agoReplace git.haskell.org with gitlab.haskell.org (#16196)
Yuriy Syrovetskiy [Mon, 1 Apr 2019 18:03:41 +0000 (21:03 +0300)] 
Replace git.haskell.org with gitlab.haskell.org (#16196)

(cherry picked from commit 75abaaead796415cf2b5da610f4b3ee75b9d7759)

3 weeks agoMake Extension derive Bounded
Shayne Fletcher [Thu, 25 Apr 2019 15:09:00 +0000 (11:09 -0400)] 
Make Extension derive Bounded

(cherry picked from commit 9047f1844d3f332e15f9e04e74891c771388da3d)

3 weeks agoghci: Ensure that system libffi include path is searched
Ben Gamari [Fri, 12 Apr 2019 20:59:50 +0000 (16:59 -0400)] 
ghci: Ensure that system libffi include path is searched

Previously hsc2hs failed when building against a system FFI.

(cherry picked from commit 1abb76ab8e32e7be224631506201d1beec62a5c2)

3 weeks agousers guide: Mention supported LLVM version
Ben Gamari [Sun, 23 Jun 2019 14:34:01 +0000 (10:34 -0400)] 
users guide: Mention supported LLVM version

3 weeks agoAdd a missing update of sc_hole_ty (#16312)
Simon Peyton Jones [Wed, 29 May 2019 17:29:21 +0000 (13:29 -0400)] 
Add a missing update of sc_hole_ty (#16312)

In simplCast I totally failed to keep the sc_hole_ty field of
ApplyToTy (see Note [The hole type in ApplyToTy]) up to date.
When a cast goes by, of course the hole type changes.

Amazingly this has not bitten us before, but #16312 finally
triggered it.  Fortunately the fix is simple.

Fixes #16312.

(cherry picked from commit ef36b10233e46f8462f42531e8e0c1ebe0bcb1eb)

3 weeks agoVisibility: handle multiple units with the same name
Michael Peyton Jones [Wed, 13 Mar 2019 11:46:56 +0000 (11:46 +0000)] 
Visibility: handle multiple units with the same name

Fixes #16228. The included test case is adapted from the reproduction in
the issue, and fails without this patch.

------

We compute an initial visilibity mapping for units based on what is
present in the package databases. To seed this, we compute a set of all
the package configs to add visibilities for.

However, this set was keyed off the unit's *package name*. This is
correct, since we compare packages across databases by version. However,
we would only ever consider a single, most-preferable unit from the
database in which it was found.

The effect of this was that only one of the libraries in a Cabal package
would be added to this initial set. This would cause attempts to use
modules from the omitted libraries to fail, claiming that the package
was hidden (even though `ghc-pkg` would correctly show it as visible).

A solution is to do the selection of the most preferable packages
separately, and then be sure to consider exposing all units in the
same package in the same package db. We can do this by picking a
most-preferable unit for each package name, and then considering
exposing all units that are equi-preferable with that unit.

------

Why wasn't this bug apparent to all people trying to use sub-libraries
in Cabal? The answer is that Cabal explicitly passes `-package` and
`-package-id` flags for all the packages it wants to use, rather than
relying on the state of the package database. So this bug only really
affects people who are trying to use package databases produced by Cabal
outside of Cabal itself.

One particular example of this is the way that the
Nixpkgs Haskell infrastructure provides wrapped GHCs: typically these
are equipped with a package database containing all the needed
package dependencies, and the user is not expected to pass
`-package` flags explicitly.

(cherry picked from commit 8a20bfc21da6a47087c8069f92691629eb47951d)

3 weeks agotestsuite: Fix expected output
Ben Gamari [Sat, 22 Jun 2019 04:38:21 +0000 (00:38 -0400)] 
testsuite: Fix expected output

3 weeks agoMerge branch 'wip/backport-MR951' into wip/ghc-8.8-merges
Ben Gamari [Fri, 21 Jun 2019 21:17:46 +0000 (17:17 -0400)] 
Merge branch 'wip/backport-MR951' into wip/ghc-8.8-merges

3 weeks agoFix #16517 by bumping the TcLevel for method sigs
Richard Eisenberg [Wed, 5 Jun 2019 22:02:13 +0000 (18:02 -0400)] 
Fix #16517 by bumping the TcLevel for method sigs

There were actually two bugs fixed here:

1. candidateQTyVarsOfType needs to be careful that it does not
   try to zap metavariables from an outer scope as "naughty"
   quantification candidates. This commit adds a simple check
   to avoid doing so.

2. We weren't bumping the TcLevel in kcHsKindSig, which was used
   only for class method sigs. This mistake led to the acceptance
   of

     class C a where
       meth :: forall k. Proxy (a :: k) -> ()

   Note that k is *locally* quantified. This patch fixes the
   problem by using tcClassSigType, which correctly bumps the
   level. It's a bit inefficient because tcClassSigType does other
   work, too, but it would be tedious to repeat much of the code
   there with only a few changes. This version works well and is
   simple.

And, while updating comments, etc., I noticed that tcRnType was
missing a pushTcLevel, leading to #16767, which this patch also
fixes, by bumping the level. In the refactoring here, I also
use solveEqualities. This initially failed ghci/scripts/T15415,
but that was fixed by teaching solveEqualities to respect
-XPartialTypeSignatures.

This patch also cleans up some Notes around error generation that
came up in conversation.

Test case: typecheck/should_fail/T16517, ghci/scripts/T16767

(cherry picked from commit a22e51ea6f7a046c87d57ce30d143eef6abee9ff)
(cherry picked from commit 19ab32c5fb3ebd88927b94acf6b348facc1552a2)

3 weeks agoFail fast in solveLocalEqualities
Simon Peyton Jones [Thu, 14 Feb 2019 08:28:43 +0000 (08:28 +0000)] 
Fail fast in solveLocalEqualities

This patch makes us fail fast in TcSimplify.solveLocalEqualities,
and in TcHsType.tc_hs_sig_type, if there are insoluble constraints.

Previously we ploughed on even if there were insoluble constraints,
leading to a cascade of hard-to-understand type errors. Failing
eagerly is much better; hence a lot of testsuite error message
changes.  Eg if we have
          f :: [Maybe] -> blah
          f xs = e
then trying typecheck 'f x = e' with an utterly bogus type
is just asking for trouble.

I can't quite remember what provoked me to make this change,
but I think the error messages are notably improved, by
removing confusing clutter and focusing on the real error.

(cherry picked from commit 5c1f268e2744fab2d36e64c163858995451d7095)

3 weeks agoBump unix submodule
Ben Gamari [Tue, 18 Jun 2019 17:13:35 +0000 (13:13 -0400)] 
Bump unix submodule

4 weeks agoRTS: Add missing memory barrier
Peter Trommler [Sun, 24 Feb 2019 16:11:00 +0000 (17:11 +0100)] 
RTS: Add missing memory barrier

In the work stealing queue a load-load-barrier is required to ensure
that a read of queue data cannot be reordered before a read of the
bottom pointer into the queue.

The added load-load-barrier ensures that the ordering of writes enforced
at the end of `pushWSDeque` is also respected in the order of reads in
`stealWSDeque_`. In other words, when reading `q->bottom` we want to make
sure that we see the updates to `q->elements`.

Fixes #13633

(cherry picked from commit 5c084e0468be46f5ab48b2c1669a7e4d4d0f3c43)

4 weeks agousers-guide: Move HIE file discussion to correct section
Ben Gamari [Sun, 16 Jun 2019 18:17:38 +0000 (14:17 -0400)] 
users-guide: Move HIE file discussion to correct section

4 weeks agoEmit GHC timing events to eventlog
Ben Gamari [Tue, 16 Apr 2019 19:19:01 +0000 (15:19 -0400)] 
Emit GHC timing events to eventlog

(cherry picked from commit ebfa35284741fca47719f531f0996261441f75b0)

4 weeks agoErrUtils: Emit progress messages to eventlog
Ben Gamari [Sun, 14 Apr 2019 21:05:50 +0000 (17:05 -0400)] 
ErrUtils: Emit progress messages to eventlog

(cherry picked from commit 1bef62c38d3737b5f5d7ebbb479f3c1a12b1aa09)

4 weeks agoBump array submodule
Ben Gamari [Sun, 16 Jun 2019 13:19:18 +0000 (09:19 -0400)] 
Bump array submodule

4 weeks agobase: Fix TBA in changelog
Ben Gamari [Sun, 16 Jun 2019 13:13:05 +0000 (09:13 -0400)] 
base: Fix TBA in changelog

4 weeks agotestsuite: Skip PartialDownsweep
Ben Gamari [Sun, 16 Jun 2019 13:10:32 +0000 (09:10 -0400)] 
testsuite: Skip PartialDownsweep

This gives different results on different platforms

4 weeks agoPrelRules: Don't break let/app invariant in shiftRule wip/backport-T16742
Ben Gamari [Mon, 10 Jun 2019 13:25:57 +0000 (09:25 -0400)] 
PrelRules: Don't break let/app invariant in shiftRule

Previously shiftRule would rewrite as invalid shift like
```
let x = I# (uncheckedIShiftL# n 80)
in ...
```
to
```
let x = I# (error "invalid shift")
in ...
```
However, this breaks the let/app invariant as `error` is not
okay-for-speculation. There isn't an easy way to avoid this so let's not
try. Instead we just take advantage of the undefined nature of invalid
shifts and return zero.

Fixes #16742.

(cherry picked from commit 0bd3b9dd0428855b6f72f757c1214b5253aa7753)

4 weeks agousers-guide: More release notes
Ben Gamari [Sat, 15 Jun 2019 18:55:05 +0000 (14:55 -0400)] 
users-guide: More release notes

4 weeks agoFix typo in 8.8.1 notes related to traceBinaryEvent
iustin [Fri, 26 Apr 2019 13:07:33 +0000 (09:07 -0400)] 
Fix typo in 8.8.1 notes related to traceBinaryEvent

- fixes double mention of `traceBinaryEvent#` (the second one should be `traceEvent#`, I think)
- fixes note about `traceEvent#` taking a `String` - the docs say it takes a zero-terminated ByteString.

(cherry picked from commit 63150b9e5583c5fc3252f242981b0d26f11348b2)

4 weeks agoAdd dwarf flavour definition ghc-8.8.1-alpha2
Ben Gamari [Thu, 13 Jun 2019 16:30:38 +0000 (12:30 -0400)] 
Add dwarf flavour definition

4 weeks agoMerge branches 'wip/backport-MR1137', 'wip/backport-MR1139', 'wip/backport-MR1160...
Ben Gamari [Thu, 13 Jun 2019 14:51:12 +0000 (10:51 -0400)] 
Merge branches 'wip/backport-MR1137', 'wip/backport-MR1139', 'wip/backport-MR1160', 'wip/backport-MR706' and 'wip/backport-MR769' into wip/ghc-8.8-merges

4 weeks agoBump process submodule to 1.6.5.1
Ben Gamari [Mon, 10 Jun 2019 16:36:11 +0000 (12:36 -0400)] 
Bump process submodule to 1.6.5.1

4 weeks agorts/linker: Use mmapForLinker to map PLT wip/backport-MR1139
Ben Gamari [Sat, 8 Jun 2019 19:31:54 +0000 (19:31 +0000)] 
rts/linker: Use mmapForLinker to map PLT

The PLT needs to be located within a close distance of
the code calling it under the small memory model.

Fixes #16784.

(cherry picked from commit 0b7f81f560c602f32cfc90fd3fb5f1c52f06ad49)

4 weeks agollvm-targets: Add armv7l-unknown-linux-gnueabi wip/backport-MR1160
Ben Gamari [Tue, 11 Jun 2019 01:59:19 +0000 (21:59 -0400)] 
llvm-targets: Add armv7l-unknown-linux-gnueabi

Fixes #15208.

[skip ci]

(cherry picked from commit 9b4ff57d71eebf6dd71a5d81d0f9c9c2aef80e65)

4 weeks agorts/linker: Only mprotect GOT after it is filled wip/backport-MR1137
Ben Gamari [Sat, 8 Jun 2019 17:28:19 +0000 (13:28 -0400)] 
rts/linker: Only mprotect GOT after it is filled

This fixes a regression, introduced by 67c422ca, where we mprotect'd the
global offset table (GOT) region to PROT_READ before we had finished
filling it, resulting in a linker crash.

Fixes #16779.

(cherry picked from commit 217e6db4af6752b13c586d4e8925a4a9a2f47245)

4 weeks agorts/linker: Make elf_got.c a bit more legible
Ben Gamari [Sat, 8 Jun 2019 17:28:08 +0000 (13:28 -0400)] 
rts/linker: Make elf_got.c a bit more legible

(cherry picked from commit bbc752c50f3adcb659cd8447635828e137a0a314)

4 weeks agoUse binary search to speedup checkUnload wip/backport-MR706
Phuong Trinh [Mon, 1 Apr 2019 19:05:47 +0000 (20:05 +0100)] 
Use binary search to speedup checkUnload

We are iterating through all object code for each heap objects when
checking whether object code can be unloaded. For large projects in
GHCi, this can be very expensive due to the large number of object code
that needs to be loaded/unloaded. To speed it up, this arrangess all
mapped sections of unloaded object code in a sorted array and use binary
search to check if an address location fall on them.

(cherry picked from commit f81f3964b718eab21f0cfe65067c195f2f2a84bd)

4 weeks agoAdd `-haddock` to prepare-system.sh and .gitlab-ci.yml wip/backport-MR769
Takenobu Tani [Sun, 14 Apr 2019 12:31:05 +0000 (21:31 +0900)] 
Add `-haddock` to prepare-system.sh and .gitlab-ci.yml

To cover ci conditions from ghc8.6 to 8.9, I add `-haddock` option
to `.circleci/prepare-system.sh` and .gitlab-ci.yml.
after including `mk/flavours/*`.

(cherry picked from commit c4f94320a7048a7f263d8d952d4e12cc0227cf72)

4 weeks agoAdd `-haddock` to perf.mk rather than prepare-system.sh
Takenobu Tani [Sun, 14 Apr 2019 10:11:12 +0000 (19:11 +0900)] 
Add `-haddock` to perf.mk rather than prepare-system.sh

To cover ci conditions from ghc8.6 to 8.9, I add `-haddock` option
to `mk/flavours/perf.mk` rather than `.circleci/prepare-system.sh`.

Because in windows condition of ghc-8.9, `mk/flavours/*` is included
after `prepare-system.sh`.

In addition, in linux condition of ghc-8.6, `mk/flavors/perf.mk` is used.

(cherry picked from commit 43a39c3c2195d5b4400efc845a54f153184b1d7f)

4 weeks agoAdd `-haddock` option under ci condition to fix #16415
Takenobu Tani [Sat, 13 Apr 2019 06:54:43 +0000 (15:54 +0900)] 
Add `-haddock` option under ci condition to fix #16415

In order to use the `:doc` command in ghci, it is necessary
to compile for core libraries with `-haddock` option.

Especially, the `-haddock` option is essential for release building.

Note:
  * The `-haddock` option may affect compile time and binary size.
  * But hadrian has already set `-haddock` as the default.
  * This patch affects the make-based building.

This patch has been split from !532.

(cherry picked from commit 33e37d0619a9d1d0b8088a109f7eeb4c6fd21027)

4 weeks agotestsuite: Mark threadstatus-T9333 as fragile in ghci way wip/backport-fragile
Ben Gamari [Mon, 8 Apr 2019 14:35:51 +0000 (10:35 -0400)] 
testsuite: Mark threadstatus-T9333 as fragile in ghci way

As noted in #16555.

(cherry picked from commit 64b1684da09ddb3dc480bd0370adc7b002657a39)

4 weeks agotestsuite: Fix fragile_for test modifier
Ben Gamari [Sat, 6 Apr 2019 13:37:52 +0000 (09:37 -0400)] 
testsuite: Fix fragile_for test modifier

(cherry picked from commit 658199cce0aabeed77f3bbbbde6abc0c5c3cc83d)

4 weeks agotestsuite: Mark T13167 as fragile in threaded2
Ben Gamari [Fri, 5 Apr 2019 02:25:23 +0000 (22:25 -0400)] 
testsuite: Mark T13167 as fragile in threaded2

As noted in #16536.

(cherry picked from commit b351004702c1a595bcedfa3ffeb4f816d5fd8503)

4 weeks agobase: Mark CPUTime001 as fragile
Ben Gamari [Thu, 30 May 2019 13:29:37 +0000 (09:29 -0400)] 
base: Mark CPUTime001 as fragile

As noted in #16224, CPUTime001 has been quite problematic, reporting
non-monotonic timestamps in CI. Unfortunately I've been unable to
reproduce this locally.

(cherry picked from commit 1a3420cabdcf6d7d90c154681230f1150604c097)

4 weeks agotestsuite: Mark heapprof001 as fragile on all platforms
Ben Gamari [Sat, 2 Mar 2019 03:57:55 +0000 (22:57 -0500)] 
testsuite: Mark heapprof001 as fragile on all platforms

See #15382.

(cherry picked from commit 23fc615679072a6fa433460a92f597af2ae388b2)

4 weeks agotestsuite: Mark heapprof001 as fragile on i386
Ben Gamari [Tue, 26 Feb 2019 15:14:02 +0000 (10:14 -0500)] 
testsuite: Mark heapprof001 as fragile on i386

(cherry picked from commit 910185a3eb5fd2148e42d39f6374ab03d098b682)

4 weeks agotestsuite: Introduce fragile modifier
Ben Gamari [Tue, 26 Feb 2019 15:13:44 +0000 (10:13 -0500)] 
testsuite: Introduce fragile modifier

Now since we have been a bit more stringent in testsuite cleanliness we
have been marking a lot of tests as fragile using the `skip` modifier.
However, this unfortunately means that we lose the association with the
ticket number documenting the fragility.

Here we introduce `fragile` and `fragile_for` to retain this
information.

(cherry picked from commit 4ca271d1880a6f4c5f49869de7f1920a2073adb6)

5 weeks agoBump binary to 0.8.7.0
Ben Gamari [Fri, 7 Jun 2019 21:34:16 +0000 (17:34 -0400)] 
Bump binary to 0.8.7.0

5 weeks agoBump Cabal submodule
Ben Gamari [Wed, 5 Jun 2019 00:37:31 +0000 (20:37 -0400)] 
Bump Cabal submodule

5 weeks agoBump time submodule to 1.9.3
Ben Gamari [Wed, 5 Jun 2019 00:34:27 +0000 (20:34 -0400)] 
Bump time submodule to 1.9.3

5 weeks agoBump terminfo to 0.4.1.4
Ben Gamari [Wed, 5 Jun 2019 00:31:38 +0000 (20:31 -0400)] 
Bump terminfo to 0.4.1.4

5 weeks agoHaddock for hiefile-header
Ben Gamari [Tue, 4 Jun 2019 22:59:31 +0000 (18:59 -0400)] 
Haddock for hiefile-header

5 weeks agoFix ghc-in-ghci
Ben Gamari [Tue, 4 Jun 2019 22:59:24 +0000 (18:59 -0400)] 
Fix ghc-in-ghci

5 weeks agoMerge branch '8.8-haddock-release' of gitlab.haskell.org:harpocrates/ghc into wip...
Ben Gamari [Tue, 4 Jun 2019 22:54:55 +0000 (18:54 -0400)] 
Merge branch '8.8-haddock-release' of gitlab.haskell.org:harpocrates/ghc into wip/ghc-8.8-merges

5 weeks agoAdd missing import
Ben Gamari [Tue, 4 Jun 2019 22:18:44 +0000 (18:18 -0400)] 
Add missing import

Missing from f8d24178f30b7837b35a9ea328bc6f520092ff08.

5 weeks agoMerge branch 'hiefile-header-8.8' of https://gitlab.haskell.org/wz1000/ghc into wip...
Ben Gamari [Tue, 4 Jun 2019 22:07:26 +0000 (18:07 -0400)] 
Merge branch 'hiefile-header-8.8' of https://gitlab.haskell.org/wz1000/ghc into wip/ghc-8.8-merges

5 weeks agoMerge branch 'wip/8-8-ghci' of gitlab.haskell.org:ghc/ghc into wip/ghc-8.8-merges
Ben Gamari [Tue, 4 Jun 2019 22:06:59 +0000 (18:06 -0400)] 
Merge branch 'wip/8-8-ghci' of gitlab.haskell.org:ghc/ghc into wip/ghc-8.8-merges

5 weeks agoMerge branch 'cherry-pick-e172a6d1' of gitlab.haskell.org:ghc/ghc into wip/ghc-8...
Ben Gamari [Tue, 4 Jun 2019 22:04:04 +0000 (18:04 -0400)] 
Merge branch 'cherry-pick-e172a6d1' of gitlab.haskell.org:ghc/ghc into wip/ghc-8.8-merges

5 weeks agoMerge branch 'wip/backport-ecc9366a0e0db107c286935130837b2222e2dd82' of https://gitla...
Ben Gamari [Tue, 4 Jun 2019 22:03:41 +0000 (18:03 -0400)] 
Merge branch 'wip/backport-ecc9366a0e0db107c286935130837b2222e2dd82' of https://gitlab.haskell.org/RyanGlScott/ghc into wip/ghc-8.8-merges

5 weeks agoMerge branch 'hie-backports-8.8' of https://gitlab.haskell.org/DanielG/ghc into wip...
Ben Gamari [Tue, 4 Jun 2019 22:03:03 +0000 (18:03 -0400)] 
Merge branch 'hie-backports-8.8' of https://gitlab.haskell.org/DanielG/ghc into wip/ghc-8.8-merges

5 weeks agoMerge remote-tracking branch 'osa1/port_16449_ghc_8_8' into wip/ghc-8.8-merges
Ben Gamari [Tue, 4 Jun 2019 22:02:11 +0000 (18:02 -0400)] 
Merge remote-tracking branch 'osa1/port_16449_ghc_8_8' into wip/ghc-8.8-merges

5 weeks agoMerge remote-tracking branch 'origin/cherry-pick-43a43a33' into wip/ghc-8.8-merges
Ben Gamari [Tue, 4 Jun 2019 22:01:54 +0000 (18:01 -0400)] 
Merge remote-tracking branch 'origin/cherry-pick-43a43a33' into wip/ghc-8.8-merges

5 weeks agoMerge remote-tracking branch 'osa1/backport_t16066' into wip/ghc-8.8-merges
Ben Gamari [Tue, 4 Jun 2019 22:00:59 +0000 (18:00 -0400)] 
Merge remote-tracking branch 'osa1/backport_t16066' into wip/ghc-8.8-merges

5 weeks agotestsuite: Mark concprog001 as fragile
Ben Gamari [Fri, 26 Apr 2019 04:54:21 +0000 (00:54 -0400)] 
testsuite: Mark concprog001 as fragile

Due to #16604.

6 weeks agoUse datatype for unboxed returns when loading ghc into ghci wip/8-8-ghci
Michael Sloan [Fri, 15 Mar 2019 00:26:51 +0000 (17:26 -0700)] 
Use datatype for unboxed returns when loading ghc into ghci

See #13101 and #15454

(cherry picked from commit 64959e51bf17a9f991cc345476a40515e7b32d81)

6 weeks agoExtract out use of UnboxedTuples from GHCi.Leak
Michael Sloan [Thu, 14 Mar 2019 23:12:09 +0000 (16:12 -0700)] 
Extract out use of UnboxedTuples from GHCi.Leak

See #13101 + #15454 for motivation.  This change reduces the number of
modules that need to be compiled to object code when loading GHC into
GHCi.

(cherry picked from commit c01d5af31c8feb634fc3dffc84e6e7ece61ba190)

6 weeks agoRemove unnecessary uses of UnboxedTuples pragma (see #13101 / #15454)
Michael Sloan [Thu, 14 Mar 2019 23:01:44 +0000 (16:01 -0700)] 
Remove unnecessary uses of UnboxedTuples pragma (see #13101 / #15454)

Also removes a couple unnecessary MagicHash pragmas

(cherry picked from commit 061276ea5d265eb3c23a3698f0a10f6a764ff4b4)

6 weeks agoAdd PlainPanic for throwing exceptions without depending on pprint
Michael Sloan [Thu, 14 Mar 2019 22:47:44 +0000 (15:47 -0700)] 
Add PlainPanic for throwing exceptions without depending on pprint

This commit splits out a subset of GhcException which do not depend on
pretty printing (SDoc), as a new datatype called
PlainGhcException. These exceptions can be caught as GhcException,
because 'fromException' will convert them.

The motivation for this change is that that the Panic module
transitively depends on many modules, primarily due to pretty printing
code.  It's on the order of about 130 modules.  This large set of
dependencies has a few implications:

1. To avoid cycles / use of boot files, these dependencies cannot
throw GhcException.

2. There are some utility modules that use UnboxedTuples and also use
`panic`. This means that when loading GHC into GHCi, about 130
additional modules would need to be compiled instead of
interpreted. Splitting the non-pprint exception throwing into a new
module resolves this issue. See #13101

(cherry picked from commit fe9034e9b4820214a8c703bd8a3146ce6eed37b8)

6 weeks agoHave GHCi use object code for UnboxedTuples modules #15454
Michael Sloan [Thu, 14 Mar 2019 06:04:41 +0000 (23:04 -0700)] 
Have GHCi use object code for UnboxedTuples modules #15454

The idea is to automatically enable -fobject-code for modules that use
UnboxedTuples, along with all the modules they depend on. When looking
into how to solve this, I was pleased to find that there was already
highly similar logic for enabling code generation when -fno-code is
specified but TemplateHaskell is used.

The state before this patch was that if you used unboxed tuples then you
had to enable `-fobject-code` globally rather than on a per module
basis.