ghc.git
18 months agoComments and refactoring only
Simon Marlow [Wed, 16 May 2018 13:03:55 +0000 (14:03 +0100)] 
Comments and refactoring only

Addressing review comments on D4637

18 months agoFix #15073 by suggesting UnboxedTuples in an error message
Ryan Scott [Wed, 16 May 2018 16:59:45 +0000 (12:59 -0400)] 
Fix #15073 by suggesting UnboxedTuples in an error message

Under certain circumstances, `GeneralizedNewtypeDeriving`
can emit code which uses unboxed tuple types, but if `UnboxedTuples`
wasn't enabled, the error message that GHC gave didn't make it very
clear that it could be worked around by explicitly enabling the
extension. Easily fixed.

Test Plan: make test TEST=T15073

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: simonpj, thomie, carter

GHC Trac Issues: #15073

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

18 months agoImprove numeric stability of numericEnumFrom for floating numbers
HE, Tao [Wed, 16 May 2018 16:13:16 +0000 (12:13 -0400)] 
Improve numeric stability of numericEnumFrom for floating numbers

Fixes #15081.

Test Plan: cd libraries/base && make test TEST="enumNumeric"

Reviewers: hvr, bgamari

Reviewed By: bgamari

Subscribers: dfeuer, simonpj, thomie, carter

GHC Trac Issues: #15081

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

18 months agoFix #15039 by pretty-printing equalities more systematically
Ryan Scott [Wed, 16 May 2018 16:11:37 +0000 (12:11 -0400)] 
Fix #15039 by pretty-printing equalities more systematically

GHC previously had a handful of special cases for
pretty-printing equalities in a more user-friendly manner, but they
were far from comprehensive (see #15039 for an example of where this
fell apart).

This patch makes the pretty-printing of equalities much more
systematic. I've adopted the approach laid out in
https://ghc.haskell.org/trac/ghc/ticket/15039#comment:4, and updated
`Note [Equality predicates in IfaceType]` accordingly. We are now
more careful to respect the properties of the
`-fprint-explicit-kinds` and `-fprint-equality-relations` flags,
which led to some improvements in error message outputs.

Along the way, I also tweaked the error-reporting machinery not to
print out the type of a typed hole when the type is an unlifted
equality, since it's kind (`TYPE ('TupleRep '[])`) was more
confusing than anything.

Test Plan: make test TEST="T15039a T15039b T15039c T15039d"

Reviewers: simonpj, goldfire, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #15039

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

18 months agoAdd pprTraceM to Outputable as analog to traceM.
klebinger.andreas@gmx.at [Wed, 16 May 2018 16:11:27 +0000 (12:11 -0400)] 
Add pprTraceM to Outputable as analog to traceM.

Test Plan: ci, using it in monadic code.

Reviewers: bgamari, mpickering

Reviewed By: mpickering

Subscribers: rwbarton, thomie, carter

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

18 months agoInfoTables: Fix #if uses introduced by D4634
Ben Gamari [Wed, 16 May 2018 16:15:32 +0000 (12:15 -0400)] 
InfoTables: Fix #if uses introduced by D4634

18 months agoMake finalizers more reliable.
Tamar Christina [Wed, 16 May 2018 01:20:45 +0000 (21:20 -0400)] 
Make finalizers more reliable.

Ignore any errors thrown by finalizers when running them.

This prevents a faulty finalizer from stopping the rest being called.

Test Plan: ./validate, new test T13167

Reviewers: hvr, bgamari, simonmar

Reviewed By: bgamari, simonmar

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #13167

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

18 months agoMerge FUN_STATIC closure with its SRT
Simon Marlow [Sun, 22 Apr 2018 18:34:32 +0000 (19:34 +0100)] 
Merge FUN_STATIC closure with its SRT

Summary:
The idea here is to save a little code size and some work in the GC,
by collapsing FUN_STATIC closures and their SRTs.

This is (4) in a series; see D4632 for more details.

There's a tradeoff here: more complexity in the compiler in exchange
for a modest code size reduction (probably around 0.5%).

Results:
* GHC binary itself (statically linked) is 1% smaller
* -0.2% binary sizes in nofib (-0.5% module sizes)

Full nofib results comparing D4634 with this: P177 (ignore runtimes,
these aren't stable on my laptop)

Test Plan: validate, nofib

Reviewers: bgamari, niteria, simonpj, erikd

Subscribers: thomie, carter

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

18 months agoSave a word in the info table on x86_64
Simon Marlow [Sun, 22 Apr 2018 13:28:47 +0000 (14:28 +0100)] 
Save a word in the info table on x86_64

Summary:
An info table with an SRT normally looks like this:

    StgWord64 srt_offset
    StgClosureInfo layout
    StgWord32 layout
    StgWord32 has_srt

But we only need 32 bits for srt_offset on x86_64, because the small
memory model requires that code segments are at most 2GB. So we can
optimise this to

    StgClosureInfo layout
    StgWord32 layout
    StgWord32 srt_offset

saving a word.  We can tell whether the info table has an SRT or not,
because zero is not a valid srt_offset, so zero still indicates that
there's no SRT.

Test Plan:
* validate
* For results, see D4632.

Reviewers: bgamari, niteria, osa1, erikd

Subscribers: thomie, carter

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

18 months agoAllow CmmLabelDiffOff with different widths
Simon Marlow [Sun, 22 Apr 2018 11:48:11 +0000 (12:48 +0100)] 
Allow CmmLabelDiffOff with different widths

Summary:
This change makes it possible to generate a static 32-bit relative label
offset on x86_64. Currently we can only generate word-sized label
offsets.

This will be used in D4634 to shrink info tables.  See D4632 for more
details.

Test Plan: See D4632

Reviewers: bgamari, niteria, michalt, erikd, jrtc27, osa1

Subscribers: thomie, carter

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

18 months agoAn overhaul of the SRT representation
Simon Marlow [Mon, 26 Sep 2016 11:07:05 +0000 (12:07 +0100)] 
An overhaul of the SRT representation

Summary:
- Previously we would hvae a single big table of pointers per module,
  with a set of bitmaps to reference entries within it. The new
  representation is identical to a static constructor, which is much
  simpler for the GC to traverse, and we get to remove the complicated
  bitmap-traversal code from the GC.

- Rewrite all the code to generate SRTs in CmmBuildInfoTables, and
  document it much better (see Note [SRTs]). This has been something
  I've wanted to do since we moved to the new code generator, I
  finally had the opportunity to finish it while on a transatlantic
  flight recently :)

There are a series of 4 diffs:

1. D4632 (this one), which does the bulk of the changes

2. D4633 which adds support for smaller `CmmLabelDiffOff` constants

3. D4634 which takes advantage of D4632 and D4633 to save a word in
   info tables that have an SRT on x86_64. This is where most of the
   binary size improvement comes from.

