ghc.git
2 years agoAvoid excessive space usage from unfoldings in CoreTidy wip/rwbarton-D3516
Reid Barton [Sun, 30 Apr 2017 23:43:03 +0000 (19:43 -0400)] 
Avoid excessive space usage from unfoldings in CoreTidy

Test Plan: validate

Reviewers: austin, bgamari

Subscribers: thomie

GHC Trac Issues: #13564

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

2 years agoRemove unused tidyOccNames and update Note
Joachim Breitner [Sun, 30 Apr 2017 07:29:49 +0000 (09:29 +0200)] 
Remove unused tidyOccNames and update Note

addressing rwbarton’s concerns in
https://phabricator.haskell.org/rGHC18ac80ff729e#66197

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

2 years agoPrefer #if defined to #ifdef
Ben Gamari [Fri, 21 Apr 2017 13:16:48 +0000 (09:16 -0400)] 
Prefer #if defined to #ifdef

Our new CPP linter enforces this.

2 years agoEnable new warning for fragile/incorrect CPP #if usage
Erik de Castro Lopo [Tue, 4 Apr 2017 19:53:46 +0000 (05:53 +1000)] 
Enable new warning for fragile/incorrect CPP #if usage

The C code in the RTS now gets built with `-Wundef` and the Haskell code
(stages 1 and 2 only) with `-Wcpp-undef`. We now get warnings whereever
`#if` is used on undefined identifiers.

Test Plan: Validate on Linux and Windows

Reviewers: austin, angerman, simonmar, bgamari, Phyx

Reviewed By: bgamari

Subscribers: thomie, snowleopard

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

2 years agoImprove code generation for conditionals
Simon Peyton Jones [Wed, 8 Mar 2017 11:05:53 +0000 (11:05 +0000)] 
Improve code generation for conditionals

This patch in in preparation for the fix to Trac #13397

