8 months agotestsuite: Report stdout and stderr in JUnit output
Ben Gamari [Thu, 24 Jan 2019 19:20:11 +0000 (14:20 -0500)] 
testsuite: Report stdout and stderr in JUnit output

This patch makes the JUnit output more useful as now we also report the
stdout/stderr in the message which can be used to quickly identify why a
test is failing without downloading the log.

This also introduces TestResult,
previously we were simply passing around tuples, making things the
implementation rather difficult to follow and harder to extend.

8 months agoCapture and simplify constraints arising from running typed splices
Matthew Pickering [Sun, 3 Feb 2019 11:46:28 +0000 (11:46 +0000)] 
Capture and simplify constraints arising from running typed splices

This fixes a regression caused by #15471 where splicing in a trivial
program such as `[|| return () ||]` would fail as the dictionary for
`return` would never get bound in the module containing the splice.

Arguably this is symptomatic of a major problem affecting TTH where we
serialise renamed asts and then retype check them. The reference to the
dictionary should be fully determined at the quote site so that splicing
doesn't have to solve any implicits at all. It's a coincidence this
works due to coherence but see #15863 and #15865 for examples where
things do go very wrong.

Fixes #16195

8 months agoRemove ghctags (#16274)
Sylvain Henry [Thu, 7 Feb 2019 00:02:04 +0000 (01:02 +0100)] 
Remove ghctags (#16274)

8 months agoMake CI via Hadrian build docs
Alec Theriault [Tue, 29 Jan 2019 08:54:10 +0000 (00:54 -0800)] 
Make CI via Hadrian build docs

8 months agoFix invalid doc comment
Alec Theriault [Tue, 29 Jan 2019 08:35:24 +0000 (00:35 -0800)] 
Fix invalid doc comment

The invalid doc comments were exposed by 24b39ce53eedad4cefc30f6786542d2072d1f9b0.
The fix is to properly escaped the `{-` and `-}` in the doc comments.
Some other miscallaneous markup issues are also fixed.

8 months agoFix inverted position pragma flag in parser API
Alec Theriault [Tue, 29 Jan 2019 06:11:08 +0000 (22:11 -0800)] 
Fix inverted position pragma flag in parser API

The behviour of `lexTokenStream` around position pragma was
accidentally inverted in 469fe6133646df5568c9486de2202124cb734242.
This fixes that bug.

This also unbreaks #16239.

8 months agoUpgrade to the latest stack resolver
Neil Mitchell [Thu, 7 Feb 2019 14:50:47 +0000 (14:50 +0000)] 
Upgrade to the latest stack resolver

8 months agoSimplify the build.stack.bat script to use 'stack run'
Neil Mitchell [Thu, 7 Feb 2019 14:49:33 +0000 (14:49 +0000)] 
Simplify the build.stack.bat script to use 'stack run'

8 months agoImprove snocView implementation. [Tue, 22 Jan 2019 15:17:40 +0000 (16:17 +0100)] 
Improve snocView implementation.

The new implementation isn't tailrecursive and instead
builds up the initial part of the list as it goes.

This improves allocation numbers as we don't build up an intermediate
list just to reverse it later.

This is slightly slower for lists of size <= 3. But in benchmarks
significantly faster for any list above 5 elements, assuming the
majority of the resulting list will be evaluated.

8 months agoReplace a few uses of snocView with last/lastMaybe. [Mon, 21 Jan 2019 16:55:22 +0000 (17:55 +0100)] 
Replace a few uses of snocView with last/lastMaybe.

These never used the first part of the result from snocView.
Hence replacing them with last[Maybe] is both clearer and
gives better performance.

8 months agoStack: fix name mangling.
Tamar Christina [Sun, 27 Jan 2019 15:54:36 +0000 (15:54 +0000)] 
Stack: fix name mangling.

8 months agoMinor refactor of CUSK handling
Simon Peyton Jones [Thu, 7 Feb 2019 09:51:36 +0000 (09:51 +0000)] 
Minor refactor of CUSK handling

Previously, in getFamDeclInitialKind, we were figuring
out whether the enclosing class decl had a CUSK very
indirectly, via tcTyConIsPoly.  This patch just makes
the computation much more direct and easy to grok.

No change in behaviour.

8 months agoComments only about the binder-swap in OccurAnal
Simon Peyton Jones [Thu, 7 Feb 2019 08:46:48 +0000 (08:46 +0000)] 
Comments only about the binder-swap in OccurAnal

8 months agoComments only
Simon Peyton Jones [Fri, 18 Jan 2019 17:12:13 +0000 (17:12 +0000)] 
Comments only

8 months agoRemove a few undefined prel names
Ömer Sinan Ağacan [Wed, 6 Feb 2019 07:26:00 +0000 (10:26 +0300)] 
Remove a few undefined prel names

- breakpointAuto
- breakpointJump
- breakpointCondJump
- breakpointAutoJump

These Ids are never defined, but there were definitions about those in
PrelNames. Those are now removed.

8 months agoFix optSemi type in Parser.y
Vladislav Zavialov [Wed, 6 Feb 2019 01:01:36 +0000 (20:01 -0500)] 
Fix optSemi type in Parser.y

The definition of 'optSemi' claimed it had type

([Located a],Bool)

Note that its production actually returns ([Located Token],Bool):

  : ';' { ([$1],True) }   -- $1 :: Located Token

Due to an infelicity in the implementation of 'happy -c', it effectively
resulted in 'unsafeCoerce :: Token -> a'.

If any consumer of 'optSemi' tried to instantiate 'a' to something not
representationally equal to 'Token', they would experience a segfault.

In addition to that, this definition made it impossible to compile Parser.y
without the -c flag (as it's reliant on this bug to cast 'Token' to 'forall
a. a').

8 months agoCleanup in parser/Ctype.hs
Sylvain Henry [Tue, 5 Feb 2019 14:55:03 +0000 (15:55 +0100)] 
Cleanup in parser/Ctype.hs

* GHC now performs constant folding on bit operations like (.|.) so we
use them and we remove the misleading comment

* we use Word8 instead of Int and we remove the useless conversion to
Int32. Hopefully future releases of GHC could transform the big case in
`charType` into a value table indexing instead of a jump table. Word8
would make the table smaller.

* we use INLINABLE pragma instead of INLINE on `is_ctype`: in my test,
the latter *prevents* `is_ctype` to be inlined because `charType` is
inlined into `is_ctype` (to call charType`s worker on the unboxed Char

8 months agorts/ProfilerReportJson: Fix format string
Ben Gamari [Tue, 5 Feb 2019 02:42:41 +0000 (21:42 -0500)] 
rts/ProfilerReportJson: Fix format string

This was warning on i386.

8 months agoLexer: Alternate Layout Rule injects actual not virtual braces
Alan Zimmerman [Sun, 3 Feb 2019 08:27:42 +0000 (10:27 +0200)] 
Lexer: Alternate Layout Rule injects actual not virtual braces

When the alternate layout rule is activated via a pragma, it injects
tokens for { and } to make sure that the source is parsed properly.

But it injects ITocurly and ITccurly, rather than their virtual
counterparts ITvocurly and ITvccurly.

This causes problems for ghc-exactprint, which tries to print these.

Likewise, any injected ITsemi should have a zero-width SrcSpan.

Test case (the existing T13087.hs)

    {-# LANGUAGE AlternativeLayoutRule #-}
    {-# LANGUAGE LambdaCase            #-}

    isOne :: Int -> Bool
    isOne = \case 1 -> True
                  _ -> False

    main = return ()

Closes #16279

8 months agoAPI Annotations: parens anns discarded for `(*)` operator
Alan Zimmerman [Sat, 2 Feb 2019 14:29:05 +0000 (16:29 +0200)] 
API Annotations: parens anns discarded for `(*)` operator

The patch from introduces

    go _ (HsParTy _ (dL->L l (HsStarTy _ isUni))) acc ann fix
      = do { warnStarBndr l
           ; let name = mkOccName tcClsName (if isUni then "★" else "*")
           ; return (cL l (Unqual name), acc, fix, ann) }

which discards the parens annotations belonging to the HsParTy.

Updates haddock submodule

Closes #16265

8 months agoAPI Annotations: AnnAt disconnected for TYPEAPP
Alan Zimmerman [Wed, 30 Jan 2019 14:20:52 +0000 (16:20 +0200)] 
API Annotations: AnnAt disconnected for TYPEAPP

For the code

    type family F1 (a :: k) (f :: k -> Type) :: Type where
      F1 @Peano a f = T @Peano f a

the API annotation for the first @ is not attached to a SourceSpan in
the ParsedSource

Closes #16236

8 months agoAPI Annotations: more explicit foralls fixup
Alan Zimmerman [Thu, 24 Jan 2019 21:22:59 +0000 (23:22 +0200)] 
API Annotations: more explicit foralls fixup

The AnnForall annotations introduced via Phab:D4894 are not always
attached to the correct SourceSpan.

Closes #16230

8 months agoImplicitParams does not imply FlexibleContexts or FlexibleInstances, fixes #16248
Neil Mitchell [Sun, 3 Feb 2019 20:45:12 +0000 (15:45 -0500)] 
ImplicitParams does not imply FlexibleContexts or FlexibleInstances, fixes #16248

8 months agoUpdate directory submodule
Herbert Valerio Riedel [Fri, 1 Feb 2019 21:48:07 +0000 (22:48 +0100)] 
Update directory submodule

8 months agoUpdate filepath submodule
Herbert Valerio Riedel [Fri, 1 Feb 2019 21:48:40 +0000 (22:48 +0100)] 
Update filepath submodule

8 months agoAdd a changelog for base
Langston Barrett [Mon, 4 Feb 2019 16:59:56 +0000 (08:59 -0800)] 
Add a changelog for base

8 months agoTestEquality instance for Compose
Langston Barrett [Fri, 1 Feb 2019 20:33:38 +0000 (12:33 -0800)] 
TestEquality instance for Compose

8 months agoFix test for T16180 on Darwin (fix #16128)
Sylvain Henry [Tue, 29 Jan 2019 01:14:12 +0000 (02:14 +0100)] 
Fix test for T16180 on Darwin (fix #16128)

8 months agoHadrian: compile libgmp static on Windows
Tamar Christina [Sun, 27 Jan 2019 21:30:50 +0000 (21:30 +0000)] 
Hadrian: compile libgmp static on Windows

8 months agoUpdate hpc submodule
Herbert Valerio Riedel [Sun, 27 Jan 2019 21:35:35 +0000 (22:35 +0100)] 
Update hpc submodule

8 months agoAllow resizing the stack for the graph allocator. [Fri, 25 Jan 2019 23:26:02 +0000 (00:26 +0100)] 
Allow resizing the stack for the graph allocator.

The graph allocator now dynamically resizes the number of stack
slots when running into the limit.

This fixes #8657.

Also loop membership of basic blocks is now available
in the register allocator for cost heuristics.

8 months agoFix #14729 by making the normaliser homogeneous
Richard Eisenberg [Thu, 24 Jan 2019 15:22:58 +0000 (10:22 -0500)] 
Fix #14729 by making the normaliser homogeneous

This ports the fix to #12919 to the normaliser. (#12919 was about
the flattener.) Because the fix is involved, this is done by
moving the critical piece of code to Coercion, and then calling
this from both the flattener and the normaliser.

The key bit is: simplifying type families in a type is always
a *homogeneous* operation. See #12919 for a discussion of why
this is the Right Way to simplify type families.

Also fixes #15549.

test case: dependent/should_compile/T14729{,kind}

8 months agotestsuite: Mark T5515 as broken with debugged compiler
Ben Gamari [Mon, 28 Jan 2019 21:58:15 +0000 (16:58 -0500)] 
testsuite: Mark T5515 as broken with debugged compiler

As noted in #16251.

8 months agotestsuite: Mark T14740 and tcfail159 as broken in debugged compiler
Ben Gamari [Sun, 30 Dec 2018 18:32:50 +0000 (13:32 -0500)] 
testsuite: Mark T14740 and tcfail159 as broken in debugged compiler

As noted in #16113, these trigger an assertion in isUnliftedRuntimeRep.

8 months agotestsuite: Mark recomp007 as broken in debugged compiler
Ben Gamari [Sun, 30 Dec 2018 18:30:32 +0000 (13:30 -0500)] 
testsuite: Mark recomp007 as broken in debugged compiler

As noted in #14759, this triggers a warning in ListSetOps.

8 months agotestsuite: Mark T11334b as broken in debugged compiler
Ben Gamari [Sun, 30 Dec 2018 18:28:07 +0000 (13:28 -0500)] 
testsuite: Mark T11334b as broken in debugged compiler

As noted in #16112.

8 months agoRevert "gitlab-ci: More aggressive artifact expiration"
Matthew Pickering [Sun, 3 Feb 2019 11:30:49 +0000 (11:30 +0000)] 
Revert "gitlab-ci: More aggressive artifact expiration"

This reverts commit d87b38a2519212aaf8bad927c65abecc509a7212.

8 months agogitlab-ci: More aggressive artifact expiration
Ben Gamari [Sun, 30 Dec 2018 18:22:38 +0000 (13:22 -0500)] 
gitlab-ci: More aggressive artifact expiration

8 months agogitlab-ci: Add a devel2 build
Ben Gamari [Sat, 22 Dec 2018 05:59:43 +0000 (00:59 -0500)] 
gitlab-ci: Add a devel2 build

8 months agoFix #16287 by checking for more unsaturated synonym arguments
Ryan Scott [Tue, 5 Feb 2019 13:50:59 +0000 (08:50 -0500)] 
Fix #16287 by checking for more unsaturated synonym arguments

Trac #16287 shows that we were checking for unsaturated type synonym
arguments (in `:kind`) when the argument was to a type synonym, but
_not_ when the argument was to some other form of type constructor,
such as a data type. The solution is to use the machinery that
rejects unsaturated type synonym arguments (previously confined to
`check_syn_tc_app`) to `check_arg_type`, which checks these other
forms of arguments. While I was in town, I cleaned up
`check_syn_tc_app` a bit to only invoke `check_arg_type` so as to
minimize the number of different code paths that that function could
go down.

8 months agoAdd int-index as parser/* codeowner
Vladislav Zavialov [Sun, 3 Feb 2019 20:50:58 +0000 (15:50 -0500)] 
Add int-index as parser/* codeowner

8 months agoFix #14579 by defining tyConAppNeedsKindSig, and using it
Ryan Scott [Wed, 6 Feb 2019 00:57:29 +0000 (19:57 -0500)] 
Fix #14579 by defining tyConAppNeedsKindSig, and using it

8 months agoRefactor splice_exp in Parser.y
Vladislav Zavialov [Fri, 1 Feb 2019 06:25:45 +0000 (09:25 +0300)] 
Refactor splice_exp in Parser.y

8 months agoAdd `-fplugin-trustworthy` to avoid marking modules as unsafe
Zejun Wu [Thu, 31 Jan 2019 06:13:42 +0000 (22:13 -0800)] 
Add `-fplugin-trustworthy` to avoid marking modules as unsafe

By default, when a module is compiled with plugins, it will be marked as
unsafe. With this flag passed, all plugins are treated as trustworthy
and the safety inference will no longer be affected.

This fixes Trac #16260.

8 months agogitlab-ci: Don't allow x86_64-linux-deb9-llvm to fail
Ben Gamari [Tue, 29 Jan 2019 00:26:57 +0000 (19:26 -0500)] 
gitlab-ci: Don't allow x86_64-linux-deb9-llvm to fail

8 months agotestsuite: Mark print037 as broken when GHC is built with LLVM
Ben Gamari [Tue, 29 Jan 2019 00:26:10 +0000 (19:26 -0500)] 
testsuite: Mark print037 as broken when GHC is built with LLVM

As noted in #16205 this configuration reliably segfaults.

8 months agotestsuite: Use makefile_test for T16212
Ben Gamari [Sat, 2 Feb 2019 19:35:29 +0000 (14:35 -0500)] 
testsuite: Use makefile_test for T16212

8 months agotestsuite: Skip T15897 in unregisterised way
Ben Gamari [Sat, 2 Feb 2019 17:52:21 +0000 (12:52 -0500)] 
testsuite: Skip T15897 in unregisterised way

As noted in #16227 this test routinely times out when run in the
unregisterised way.

See also #15467.

8 months agoReport multiple errors
Vladislav Zavialov [Fri, 1 Feb 2019 17:39:57 +0000 (20:39 +0300)] 
Report multiple errors

8 months agoAdd werror function to Flavour.hs
Matthew Pickering [Thu, 31 Jan 2019 11:01:04 +0000 (11:01 +0000)] 
Add werror function to Flavour.hs

This function makes it easy to turn on `-Werror` in the correct manner
to mimic how CI turns on -Werror.

8 months agoFix missing space in ppr_cmd for HsCmdArrForm
Vladislav Zavialov [Sat, 2 Feb 2019 14:30:05 +0000 (17:30 +0300)] 
Fix missing space in ppr_cmd for HsCmdArrForm

8 months agodocs: change meta-variable of -interactive-print from expr to name
Zejun Wu [Thu, 31 Jan 2019 01:35:50 +0000 (17:35 -0800)] 
docs: change meta-variable of -interactive-print from expr to name

`-interactive-print` doesn't accept **expr** as `-e` or `:def` does. It must
be a qualified or unqualified **name** in scope.

8 months agoTurn on -Wno-unused-imports in make build system
Matthew Pickering [Fri, 1 Feb 2019 19:10:07 +0000 (19:10 +0000)] 
Turn on -Wno-unused-imports in make build system

This mirrors Hadrian and it good enough to get us unstuck.

8 months agoBump hsc2hs for removed unused match
Sebastian Graf [Fri, 1 Feb 2019 11:43:27 +0000 (12:43 +0100)] 
Bump hsc2hs for removed unused match

8 months agoRemove unused imports
Sebastian Graf [Wed, 30 Jan 2019 12:59:10 +0000 (13:59 +0100)] 
Remove unused imports

8 months agoTurn on -Werror when validating
Matthew Pickering [Wed, 30 Jan 2019 13:29:26 +0000 (08:29 -0500)] 
Turn on -Werror when validating

8 months agoPolished Note [Exceptions and strictness]
Sebastian Graf [Fri, 1 Feb 2019 12:25:42 +0000 (13:25 +0100)] 
Polished Note [Exceptions and strictness]

[ci skip]

8 months agoUpdate with a pointer to `Packages`
Sebastian Graf [Fri, 1 Feb 2019 09:48:41 +0000 (04:48 -0500)] 
Update with a pointer to `Packages`

[skip ci]

8 months agoReject oversaturated VKAs in type family equations
Ryan Scott [Sat, 2 Feb 2019 00:10:55 +0000 (19:10 -0500)] 
Reject oversaturated VKAs in type family equations

8 months agoRemove ExnStr and ThrowsExn business
Sebastian Graf [Fri, 1 Feb 2019 11:46:32 +0000 (06:46 -0500)] 
Remove ExnStr and ThrowsExn business

8 months agoFix #16219: TemplateHaskell causes indefinite package build error
Edward Z. Yang [Fri, 1 Feb 2019 01:00:50 +0000 (20:00 -0500)] 
Fix #16219: TemplateHaskell causes indefinite package build error

It should work to write an indefinite package using TemplateHaskell,
so long as all of the actual TH code lives outside of the package.
However, cleverness we had to build TH code even when building
with -fno-code meant that we attempted to build object code for
modules in an indefinite package, even when the signatures were
not instantiated.  This patch disables said logic in the event
that an indefinite package is being typechecked.

Signed-off-by: Edward Z. Yang <>
Test Plan: validate

Reviewers: simonpj, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, carter

GHC Trac Issues: #16219

Differential Revision:

8 months agoRevert "Performance tests: recover a baseline from ancestor commits and CI results."
Ben Gamari [Fri, 1 Feb 2019 00:47:53 +0000 (19:47 -0500)] 
Revert "Performance tests: recover a baseline from ancestor commits and CI results."

Unfortunately this has broken all future commits due to spurious(?)
performance changes which I have been unable to work around.

This reverts commit cc2261d42f6a954d88e355aaad41f001f65c95da.

8 months agoHadrian: Fix outdated link.
Andrey Mokhov [Sun, 27 Jan 2019 22:42:23 +0000 (22:42 +0000)] 
Hadrian: Fix outdated link.

8 months agoHadrian: Update instructions for building on Windows
Andrey Mokhov [Sun, 27 Jan 2019 22:34:30 +0000 (22:34 +0000)] 
Hadrian: Update instructions for building on Windows

The `hadrian/doc/` file has falled out of date. In particular
it still points to the old GitHub repository, and uses incorrect path
to GHC. This patch fixes it.

8 months agoUpdate terminfo submodule
Herbert Valerio Riedel [Sun, 27 Jan 2019 21:35:35 +0000 (22:35 +0100)] 
Update terminfo submodule

8 months agoUpdate stm submodule
Herbert Valerio Riedel [Sun, 27 Jan 2019 21:35:35 +0000 (22:35 +0100)] 
Update stm submodule

8 months agoUpdate process submodule
Herbert Valerio Riedel [Sun, 27 Jan 2019 21:35:35 +0000 (22:35 +0100)] 
Update process submodule

8 months agoUpdate parsec submodule
Herbert Valerio Riedel [Sun, 27 Jan 2019 21:35:35 +0000 (22:35 +0100)] 
Update parsec submodule

8 months agoUpdate haskeline submodule
Herbert Valerio Riedel [Sun, 27 Jan 2019 21:35:36 +0000 (22:35 +0100)] 
Update haskeline submodule

8 months agoUpdate deepseq submodule
Herbert Valerio Riedel [Sun, 27 Jan 2019 21:35:36 +0000 (22:35 +0100)] 
Update deepseq submodule

8 months agoUpdate unix submodule
Herbert Valerio Riedel [Sun, 27 Jan 2019 21:35:35 +0000 (22:35 +0100)] 
Update unix submodule

8 months agoUpdate text submodule
Herbert Valerio Riedel [Sun, 27 Jan 2019 21:35:35 +0000 (22:35 +0100)] 
Update text submodule

8 months agoUpdate hsc2hs submodule
Herbert Valerio Riedel [Sun, 27 Jan 2019 14:33:22 +0000 (15:33 +0100)] 
Update hsc2hs submodule

8 months agoPPC NCG: Promote integers to word size in C calls
Peter Trommler [Wed, 23 Jan 2019 22:13:57 +0000 (23:13 +0100)] 
PPC NCG: Promote integers to word size in C calls

Fixes #16222

8 months agoSmall optimizations to BlockLayout. [Thu, 24 Jan 2019 23:08:21 +0000 (00:08 +0100)] 
Small optimizations to BlockLayout.

* Remove `takeL/R 1` occurences by lastOL/headOL.

* Make BlockChain a OrdList newtype by removing the set of blocks.

Initially BlockChain contained both, a set for membership test
and a ordered list of blocks. The set is not used for any
performance sensitive lookups so we get rid of it.

8 months agoReplace BlockSequence with OrdList in BlockLayout.hs [Thu, 24 Jan 2019 22:02:51 +0000 (23:02 +0100)] 
Replace BlockSequence with OrdList in BlockLayout.hs

OrdList does the same thing and more so there is no reason
to have both.

8 months agotestsuite: Add test for #14828
Ben Gamari [Tue, 22 Jan 2019 21:58:04 +0000 (16:58 -0500)] 
testsuite: Add test for #14828

8 months agoIntroduce GhciMonad and generalize types of functions in GHCi.UI
Zejun Wu [Tue, 22 Jan 2019 00:28:01 +0000 (16:28 -0800)] 
Introduce GhciMonad and generalize types of functions in GHCi.UI

Introduce `GhciMonad`, which is bascially `GhcMonad` + `HasGhciState`.
Generalize the commands and help functions defined in `GHCi.UI` so they
can be used as both `GHCi a` and `InputT GHCi a`.

The long term plan is to move reusable bits to ghci library and make it
easier to build a customized interactive ui which carries customized state
and provides customized commands.

Most changes are trivial in this diff by relaxing the type constraint or
add/remove lift as necessary. The non-trivial changes are:

* Change `HasGhciState` to `GhciMonad` and expose it.
* Implementation of `reifyGHCi`.

Test Plan:

Reviewers: simonmar, hvr, bgamari

Reviewed By: simonmar

Subscribers: rwbarton, carter

Differential Revision:

8 months agoAdd O2 to hsCompiler on stage0 for most hadrian flavours. [Fri, 25 Jan 2019 00:27:05 +0000 (01:27 +0100)] 
Add O2 to hsCompiler on stage0 for most hadrian flavours.

8 months agoUse O2 on stage1 for faster overall build times with make. [Thu, 24 Jan 2019 19:20:39 +0000 (20:20 +0100)] 
Use O2 on stage1 for faster overall build times with make.

Build times when using the quick flavour:

stage1 opt | time (wall) | time (user)
     -O1   |        13m  |        53m
     -O2   |        13m  |        51m
So even when we compile stage2 with -O0 (quick)
using -O2 on stage1 is already faster.

The difference is even bigger when freezing
stage1 and doing multiple builds or compiling
stage2 with optimizations.

8 months agoAdd -fdefer-diagnostics to defer and group diagnostic messages in make-mode
Zejun Wu [Fri, 28 Dec 2018 08:10:22 +0000 (00:10 -0800)] 
Add -fdefer-diagnostics to defer and group diagnostic messages in make-mode

When loading many modules in parallel there can a lot of warnings and
errors get mixed up with regular output. When the compilation fails,
the relevant error message can be thousands of lines backward and is
hard to find. When the compilation successes, warning message is likely
to be ignored as it is not seen. We can address this by deferring the
warning and error message after the compilation. We also put errors
after warnings so it is more visible.

This idea was originally proposed by Bartosz Nitka in

8 months agohWaitForInput-accurate-stdin test
Ben Gamari [Thu, 31 Jan 2019 04:36:17 +0000 (23:36 -0500)] 
hWaitForInput-accurate-stdin test

8 months agoOptimize pprASCII
Sylvain Henry [Thu, 17 Jan 2019 23:01:45 +0000 (00:01 +0100)] 
Optimize pprASCII

* Use `ByteString.foldr` instead of `(List.foldr . BS.unpack)`
* Avoid calling `chr` and its test that checks for invalid Unicode
codepoints: we stay in the ASCII range so we know we're ok
* Avoid calling `isPrint` (unsafe FFI call): we can check the ASCII
printable range directly
* Use bit operations (`unsafeShiftR`, `.&.`) instead of `div` and `mod`

8 months agoUse ByteString to represent Cmm string literals (#16198)
Sylvain Henry [Thu, 17 Jan 2019 12:34:32 +0000 (13:34 +0100)] 
Use ByteString to represent Cmm string literals (#16198)

Also used ByteString in some other relevant places

8 months agoFix syntax in CODEOWNERS file
Matthew Pickering [Wed, 30 Jan 2019 12:28:08 +0000 (07:28 -0500)] 
Fix syntax in CODEOWNERS file

[skip ci]

8 months agoDon't use X86_64_ELF_NONPIC_HACK for +RTS -xp
Zejun Wu [Sat, 29 Dec 2018 04:48:31 +0000 (20:48 -0800)] 
Don't use X86_64_ELF_NONPIC_HACK for +RTS -xp

When `+RTS -xp` is passed, when don't need the X86_64_ELF_NONPIC_HACK,
becasue the relocation offset should only be out of range if

* the object file was not compiled with `-fPIC -fexternal-dynamic-refs`;
* ghc generates non-pic code while it should (e.g. #15723)

In either case, we should print an error message rather that silently
attempt to use a hacky workaround that may not work.

This could have made debugging #15723 and #15729 much easier.

Test Plan:
Run this in a case where ghci used to crash becasue of T15723. Now we
see helpful message like:

ghc-iserv-prof: R_X86_64_PC32 relocation out of range:

Reviewers: simonmar, bgamari, erikd

Reviewed By: simonmar, bgamari

Subscribers: rwbarton, carter

Differential Revision:

8 months agoAllocate bss section within proper range of other sections
Zejun Wu [Sat, 29 Dec 2018 04:47:33 +0000 (20:47 -0800)] 
Allocate bss section within proper range of other sections

This re-applies {D5195} and {D5235}, they were reverted as part of diff
stack to unbreak i386. The proper fix is done in {D5289}.

Allocate bss section within proper range of other sections:

* when `+RTS -xp` is passed, allocate it contiguously as we did for
  jump islands
* when we mmap the code to lower 2Gb, we should allocate bss section
  there too

Test Plan:
1. `./validate`




`TEST="T15729" make test` passed in both linux (both i386 and x86_64) and macos.


Also test in a use case where we used to encouter error like:

ghc-iserv-prof: R_X86_64_PC32 relocation out of range: (noname) =

and now, everything works fine.

Reviewers: simonmar, bgamari, angerman, erikd

Reviewed By: simonmar

Subscribers: rwbarton, carter

GHC Trac Issues: #15729

Differential Revision:

8 months agoAdd a RTS option -xp to load PIC object anywhere in address space
Zejun Wu [Sat, 29 Dec 2018 04:37:13 +0000 (20:37 -0800)] 
Add a RTS option -xp to load PIC object anywhere in address space

This re-applies {D5195} with fixes for i386:
* Fix unused label warnings, see {D5230} or {D5273}
* Fix a silly bug introduced by moving `#if`


Add a RTS option -xp to load PIC object anywhere in address space. We do
this by relaxing the requirement of <0x80000000 result of
`mmapForLinker` and implying USE_CONTIGUOUS_MMAP.

We also need to change calls to `ocInit` and `ocGetNames` to avoid
dangling pointers when the address of `oc->image` is changed by

Test Plan:
See {D5195}, also test under i386:

$ uname -a
Linux watashi-arch32 4.18.5-arch1-1.0-ARCH #1 SMP PREEMPT Tue Aug 28
20:45:30 CEST 2018 i686 GNU/Linux
$ cd testsuite/tests/th/ && make test

will run `./validate` on stacked diff.

Reviewers: simonmar, bgamari, alpmestan, trommler, hvr, erikd

Reviewed By: simonmar

Subscribers: rwbarton, carter

Differential Revision:

8 months agoAPI Annotations: Parens not attached correctly for ClassDecl
Alan Zimmerman [Thu, 24 Jan 2019 08:14:55 +0000 (10:14 +0200)] 
API Annotations: Parens not attached correctly for ClassDecl

The parens around the kinded tyvars should be attached to the class
declaration as a whole, they are attached to the tyvar instead,
outside the span.

An annotation must always be within or after the span it is contained

Closes #16212

8 months agoOnly build vanilla way in devel2 flavour
Matthew Pickering [Fri, 25 Jan 2019 15:48:54 +0000 (15:48 +0000)] 
Only build vanilla way in devel2 flavour

Fixes #16210

8 months agoInclude type info for only some exprs in HIE files
Alec Theriault [Fri, 25 Jan 2019 01:33:52 +0000 (17:33 -0800)] 
Include type info for only some exprs in HIE files

This commit relinquishes some some type information in `.hie` files in
exchange for better performance. See #16233 for more on this.

Using `.hie` files to generate hyperlinked sources is a crucial milestone
towards Hi Haddock (the initiative to move Haddock to work over `.hi`
files and embed docstrings in those). Unfortunately, even after much
optimization on the Haddock side, the `.hie` based solution is still
considerably slower and more memory hungry than the existing implementation
- and the @.hie@ code is to blame.

This changes `.hie` file generation to track type information for only
a limited subset of expressions (specifically, those that might eventually
turn into hyperlinks in the Haddock's hyperlinker backend).

8 months agoUse `NameEnv Id` instead of `Map Name Id`
Alec Theriault [Thu, 24 Jan 2019 21:59:18 +0000 (13:59 -0800)] 
Use `NameEnv Id` instead of `Map Name Id`

This is more consistent with the rest of the GHC codebase.

8 months agomake ghc-pkg shut up
Moritz Angermann [Wed, 23 Jan 2019 02:59:38 +0000 (10:59 +0800)] 
make ghc-pkg shut up

8 months agoAvoid compiling Hadrian dependencies with profiling on Cabal/Linux
Neil Mitchell [Wed, 16 Jan 2019 16:21:00 +0000 (11:21 -0500)] 
Avoid compiling Hadrian dependencies with profiling on Cabal/Linux

8 months agoAvoid compiling Hadrian dependencies with profiling on Cabal/Windows
Neil Mitchell [Wed, 16 Jan 2019 16:20:27 +0000 (11:20 -0500)] 
Avoid compiling Hadrian dependencies with profiling on Cabal/Windows

8 months agogitlab-ci: Use build cleanup logic on Darwin as well
Ben Gamari [Mon, 21 Jan 2019 15:55:48 +0000 (10:55 -0500)] 
gitlab-ci: Use build cleanup logic on Darwin as well

We use the shell executor on Darwin as well as Windows.

8 months agoCompile count{Leading,Trailing}Zeros to corresponding x86_64 instructions under ...
Dmitry Ivanov [Sat, 8 Dec 2018 15:45:02 +0000 (16:45 +0100)] 
Compile count{Leading,Trailing}Zeros to corresponding x86_64 instructions under -mbmi2

This works similarly to existing implementation for popCount.
Trac ticket: #16086.

8 months agoPerformance tests: recover a baseline from ancestor commits and CI results.
David Eichmann [Tue, 22 Jan 2019 14:57:23 +0000 (09:57 -0500)] 
Performance tests: recover a baseline from ancestor commits and CI results.

gitlab-ci: push performance metrics as git notes to the "GHC Performance Notes" repository.

8 months agotestsuite: Use makefile_test
Ben Gamari [Mon, 21 Jan 2019 04:46:13 +0000 (23:46 -0500)] 
testsuite: Use makefile_test

This eliminates most uses of run_command in the testsuite in favor of the more
structured makefile_test.

8 months agotestsuite: Introduce makefile_test
Ben Gamari [Mon, 21 Jan 2019 03:54:48 +0000 (22:54 -0500)] 
testsuite: Introduce makefile_test