4. D4637 which makes a further optimisation to merge some SRTs with
   static FUN closures.  This adds some complexity and the benefits
   are fairly modest, so it's not clear yet whether we should do this.

Results (after (3), on x86_64)

- GHC itself (staticaly linked) is 5.2% smaller

- -1.7% binary sizes in nofib, -2.9% module sizes. Full nofib results: P176

- I measured the overhead of traversing all the static objects in a
  major GC in GHC itself by doing `replicateM_ 1000 performGC` as the
  first thing in `Main.main`.  The new version was 5-10% faster, but
  the results did vary quite a bit.

- I'm not sure if there's a compile-time difference, the results are
  too unreliable.

Test Plan: validate

Reviewers: bgamari, michalt, niteria, simonpj, erikd, osa1

Subscribers: thomie, carter

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

18 months agoForce findPtr to be included in the binary
Simon Marlow [Wed, 9 May 2018 12:37:30 +0000 (13:37 +0100)] 
Force findPtr to be included in the binary

Summary: A better alternative to D4657.

Test Plan:
```
cd testsuite/tests/codeGen/should_run
../../../../inplace/bin/ghc-stage2 -debug cgrun001
nm cgrun001 | grep findPtr
```

Reviewers: bgamari, Phyx, erikd

Subscribers: rwbarton, thomie, carter

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

18 months agoLess Tc inside simplCore (Phase 1 for #14391)
Artem Pelenitsyn [Tue, 15 May 2018 22:07:23 +0000 (18:07 -0400)] 
Less Tc inside simplCore (Phase 1 for #14391)

Simplifier depends on typechecker in two points: `thNameToGhcName`
(`lookupThName_maybe`, in particular)  and `lookupGlobal`. We want to
cut the ties in two steps.

1. (Presented in this commit), reimplement both functions in a way that
doesn't use typechecker.

2. (Should follow), do code moving: a) `lookupGlobal` should go in some
typechecker-free place; b) `thNameToGhcName` should leave simplifier,
because it is not used there at all (probably, it should be placed
somewhere where `GhcPlugins` can see it -- this is suggested by Joachim
on Trac).

Details
=======

We redesigned lookup interface a bit so that it exposes some
`IO`-equivalents of `Tc`-features in use.

First, `CoreMonad.hs` still calls `lookupGlobal` which is no longer
bound to the typechecker monad, but still resides in `TcEnv.hs` — it
should be moved out of Tc-land at some point (“Phase 2”) in the
future in order to achieve its part of the #14391's goal.

Second, `lookupThName_maybe` is eliminated from `CoreMonad.hs`
completely; this already achieves its part of the goal of #14391. Its
client, though, `thNameToGhcName`, is better to be moved in the future
also, for it is not used in the `CoreMonad.hs` (or anywhere else)
anyway. Joachim suggested “any module reexported by GhcPlugins (or
maybe even that module itself)”.

As a side goal, we removed `initTcForLookup` which was instrumental for
the past version of `lookupGlobal`. This, in turn, called for pushing
some more parts of the lookup interface from the `Tc`-monad to `IO`,
most notably, adding `IO`-version of `lookupOrig` and pushing
`dataConInfoPtrToName` to `IO`. The `lookupOrig` part, in turn,
triggered a slight redesign of name cache updating interface: we now
have both, `updNameCacheIO` and `updNameCacheTc`, both accepting `mod`
and `occ` to force them inside, instead of more error-prone outside
before. But all these hardly have to do anything with #14391, mere
refactoring.

Reviewers: simonpj, nomeata, bgamari, hvr

Reviewed By: simonpj, bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14391

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

18 months agoAlgebraically simplify add/sub with carry/overflow
Sebastian Graf [Tue, 15 May 2018 17:12:56 +0000 (13:12 -0400)] 
Algebraically simplify add/sub with carry/overflow

Previously, the `{add,sub}{Int,Word}C#` PrimOps weren't handled
in PrelRules (constant folding and algebraic simplification) at all.
This implements the necessary logic, so that using these primitives
isn't too punishing compared to their well-optimised, overflow-unaware
counterparts.

This is so that using these primitives in `enumFromThenTo @Int` can
be optimized by constant folding, reducing closure sizes.

Reviewers: bgamari, simonpj, hsyl20

Reviewed By: bgamari, simonpj

Subscribers: AndreasK, thomie, carter

GHC Trac Issues: #8763

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