The code generator has a special case for
  case tagToEnum (a>#b) of
    False -> e1
    True  -> e2

but it was not doing nearly so well on
  case a>#b of
    DEFAULT -> e1
    1#      -> e2

This patch arranges to behave essentially identically in
both cases.  In due course we can eliminate the special
case for tagToEnum#, once we've completed Trac #13397.

The changes are:

* Make CmmSink swizzle the order of a conditional where necessary;
  see Note [Improving conditionals] in CmmSink

* Hack the general case of StgCmmExpr.cgCase so that it use
  NoGcInAlts for conditionals.  This doesn't seem right, but it's
  the same choice as the tagToEnum version. Without it, code size
  increases a lot (more heap checks).

  There's a loose end here.

* Add comments in CmmOpt.cmmMachOpFoldM

2 years agoRe-engineer caseRules to add tagToEnum/dataToTag
Simon Peyton Jones [Wed, 8 Mar 2017 10:26:47 +0000 (10:26 +0000)] 
Re-engineer caseRules to add tagToEnum/dataToTag

See Note [Scrutinee Constant Folding] in SimplUtils

* Add cases for tagToEnum and dataToTag. This is the main new
  bit.  It allows the simplifier to remove the pervasive uses
  of     case tagToEnum (a > b) of
            False -> e1
            True  -> e2
  and replace it by the simpler
         case a > b of
            DEFAULT -> e1
            1#      -> e2
  See Note [caseRules for tagToEnum]
  and Note [caseRules for dataToTag] in PrelRules.

* This required some changes to the API of caseRules, and hence
  to code in SimplUtils.  See Note [Scrutinee Constant Folding]
  in SimplUtils.

* Avoid duplication of work in the (unusual) case of
     case BIG + 3# of b
       DEFAULT -> e1
       6#      -> e2

  Previously we got
     case BIG of
       DEFAULT -> let b = BIG + 3# in e1
       3#      -> let b = 6#       in e2

  Now we get
     case BIG of b#
       DEFAULT -> let b = b' + 3# in e1
       3#      -> let b = 6#      in e2

* Avoid duplicated code in caseRules

A knock-on refactoring:

* Move Note [Word/Int underflow/overflow] to Literal, as
  documentation to accompany mkMachIntWrap etc; and get
  rid of PrelRuls.intResult' in favour of mkMachIntWrap

2 years agoMove dataConTagZ to DataCon
Simon Peyton Jones [Tue, 7 Mar 2017 13:28:34 +0000 (13:28 +0000)] 
Move dataConTagZ to DataCon

Just a simple refactoring to remove duplication

2 years agonativeGen: Use SSE2 SQRT instruction
Ben Gamari [Fri, 28 Apr 2017 18:24:53 +0000 (14:24 -0400)] 
nativeGen: Use SSE2 SQRT instruction

Reviewers: austin, dfeuer

Subscribers: dfeuer, rwbarton, thomie

GHC Trac Issues: #13629

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

2 years agoCSE: Fix cut and paste error
Ben Gamari [Fri, 28 Apr 2017 17:25:17 +0000 (13:25 -0400)] 
CSE: Fix cut and paste error

extendCSRecEnv took the map to be extended from cs_map instead of
cs_rec_map.  Oops!

Test Plan: Validate

Reviewers: simonpj, austin

Subscribers: rwbarton, thomie

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

2 years agoUse memcpy in cloneArray
Ben Gamari [Fri, 28 Apr 2017 17:24:47 +0000 (13:24 -0400)] 
Use memcpy in cloneArray

While looking at #13615 I noticed that there was this strange open-coded
memcpy in the definition of the cloneArray macro. I don't see why this
should be preferable to memcpy.

Test Plan: Validate, particularly focusing on array operations

Reviewers: simonmar, tibbe, austin, alexbiehl

Reviewed By: tibbe, alexbiehl

Subscribers: alexbiehl, rwbarton, thomie

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

2 years agoMake the tyvars in TH-reified data family instances uniform
Ryan Scott [Fri, 28 Apr 2017 17:24:31 +0000 (13:24 -0400)] 
Make the tyvars in TH-reified data family instances uniform

It turns out we were using two different sets of type variables when
reifying data family instances in Template Haskell. We were using the
tyvars quantifying over the instance itself for the LHS, but using the
tyvars quantifying over the data family instance constructor for the
RHS. This commit uses the instance tyvars for both the LHS and the RHS,
fixing #13618.

Test Plan: make test TEST=T13618

Reviewers: goldfire, austin, bgamari

Reviewed By: goldfire, bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13618

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

2 years agoAdd regression test for #12104
Ryan Scott [Fri, 28 Apr 2017 17:24:11 +0000 (13:24 -0400)] 
Add regression test for #12104

Commit 2f9f1f86849ebc18af409c9b3fd809c9cd464021
(#13487) fixes #12104 as well. This adds a regression test for the
program reported in #12104 to keep it fixed.

Test Plan: make test TEST=T12104

Reviewers: bgamari, austin

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #12104

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

2 years agoget-win32-tarballs: Grab perl tarball from haskell.org, not GitHub
Ben Gamari [Fri, 28 Apr 2017 17:20:14 +0000 (13:20 -0400)] 
get-win32-tarballs: Grab perl tarball from haskell.org, not GitHub

Reviewers: austin, dfeuer

Reviewed By: dfeuer

Subscribers: Phyx, rwbarton, thomie

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

2 years agoBe a bit more eager to inline in a strict context
Simon Peyton Jones [Thu, 27 Apr 2017 16:42:01 +0000 (17:42 +0100)] 
Be a bit more eager to inline in a strict context

If we see f (g x), and f is strict, we want to be a bit more eager to
inline g, because it may well expose an eval (on x perhaps) that can
be eliminated or shared.

I saw this in nofib boyer2, function RewriteFuns.onewayunify1.  It
showed up as a consequence of the preceding patch that makes the
simplifier do less work (Trac #13379).  We had

   f d (g x)

where f was a class-op. Previously we simplified both d and
(g x) with a RuleArgCtxt (making g a bit more eager to inline).
But now we simplify only d that way, then fire the rule, and
only then simplify (g x).  Firing the rule produces a strict
funciion, so we want to make a strict function encourage
inlining a bit.

2 years agoCure exponential behaviour in the simplifier
Simon Peyton Jones [Wed, 26 Apr 2017 16:31:36 +0000 (17:31 +0100)] 
Cure exponential behaviour in the simplifier

This patch nails a Bad Bug exposed in Trac #13379. Roughly,
a deeply-nested application like
   f (f (f ....) ) )
could make the simplifier go exponential -- without producing
an exponential-sized result!

The reason was that we
  - simplified a (big) function argument
  - then decided to inline the function
  - then preInilneUnconditionally the argument
  - and then re-simplified the big argument

And if the "big argument" itself had a similar structure
things could get very bad.

Once I'd understood, it was easy to fix:

* See Note Note [Avoiding exponential behaviour] for an overview

* The key change is that Simplify.simplLam now as a case for
  (isSimplified dup). This is what removes the perf bug.

* But I also made simplCast more parsimonious about simplifying,
  avoiding doing so when the coercion is Refl

* And similarly I now try to avoid simplifying arguments
  where possible before applying rules.
  See Note [Trying rewrite rules]

The latter two points tackle common cases, and in those cases make the
simplifier take fewer iterations.

2 years agoEta expansion and join points
Simon Peyton Jones [Wed, 26 Apr 2017 15:57:15 +0000 (16:57 +0100)] 
Eta expansion and join points

CoreArity.etaExpand tried to deal with eta-expanding expressions
with join points.  For example
    let j x = e in \y. b

But it is hard to eta-expand this in the "no-crap" way described in
Note [No crap in eta-expanded code], becuase it would mean pushing
the "apply to y" into the join RHS, and changing its type. And the
join might be recursive, and it might have an unfolding.

Moreover in elaborate cases like this I don't think we need the
no-crap thing.  So for now I'm simplifying the code by generating
   \z. (let j x = e in \y. b) z

Let's see if that gives rise to any problems.
See Note [Eta expansion for join points]

2 years agoComments only
Simon Peyton Jones [Wed, 26 Apr 2017 15:56:33 +0000 (16:56 +0100)] 
Comments only

2 years agoComments only
Simon Peyton Jones [Tue, 25 Apr 2017 12:15:44 +0000 (13:15 +0100)] 
Comments only

2 years agoA bit more tcTrace
Simon Peyton Jones [Tue, 25 Apr 2017 12:15:04 +0000 (13:15 +0100)] 
A bit more tcTrace

2 years agoComments and tiny refactoring
Simon Peyton Jones [Fri, 21 Apr 2017 12:12:15 +0000 (13:12 +0100)] 
Comments and tiny refactoring

2 years agoBump process to 1.6
Ben Gamari [Fri, 21 Apr 2017 16:45:40 +0000 (12:45 -0400)] 
Bump process to 1.6

Also bumps Cabal submodule due to version bound bump.

2 years agoUpdate Cabal submodule, with necessary wibbles.
Edward Z. Yang [Wed, 26 Apr 2017 19:26:56 +0000 (15:26 -0400)] 
Update Cabal submodule, with necessary wibbles.

Test Plan: validate

Reviewers: bgamari, austin

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

2 years agoUpdate hsc2hs submodule to 0.68.2
Ben Gamari [Wed, 26 Apr 2017 17:05:57 +0000 (13:05 -0400)] 
Update hsc2hs submodule to 0.68.2

2 years agoAdd instances for Data.Ord.Down
Adam Sandberg Eriksson [Tue, 25 Apr 2017 22:41:28 +0000 (18:41 -0400)] 
Add instances for Data.Ord.Down

Namely `Num`, `Functor`, `Applicative`, `Monad`, `Semigroup` and
`Monoid` for `Data.Ord.Down` (#13097).

Reviewers: austin, hvr, bgamari, RyanGlScott

Reviewed By: bgamari, RyanGlScott

Subscribers: RyanGlScott, rwbarton, thomie

GHC Trac Issues: #13097

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

2 years agoDocument mkWeak#
Ben Gamari [Tue, 25 Apr 2017 22:39:58 +0000 (18:39 -0400)] 
Document mkWeak#

Reviewers: simonmar, austin

Reviewed By: simonmar

Subscribers: RyanGlScott, rwbarton, thomie

GHC Trac Issues: #10640, #13611

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

2 years agoOnly pretty-print binders in closed type families with -fprint-explicit-foralls
Ryan Scott [Tue, 25 Apr 2017 22:38:34 +0000 (18:38 -0400)] 
Only pretty-print binders in closed type families with -fprint-explicit-foralls

Previously, we were unconditionally pretty-printing all type variable
binders when pretty-printing closed type families (e.g., in the output
of `:info` in GHCi). This threw me for a loop, so let's guard this behind
the `-fprint-explicit-foralls` flag.

Test Plan: make test TEST=T13420

Reviewers: goldfire, austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13420

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

2 years agoAdd backup url and sync support for Win32 tarball script
Tamar Christina [Tue, 25 Apr 2017 22:38:14 +0000 (18:38 -0400)] 
Add backup url and sync support for Win32 tarball script

This imports @bgamari's sync script into the mirror script
and adds a backup url for packages.

The idea is that the URLs won't need updating when updating
the tarballs from now on.

It will first try haskell.org,
failing that it'll try repo.msys2.org

Test Plan: try new command `mk/get-win32-tarballs.sh sync`

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, bgamari

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

2 years agoPPC NCG: Implement callish prim ops
Peter Trommler [Tue, 25 Apr 2017 22:37:16 +0000 (18:37 -0400)] 
PPC NCG: Implement callish prim ops

Provide PowerPC optimised implementations of callish prim ops.

MO_?_QuotRem
The generic implementation of quotient remainder prim ops uses
a division and a remainder operation. There is no remainder on
PowerPC and so we need to implement remainder "by hand" which
results in a duplication of the divide operation when using the
generic code.

Avoid this duplication by implementing the prim op in the native
code generator.

MO_U_Mul2
Use PowerPC's instructions for long multiplication.

Addition and subtraction
Use PowerPC add/subtract with carry/overflow instructions

MO_Clz and MO_Ctz
Use PowerPC's CNTLZ instruction and implement count trailing
zeros using count leading zeros

MO_QuotRem2
Implement an algorithm given by Henry Warren in "Hacker's Delight"
using PowerPC divide instruction. TODO: Use long division instructions
when available (POWER7 and later).

Test Plan: validate on AIX and 32-bit Linux

Reviewers: simonmar, erikd, hvr, austin, bgamari

Reviewed By: erikd, hvr, bgamari

Subscribers: trofi, kgardas, thomie

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

2 years agoconfigure: Kill off FP_ARG_WITH_*
Ben Gamari [Tue, 25 Apr 2017 22:32:24 +0000 (18:32 -0400)] 
configure: Kill off FP_ARG_WITH_*

This replaces the --with-* configure flags with the usual autoconf
environment variables, as suggested by #13583.

Test Plan: Configure on various platforms

Reviewers: hvr, trofi, thomie, austin

Reviewed By: trofi

Subscribers: rwbarton, erikd

GHC Trac Issues: #13583

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

2 years agoRevert "Remove special casing of Windows in generic files"
Ben Gamari [Tue, 25 Apr 2017 13:28:40 +0000 (09:28 -0400)] 
Revert "Remove special casing of Windows in generic files"

This commit didn't consider the fact that binary distributions on Windows must
have relative toolchain paths. This caused #13560.

This reverts commit 48385cb2fc295eb8af9188cbe140142c1807d5a7 (except for a
helpful comment).

2 years agoDon't describe tuple sections as "Python-style"
Chris Martin [Sat, 22 Apr 2017 22:26:22 +0000 (18:26 -0400)] 
Don't describe tuple sections as "Python-style"

(cherry picked from commit 960589e89da3dbf60e88042d7e064ad4a98fb2ff)

2 years agoDon't setProgramDynFlags on every :load
Simon Marlow [Thu, 30 Mar 2017 09:31:08 +0000 (10:31 +0100)] 
Don't setProgramDynFlags on every :load

Summary:
setProgramDynFlags invalidates the whole module graph, forcing
everything to be re-summarised (including preprocessing) on every
:reload.

Looks like this was a bad regression in 8.0, but we didn't notice
because there was no test for it.  Now there is!

Test Plan:
* validate
* new unit test

Reviewers: bgamari, triple, austin, niteria, erikd, jme

Subscribers: rwbarton, thomie

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

2 years agocore-spec: Simplify the handling of LetRec
Joachim Breitner [Tue, 18 Apr 2017 20:33:38 +0000 (16:33 -0400)] 
core-spec: Simplify the handling of LetRec

We do not need to keep an enrivonment around to implement letrec, as
long as we only do call-by-name. Instead, evaluate letrec by
substituting for all the variables with their RHS wrapped in the letrec
binding.

Since nothing adds to the enrivonment any more, there is no need for a
S_Var rule.

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

2 years agoGuard yet another /bin/sh `for in` loop against empty vars
Herbert Valerio Riedel [Mon, 24 Apr 2017 20:22:32 +0000 (22:22 +0200)] 
Guard yet another /bin/sh `for in` loop against empty vars

This is a follow-up to df6794035f1e4397d89896f329525e5368b7d1cc
which missed `INSTALL_BINS`

2 years agoAdd failing test case for T13611
Joachim Breitner [Mon, 24 Apr 2017 17:15:47 +0000 (13:15 -0400)] 
Add failing test case for T13611

this program should be rejected, but is not (and segfaults).

2 years agotestsuite/driver: Fix deletion retry logic on Windows
Ben Gamari [Mon, 24 Apr 2017 13:41:56 +0000 (09:41 -0400)] 
testsuite/driver: Fix deletion retry logic on Windows

Previously rmtree's error callback would throw an exception, breaking
out of the retry loop.

Test Plan: Validate on Windows

Reviewers: Phyx, austin

Reviewed By: Phyx

Subscribers: rwbarton, thomie

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

2 years agocompiler/cmm/PprC.hs: constify labels in .rodata
Sergei Trofimovich [Mon, 24 Apr 2017 13:41:35 +0000 (09:41 -0400)] 
compiler/cmm/PprC.hs: constify labels in .rodata

Consider one-line module
    module B (v) where v = "hello"
in -fvia-C mode it generates code like
    static char gibberish_str[] = "hello";

It resides in data section (precious resource on ia64!).
The patch switches genrator to emit:
    static const char gibberish_str[] = "hello";

Other types if symbols that gained 'const' qualifier are:

- info tables (from haskell and CMM)
- static reference tables (from haskell and CMM)

Cleanups along the way:

- fixed info tables defined in .cmm to reside in .rodata
- split out closure declaration into 'IC_' / 'EC_'
- added label declaration (based on label type) right before
  each label definition (based on section type) so that C
  compiler could check if declaration and definition matches
  at definition site.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Test Plan: ran testsuite on unregisterised x86_64 compiler

Reviewers: simonmar, ezyang, austin, bgamari, erikd

Reviewed By: bgamari, erikd

Subscribers: rwbarton, thomie

GHC Trac Issues: #8996

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

2 years agoDisable terminfo, if we don’t build it.
Moritz Angermann [Mon, 24 Apr 2017 13:38:14 +0000 (09:38 -0400)] 
Disable terminfo, if we don’t build it.

This is a derivation of a patch from @jophish.

This is necessary due to `haskeline`'s `terminfo` flag being marked as
`Manual` as of 43d7fa106027fcd4ec7f443923a8dd5b8c169f9c.

Reviewers: jophish, bgamari, austin

Reviewed By: bgamari

Subscribers: rwbarton, thomie, jophish

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

2 years agoAdd regression test for #13603
Ryan Scott [Mon, 24 Apr 2017 14:47:51 +0000 (10:47 -0400)] 
Add regression test for #13603

Summary:
Commit b207b536ded40156f9adb168565ca78e1eef2c74 (#11714) happened to
fix #13603 as well. Let's add a regression test so that it stays fixed.

Test Plan: make test TEST=T13603

Reviewers: bgamari, austin, simonpj

Reviewed By: bgamari, simonpj

Subscribers: simonpj, rwbarton, thomie

GHC Trac Issues: #13603

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

2 years agotestsuite: Mark T13075 as broken due to #13075
Ben Gamari [Sun, 23 Apr 2017 22:52:46 +0000 (18:52 -0400)] 
testsuite: Mark T13075 as broken due to #13075

2 years agoExport function for use in GHC API
Alan Zimmerman [Sun, 23 Apr 2017 16:53:33 +0000 (18:53 +0200)] 
Export function for use in GHC API

2 years agotestsuite: Add testcase for #13075
Ben Gamari [Sun, 23 Apr 2017 14:59:02 +0000 (10:59 -0400)] 
testsuite: Add testcase for #13075

2 years agotestsuite: Increase T13056 window size to +/-10%
Ben Gamari [Sat, 22 Apr 2017 14:18:23 +0000 (10:18 -0400)] 
testsuite: Increase T13056 window size to +/-10%

2 years agotestsuite: Add testcase for #13587
Ben Gamari [Sun, 23 Apr 2017 14:04:03 +0000 (10:04 -0400)] 
testsuite: Add testcase for #13587

Test Plan: Validate

Reviewers: austin

Subscribers: rwbarton, thomie

GHC Trac Issues: #13587

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

2 years agotestsuite: Add test for #13591
Ben Gamari [Sun, 23 Apr 2017 14:03:46 +0000 (10:03 -0400)] 
testsuite: Add test for #13591

Reviewers: austin

Subscribers: rwbarton, thomie

GHC Trac Issues: #13591

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

2 years agoOnly build iserv with -threaded if GhcThreaded is set
Reid Barton [Sun, 23 Apr 2017 14:03:22 +0000 (10:03 -0400)] 
Only build iserv with -threaded if GhcThreaded is set

By default GhcThreaded is set by
```
GhcThreaded = $(if $(findstring thr,$(GhcRTSWays)),YES,NO)
```
so it seems incorrect to try to build iserv with -threaded when
GhcThreaded is not set. This came up when I was building GHC with
some strange combination of flavours (debugged and profiled but not
threaded).

Test Plan: harbormaster

Reviewers: simonmar, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie, snowleopard

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

2 years agoDocument the kind generalization behavior observed in #13555
Ryan Scott [Sun, 23 Apr 2017 14:02:45 +0000 (10:02 -0400)] 
Document the kind generalization behavior observed in #13555

The conclusion of #13555 was that a program which began to fail to
typecheck (starting in GHC 8.2) was never correct to begin with. Let's
document why this is the case with respect to `MonoLocalBinds`'
interaction with kind generalization. Also adds the reported program as
a `compile_fail` testcase.

Test Plan: make test TEST=T13555 # Also, read the docs

Reviewers: goldfire, simonpj, austin, bgamari

Reviewed By: goldfire, simonpj, bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13555

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

2 years ago[linker] Adds elf_compat.h, util.h, elf_util.h
Moritz Angermann [Sun, 23 Apr 2017 14:02:21 +0000 (10:02 -0400)] 
[linker] Adds elf_compat.h, util.h, elf_util.h

Further cleanup of the linker, we'll add elf_compat.h for a more
complete set of relocations.

Also Util.h has been added as suggested in the code already.

Depends on D3444, D3445

Reviewers: bgamari, austin, erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, thomie

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

2 years ago[linker] Adds ElfTypes
Moritz Angermann [Sun, 23 Apr 2017 14:02:02 +0000 (10:02 -0400)] 
[linker] Adds ElfTypes

This diff introduces ElfTypes similar to provide the linker
code with a richer data structure, similar to the approach
taken for mach-o already.

Reviewers: bgamari, austin, erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, thomie

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

2 years agorts: Fix "ASSERT ("s
Ben Gamari [Sun, 23 Apr 2017 14:00:19 +0000 (10:00 -0400)] 
rts: Fix "ASSERT ("s

Reviewers: austin, erikd, simonmar

Reviewed By: erikd

Subscribers: rwbarton, thomie

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

2 years agocpp: Use #pragma once instead of #ifndef guards
Ben Gamari [Sat, 22 Apr 2017 13:34:18 +0000 (09:34 -0400)] 
cpp: Use #pragma once instead of #ifndef guards

This both says what we mean and silences a bunch of spurious CPP linting
warnings. This pragma is supported by all CPP implementations which we
support.

Reviewers: austin, erikd, simonmar, hvr

Reviewed By: simonmar

Subscribers: rwbarton, thomie

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

2 years agowin32/Ticker: Stop ticker on exit
Ben Gamari [Sat, 22 Apr 2017 13:33:31 +0000 (09:33 -0400)] 
win32/Ticker: Stop ticker on exit

While debugging an unrelated issue I noticed that we leak a
TimerQueueTimer on exit since we don't necessarily call stopTicker
before exitTicker. Fix this.

Test Plan: Validate on Windows

Reviewers: simonmar, austin, erikd

Reviewed By: simonmar

Subscribers: rwbarton, thomie

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

2 years agoghc.mk: fix 'make install' for cross-mingw32
Sergei Trofimovich [Sun, 23 Apr 2017 14:31:13 +0000 (15:31 +0100)] 
ghc.mk: fix 'make install' for cross-mingw32

Attempt to install cross-compiled mingw32 GHC built on linux failed as:

    $ make install DESTDIR=$(pwd)/__i__

    "mv" "$(pwd)/__i__/usr/local/lib/ghc-8.3.20170422/bin/ghc-stage2" \
         "$(pwd)/__i__/usr/local/lib/ghc-8.3.20170422/bin/ghc"
    mv: failed to stat
         '$(pwd)/__i__/usr/local/lib/ghc-8.3.20170422/bin/ghc-stage2': \
         No such file or directory

The rename should not be performed for windows targets.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2 years agoghc: tweak cross-compilation to mingw32
Sergei Trofimovich [Sun, 23 Apr 2017 14:10:26 +0000 (15:10 +0100)] 
ghc: tweak cross-compilation to mingw32

The build failure when cross-compiling from
linux to windows looks like:

    HC [stage 1] ghc/stage2/build/tmp/ghc-stage2.exe
      Call hs_init_ghc() from your main() function to set these options.
  /usr/libexec/gcc/i686-w64-mingw32/ld: cannot find -lHSghc-8.3-0

Similar to commit 745032dd02da511067c2939259ed212852187e0f
("rts: tweak cross-compilation to mingw32") decision to split
stage2 should be done based based on TargetOS, not HostOS.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2 years agoFix compilation for !HAVE_FLOCK
Herbert Valerio Riedel [Sun, 23 Apr 2017 13:41:50 +0000 (15:41 +0200)] 
Fix compilation for !HAVE_FLOCK

2 years agoMinor reordering of `#include`s fixing compilation on AIX
Herbert Valerio Riedel [Sun, 23 Apr 2017 13:28:52 +0000 (15:28 +0200)] 
Minor reordering of `#include`s fixing compilation on AIX

This helps ensure that system includes on some more fragile
platforms (like e.g. AIX) see a more consistent set of CPP defines,
and consequently reduce the risk of conflicting typdefs/prototypes
being exposed.

2 years agorts: tweak cross-compilation to mingw32
Sergei Trofimovich [Sun, 23 Apr 2017 10:44:45 +0000 (11:44 +0100)] 
rts: tweak cross-compilation to mingw32

Found the problem on x86_64-linux host where
I tried to cross-compile GHC to windows as:

    $ ./configure --target=i686-w64-mingw32 \
                  Windres=i686-w64-mingw32-windres \
                  DllWrap=i686-w64-mingw32-dllwrap

As a result build failed as POSIX bits of RTS.
For example 'rts/posix/OSMem.c' contains unix-specific
mmap() syscalls and constants and thus can't be compiled
by i686-w64-mingw32 toolchain.

It's caused by the following part of 'rts/ghc.mk':

  ifeq "$(HostOS_CPP)" "mingw32"
  ALL_DIRS += win32
  else
  ALL_DIRS += posix
  endif

In our case _CPP variables are defined this way (project.mk):
  BuildOS_CPP                = linux
  HostOS_CPP                 = linux
  TargetOS_CPP               = mingw32

RTS should never be built for 'BuildOS' or 'HostOS' as it's
always built by ghc-stage1 (targeted at TargetOS).

The change is to flip 'HostOS_CPP' to 'TargetOS_CPP' in 'rts/ghc.mk'.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2 years agoaclocal.m4: treat '*-w64-mingw32' targets as windows
Sergei Trofimovich [Sun, 23 Apr 2017 10:25:29 +0000 (11:25 +0100)] 
aclocal.m4: treat '*-w64-mingw32' targets as windows

Noticed when tried to cross-compile GHC from x86_64-linux
to --target=i686-w64-mingw32. Final ghc executables did
not have '.exe' extensions.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2 years agoconfigure.ac: print paths to dllwrap and windres
Sergei Trofimovich [Sun, 23 Apr 2017 10:22:44 +0000 (11:22 +0100)] 
configure.ac: print paths to dllwrap and windres

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2 years agoFirst update mingw-w64 packages for 8.4
Tamar Christina [Sun, 23 Apr 2017 10:21:18 +0000 (11:21 +0100)] 
First update mingw-w64 packages for 8.4

Summary: Updating to get latest binutils etc.

Test Plan: ./validate

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, snowleopard

GHC Trac Issues: #12913

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

2 years agoskip T13525 when running on Windows.
Tamar Christina [Sun, 23 Apr 2017 09:44:54 +0000 (10:44 +0100)] 
skip T13525 when running on Windows.

2 years agoHaddock submodule update.
Edward Z. Yang [Sun, 23 Apr 2017 03:39:18 +0000 (20:39 -0700)] 
Haddock submodule update.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
2 years agoBump time submodule
Ben Gamari [Fri, 21 Apr 2017 16:42:50 +0000 (12:42 -0400)] 
Bump time submodule

2 years agoBump filepath submodule
Ben Gamari [Fri, 21 Apr 2017 16:39:35 +0000 (12:39 -0400)] 
Bump filepath submodule

2 years agoBump deepseeq submodule
Ben Gamari [Fri, 21 Apr 2017 16:36:33 +0000 (12:36 -0400)] 
Bump deepseeq submodule

2 years agobase: update comment to match the change from e134af01
Andrzej Rybczak [Sat, 22 Apr 2017 00:11:35 +0000 (20:11 -0400)] 
base: update comment to match the change from e134af01

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

2 years agotestsuite: Update performance metrics
Ben Gamari [Sat, 22 Apr 2017 00:06:27 +0000 (20:06 -0400)] 
testsuite: Update performance metrics

2 years agoEdit eventlog-formats.rst to match implementation
Mitsutoshi Aoe [Sun, 16 Apr 2017 21:08:25 +0000 (06:08 +0900)] 
Edit eventlog-formats.rst to match implementation

* Add missing filters in EVENT_HEAP_PROF_BEGIN and reorder them
* EVENT_HEAP_PROF_SAMPLE_COST_CENTRE isn't used in retainer profiling
* Modify EVENT_HEAP_PROF_SAMPLE_STRING's format
* Biography break-down isn't implemented

2 years agoSync up terminfo submodule to 0.4.1.0 release tag
Herbert Valerio Riedel [Fri, 21 Apr 2017 22:50:26 +0000 (00:50 +0200)] 
Sync up terminfo submodule to 0.4.1.0 release tag

2 years agoBuild system: fix bindist for cross-build GHC
Fangrui Song [Fri, 21 Apr 2017 00:03:30 +0000 (17:03 -0700)] 
Build system: fix bindist for cross-build GHC

The change fixes case of installing cross-built GHC
from bindist (BINDIST=YES) on TARGET.

In this case we need to use TARGET tools in `INSTALLED_GHC{,_PKG}_REAL`.

The original change is provided by Fangrui Song
as pull request https://github.com/ghc/ghc/pull/34

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2 years agoBump haskeline and terminfo submodules
Ben Gamari [Fri, 21 Apr 2017 15:33:47 +0000 (11:33 -0400)] 
Bump haskeline and terminfo submodules

2 years agolinters/check-cpp: Demote #if lints to warnings
Ben Gamari [Fri, 21 Apr 2017 16:27:51 +0000 (12:27 -0400)] 
linters/check-cpp: Demote #if lints to warnings

Errors trigger even for lines which the author didn't touch, which is undesired.

2 years agocatch the case where there is no symCmd
Moritz Angermann [Fri, 21 Apr 2017 16:12:01 +0000 (12:12 -0400)] 
catch the case where there is no symCmd

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

Test Plan: The validation failure on windows is rather suspicious...
let's try this one

Reviewers: bgamari, adinapoli, austin, erikd, simonmar

Reviewed By: adinapoli

Subscribers: thomie, rwbarton

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

2 years agoFix build on DragonflyBSD
Ben Gamari [Fri, 21 Apr 2017 16:11:41 +0000 (12:11 -0400)] 
Fix build on DragonflyBSD

Test Plan: Validate on DragonflyBSD

Reviewers: austin, erikd, simonmar

Reviewed By: erikd

Subscribers: rwbarton, thomie

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

2 years agobase: Fix hWaitForInput with timeout on POSIX
Ben Gamari [Fri, 21 Apr 2017 16:11:28 +0000 (12:11 -0400)] 
base: Fix hWaitForInput with timeout on POSIX

This was previously broken (#13252) by
f46369b8a1bf90a3bdc30f2b566c3a7e03672518, which ported the fdReady
function from `select` to `poll` and in so doing dropping support for
timeouts. Unfortunately, while `select` tells us the amount of time not
slept (on Linux anyways; it turns out this is implementation dependent),
`poll` does not give us this luxury. Consequently, we manually need to
track time slept in this case.

Unfortunately, portably measuring time is hard. Ideally we would use
`clock_gettime` with the monotonic clock here, but sadly this isn't
supported on most versions of Darwin. Consequently, we instead use
`gettimeofday`, running the risk of system time changes messing us up.

Test Plan: Validate

Reviewers: simonmar, austin, hvr

Reviewed By: simonmar

Subscribers: rwbarton, thomie

GHC Trac Issues: #13252

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

2 years agotestsuite: Bump timeout multiplier for T11195
Ben Gamari [Fri, 21 Apr 2017 02:34:21 +0000 (22:34 -0400)] 
testsuite: Bump timeout multiplier for T11195

This test has been occassionally failing on the Darwin build bot for some time
now.

(cherry picked from commit b3a4dd1152884ff1240824137eca0a49cb6e5a2c)

2 years agobase: Fix offset initialization of Windows hLock implementation
Ben Gamari [Fri, 21 Apr 2017 16:10:33 +0000 (12:10 -0400)] 
base: Fix offset initialization of Windows hLock implementation

The previous implementation swapped the buffer size with the byte to be
set, essentially resulting in an uninitialized buffer.

Test Plan: Validate on Windows

Reviewers: austin, hvr

Subscribers: rwbarton, thomie

GHC Trac Issues: #13599

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

2 years agoSync up haskeline submodule to 0.7.4.0 release tag
Herbert Valerio Riedel [Thu, 20 Apr 2017 23:44:03 +0000 (01:44 +0200)] 
Sync up haskeline submodule to 0.7.4.0 release tag

2 years agoutils/debugNCG: remove old tool
Sergei Trofimovich [Fri, 21 Apr 2017 07:27:58 +0000 (08:27 +0100)] 
utils/debugNCG: remove old tool

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

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

2 years agopprDebugCLabel: drop duplicate trailing ')'
Sergei Trofimovich [Thu, 20 Apr 2017 19:49:26 +0000 (20:49 +0100)] 
pprDebugCLabel: drop duplicate trailing ')'

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2 years agotestsuite: disable 'optllvm' for unregisterised compiler
Sergei Trofimovich [Thu, 20 Apr 2017 19:13:25 +0000 (20:13 +0100)] 
testsuite: disable 'optllvm' for unregisterised compiler

commit 74615f412ad3de2910a156ff494bfe5497fada7e
("UNREG: ignore -fllvm (Trac #13495)") enabled
'optllvm' tests to be ran in 'make fulltest' mode.

As a result many (~1000) tests fail due to stderr misamatch:
  +when making flags consistent: warning:
  +    Compiler unregisterised, so compiling via C

The change removes 'optllvm' tests for unregisterised compiler.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2 years agoSimplify StgCases when all alts refer to the case binder
Joachim Breitner [Tue, 18 Apr 2017 21:20:59 +0000 (17:20 -0400)] 
Simplify StgCases when all alts refer to the case binder

as proposed in #13588.

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

2 years agoRevert "linker/mach-o: Catch the case where there is no symCmd"
Ben Gamari [Tue, 18 Apr 2017 01:02:07 +0000 (21:02 -0400)] 
Revert "linker/mach-o: Catch the case where there is no symCmd"

This causes validation failures on Windows.

This reverts commit 6c05b27e5bafe9f232e7014f4760335f5e3ba591.

2 years agoAdd failing test case for #13588
Joachim Breitner [Tue, 18 Apr 2017 21:05:10 +0000 (17:05 -0400)] 
Add failing test case for #13588

2 years agoFix LaTeX in core-spec
Joachim Breitner [Tue, 18 Apr 2017 20:18:33 +0000 (16:18 -0400)] 
Fix LaTeX in core-spec

where d49b2bb21691892ca6ac8f2403e31f2a5e53feb3 introduced some TeX
breakage, and re-generate core-spec.pdf.

2 years agoUpdate xhtml submodule to potential 3000.2.2 release commit
Herbert Valerio Riedel [Tue, 18 Apr 2017 15:22:50 +0000 (17:22 +0200)] 
Update xhtml submodule to potential 3000.2.2 release commit

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

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

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

Reviewers: austin, bgamari, Rufflewind, trofi

Reviewed By: Rufflewind, trofi

Subscribers: rwbarton, thomie

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

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

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

Test Plan: ./validate

Reviewers: simonpj, bgamari, austin, goldfire

Reviewed By: bgamari

Subscribers: rwbarton, thomie, simonmar

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

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

If you go to
https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/index.html
the window title has `<release>` in it.  I don't understand how it all
works, but inspired by the line below which produces a correct string in
the docs I just blindly changed it in the same way.  Cabal appears to
have the same problem.

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

Reviewers: thomie, bgamari, austin

Reviewed By: bgamari

Subscribers: rwbarton, simonmar

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

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

Reviewers: austin, bgamari, dfeuer

Reviewed By: bgamari, dfeuer

Subscribers: rwbarton, thomie

GHC Trac Issues: #13392

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

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

Reviewers: bgamari, austin

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

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

Reviewers: austin, hvr

Subscribers: rwbarton, thomie

GHC Trac Issues: #13527

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

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

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

Reviewers: austin, hvr, mpickering

Subscribers: siddhanathan, rwbarton, thomie

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

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

Test Plan: Validate on all the platforms

Reviewers: nh2, hvr, austin

Subscribers: Phyx, nh2, rwbarton, thomie

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

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

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

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

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

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

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

    FP_ARG_WITH_PATH_GNU_PROG([AR], [ar], [ar])
    ArCmd="$AR"
    fp_prog_ar="$AR"
    AC_SUBST([ArCmd])

The change keeps that value.

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

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

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

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

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

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Test Plan: ./validate

Reviewers: simonmar, austin, bgamari, erikd

Reviewed By: simonmar

Subscribers: rwbarton, thomie

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

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

Spelling if warning message slightly mismathed passed commandline:

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

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

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

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