18 months agoCalling GetLastError() on Windows for socket IO (trac issue #12012)
ARJANEN Loïc Jean David [Mon, 14 May 2018 20:38:21 +0000 (16:38 -0400)] 
Calling GetLastError() on Windows for socket IO (trac issue #12012)

For the threaded RTS, putting a private copy of the throwErrno
series in GHC.IO.FD which gets if the operation was on a socket,
so that we can call c_maperrno if need be.
For the non-threaded RTS, if memory serves we call GetLastError()
in case of an error on socket IO. However, we don't do the translation
ErrCode ↔ Errno currently (and besides, it's a primop) so we do it if
needed through c_maperrno_func in the asynchronous read/write
functions.

Signed-off-by: ARJANEN Loïc Jean David <arjanen.loic@gmail.com>
Reviewers: ekmett, hvr, bgamari

Reviewed By: bgamari

Subscribers: thomie, carter

GHC Trac Issues: #12012

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

18 months agotestsuite: Disable T14697 on Windows
Ben Gamari [Mon, 14 May 2018 20:36:52 +0000 (16:36 -0400)] 
testsuite: Disable T14697 on Windows

Test Plan: Validate on Windows

Subscribers: thomie, carter

GHC Trac Issues: #14697, #15072

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

18 months agoMore explicit comment on switch in registerDelay
Kirill Zaborsky [Thu, 10 May 2018 14:57:59 +0000 (17:57 +0300)] 
More explicit comment on switch in registerDelay

18 months agoEnsure that RTS cabal file reflects dependency on libnuma
Ben Gamari [Mon, 14 May 2018 14:17:51 +0000 (10:17 -0400)] 
Ensure that RTS cabal file reflects dependency on libnuma

Test Plan: Validate with Hadrian and `libnuma` support

Reviewers: snowleopard, hvr, erikd, simonmar

Subscribers: izgzhen, alpmestan, thomie, carter

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

18 months agoRevert "Simplify callSiteInline a little"
Ben Gamari [Mon, 14 May 2018 13:25:32 +0000 (09:25 -0400)] 
Revert "Simplify callSiteInline a little"

This lead to some rather significant performance regressions.
Specifically,

    bytes allocated value is too high:
        Expected    T5631(normal) bytes allocated: 1106015512 +/-5%
        Lower bound T5631(normal) bytes allocated: 1050714736
        Upper bound T5631(normal) bytes allocated: 1161316288
        Actual      T5631(normal) bytes allocated: 1164953208
        Deviation   T5631(normal) bytes allocated:        5.3 %
    *** unexpected stat test failure for T5631(normal)
    max_bytes_used value is too high:
        Expected    T9630(normal) max_bytes_used: 35324712 +/-15%
        Lower bound T9630(normal) max_bytes_used: 30026005
        Upper bound T9630(normal) max_bytes_used: 40623419
        Actual      T9630(normal) max_bytes_used: 43490984
        Deviation   T9630(normal) max_bytes_used:     23.1 %
    *** unexpected stat test failure for T9630(normal)

This reverts commit 7271db46c332f15c302b9a55f4ed005cdd0fb898.
This reverts commit b750dcc5d9e1df8505788a41d0cf0d92acd17f0d.
This reverts commit 33de71fa06d03e6da396a7c0a314fea3b492ab91.

18 months agotestsuite: Fix expected allocations of T9020 and T12425
Ben Gamari [Mon, 14 May 2018 21:19:07 +0000 (17:19 -0400)] 
testsuite: Fix expected allocations of T9020 and T12425

These were both improved by d92c7556501a4cdeb7d269c4624992c94d9b3b8b but the
changes were lost due to merge silliness.

18 months agoTidy up error suppression
Simon Peyton Jones [Tue, 15 May 2018 10:36:28 +0000 (11:36 +0100)] 
Tidy up error suppression

Trac #15152 showed that when a flag turned an error into a warning, we
were still (alas) suppressing subequent errors; includign their
essential addTcEvBind.  That led (rightly) to a Lint error.

This patch fixes it, and incidentally tidies up an ad-hoc special
case of out-of-scope variables (see the old binding for
'out_of_scope_killer' in 'tryReporters').

No test, because the problem was only shown up when turning
inaccessible code into a warning.

18 months agorts: export new absentSumFieldError from base
Sergei Trofimovich [Mon, 14 May 2018 20:51:48 +0000 (21:51 +0100)] 
rts: export new absentSumFieldError from base

commit b2ff5dde399cd012218578945ada1d9ff68daa35 "Fix #15038"
added new stable closure 'absentSumFieldError_closure' to
base package. This closure is used in rts package.

Unfortunately the symbol was not explicitly exported and build
failed on windows as:

```
"inplace/bin/ghc-stage1" -o ...hsc2hs.exe ...
rts/dist/build/libHSrts.a(RtsStartup.o): In function `hs_init_ghc':

rts/RtsStartup.c:272:0: error:
     undefined reference to `base_ControlziExceptionziBase_absentSumFieldError_closure'
    |
272 |     getStablePtr((StgPtr)absentSumFieldError_closure);
    | ^

```

This change adds 'absentSumFieldError_closure' to explicit export
into libHSbase.def.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
18 months agoFix performance regressions from #14737
Tobias Dammers [Mon, 14 May 2018 12:50:29 +0000 (08:50 -0400)] 
Fix performance regressions from #14737

See #15019. When removing an unnecessary type equality check in #14737,
several regression tests failed. The cause was that some coercions that
are actually Refl coercions weren't passed in as such, which made the
equality check needlessly complex (Refl coercions can be discarded in
this particular check immediately, without inspecting the types at all).

We fix that, and get additional performance improvements for free.

Reviewers: goldfire, bgamari, simonpj

Reviewed By: bgamari, simonpj

Subscribers: simonpj, thomie, carter

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

18 months agoRevert "rts: Compile with gcc -Og"
Ben Gamari [Mon, 14 May 2018 12:48:42 +0000 (08:48 -0400)] 
Revert "rts: Compile with gcc -Og"

This reverts commit d4abd031f6e8c2fa01f8949f60d8a02cca513804.

18 months agoFix #14973
Denis M [Mon, 14 May 2018 04:08:36 +0000 (00:08 -0400)] 
Fix #14973

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: thomie, carter

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

18 months agoutils/fs: use <sys/stat.h>, not <sys\stat.h>
Sergei Trofimovich [Mon, 14 May 2018 08:09:58 +0000 (09:09 +0100)] 
utils/fs: use <sys/stat.h>, not <sys\stat.h>

Fix cross-compilation failure from linux to windows:
```
  CC utils/unlit/dist-install/build/fs.o
utils/unlit/fs.c:24:10: fatal error: sys\stat.h: No such file or directory
 #include <sys\stat.h>
          ^~~~~~~~~~~~
```

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
18 months agoImprove some Foldable methods for NonEmpty
David Feuer [Mon, 14 May 2018 03:26:08 +0000 (23:26 -0400)] 
Improve some Foldable methods for NonEmpty

* `length` is improved by using the default definition,
  while `foldr1` is improved by using a custom one.

* Several methods had useless lazy pattern matches
  (i.e., the functions were actually strict in those arguments).
  Remove `~`s to clarify.

Reviewers: hvr, bgamari, mpickering, nomeata

Reviewed By: bgamari

Subscribers: ygale, rwbarton, thomie, carter

GHC Trac Issues: #15131

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

18 months agoFix another batch of `./validate --slow` failures
Alp Mestanogullari [Sun, 13 May 2018 22:38:18 +0000 (18:38 -0400)] 
Fix another batch of `./validate --slow` failures

A rather detailed summary can be found at:

    https://gist.github.com/alpmestan/be82b47bb88b7dc9ff84105af9b1bb82

This doesn't fix all expectation mismatches yet, but we're down to about
20 mismatches with my previous patch and this one, as opposed to ~150
when I got started.

Test Plan: ./validate --slow

Reviewers: bgamari, erikd, simonmar

Reviewed By: simonmar

Subscribers: thomie, carter

GHC Trac Issues: #14890

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

18 months agoAdd support for opting out of package environments
Herbert Valerio Riedel [Sun, 13 May 2018 22:37:18 +0000 (18:37 -0400)] 
Add support for opting out of package environments

This implements the first part proposed in #13753:

Define a special magic "null" environment, which instructs GHC to ignore
any package environment files. To this end, I propose to use the name
`-` (i.e. a single dash), as that is more portable than using the empty
string for environment variables. In other words, a

- `-package-env -` CLI flag, or a
- `GHC_ENVIRONMENT=-` env var (unless a `-package-env` flag is present)

would inhibit GHC from looking up and interpreting any package
environment files from the filesystem; this is the equivalent of
`-ignore-dot-ghci` for package environment files.

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #13753

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

18 months agoghc-pkg: Configure handle encodings
Ben Gamari [Sun, 13 May 2018 22:36:59 +0000 (18:36 -0400)] 
ghc-pkg: Configure handle encodings

This fixes #15021 using a the same approach as was used to fix the issue
in ghc (#10762).

Test Plan: Validate on Windows as user whose username contains
non-ASCII characters

Reviewers: simonmar

Reviewed By: simonmar

Subscribers: lehins, thomie, carter

GHC Trac Issues: #15021

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

18 months agoFix #14875 by introducing PprPrec, and using it
Ryan Scott [Sun, 13 May 2018 22:36:23 +0000 (18:36 -0400)] 
Fix #14875 by introducing PprPrec, and using it

Trying to determine when to insert parentheses during TH
conversion is a bit of a mess. There is an assortment of functions
that try to detect this, such as:

* `hsExprNeedsParens`
* `isCompoundHsType`
* `hsPatNeedsParens`
* `isCompoundPat`
* etc.

To make things worse, each of them have slightly different semantics.
Plus, they don't work well in the presence of explicit type
signatures, as #14875 demonstrates.

All of these problems can be alleviated with the use of an explicit
precedence argument (much like what `showsPrec` currently does). To
accomplish this, I introduce a new `PprPrec` data type, and define
standard predences for things like function application, infix
operators, function arrows, and explicit type signatures (that last
one is new). I then added `PprPrec` arguments to the various
`-NeedsParens` functions, and use them to make smarter decisions
about when things need to be parenthesized.

A nice side effect is that functions like `isCompoundHsType` are
now completely unneeded, since they're simply aliases for
`hsTypeNeedsParens appPrec`. As a result, I did a bit of refactoring
to remove these sorts of functions. I also did a pass over various
utility functions in GHC for constructing AST forms and used more
appropriate precedences where convenient.

Along the way, I also ripped out the existing `TyPrec`
data type (which was tailor-made for pretty-printing `Type`s) and
replaced it with `PprPrec` for consistency.

Test Plan: make test TEST=T14875

Reviewers: alanz, goldfire, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14875

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

18 months agoAdd note documenting refineDefaultAlt
Matthew Pickering [Sun, 13 May 2018 22:36:10 +0000 (18:36 -0400)] 
Add note documenting refineDefaultAlt

Reviewers: sjakobi, bgamari

Reviewed By: sjakobi

Subscribers: rwbarton, thomie, carter

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

18 months agoClarify what the FFI spec says
David Feuer [Sun, 13 May 2018 22:35:34 +0000 (18:35 -0400)] 
Clarify what the FFI spec says

Section 10.1.1 claimed that

> The FFI addendum stipulates that an implementation is free to
implement an unsafe call by performing a safe call ...

Reading through the FFI addendum (and the Haskell 2010 Report, which
integrates it), I see no such stipulation. I think this explains the
situation a bit better.

[ci skip]

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: thomie, carter

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

18 months agoGHCi: Include a note in the hint to expose a hidden package
Chaitanya Koparkar [Sun, 13 May 2018 22:35:18 +0000 (18:35 -0400)] 
GHCi: Include a note in the hint to expose a hidden package

Test Plan: validate

Reviewers: bgamari, RyanGlScott, osa1

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #15055

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

18 months agorts: Compile with gcc -Og
Ben Gamari [Sun, 13 May 2018 22:34:48 +0000 (18:34 -0400)] 
rts: Compile with gcc -Og

This optimisation level is specifically designed to provide the benefits
of optimisation without the obfuscation that sometimes results.

Test Plan: Validate

Reviewers: simonmar

Reviewed By: simonmar

Subscribers: rwbarton, thomie, carter

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

18 months agoRemove unused things from utils/Digraph
David Feuer [Sun, 13 May 2018 22:34:38 +0000 (18:34 -0400)] 
Remove unused things from utils/Digraph

`utils/Digraph` had a bunch of code that wasn't actually being used,
much of which wasn't documented at all, some of which was clearly
ill-considered, and some of which was documented as being inefficient.

Remove all unused code from that module except for the obvious and
innocuous `emptyG`.

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

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

18 months agoFix changelog message for asinh
David Feuer [Sun, 13 May 2018 22:34:26 +0000 (18:34 -0400)] 
Fix changelog message for asinh

Reviewers: bgamari, hvr

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

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

18 months agoFix a few GCC warnings
Michal Terepeta [Sun, 13 May 2018 22:34:03 +0000 (18:34 -0400)] 
Fix a few GCC warnings

GCC 8 now generates warnings for incompatible function pointer casts
[-Werror=cast-function-type]. Apparently there are a few of those in rts
code, which makes `./validate` unhappy (since we compile with `-Werror`)

This commit tries to fix these issues by changing the functions to have
the correct type (and, if necessary, moving the casts into those
functions).

For instance, hash/comparison function are declared (`Hash.h`) to take
`StgWord` but we want to use `StgWord64[2]` in `StaticPtrTable.c`.
Instead of casting the function pointers, we can cast the `StgWord`
parameter to `StgWord*`. I think this should be ok since `StgWord`
should be the same size as a pointer.

Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>
Test Plan: ./validate

Reviewers: bgamari, erikd, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

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

18 months agoRefactor LitString
Sylvain Henry [Sun, 13 May 2018 15:36:28 +0000 (11:36 -0400)] 
Refactor LitString

Refactor LitString so that the string length is computed at most once
and then stored.

Also remove strlen and memcmp wrappers (it seems like they were a
workaround for a very old GCC when using -fvia-C).

Bumps haddock submodule.

Reviewers: bgamari, dfeuer, nickkuk

Reviewed By: bgamari, nickkuk

Subscribers: nickkuk, dfeuer, thomie, carter

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

18 months agoBump array submodule
Ben Gamari [Sun, 13 May 2018 15:52:56 +0000 (11:52 -0400)] 
Bump array submodule

18 months agoTcInteract: Ensure that tycons have representations before solving for Typeable
Ben Gamari [Sun, 13 May 2018 15:41:16 +0000 (11:41 -0400)] 
TcInteract: Ensure that tycons have representations before solving for Typeable

Summary: This fixes #15067.

Test Plan: Validate

Subscribers: thomie, carter, RyanGlScott

GHC Trac Issues: #15067

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

18 months agobase: Fix handling of showEFloat (Just 0)
Ben Gamari [Sun, 13 May 2018 15:40:18 +0000 (11:40 -0400)] 
base: Fix handling of showEFloat (Just 0)

Previously `showEFloat (Just 0) pi ""` would produce `3.0e0`. Of
course, this
blatantly disrespects the user's request to print with zero digits of
precision.
Fix this.

This is tested by base's `num008` testcase.

Test Plan: Validate

Reviewers: hvr

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #15115

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

18 months agoSimplify -ddump-json implementation
Matthew Pickering [Sun, 13 May 2018 15:39:34 +0000 (11:39 -0400)] 
Simplify -ddump-json implementation

This patch takes the much simpler route of whenever the compiler tries
to output something. We just dump a JSON document there and then.

I think this should be sufficient to work with and anything more refined
quickly got complicated as it was necessary to demarcate message scopes
and so on.

Reviewers: bgamari, dfeuer

Reviewed By: bgamari

Subscribers: Phyx, dfeuer, rwbarton, thomie, carter

GHC Trac Issues: #14078

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

18 months agoEmit info-level log message when package envs are loaded
Herbert Valerio Riedel [Sun, 13 May 2018 17:32:29 +0000 (19:32 +0200)] 
Emit info-level log message when package envs are loaded

A common complaint with the new package environment files feature is
that it's not obvious when package environments have been picked up.
This patch applies the same strategy that was already used for `.ghci` files
(which exhibit similar potential for confusion, c.f. #11389) to package
environment files.

For instance, this new notification looks like below for a GHCi invocation which
loads both, a GHCi configuration as well as a package environment:

  GHCi, version 8.5.20180512: http://www.haskell.org/ghc/  :? for help
  Loaded package environment from /tmp/parsec-3.1.13.0/.ghc.environment.x86_64-linux-8.5.20180512
  Loaded GHCi configuration from /home/hvr/.ghci
  Prelude>

Addresses #15145

Reviewed By: bgamari, angerman

GHC Trac Issues: #15145

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

18 months agoUse correct source spans for EmptyCase
Ryan Scott [Sat, 12 May 2018 16:56:30 +0000 (12:56 -0400)] 
Use correct source spans for EmptyCase

Summary:
The parser's calculation of source spans for `EmptyCase`
expressions was a bit off, leading to some wonky-looking error
messages. Easily fixed with some uses of `comb3` and `sLL`.

Test Plan: make test TEST=T15139

Reviewers: bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, thomie, mpickering, carter

GHC Trac Issues: #15139

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

18 months agoRevert "Fix unwinding of C -> Haskell FFI calls with -threaded"
Bartosz Nitka [Sat, 12 May 2018 14:31:20 +0000 (07:31 -0700)] 
Revert "Fix unwinding of C -> Haskell FFI calls with -threaded"

This reverts commit cb5c2fe875965b7aedbc189012803fc62e48fb3f.

It appears to have broken OSX and Windows builds.

18 months agoAdds CTRL-C handler in Windows's timeout (trac issue #12721)
ARJANEN Loïc Jean David [Sat, 12 May 2018 07:35:27 +0000 (08:35 +0100)] 
Adds CTRL-C handler in Windows's timeout (trac issue #12721)

Summary:
Uses Win32's System.Win32.Console.CtrlHandler.withConsoleCtrlHandler to add
to Windows's version of the timeout executable a CTRL-C/CTRL-BREAK
handler which does the close IO port/kill job cleanup, just in case.

Signed-off-by: ARJANEN Loïc Jean David <arjanen.loic@gmail.com>
Reviewers: Phyx, bgamari

Reviewed By: Phyx

Subscribers: dfeuer, thomie, carter

GHC Trac Issues: #12721

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

18 months agoExpand $tooldir in ghc --info output
Alp Mestanogullari [Sat, 12 May 2018 07:36:19 +0000 (08:36 +0100)] 
Expand $tooldir in ghc --info output

Summary:
This requires adding an `sToolDir :: Maybe FilePath` field to Settings, since
compilerInfo is pure and therefore needs to have all the information
available in the DynFlags.

This should fix #15101 and #15107.

Test Plan: ./validate --fast

Reviewers: Phyx, bgamari

Reviewed By: Phyx

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #15101, #15107

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

18 months agoFix unwinding of C -> Haskell FFI calls with -threaded
Bartosz Nitka [Thu, 3 May 2018 17:43:38 +0000 (10:43 -0700)] 
Fix unwinding of C -> Haskell FFI calls with -threaded

See the new note.

Test Plan:
manual testing with patched gdb

Reviewers: bgamari, simonmar, erikd

Subscribers: rwbarton, thomie, carter

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

18 months agoBlockAlloc.c: reuse tail_of function
Ömer Sinan Ağacan [Fri, 11 May 2018 07:24:00 +0000 (10:24 +0300)] 
BlockAlloc.c: reuse tail_of function

18 months agoRevert "Add -fghci-leak-check to check for space leaks"
Simon Marlow [Thu, 10 May 2018 16:39:53 +0000 (17:39 +0100)] 
Revert "Add -fghci-leak-check to check for space leaks"

This reverts commit 5fe6aaa3756cda654374ebfd883fa8f064ff64a4.

18 months agorts: remove unused round_up_to_mblocks function
Ömer Sinan Ağacan [Thu, 10 May 2018 15:05:51 +0000 (18:05 +0300)] 
rts: remove unused round_up_to_mblocks function

18 months agoFix #15038
Ömer Sinan Ağacan [Thu, 10 May 2018 08:13:37 +0000 (11:13 +0300)] 
Fix #15038

We introduce a new Id for unused pointer values in unboxed sums that is
not CAFFY. Because the Id is not CAFFY it doesn't make non-CAFFY
definitions CAFFY, fixing #15038.

To make sure anything referenced by the new id will be retained we get a
stable pointer to in on RTS startup.

Test Plan: Passes validate

Reviewers: simonmar, simonpj, hvr, bgamari, erikd

Reviewed By: simonmar

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #15038

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

18 months agoAdd -fghci-leak-check to check for space leaks
Simon Marlow [Wed, 2 May 2018 10:01:13 +0000 (11:01 +0100)] 
Add -fghci-leak-check to check for space leaks

Summary:
Space leaks in GHCi emerge from time to time and tend to come back again
after they get fixed. This is an attempt to limit regressions by

* adding a reliable detection for some classes of space leaks in GHCi
* turning on leak checking for all GHCi tests in the test suite, so that
  we'll notice if the leak appears again.

The idea for detecting space leaks is quite simple:

* find some data that we expect to be GC'd later, make a weak pointer to it
* when we expect the data to be dead, do a `performGC` and then check
  the status of the weak pointer.

It would be nice to apply this trick to lots of things in GHC,
e.g. ensuring that HsSyn is not retained after the desugarer, or
ensuring that CoreSyn from the previous simplifier pass is not retained.

Test Plan: validate

Reviewers: bgamari, simonpj, erikd, niteria

Subscribers: thomie, carter

GHC Trac Issues: #15111

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

18 months agoNormalize the element type of ListPat, fix #14547
HE, Tao [Tue, 8 May 2018 14:53:41 +0000 (10:53 -0400)] 
Normalize the element type of ListPat, fix #14547

Summary:
The element type of `List` maybe a type family instacen, rather than a trivial type.
For example in Trac #14547,

```
{-# LANGUAGE TypeFamilies, OverloadedLists #-}

class Foo f where
        type It f
        foo :: [It f] -> f

data List a = Empty | a :! List a deriving Show

instance Foo (List a) where
        type It (List a) = a
        foo [] = Empty
        foo (x : xs) = x :! foo xs
```

Here the element type of `[]` is `It (List a)`, we should also normalize
it as `a`.

Test Plan: make test TEST="T14547"

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: thomie, carter

GHC Trac Issues: #14547

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

18 months agoRevert "Normalize the element type of ListPat, fix #14547"
Ben Gamari [Tue, 8 May 2018 14:52:28 +0000 (10:52 -0400)] 
Revert "Normalize the element type of ListPat, fix #14547"

This reverts commit 981bf4718de7daef7817a363ccc14030c2688632.

18 months agoNormalize the element type of ListPat, fix #14547
Ben Gamari [Tue, 8 May 2018 14:08:04 +0000 (10:08 -0400)] 
Normalize the element type of ListPat, fix #14547

The element type of `List` maybe a type family instacen, rather than a
trivial type.
For example in Trac #14547,

```
{-# LANGUAGE TypeFamilies, OverloadedLists #-}

class Foo f where
        type It f
        foo :: [It f] -> f

data List a = Empty | a :! List a deriving Show

instance Foo (List a) where
        type It (List a) = a
        foo [] = Empty
        foo (x : xs) = x :! foo xs
```

Here the element type of `[]` is `It (List a)`, we should also normalize
it as `a`.

Test Plan: make test TEST="T14547"

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: thomie, carter

GHC Trac Issues: #14547

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

18 months agoRevert "Normalize the element type of ListPat, fix #14547"
Ben Gamari [Tue, 8 May 2018 14:07:53 +0000 (10:07 -0400)] 
Revert "Normalize the element type of ListPat, fix #14547"

This reverts commit 361d23a8ebb44f5df5167306d7b98d8bd1724e06.

18 months agousers-guide: Move discussion MAX_PATH out of release notes
Ben Gamari [Mon, 7 May 2018 18:43:45 +0000 (14:43 -0400)] 
users-guide: Move discussion MAX_PATH out of release notes

This discussion will be useful for users; move it into the users-guide proper.
Also fixes a few typos noted by @Phyx.

Test Plan: Read it

Reviewers: Phyx

Reviewed By: Phyx

Subscribers: dfeuer, Phyx, rwbarton, thomie, carter

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

18 months agoSimplify the kind checking for type/class decls
Simon Peyton Jones [Fri, 4 May 2018 15:31:55 +0000 (16:31 +0100)] 
Simplify the kind checking for type/class decls

This patch deletes quite a bit of code,
AND fixes Trac #15116.

18 months agoUsed named fields for DataDeclRn
Simon Peyton Jones [Fri, 4 May 2018 15:25:46 +0000 (16:25 +0100)] 
Used named fields for DataDeclRn

18 months agoSmall refactoring in Exitify
Simon Peyton Jones [Fri, 4 May 2018 15:24:26 +0000 (16:24 +0100)] 
Small refactoring in Exitify

This refactoring was provoked by our conversation on
Trac #14152.  No change in behaviour.

18 months agoprintStackChunk: recognise a few more ret frames
Ömer Sinan Ağacan [Sun, 6 May 2018 07:31:22 +0000 (10:31 +0300)] 
printStackChunk: recognise a few more ret frames

18 months agotestsuite: Bump T5631 expected allocations
Ben Gamari [Sun, 6 May 2018 01:50:37 +0000 (21:50 -0400)] 
testsuite: Bump T5631 expected allocations

This was failing on Darwin; I believe this is due to 33de71fa06d0.

18 months agobase/changelog: Note stabilization of asinh (#14927)
Ben Gamari [Sun, 6 May 2018 01:48:17 +0000 (21:48 -0400)] 
base/changelog: Note stabilization of asinh (#14927)

18 months agoStable area hyperbolic sine for `Double` and `Float`.
Justus Sagemüller [Wed, 28 Mar 2018 13:51:16 +0000 (15:51 +0200)] 
Stable area hyperbolic sine for `Double` and `Float`.

This function was unstable, in particular for negative arguments.

https://ghc.haskell.org/trac/ghc/ticket/14927

The reason is that the formula `log (x + sqrt (1 + x*x))` is dominated
by the numerical error of the `sqrt` function when x is strongly negative
(and thus the summands in the `log` mostly cancel). However, the area
hyperbolic sine is an odd function, thus the negative side can as well
be calculated by flipping over the positive side, which avoids this instability.

Furthermore, for _very_ big arguments, the `x*x` subexpression overflows. However,
long before that happens, the square root is anyways completely dominated
by that term, so we can neglect the `1 +` and get

    sqrt (1 + x*x) ≈ sqrt (x*x) = x

and therefore

    asinh x ≈ log (x + x) = log (2*x) = log 2 + log x

which does not overflow for any normal-finite positive argument, but
perfectly matches the exact formula within the floating-point accuracy.

18 months agoAdd hyperbolic functions to test of Float-inverses
Justus Sagemüller [Wed, 28 Mar 2018 12:44:51 +0000 (14:44 +0200)] 
Add hyperbolic functions to test of Float-inverses

The area hyperbolic sine is currently broken,
see https://ghc.haskell.org/trac/ghc/ticket/14927.

18 months agoAdd test for invertability of `Floating` methods.
Justus Sagemüller [Wed, 28 Mar 2018 10:52:30 +0000 (12:52 +0200)] 
Add test for invertability of `Floating` methods.

These functions have inverses only on part of the real line, but
there they should be reliably inverted – that's basically the whole
point of the functions like `asin`, `atan` etc..

18 months agoAdd 'addWordC#' PrimOp
Sebastian Graf [Sat, 5 May 2018 17:30:32 +0000 (13:30 -0400)] 
Add 'addWordC#' PrimOp

This is mostly for congruence with 'subWordC#' and '{add,sub}IntC#'.
I found 'plusWord2#' while implementing this, which both lacks
documentation and has a slightly different specification than
'addWordC#', which means the generic implementation is unnecessarily
complex.

While I was at it, I also added lacking meta-information on PrimOps
and refactored 'subWordC#'s generic implementation to be branchless.

Reviewers: bgamari, simonmar, jrtc27, dfeuer

Reviewed By: bgamari, dfeuer

Subscribers: dfeuer, thomie, carter

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

18 months agoUse unsafeInsertNew to create timers in TimerManager
Mitchell Rosen [Mon, 30 Apr 2018 22:05:07 +0000 (18:05 -0400)] 
Use unsafeInsertNew to create timers in TimerManager

18 months agoDo not supply `-mcpu` if `-optlc` provides `-mcpu` already.
Moritz Angermann [Fri, 4 May 2018 18:39:16 +0000 (14:39 -0400)] 
Do not supply `-mcpu` if `-optlc` provides `-mcpu` already.

Reviewers: bgamari

Subscribers: thomie, carter

GHC Trac Issues: #14982

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

18 months agotestsuite: Add test for #15067
Ben Gamari [Fri, 4 May 2018 18:26:30 +0000 (14:26 -0400)] 
testsuite: Add test for #15067

Subscribers: thomie, carter, RyanGlScott

GHC Trac Issues: #15067

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

18 months agoNormalize the element type of ListPat, fix #14547
HE, Tao [Thu, 3 May 2018 21:16:09 +0000 (17:16 -0400)] 
Normalize the element type of ListPat, fix #14547

The element type of `List` maybe a type family instacen, rather than a
trivial type.  For example in Trac #14547,

```
{-# LANGUAGE TypeFamilies, OverloadedLists #-}

class Foo f where
        type It f
        foo :: [It f] -> f

data List a = Empty | a :! List a deriving Show

instance Foo (List a) where
        type It (List a) = a
        foo [] = Empty
        foo (x : xs) = x :! foo xs
```

Here the element type of `[]` is `It (List a)`, we should also normalize
it as `a`.

Test Plan: make test TEST="T14547"

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: thomie, carter

GHC Trac Issues: #14547

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

18 months agoSplit TrieMap into a general (TrieMap) and core specific (CoreTrieMap) module.
klebinger.andreas@gmx.at [Thu, 3 May 2018 20:20:03 +0000 (16:20 -0400)] 
Split TrieMap into a general (TrieMap) and core specific (CoreTrieMap) module.

Splitting TrieMap into a general and core specific part allows us to
define instances for TrieMap without creating a transitive dependency on
CoreSyn.

Test Plan: ci

Reviewers: goldfire, bgamari, simonmar, simonpj

Reviewed By: bgamari, simonpj

Subscribers: simonpj, nomeata, thomie, carter

GHC Trac Issues: #15082

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

18 months agorel-notes: Note that -hT is now allowed
Ben Gamari [Thu, 3 May 2018 20:19:22 +0000 (16:19 -0400)] 
rel-notes: Note that -hT is now allowed

See #15086.

[skip-ci]

18 months agoFix typo in user guide about promoted list
Masahiro Sakai [Thu, 26 Apr 2018 14:42:43 +0000 (23:42 +0900)] 
Fix typo in user guide about promoted list

`:'` in explanation text should be `':` to match code example.

18 months agoUpdate docker images to use GHC 8.4.2 and cabal-install-2.2
mrkkrp [Thu, 26 Apr 2018 08:12:15 +0000 (15:12 +0700)] 
Update docker images to use GHC 8.4.2 and cabal-install-2.2

The ‘haskell’ images are not being updated and there is no image with GHC
8.4.2, so we probably should not use them anymore. I adapted Dockerfiles
used by those images so the end result is almost the same except we get
newer GHC and cabal-install.

18 months agotestsuite: Bump T9630 allocations as a result of 33de71fa06d0
Ben Gamari [Sat, 5 May 2018 17:08:04 +0000 (13:08 -0400)] 
testsuite: Bump T9630 allocations as a result of 33de71fa06d0

This patch made the simplifier inline nested function bindings less aggressively
and, while it didn't seem to affect nofib, appears to have regressed T9630
rather considerably.

18 months agoSimplify callSiteInline a little
Simon Peyton Jones [Fri, 4 May 2018 14:47:31 +0000 (15:47 +0100)] 
Simplify callSiteInline a little

This patch has virtually no effect on anything (according to a
nofib run).  But it simplifies the definition of interesting_call
by being a bit less gung-ho about inlining nested function
bindings.  See Note [Nested functions]

-----------------------------------------------------------------------
        Program           Size    Allocs   Runtime   Elapsed  TotalMem
-----------------------------------------------------------------------
           anna          +0.2%     -0.0%     0.163     0.163      0.0%
   binary-trees          +0.1%     +0.0%     -4.5%     -4.5%      0.0%
      cacheprof          -0.1%     +0.1%     -4.7%     -4.8%     +2.7%
          fasta          +0.2%      0.0%     +2.6%     +3.0%      0.0%
          fluid          -0.0%     -0.6%     0.011     0.011      0.0%
         gamteb          -0.1%     -0.0%     0.069     0.070      0.0%
            hpg          +0.1%     +0.0%     +0.7%     +0.7%      0.0%
          infer          +0.3%     +0.2%     0.097     0.098      0.0%
         lambda          -0.1%     -0.0%     +2.0%     +2.0%      0.0%
         n-body          +0.1%     -0.1%     -0.1%     -0.1%      0.0%
         simple          -0.2%     -0.2%     +0.6%     +0.6%      0.0%
  spectral-norm          +0.1%     -0.0%     -0.1%     -0.1%      0.0%
            tak          -0.0%     -0.1%     0.024     0.024      0.0%
--------------------------------------------------------------------------------
            Min          -0.4%     -0.6%     -5.3%     -5.3%      0.0%
            Max          +0.3%     +0.2%     +3.3%     +3.3%    +15.0%
 Geometric Mean          -0.0%     -0.0%     -0.3%     -0.3%     +0.2%

18 months agoNormalize T14999 test output some more
Bartosz Nitka [Fri, 4 May 2018 09:44:46 +0000 (02:44 -0700)] 
Normalize T14999 test output some more

@osa1 reported that the output on his machine has extra newlines:
https://phabricator.haskell.org/D4606#129092. This collapses consecutive
newlines.

18 months agoEnable warning flags to safe-guard against regressions in `base`
Herbert Valerio Riedel [Thu, 3 May 2018 16:50:25 +0000 (12:50 -0400)] 
Enable warning flags to safe-guard against regressions in `base`

Test Plan: via CI

Reviewers: bgamari

Subscribers: dfeuer, thomie, carter

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

18 months agorts: Throw better error if --numa is used without libnuma support
Ben Gamari [Thu, 3 May 2018 16:42:24 +0000 (12:42 -0400)] 
rts: Throw better error if --numa is used without libnuma support

Test Plan: Validate, run program with `+RTS --numa` without libnuma
support compiled in

Reviewers: erikd, simonmar

Subscribers: thomie, carter

GHC Trac Issues: #14956

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

18 months agoGHCi: Improve the error message for hidden packages
Chaitanya Koparkar [Thu, 3 May 2018 16:39:45 +0000 (12:39 -0400)] 
GHCi: Improve the error message for hidden packages

Test Plan: make test TEST=T15055

Reviewers: bgamari, RyanGlScott, osa1, Iceland_jack

Reviewed By: osa1

Subscribers: ulysses4ever, thomie, carter

GHC Trac Issues: #15055

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

18 months agoMove the ResponseFile module from haddock into base
Chaitanya Koparkar [Thu, 3 May 2018 16:38:36 +0000 (12:38 -0400)] 
Move the ResponseFile module from haddock into base

GHC and the build tools use "response files" to work around the limit
on the length of command line arguments on Windows. Haddock's
implementation of parsing response files (i.e escaping/unescaping the
appropriate characters) seems complete, is well tested, and also
closely matches the GCC version. This patch moves the relevant bits
into `base` so that it's easier for other libraries to reuse it.

Test Plan: make test TEST=T13896

Reviewers: bgamari, RyanGlScott, 23Skidoo, hvr

Reviewed By: RyanGlScott

Subscribers: thomie, carter

GHC Trac Issues: #13896

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

18 months agoCorrectly add unwinding info in manifestSp and makeFixupBlocks
Bartosz Nitka [Thu, 3 May 2018 16:37:00 +0000 (12:37 -0400)] 
Correctly add unwinding info in manifestSp and makeFixupBlocks

In `manifestSp` the unwind info was before the relevant instruction, not
after.  I added some notes to establish semantics.  Also removes
redundant annotation in stg_catch_frame.

For `makeFixupBlocks` it looks like we were off by `wORD_SIZE dflags`.
I'm not sure why, but it lines up with `manifestSp`.  In fact it lines
up so well so that I can consolidate the Sp unwind logic in
`maybeAddUnwind`.  I detected the problems with `makeFixupBlocks` by
running T14779b after patching D4559.

Test Plan: added a new test

Reviewers: bgamari, scpmw, simonmar, erikd

Reviewed By: bgamari

Subscribers: thomie, carter

GHC Trac Issues: #14999

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

18 months agoFix NUMA support on Windows (#15049)
David Kraeutmann [Thu, 3 May 2018 16:36:34 +0000 (12:36 -0400)] 
Fix NUMA support on Windows (#15049)

* osNumaNodes now returns the right number of nodes
* thread affinity is now correctly set

TODO: no noticeable performance improvement.
does windows already distribute threads in a NUMA-aware fashion?

Test Plan:
* validate
* local tests on a NUMA machine

Reviewers: bgamari, erikd, simonmar

Reviewed By: bgamari, simonmar

Subscribers: thomie, carter

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

18 months agoCircleCI: Save test results as JUnit XML
Matthew Pickering [Thu, 3 May 2018 16:35:22 +0000 (12:35 -0400)] 
CircleCI: Save test results as JUnit XML

Reviewers: mrkkrp, bgamari

Reviewed By: mrkkrp, bgamari

Subscribers: thomie, carter

GHC Trac Issues: #15093

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

18 months agoDon't shadow "result" in JUnit driver
Matthew Pickering [Thu, 3 May 2018 16:35:07 +0000 (12:35 -0400)] 
Don't shadow "result" in JUnit driver

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: thomie, carter

GHC Trac Issues: #15093

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

18 months agominor improvement to wording of warning against First. Add warning against Last
Andrew Martin [Thu, 26 Apr 2018 01:01:25 +0000 (21:01 -0400)] 
minor improvement to wording of warning against First. Add warning against Last

18 months agodocument the plan for removing Data.Semigroup.Option
Andrew Martin [Wed, 25 Apr 2018 23:44:29 +0000 (19:44 -0400)] 
document the plan for removing Data.Semigroup.Option

18 months agoWarn against using Data.Monoid.First
Andrew Martin [Wed, 25 Apr 2018 23:35:36 +0000 (19:35 -0400)] 
Warn against using Data.Monoid.First

Noting that it will be removed in the future.

18 months agoCompute DW_FORM_block length correctly; also fixes #15068
Bertram Felgenhauer [Thu, 3 May 2018 15:03:53 +0000 (18:03 +0300)] 
Compute DW_FORM_block length correctly; also fixes #15068

Before this patch, the pprUnwindwExpr function computed the length of
by the following assembly fragment:

.uleb128 1f-.-1
<expression data>
1:

That is, to compute the length, it takes the difference of the label 1
and the address of the .uleb128 directive, and subtracts 1.

In #15068 it was reported that `as` from binutils 4.30 has trouble with
evaluating the `.` part of the expression. However, there is actually a
problem with the expression, if the length of the data ever becomes
larger than 128: In that case, the .uleb128 directive will emit more
than 1 byte, and the computed length will be wrong.

The present patch changes the assembly fragment to use two labels,
which fixes both these problems.

.uleb128 2f-1f
1:
<expression data>
2:

Test Plan: validate

Reviewers: bgamari, osa1

Reviewed By: bgamari

Subscribers: thomie, carter

GHC Trac Issues: #15068

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

18 months agoAdd regression tests for #14904
Ryan Scott [Thu, 3 May 2018 14:15:45 +0000 (10:15 -0400)] 
Add regression tests for #14904

Trac #14904 was fixed in commit
faec8d358985e5d0bf363bd96f23fe76c9e281f7. Let's add some tests to
ensure that it stays fixed.

18 months agoTest Trac #15114
Simon Peyton Jones [Thu, 3 May 2018 07:51:29 +0000 (08:51 +0100)] 
Test Trac #15114

18 months agoSet arity for absentError
David Feuer [Thu, 3 May 2018 03:43:13 +0000 (23:43 -0400)] 
Set arity for absentError

* The note on how to prevent stable unfoldings from leading to
  `case` on `absentError` was wrong. Make it reflect reality.

* Reviewing the above change, Simon noticed that we didn't
  set an arity for `absentError`, which definitely has arity 1.
  It may not matter much, since `absentError` usually vanishes
  quickly, but we might as well set it properly, so now we do.

Reviewers: simonpj, bgamari

Reviewed By: simonpj

Subscribers: thomie, carter

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

18 months agostorageAddCapabilities: fix bug in updating nursery pointers
Simon Marlow [Fri, 27 Apr 2018 18:31:19 +0000 (11:31 -0700)] 
storageAddCapabilities: fix bug in updating nursery pointers

Summary:
We were unconditionally updating the nursery pointers to be
`nurseries[cap->no]`, but when using nursery chunks this might be
wrong. This manifested as a later assertion failure in allocate().

Test Plan: new test case

Reviewers: bgamari, niteria, erikd

Subscribers: thomie, carter

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

18 months agoerrorWithoutStackTrace: omit profiling stack trace (#14970)
Simon Marlow [Sat, 21 Apr 2018 11:22:18 +0000 (12:22 +0100)] 
errorWithoutStackTrace: omit profiling stack trace (#14970)

Test Plan: validate

Reviewers: hvr, bgamari, erikd

Subscribers: thomie, carter

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

18 months agoExitify: Do not trip over shadowing (fixes #15110)
Joachim Breitner [Wed, 2 May 2018 02:33:01 +0000 (22:33 -0400)] 
Exitify: Do not trip over shadowing (fixes #15110)

18 months agorts: Allow profiling by closure type in prof way
Ben Gamari [Tue, 1 May 2018 17:10:13 +0000 (13:10 -0400)] 
rts: Allow profiling by closure type in prof way

Previously we inexplicably disabled support for `-hT` profiling in the profiled
way. Admittedly, there are relatively few cases where one would prefer -hT to
`-hd`, but the option should nevertheless be available for the sake of
consistency.

Note that this does mean that there is a bit of an inconsistency in the behavior
of `-h`: in the profiled way `-h` behaves like `-hc` whereas in the non-profiled
way it defaults to `-hT`.

18 months agorts: Add -hT to the rts usage message
Ben Gamari [Tue, 1 May 2018 18:57:31 +0000 (14:57 -0400)] 
rts: Add -hT to the rts usage message

Reviewers: erikd, simonmar

Subscribers: thomie, carter

GHC Trac Issues: #15086

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