ghc.git
23 months agofix dllwrap issue.
Tamar Christina [Sat, 22 Jul 2017 13:11:07 +0000 (14:11 +0100)] 
fix dllwrap issue.

Summary: Always set dllwrap and windres values.

Reviewers: austin, hvr, bgamari, trofi

Reviewed By: trofi

Subscribers: rwbarton, thomie, erikd

GHC Trac Issues: #13792

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

23 months agoFix ungrammatical error message
Ryan Scott [Sat, 22 Jul 2017 03:08:24 +0000 (23:08 -0400)] 
Fix ungrammatical error message

Test Plan: If it builds, ship it

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

23 months agobuild system: Ensure there are no duplicate files in bindist list
Ben Gamari [Fri, 21 Jul 2017 01:39:27 +0000 (21:39 -0400)] 
build system: Ensure there are no duplicate files in bindist list

Several executables inexplicably appear twice in bindist.list, which
ends up producing multiple tar file entries, consequently breaking BSD
tar during extraction. I spent a fair amount of time trying to work out
where these duplicates were coming from to no avail. Since Hadrian is
right around the corner I'm satisfied with a terrible hack: just uniq
bindist.list before producing the bindist tarball.

Test Plan: Validate

Reviewers: austin

Subscribers: rwbarton, thomie

GHC Trac Issues: #13979, #13974

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

23 months agoHsPat: Assume that no spliced patterns are irrefutable
Ben Gamari [Thu, 20 Jul 2017 23:24:00 +0000 (19:24 -0400)] 
HsPat: Assume that no spliced patterns are irrefutable

This is a conservative assumption which will limit some uses of spliced
patterns, but it fixes #13984.

Test Plan: Validate

Reviewers: RyanGlScott, AaronFriel, austin

Reviewed By: RyanGlScott

Subscribers: rwbarton, thomie

GHC Trac Issues: #13984

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

23 months agoRevert "testsuite: Add test for #13916"
Ben Gamari [Thu, 20 Jul 2017 16:06:03 +0000 (12:06 -0400)] 
Revert "testsuite: Add test for #13916"

This reverts commit b2d3ec370b97fe5f448e8f1d4e0b7374c63c60a8. Didn't
mean to push this one.

23 months agotestsuite: Add test for #13916
Ben Gamari [Thu, 20 Jul 2017 15:43:06 +0000 (11:43 -0400)] 
testsuite: Add test for #13916

23 months agodistrib/configure: Canonicalize triples
Ben Gamari [Thu, 20 Jul 2017 15:34:00 +0000 (11:34 -0400)] 
distrib/configure: Canonicalize triples

Previously we failed to do this, which meant that the bindist's
configure would fail when passed --target (as you may need to do when
installing an armv7 bindist on an aarch64 machine, for instance).

Reviewers: hvr, erikd, austin

Reviewed By: hvr

Subscribers: rwbarton, thomie

GHC Trac Issues: #13934

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

23 months agorts: Claim AP_STACK before adjusting Sp
Ben Gamari [Thu, 20 Jul 2017 15:33:51 +0000 (11:33 -0400)] 
rts: Claim AP_STACK before adjusting Sp

In the fix to #13615 we introduced some logic to atomically blackhole
AP_STACKs closures upon entry. However, this logic was placed *after* a
stack pointer adjustment. This meant that if someone else beat us to
blackholing the AP_STACK we would suspend the thread with uninitialized
content on the stack.  This would then later blow up when threadPaused
attempted to walk the stack, hence #13970.

Silly bug but still cost lots of head-scratching to find.

Thanks to albertov for the great repro.

Fixes #13970. Bug originally introduced by the fix to #13615.

Reviewers: austin, erikd, simonmar

Reviewed By: erikd, simonmar

Subscribers: rwbarton, thomie

GHC Trac Issues: #13970, #13615

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

23 months agoInterpreter.c: use macros to access/modify Sp
Michal Terepeta [Thu, 20 Jul 2017 15:30:54 +0000 (11:30 -0400)] 
Interpreter.c: use macros to access/modify Sp

This is another step in fixing #13825 (based on D38 by Simon Marlow).

This commit adds a few macros for accessing and modifying `Sp`
(interpreter stack) and will be useful to allow sub-word
indexing/pushing. (but that will be a separate change, this commit
should introduce no changes in behavior)

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

Reviewers: bgamari, simonmar, austin, erikd

Reviewed By: bgamari, erikd

Subscribers: rwbarton, thomie

GHC Trac Issues: #13825

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

23 months agoMake IfaceAxiom typechecking lazier.
Edward Z. Yang [Thu, 20 Jul 2017 15:30:46 +0000 (11:30 -0400)] 
Make IfaceAxiom typechecking lazier.

Fixes #13803, but adds a note about a yet to be fixed #13981.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate

Reviewers: bgamari, austin

Reviewed By: bgamari

Subscribers: simonpj, rwbarton, thomie

GHC Trac Issues: #13803

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

23 months agoFix busy-wait in SysTools.builderMainLoop
Douglas Wilson [Thu, 20 Jul 2017 12:48:12 +0000 (08:48 -0400)] 
Fix busy-wait in SysTools.builderMainLoop

Test T13701 was failing sporadically. The problem manifested while the
test was run on a system under load. Profiling showed the increased
allocations were in SysTools.builderMainLoop.loop, during calls to the
assembler. This was due to loop effectively busy-waiting from when both
stdin and stderr handles were closed, until getProcessExitCode
succeeded.

This is fixed by removing exit code handling from loop. We now wait for
loop to finish, then read the exit code with waitForProcess.

Some exception safety is added: the readerProc threads will now be
killed and the handles will be closed if an exception is thrown.

A TODO saying that threads dying is not accounted for is removed. I
believe that this case is handled by readerProc sending EOF in a finally
clause.

Test Plan:
Replicate test failures using procedure on the ticket, verify that they
do not occur with this patch.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13987

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

23 months agoarcconfig: Set project ruleset to use master merge-base by default
Ben Gamari [Thu, 20 Jul 2017 12:41:09 +0000 (08:41 -0400)] 
arcconfig: Set project ruleset to use master merge-base by default

Reviewers: austin

Subscribers: rwbarton, thomie

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

23 months agotestsuite: Pipe stdin directly to process
Ben Gamari [Thu, 20 Jul 2017 12:40:49 +0000 (08:40 -0400)] 
testsuite: Pipe stdin directly to process

Previously the driver would read the stdin content from the source file
and then write it to the subprocess' stdin. We now simply open the stdin
file and provide that handle to the subprocess as its stdin

Test Plan: Validate

Reviewers: austin

Subscribers: rwbarton, thomie, goldfire

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

23 months agoIntroduce -fcatch-bottoms
Ben Gamari [Thu, 20 Jul 2017 02:31:16 +0000 (22:31 -0400)] 
Introduce -fcatch-bottoms

This flag instructs the simplifier to emit ``error`` expressions in the
continutation of empty case analyses (which should bottom and
consequently not return). This is helpful when debugging demand analysis
bugs which can sometimes manifest as segmentation faults.

Test Plan: Validate

Reviewers: simonpj, austin

Subscribers: niteria, rwbarton, thomie

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

23 months agoDemand: Improve comments
Ben Gamari [Thu, 20 Jul 2017 02:25:26 +0000 (22:25 -0400)] 
Demand: Improve comments

[skip-ci]

Reviewers: austin

Subscribers: rwbarton, thomie

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

23 months agoSpelling fixes
Gabor Greif [Thu, 20 Jul 2017 08:46:14 +0000 (10:46 +0200)] 
Spelling fixes

23 months agoTypeable: Ensure that promoted data family instance tycons get bindings
Ben Gamari [Wed, 19 Jul 2017 23:33:00 +0000 (19:33 -0400)] 
Typeable: Ensure that promoted data family instance tycons get bindings

This fixes #13915, where the promoted tycons belonging to data family
instances wouldn't get Typeable bindings, resulting in missing
declarations.

Test Plan: Validate with included testcases

Reviewers: austin, simonpj

Reviewed By: simonpj

Subscribers: simonpj, RyanGlScott, rwbarton, thomie

GHC Trac Issues: #13915

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

23 months agobase: Improve docs to clarify when finalizers may not be run
Andrew Martin [Thu, 13 Jul 2017 15:09:34 +0000 (11:09 -0400)] 
base: Improve docs to clarify when finalizers may not be run

23 months agotypo: -XUndeci[d]ableInstances
Chris Martin [Sun, 16 Jul 2017 00:23:50 +0000 (19:23 -0500)] 
typo: -XUndeci[d]ableInstances

23 months agoFix #13983 by creating a TyConFlavour type, and using it
Ryan Scott [Wed, 19 Jul 2017 19:07:01 +0000 (15:07 -0400)] 
Fix #13983 by creating a TyConFlavour type, and using it

An error message was referring to a type synonym as a datatype.
Annoyingly, learning that the TyCon over which the error message is
operating is actually a type synonym was previously impossible, since
that code only had access to a TcTyCon, which doesn't retain any
information about what sort of TyCon it is.

To rectify this, I created a new TyConFlavour datatype, intended to
capture roughly what sort of TyCon we're dealing with. I then performing
the necessary plumbing to ensure all TcTyCons have a TyConFlavour, and
propagated this information through to the relevant error message.

Test Plan: ./validate

Reviewers: goldfire, austin, bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, thomie

GHC Trac Issues: #13983

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

23 months agodmdAnal: Ensure that ExnStr flag isn't dropped inappropriately
Ben Gamari [Wed, 19 Jul 2017 19:07:52 +0000 (15:07 -0400)] 
dmdAnal: Ensure that ExnStr flag isn't dropped inappropriately

This fixes #13977 and consequently #13615. Here an optimization in the
demand analyser was too liberal, causing us to drop the ExnStr flag and
consequently resulting in incorrect demand signatures. This manifested
as a segmentation fault in #13615 as we incorrectly concluded that an
application of catchRetry# would bottom.

Specifically, we had

    orElse' :: STM a -> STM a -> STM a
    orElse' x = catchRetry# x y
      where y = {- some action -}

Where the catchRetry# primop places a demand of <xC(S),1*C1(U)> on its
first argument. However, due to #13977 the demand analyser would assign
a demand of <C(S),1*C1(U)> on the first argument of orElse'. Note the
missing `x`.

    case orElse' bottomingAction anotherAction of { x -> Just x }

being transformed to,

    case orElse' bottomingAction anotherAction of {}

by the simplifier. This would naturally blow up when orElse' returned at
runtime, causing the segmentation fault described in #13615.

Test Plan: Validate, perhaps add a testcase

Reviewers: austin, simonpj

Reviewed By: simonpj

Subscribers: rwbarton, thomie

GHC Trac Issues: #13977, #13615

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

23 months agoAdd Haddocks for Eq (STRef a) and Eq (IORef a)
Adam Sandberg Eriksson [Wed, 19 Jul 2017 19:07:44 +0000 (15:07 -0400)] 
Add Haddocks for Eq (STRef a) and Eq (IORef a)

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: RyanGlScott, rwbarton, thomie

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

23 months agoFix links to SPJ’s papers (fixes #12578)
Takenobu Tani [Wed, 19 Jul 2017 19:06:27 +0000 (15:06 -0400)] 
Fix links to SPJ’s papers (fixes #12578)

This fixes #12578.
Update links to SPJ's papers in following files:

  * compiler/coreSyn/CoreSyn.hs
  * docs/users_guide/using-optimisation.rst
  * docs/users_guide/parallel.rst
  * docs/users_guide/glasgow_exts.rst

This commit is for ghc-8.2 branch.

Test Plan: build

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #12578

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

23 months agoAllow visible type application for []
Ryan Scott [Wed, 19 Jul 2017 19:06:12 +0000 (15:06 -0400)] 
Allow visible type application for []

This amounts to a one-line change in `tcExpr`. I've added a Note to
explain what is going on.

This requires a separate change in the pattern-match checker to
account for the fact that typechecked `[]` expressions become
`ConLikeOut`s, not `ExplicitList`s.

Test Plan: make test TEST=T13680

Reviewers: goldfire, mpickering, austin, bgamari

Reviewed By: mpickering, bgamari

Subscribers: rwbarton, thomie, goldfire

GHC Trac Issues: #13680

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

23 months agotestsuite: Ensure that hs_try_putmvar003 terminates
Ben Gamari [Wed, 19 Jul 2017 19:06:02 +0000 (15:06 -0400)] 
testsuite: Ensure that hs_try_putmvar003 terminates

Test Plan: Validate

Reviewers: austin, simonmar

Reviewed By: simonmar

Subscribers: simonmar, rwbarton, thomie

GHC Trac Issues: #13434

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

23 months agoconfigure: Cleanup ARM COPY bug test artifacts
Ben Gamari [Sat, 8 Jul 2017 03:16:47 +0000 (23:16 -0400)] 
configure: Cleanup ARM COPY bug test artifacts

23 months agoTypeable: Always use UTF-8 string unpacking primitive
Ben Gamari [Tue, 18 Jul 2017 21:50:07 +0000 (17:50 -0400)] 
Typeable: Always use UTF-8 string unpacking primitive

Reviewers: austin, hvr

Subscribers: Phyx, rwbarton, thomie

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

23 months agoMake module membership on ModuleGraph faster
Bartosz Nitka [Wed, 31 May 2017 17:47:03 +0000 (10:47 -0700)] 
Make module membership on ModuleGraph faster

When loading/reloading with a large number of modules
(>5000) the cost of linear lookups becomes significant.

The changes here made `:reload` go from 6s to 1s on my
test case.

The bottlenecks were `needsLinker` in `DriverPipeline` and
`getModLoop` in `GhcMake`.

Test Plan: ./validate

Reviewers: simonmar, austin, bgamari

Subscribers: thomie, rwbarton

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

23 months agoTypos in comments and explanation for unusused imports
Gabor Greif [Mon, 17 Jul 2017 13:35:59 +0000 (15:35 +0200)] 
Typos in comments and explanation for unusused imports

23 months agoFix a missing getNewNursery(), and related cleanup
Simon Marlow [Mon, 17 Jul 2017 16:32:44 +0000 (17:32 +0100)] 
Fix a missing getNewNursery(), and related cleanup

Summary:
When we use nursery chunks with +RTS -n<size>, when the current nursery
runs out we have to check whether there's another chunk available with
getNewNursery().  There was one place we weren't doing this: the ad-hoc
heap check in scheduleProcessInbox().

The impact of the bug was that we would GC too early when using nursery
chunks, especially in programs that used messages (throwTo between
capabilities could do this, also hs_try_putmvar()).

Test Plan: validate, also local testing in our application

Reviewers: bgamari, niteria, austin, erikd

Subscribers: rwbarton, thomie

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

2 years ago[skip ci] Temporarily disable split-sections on Windows.
Tamar Christina [Thu, 13 Jul 2017 20:06:49 +0000 (21:06 +0100)] 
[skip ci] Temporarily disable split-sections on Windows.

Summary:
This temporarily disabled split-sections again on Windows because
of the overhead in linking it introduces. Unfortunately because BFD
is so slow a testsuite run gets almost 2x slower. Simply linking
Hello World takes an unacceptable long time.

So for now, it'll be disabled as we look into different linkers such
as LLD.

Test Plan: ./validate

Reviewers: austin, bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #12913

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

2 years agoFix some excessive spacing in error messages
Ryan Scott [Wed, 12 Jul 2017 23:26:37 +0000 (19:26 -0400)] 
Fix some excessive spacing in error messages

Test Plan: If it builds, ship it

Reviewers: austin, bgamari

Subscribers: rwbarton, thomie

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

2 years agotestsuite: Again update allocations of T13701
Ben Gamari [Wed, 12 Jul 2017 19:10:46 +0000 (15:10 -0400)] 
testsuite: Again update allocations of T13701

This test appears to be quite unstable.

2 years agotestsuite: Update haddock allocations
Ben Gamari [Wed, 12 Jul 2017 12:21:55 +0000 (08:21 -0400)] 
testsuite: Update haddock allocations

It seems to be the change to getNameToInstancesIndex that bumped these.

2 years ago[iserv] Fixing the word size for RemotePtr and toWordArray
Ben Gamari [Wed, 12 Jul 2017 00:50:38 +0000 (20:50 -0400)] 
[iserv] Fixing the word size for RemotePtr and toWordArray

When we load non absolute pathed .so's this usually implies that we
expect the system to have them in place already, and hence we should not
need to ship them.  Without the absolute path to the library, we are
also unable to open and send said library.  Thus we'll do library
shipping only for libraries with absolute paths.

When dealing with a host and target of different word size (say host
hast 64bit, target has 32bit), we need to fix the RemotePtr size and the
toWordArray function, as they are part of the iserv ResolvedBCO binary
protocol.  This needs to be word size independent.  The choice for
RemotePtr to 64bit was made to ensure we can store 64bit pointers when
targeting 64bit. The choice for 32bit word arrays was made wrt.
encoding/decoding on the potentially slower device.

The efficient serialization code has been graciously provided by
@bgamari.

Reviewers: bgamari, simonmar, austin, hvr

Reviewed By: bgamari

Subscribers: Ericson2314, rwbarton, thomie, ryantrinkle

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

2 years agodistrib/configure: Fail if we can't detect machine's word size
Ben Gamari [Tue, 11 Jul 2017 22:40:31 +0000 (18:40 -0400)] 
distrib/configure: Fail if we can't detect machine's word size

This is a sure sign that something is terribly wrong.

We also now verify that the word size that the binary distribution
expects matches the word size produced by the local target toolchain.

Finally we rename WordSize to TargetWordSize, since non-host/target
qualified quantities are terribly confusing.

Reviewers: austin, hvr, Phyx

Reviewed By: Phyx

Subscribers: Phyx, rwbarton, thomie, erikd

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

2 years agoFix missing escape in macro
Moritz Angermann [Wed, 12 Jul 2017 05:09:11 +0000 (01:09 -0400)] 
Fix missing escape in macro

Reviewers: angerman, austin, bgamari, erikd, simonmar

Reviewed By: angerman

Subscribers: rwbarton, thomie

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

2 years agoUse correct section types syntax for architecture
Ben Gamari [Tue, 11 Jul 2017 19:41:55 +0000 (15:41 -0400)] 
Use correct section types syntax for architecture

Previously GHC would always assume that section types began with `@` while
producing assembly, which is not true. For instance, in ARM assembly syntax
section types begin with `%`. This abstracts out section type pretty-printing
and adjusts it to correctly account for the target architectures assembly
flavor.

Reviewers: austin, hvr, Phyx

Reviewed By: Phyx

Subscribers: Phyx, rwbarton, thomie, erikd

GHC Trac Issues: #13937

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

2 years agoMention which -Werror promoted a warning to an error
Ömer Sinan Ağacan [Tue, 11 Jul 2017 19:41:20 +0000 (15:41 -0400)] 
Mention which -Werror promoted a warning to an error

Previously -Werror or -Werror=flag printed warnings as usual and then
printed
these two lines:

    <no location info>: error:
    Failing due to -Werror.

This is not ideal: first, it's not clear which flag made one of the
warnings an
error. Second, warning messages are not modified in any way, so there's
no way
to know which warnings caused this error.

With this patch we (1) promote warning messages to error messages if a
relevant
-Werror is enabled (2) mention which -Werror is used during this
promotion.

Previously:

    [1 of 1] Compiling Main             ( test.hs, test.o )

    test.hs:9:10: warning: [-Wincomplete-patterns]
        Pattern match(es) are non-exhaustive
        In a case alternative: Patterns not matched: (C2 _)
      |
    9 | sInt s = case s of
      |          ^^^^^^^^^...

    test.hs:12:14: warning: [-Wmissing-fields]
        • Fields of ‘Rec’ not initialised: f2
        • In the first argument of ‘print’, namely ‘Rec {f1 =
1}’
          In the expression: print Rec {f1 = 1}
          In an equation for ‘main’: main = print Rec {f1 = 1}
       |
    12 | main = print Rec{ f1 = 1 }
       |              ^^^^^^^^^^^^^

    <no location info>: error:
    Failing due to -Werror.

Now:

    [1 of 1] Compiling Main             ( test.hs, test.o )

    test.hs:9:10: error: [-Wincomplete-patterns,
-Werror=incomplete-patterns]
        Pattern match(es) are non-exhaustive
        In a case alternative: Patterns not matched: (C2 _)
      |
    9 | sInt s = case s of
      |          ^^^^^^^^^...

    test.hs:12:14: error: [-Wmissing-fields, -Werror=missing-fields]
        • Fields of ‘Rec’ not initialised: f2
        • In the first argument of ‘print’, namely ‘Rec {f1 =
1}’
          In the expression: print Rec {f1 = 1}
          In an equation for ‘main’: main = print Rec {f1 = 1}
       |
    12 | main = print Rec{ f1 = 1 }
       |              ^^^^^^^^^^^^^

Test Plan: - Update old tests, add new tests if there aren't any
relevant tests

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

2 years agoRemove redundant import; fix note
David Feuer [Tue, 11 Jul 2017 19:28:49 +0000 (15:28 -0400)] 
Remove redundant import; fix note

* Remove the redundant import of `Data.Maybe` from `GHC.Foreign`.

* Fix the note in `GHC.Stack.Types` to give a correct explanation
of the problematic cycle.

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

2 years agoFix minor typo
Ismail [Fri, 7 Jul 2017 16:19:33 +0000 (17:19 +0100)] 
Fix minor typo

2 years agotestsuite: Show stderr output on command failure
Ben Gamari [Tue, 11 Jul 2017 18:43:38 +0000 (14:43 -0400)] 
testsuite: Show stderr output on command failure

Reviewers: austin

Subscribers: rwbarton, thomie

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

2 years agoStgLint: Don't loop on tycons with runtime rep arguments
Ben Gamari [Tue, 11 Jul 2017 18:43:19 +0000 (14:43 -0400)] 
StgLint: Don't loop on tycons with runtime rep arguments

Test Plan: Validate

Reviewers: austin

Subscribers: rwbarton, thomie

GHC Trac Issues: #13941

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

2 years agoconfigure: Ensure that we don't set LD to unusable linker
Ben Gamari [Tue, 11 Jul 2017 18:42:04 +0000 (14:42 -0400)] 
configure: Ensure that we don't set LD to unusable linker

Previously if we found an unusable linker in PATH (e.g. ld.lld on OS X)
we would notice the -fuse-ld=... was broken, but neglected to reset LD
to a usable linker. This resulted in brokenness on OS X when lld is in
PATH.

Test Plan: Validate on OS X with lld in PATH

Reviewers: austin, hvr, angerman

Reviewed By: angerman

Subscribers: rwbarton, thomie, erikd, angerman

GHC Trac Issues: #13541

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

2 years agotestsuite: Fix T13701 allocations yet again
Ben Gamari [Tue, 11 Jul 2017 19:25:53 +0000 (15:25 -0400)] 
testsuite: Fix T13701 allocations yet again

2 years agoRemove unnecessarily returned res_ty from rejigConRes
Ryan Scott [Tue, 11 Jul 2017 18:03:13 +0000 (14:03 -0400)] 
Remove unnecessarily returned res_ty from rejigConRes

@goldfire noticed that we don't need to thread through `res_ty`
through to the return type of `rejigConRes`, as it never changes.

Reviewers: goldfire, austin, bgamari

Reviewed By: goldfire

Subscribers: rwbarton, thomie, goldfire

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

2 years agoAdd Template Haskell support for overloaded labels
Matthew Pickering [Tue, 11 Jul 2017 18:01:11 +0000 (14:01 -0400)] 
Add Template Haskell support for overloaded labels

Reviewers: RyanGlScott, austin, goldfire, bgamari

Reviewed By: RyanGlScott, goldfire, bgamari

Subscribers: rwbarton, thomie

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

2 years agoParenthesize infix type names in data declarations in TH printer
Eugene Akentyev [Tue, 11 Jul 2017 17:59:47 +0000 (13:59 -0400)] 
Parenthesize infix type names in data declarations in TH printer

Previously datatype names were not paraenthesized (#13887).

Reviewers: austin, bgamari, RyanGlScott

Reviewed By: RyanGlScott

Subscribers: RyanGlScott, rwbarton, thomie

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

2 years agoFix #13947 by checking for unbounded names more
Ryan Scott [Tue, 11 Jul 2017 17:59:29 +0000 (13:59 -0400)] 
Fix #13947 by checking for unbounded names more

Commit 2484d4dae65c81f218dcfe494b963b2630bb8fa6 accidentally dropped a
call to `isUnboundName` in an important location. This re-adds it.

Fixes #13947.

Test Plan: make test TEST=T13947

Reviewers: adamgundry, austin, bgamari

Reviewed By: adamgundry

Subscribers: rwbarton, thomie

GHC Trac Issues: #13947

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

2 years agoFix #13948 by being pickier about when to suggest DataKinds
Ryan Scott [Tue, 11 Jul 2017 17:59:07 +0000 (13:59 -0400)] 
Fix #13948 by being pickier about when to suggest DataKinds

Commit 343cb32d0983f576d344a2d04a35c3fd6eecf2c5 (#13568) made GHC a bit
too cavalier in suggesting when data constructors are in scope (and
suggesting the use of `DataKinds`). This tones down the suggestions so
that `DataKinds` is only suggested if a data constructor of that name is
actually in scope (previously, it would always suggest, even if it was
out of scope).

Fixes #13948.

Test Plan: ./validate

Reviewers: mpickering, austin, bgamari

Reviewed By: mpickering

Subscribers: rwbarton, thomie

GHC Trac Issues: #13948

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

2 years agoFix logic error in GhcMake.enableCodeGenForTH
Douglas Wilson [Tue, 11 Jul 2017 17:58:17 +0000 (13:58 -0400)] 
Fix logic error in GhcMake.enableCodeGenForTH

transitive_deps_set was incorrect, it was not considering the
dependencies of dependencies in some cases. I've corrected it and tidied
it up a little.

The test case from leftaroundabout, as linked to from the ticket, is
added with small modifications to flatten directory structure.

Test Plan: make test TEST=T13949

Reviewers: austin, bgamari, alexbiehl

Reviewed By: alexbiehl

Subscribers: rwbarton, thomie, alexbiehl

GHC Trac Issues: #13949

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

2 years agoOptimize TimerManager
alexbiehl [Tue, 11 Jul 2017 17:57:51 +0000 (13:57 -0400)] 
Optimize TimerManager

After discussion with Kazu Yamamoto we decided to try two things:
  - replace current finger tree based priority queue through a radix
    tree based one (code is based on IntPSQ from the psqueues package)
  - after editing the timer queue: don't wake up the timer manager if
    the next scheduled time didn't change

Benchmark results (number of TimerManager-Operations measured over 20
seconds, 5 runs each, higher is better)

```
-- baseline (timermanager action commented out)
28817088
28754681
27230541
27267441
28828815

-- ghc-8.3 with wake opt and new timer queue
18085502
17892831
18005256
18791301
17912456

-- ghc-8.3 with old timer queue
6982155
7003572
6834625
6979634
6664339
```

Here is the benchmark code:
```
{-# LANGUAGE BangPatterns #-}
module Main where

import Control.Monad
import Control.Monad.IO.Class
import Control.Monad.Trans.State.Strict
import Data.Foldable
import GHC.Event
import System.Random
import Control.Concurrent
import Control.Exception
import Data.IORef

main :: IO ()
main = do

  let seed = 12345 :: Int
      nthreads = 1 :: Int
      benchTime = 20 :: Int -- in seconds

  timerManager <- getSystemTimerManager :: IO TimerManager

  let
    {- worker loop
       depending on the random generator it either
        * registers a new timeout
        * updates existing timeout
        * or cancels an existing timeout

      Additionally it keeps track of a counter tracking how
      often a timermanager was being modified.
    -}
    loop :: IORef Int -> [TimeoutKey] -> StdGen -> IO a
    loop !i !timeouts !rng = do
      let (rand0, rng')   = next rng
          (rand1, rng'')  = next rng'
      case rand0 `mod` 3 of
        0 -> do
          timeout <- registerTimeout timerManager (rand1) (return ())
          modifyIORef' i (+1)
          loop i (timeout:timeouts) rng''
        1 | (timeout:_) <- timeouts
          -> do
            updateTimeout timerManager timeout (rand1)
            modifyIORef' i (+1)
            loop i timeouts rng''
          | otherwise
          -> loop i timeouts rng'
        2
          | (timeout:timeouts') <- timeouts
          -> do
              unregisterTimeout timerManager timeout
              modifyIORef' i (+1)
              loop i timeouts' rng'
          | otherwise -> loop i timeouts rng'

        _ -> loop i timeouts rng'

  let
    -- run a computation which can produce new
    -- random generators on demand
    withRng m = evalStateT m (mkStdGen seed)

    -- split a new random generator
    newRng = do
      (rng1, rng2) <- split <$> get
      put rng1
      return rng2

  counters <- withRng $ do
    replicateM nthreads $ do
      rng <- newRng
      ref <- liftIO (newIORef 0)
      liftIO $ forkIO (loop ref [] rng)
      return ref

  threadDelay (1000000 * benchTime)
  for_ counters $ \ref -> do
    n <- readIORef ref
    putStrLn (show n)

```

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: Phyx, rwbarton, thomie

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

2 years agoAdd Template Haskell support for overloaded labels
Matthew Pickering [Tue, 11 Jul 2017 18:01:31 +0000 (19:01 +0100)] 
Add Template Haskell support for overloaded labels

Reviewers: RyanGlScott, austin, goldfire, bgamari

Reviewed By: RyanGlScott, goldfire, bgamari

Subscribers: rwbarton, thomie

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

2 years agousers-guide/rel-notes: Describe #13875 fix
Ben Gamari [Tue, 11 Jul 2017 16:01:05 +0000 (12:01 -0400)] 
users-guide/rel-notes: Describe #13875 fix

Test Plan: Read it.

Reviewers: simonmar, austin

Reviewed By: simonmar

Subscribers: rwbarton, thomie

GHC Trac Issues: #13875

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

2 years agoByteCodeGen: use depth instead of offsets in BCEnv
Michal Terepeta [Tue, 11 Jul 2017 16:00:16 +0000 (12:00 -0400)] 
ByteCodeGen: use depth instead of offsets in BCEnv

This is based on unfinished work in D38 started by Simon Marlow and is
the first step for fixing #13825. (next step use byte-indexing for
stack)

The change boils down to adjusting everything in BCEnv by +1, which
simplifies the code a bit.

I've also looked into a weird stack adjustement that we did in
`getIdValFromApStack` and moved it to `ByteCodeGen` to just keep
everything in one place. I've left a comment about this.

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

Reviewers: austin, hvr, bgamari, simonmar

Reviewed By: bgamari, simonmar

Subscribers: simonmar, rwbarton, thomie

GHC Trac Issues: #13825

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

2 years agoAlways allow -staticlib
Moritz Angermann [Tue, 11 Jul 2017 15:57:48 +0000 (11:57 -0400)] 
Always allow -staticlib

the `-staticlib` flag is currently only supported on apple platforms,
due to the avaiablity of libtool (the apple version, which is unlike the
gnu version).  This however prevents the use of -staticlib in cases
where it would be beneficial as well.  The functionality that
`-staticlib` uses from `libtool` can be stubbed with a small script like
the following:

```
#!/bin/bash

# This script pretends to be libtool.  And supports
# only a limited set of flags.
#
# It is supposed to be a stand in for libtool -static, whic
# creates a static archive.  This is done by locating all -l<lib>
# libs in the provied -L<lib path> library paths, and building an
# MRI script to create the final archive from all the libraries, and
# other provided inputs.
#

name=${0##*/}
target=${name%-*}

set -e

ldflags_L=()
ldflags_l=()
output=""
inputs=()
STATIC=0
DYNAMIC=1
mode=$DYNAMIC
verbose=0

# find_lib <name> path path path path
function find_lib () {
        lib=$1; shift 1;
        for dir in $@; do
                if [ -f "$dir/$lib" ]; then
                        echo "$dir/$lib"
                        break
                fi
        done
}

while [ "$#" -gt 0 ]; do
        case "$1" in
                -v|--verbose) verbose=1; shift 1;;
                -o) output="$2"; shift 2;;
                -L*) ldflags_L+=("${1:2:${#1}-2}"); shift 1;;
                -l*) ldflags_l+=("lib${1:2:${#1}-2}.a"); shift 1;;
                -static) mode=$STATIC; shift 1;;
                -dynamic) mode=$DYNAMIC; shift 1;;
                -Wl,*) ldflags+=("${1#*,}"); shift 1;;
                -*) echo "unknown option: $1" >&2; exit 1;;
                *) inputs+=("$1"); shift 1;;
        esac
done

if [ ! $mode == $STATIC ]; then
        echo "-dynamic not supported!" >&2; exit 1;
fi

MRI="create ${output}\n"
for input in "${ldflags_l[@]}"; do
        lib=$(find_lib $input ${ldflags_L[@]})
        if [ -z $lib ]; then
                echo "Failed to find lib $input" >&2
                exit 1
        else
                MRI+="addlib $lib\n"
                continue
        fi
done
for input in "${inputs[@]}"; do
        MRI+="addmod $input\n"
done
MRI+="save\nend\n"
echo -e "$MRI" | $target-ar -M
$target-ranlib $output
```

if `ar` supports MRI scripts.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

2 years agoSort list of failed tests for easier comparison between runs
Andreas Klebinger [Tue, 11 Jul 2017 15:57:39 +0000 (11:57 -0400)] 
Sort list of failed tests for easier comparison between runs

Test Plan: Running the testsuite.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13922

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

2 years agoSuppress unused warnings for selectors for some derived classes
Ryan Scott [Tue, 11 Jul 2017 15:57:05 +0000 (11:57 -0400)] 
Suppress unused warnings for selectors for some derived classes

Although derived `Read`, `Show`, and `Generic` instances technically
don't //use// the record selectors of the data type for which an
instance is being derived, the derived code is affected by the
//presence// of record selectors. As a result, we should suppress
`-Wunused-binds` for those record selectors when deriving these classes.
This is accomplished by threading through more information from
`hasStockDeriving`.

Test Plan: make test TEST=T13919

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13919

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

2 years agoAdd testcase for T13818
Douglas Wilson [Tue, 11 Jul 2017 15:55:15 +0000 (11:55 -0400)] 
Add testcase for T13818

Annotations currently fail to type check if they annotation cannot
be loaded into ghci, such as when built with -fno-code.

Test Plan: ./validate

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13818

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

2 years agoImprove Wmissing-home-modules warning under Cabal
Ben Gamari [Tue, 11 Jul 2017 15:54:59 +0000 (11:54 -0400)] 
Improve Wmissing-home-modules warning under Cabal

Reviewers: hvr, alanz, austin

Reviewed By: alanz

Subscribers: rwbarton, thomie

GHC Trac Issues: #13899

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

2 years agoFix Work Balance computation in RTS stats
Douglas Wilson [Tue, 11 Jul 2017 15:54:09 +0000 (11:54 -0400)] 
Fix Work Balance computation in RTS stats

An additional stat is tracked per gc: par_balanced_copied This is the
the number of bytes copied by each gc thread under the balanced lmit,
which is simply (copied_bytes / num_gc_threads).  The stat is added to
all the appropriate GC structures, so is visible in the eventlog and in
GHC.Stats.

A note is added explaining how work balance is computed.

Remove some end of line whitespace

Test Plan:
./validate
experiment with the program attached to the ticket
examine code changes carefully

Reviewers: simonmar, austin, hvr, bgamari, erikd

Reviewed By: simonmar

Subscribers: Phyx, rwbarton, thomie

GHC Trac Issues: #13830

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

2 years agoMake ':info Coercible' display an arbitrary string (fixes #12390)
Patrick Dougherty [Tue, 11 Jul 2017 15:53:40 +0000 (11:53 -0400)] 
Make ':info Coercible' display an arbitrary string (fixes #12390)

This change enables the addition of an arbitrary string to the output of
GHCi's ':info'. It was made for Coercible in particular but could be
extended if desired.

Updates haddock submodule.

Test Plan: Modified test 'ghci059' to match new output.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: goldfire, rwbarton, thomie

GHC Trac Issues: #12390

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

2 years agouser-guide: Various fixes to FFI section
Ben Gamari [Wed, 5 Jul 2017 19:01:47 +0000 (15:01 -0400)] 
user-guide: Various fixes to FFI section

2 years agotestsuite: Decrease T13701 allocations
Ben Gamari [Tue, 11 Jul 2017 17:19:53 +0000 (13:19 -0400)] 
testsuite: Decrease T13701 allocations

2 years agoPretty-printer no longer butchers function arrow fixity
Alan Zimmerman [Mon, 10 Jul 2017 11:00:36 +0000 (13:00 +0200)] 
Pretty-printer no longer butchers function arrow fixity

It now correctly prints the parens around '(Int -> Int)' in

    {-# LANGUAGE TemplateHaskell #-}
    {-# OPTIONS_GHC -ddump-splices #-}
    module Bug where

    $([d| f :: Either Int (Int -> Int)
          f = undefined
        |])

Closes #13942

2 years agoBig-obj support for the Windows runtime linker
Tamar Christina [Sat, 8 Jul 2017 08:57:55 +0000 (09:57 +0100)] 
Big-obj support for the Windows runtime linker

Summary:
The normal object file on Windows has a limit of `2^16`
sections that can be in an object-file.

The `big-obj` format raises this to `2^32` sections.

The implementation is made difficult because we now need to support
two header formats and two section formats that differ only by a single
element size within each. The element that's different is in the middle
of the structs and since the structs are used to map regions of memory
directly, it means we need to know which struct it is when we do the
mapping or pointer arithmetics.

This is the final Object-Code format which Windows compilers can generate
which we do not support yet in GHCI. All other major compilers on the platforms
can produce it and all linkers consume it (bfd and lld).

See http://tinyurl.com/bigobj

This patch abstracts away retrieving the fields to functions which all take
an struct which describes which object format is currently being parsed.
These functions are always in-lined as they're small but would looks messy
being copy-pasted everywhere.

Test Plan:
./validate and new test `big-obj`

```
Tamar@Rage MINGW64 /r
$ gcc -c -Wa,-mbig-obj foo.c -o foo.o

Tamar@Rage MINGW64 /r
$ objdump -h foo.o

foo.o:     file format pe-bigobj-x86-64

Sections:
Idx Name          Size      VMA               LMA               File off  Algn
  0 .text         00000010  0000000000000000  0000000000000000  00000128  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .data         00000000  0000000000000000  0000000000000000  00000000  2**4
                  ALLOC, LOAD, DATA
  2 .bss          00000000  0000000000000000  0000000000000000  00000000  2**4
                  ALLOC
  3 .xdata        00000008  0000000000000000  0000000000000000  00000138  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  4 .pdata        0000000c  0000000000000000  0000000000000000  00000140  2**2
                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
  5 .rdata$zzz    00000030  0000000000000000  0000000000000000  0000014c  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, DATA

Tamar@Rage MINGW64 /r
$ echo main | ~/ghc/inplace/bin/ghc-stage2.exe --interactive bar.hs foo.o
GHCi, version 8.3.20170430: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Main             ( bar.hs, interpreted )
Ok, modules loaded: Main.
*Main> 17
*Main> Leaving GHCi.
```

Reviewers: austin, bgamari, erikd, simonmar

Subscribers: awson, rwbarton, thomie, #ghc_windows_task_force

GHC Trac Issues: #13815

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

2 years agoFix typos in Bag.hs [ci skip]
Ömer Sinan Ağacan [Sat, 8 Jul 2017 11:22:17 +0000 (14:22 +0300)] 
Fix typos in Bag.hs [ci skip]

2 years agoaclocal.m4: allow arbitrary <vendor> string in toolchain triplets
Sergei Trofimovich [Sat, 8 Jul 2017 08:47:12 +0000 (09:47 +0100)] 
aclocal.m4: allow arbitrary <vendor> string in toolchain triplets

Canonical triplets have a form of
    <arch>-<vendor>-<os>[-<abi>]

Checking for vendor is almost never correct as it's an
arbitrary string.

It's useful to have multiple "vendors" to denote
otherwise the same (WRT <arch>, <os>, <abi>) target:
    --target=x86_64-pc-linux-gnu
    --target=x86_64-unknown-linux-gnu
    --target=x86_64-ghc80-linux-gnu
    --target=x86_64-ghchead-linux-gnu

Do not fail unknown vendors. Only emit a warning.
Ideally configure checks should never use "vendor".

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2 years agoImplement split-sections support for windows.
Tamar Christina [Sun, 26 Mar 2017 18:05:46 +0000 (19:05 +0100)] 
Implement split-sections support for windows.

Summary:
Initial implementation of split-section on Windows.

This also corrects section namings and uses the platform
convention of `$` instead of `.` to separate sections.

Implementation is based on @awson's patches to binutils.

Binutils requires some extra help when compiling the libraries
for GHCi usage. We drop the `-T` and use implicit scripts to amend
the linker scripts instead of replacing it.

Because of these very large GHCi object files, we need big-obj support,
which will be added by another patch.

Test Plan: ./validate

Reviewers: awson, austin, bgamari

Subscribers: dfeuer, rwbarton, thomie, snowleopard, #ghc_windows_task_force

GHC Trac Issues: #12913

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

2 years agoTypos in comments [ci skip]
Gabor Greif [Thu, 6 Jul 2017 08:48:52 +0000 (10:48 +0200)] 
Typos in comments [ci skip]

2 years agolowercase clang
Moritz Angermann [Thu, 6 Jul 2017 03:31:20 +0000 (11:31 +0800)] 
lowercase clang

2 years agomkDocs: Don't install *.ps
Ben Gamari [Wed, 5 Jul 2017 18:48:26 +0000 (14:48 -0400)] 
mkDocs: Don't install *.ps

We now longer produce PostScript output.

2 years agorts: Address AP_STACK comment suggestion from Simon
Ben Gamari [Tue, 4 Jul 2017 16:45:30 +0000 (12:45 -0400)] 
rts: Address AP_STACK comment suggestion from Simon

2 years agorts/sm/Storage.c: tweak __clear_cache proto for clang
Sergei Trofimovich [Wed, 5 Jul 2017 07:36:08 +0000 (08:36 +0100)] 
rts/sm/Storage.c: tweak __clear_cache proto for clang

clang defines '__clear_cache' slightly differently from gcc:
    rts/sm/Storage.c:1349:13: error:
         error: conflicting types for '__clear_cache'
         |
    1349 | extern void __clear_cache(char * begin, char * end);
         |             ^
    extern void __clear_cache(char * begin, char * end);
                ^
         note: '__clear_cache' is a builtin with type 'void (void *, void *)'

Reported by Moritz Angermann.

While at it used '__builtin___clear_cache' if advertised by clang.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2 years agoRevert "rts/sm/Storage.c: tweak __clear_cache proto for clang"
Sergei Trofimovich [Wed, 5 Jul 2017 08:13:09 +0000 (09:13 +0100)] 
Revert "rts/sm/Storage.c: tweak __clear_cache proto for clang"

This reverts commit 9492703a5862ee8623455209e50344cf8c4de077.

Incomplete patch (missing begin, end assignments).

2 years agorts/sm/Storage.c: tweak __clear_cache proto for clang
Sergei Trofimovich [Wed, 5 Jul 2017 07:36:08 +0000 (08:36 +0100)] 
rts/sm/Storage.c: tweak __clear_cache proto for clang

clang defines '__clear_cache' slightly differently from gcc:
    rts/sm/Storage.c:1349:13: error:
         error: conflicting types for '__clear_cache'
         |
    1349 | extern void __clear_cache(char * begin, char * end);
         |             ^
    extern void __clear_cache(char * begin, char * end);
                ^
         note: '__clear_cache' is a builtin with type 'void (void *, void *)'

Reported by Moritz Angermann.

While at it used '__builtin___clear_cache' if advertised by clang.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2 years agoEagerly blackhole AP_STACKs
Ben Gamari [Mon, 3 Jul 2017 23:10:07 +0000 (19:10 -0400)] 
Eagerly blackhole AP_STACKs

This fixes #13615. See the rather lengthy Note [AP_STACKs must be
eagerly blackholed] for details.

Reviewers: simonmar, austin, erikd, dfeuer

Subscribers: duog, dfeuer, hsyl20, rwbarton, thomie

GHC Trac Issues: #13615

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

2 years agotestsuite: Add testcase for #13615
Ben Gamari [Mon, 3 Jul 2017 23:09:58 +0000 (19:09 -0400)] 
testsuite: Add testcase for #13615

Reviewers: austin

Subscribers: dfeuer, rwbarton, thomie

GHC Trac Issues: #13615

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

2 years agoAdd -fuse-ld flag to CFLAGS during configure
Ben Gamari [Mon, 3 Jul 2017 23:09:39 +0000 (19:09 -0400)] 
Add -fuse-ld flag to CFLAGS during configure

The decisions made by configure later in the script may depend upon the
linker used. Consequently, it is important that configure uses the same
linker as GHC will eventually use.

For instance, on Nix I found that a program requiring `libpthread` would
link fine with only `-lrt` when linked with BFD ld. However, with gold
we needed to explicitly provide the `-lpthread` dependency. Presumably
the former would happily loaded any `NEEDED` libraries whereas the
latter wants them explicitly given. Regardless, since `configure`'s
`NEED_PTHREAD_LIB` check didn't use the `-fuse-ld` flag that GHC would
eventually use, we inferred the wrong value, resulting in link errors
later in the build.

Test Plan: Validate

Reviewers: austin, hvr

Subscribers: rwbarton, thomie, erikd

GHC Trac Issues: #13541

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

2 years agorts: Fix isByteArrayPinned#'s treatment of large arrays
Ben Gamari [Mon, 3 Jul 2017 23:09:03 +0000 (19:09 -0400)] 
rts: Fix isByteArrayPinned#'s treatment of large arrays

It should respond with True to both BF_PINNED and BF_LARGE byte arrays.
However, previously it would only check the BF_PINNED flag.

Test Plan: Validate

Reviewers: simonmar, austin, erikd

Subscribers: winterland1989, rwbarton, thomie

GHC Trac Issues: #13894

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

2 years agoconfigure: Remove --with-curses-includes flag
Ben Gamari [Mon, 3 Jul 2017 23:08:43 +0000 (19:08 -0400)] 
configure: Remove --with-curses-includes flag

terminfo no longer needs to be able to find the ncurses headers.
See https://github.com/judah/terminfo/pull/22.

Reviewers: austin, hvr

Subscribers: rwbarton, thomie, erikd

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

2 years agoApplicativeDo: document behaviour with strict patterns (#13875)
Simon Marlow [Mon, 3 Jul 2017 23:08:30 +0000 (19:08 -0400)] 
ApplicativeDo: document behaviour with strict patterns (#13875)

Test Plan: unit tests, built docs

Reviewers: dfeuer, bgamari, simonpj, austin, erikd

Subscribers: rwbarton, thomie

GHC Trac Issues: #13875, #13242

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

2 years agorts: Fix uninitialised variable uses
Ben Gamari [Mon, 3 Jul 2017 23:07:59 +0000 (19:07 -0400)] 
rts: Fix uninitialised variable uses

Strangely gcc 5.4 compiling on amd64 (nixos) complained about these.
Both warnings look correct, so I'm not sure why we haven't been seeing
these up until now.

Test Plan: Validate

Reviewers: simonmar, austin, erikd

Subscribers: rwbarton, thomie

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

2 years agoBump array submodule to v0.5.2.0
Ben Gamari [Mon, 3 Jul 2017 22:22:38 +0000 (18:22 -0400)] 
Bump array submodule to v0.5.2.0

2 years agoCmmParse: Emit source notes for assignments
Ben Gamari [Mon, 3 Jul 2017 21:15:23 +0000 (17:15 -0400)] 
CmmParse: Emit source notes for assignments

Currently the line information for bare source C-- is rather spartan. These add
notes for assignments, which tend to be useful to identify. Unfortunately, we
had to settle for approximate source locations as none of the parsers in
CmmParse return located things. However, I don't think it's worth changing this.

2 years agoFix -fno-code for modules that use -XQuasiQuotes
Douglas Wilson [Mon, 3 Jul 2017 20:54:29 +0000 (16:54 -0400)] 
Fix -fno-code for modules that use -XQuasiQuotes

In commit 53c78be0aab76a3107c4dacbb1d177afacdd37fa object code is
generated for modules depended on by modules that use -XTemplateHaskell.
This turns the same logic on for modules that use -XQuasiQuotes.

A test is added.

Note that I've based this of D3646, as it has a function I want to use.

Test Plan: ./validate

Reviewers: austin, bgamari, alexbiehl

Reviewed By: alexbiehl

Subscribers: alexbiehl, rwbarton, thomie

GHC Trac Issues: #13863

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

2 years agoFix #13311 by using tcSplitNestedSigmaTys in the right place
Ryan Scott [Mon, 3 Jul 2017 20:54:14 +0000 (16:54 -0400)] 
Fix #13311 by using tcSplitNestedSigmaTys in the right place

Previously, we we only using `tcSplitSigmaTy` when determining if a
function had been applied to too few arguments, so it wouldn't work for
functions with nested `forall`s. Thankfully, this is easily fixed with a
dash of `tcSplitNestedSigmaTys`.

Test Plan: make test TEST=T13311

Reviewers: austin, bgamari, simonpj

Reviewed By: bgamari

Subscribers: goldfire, simonpj, rwbarton, thomie

GHC Trac Issues: #13311

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

2 years agoTag the FUN before making a PAP (#13767)
Simon Marlow [Mon, 3 Jul 2017 20:54:00 +0000 (16:54 -0400)] 
Tag the FUN before making a PAP (#13767)

Pointers to FUNs are not guaranteed to be tagged in general, because
the compiler doesn't always know the arity of a FUN when it needs to
reference it, e.g. with -O0 when the function is in another module.

However, there's one case where we can put the correct tag on a FUN:
when it is referenced by a PAP, because when building the PAP we know
the arity and we can tag the pointer correctly.  The AutoApply code
does this, and the sanity checker checks it, but the interpreter did
not respect this invariant.  This patch fixes it.

Test Plan:
```
(cd ghc && make 2 GhcDebugged=YES)
./inplace/bin/ghc-stage2 --interpreter +RTS -DS
```

Reviewers: niteria, bgamari, austin, erikd

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13767

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

2 years agoImplement recompilation checking for -fignore-asserts
Ömer Sinan Ağacan [Mon, 3 Jul 2017 20:53:31 +0000 (16:53 -0400)] 
Implement recompilation checking for -fignore-asserts

Test Plan: Added a test which was previously failing

Reviewers: austin, bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, thomie

GHC Trac Issues: #13914

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

2 years agoAllow per-argument documentation on pattern synonym signatures
alexbiehl [Mon, 3 Jul 2017 20:53:10 +0000 (16:53 -0400)] 
Allow per-argument documentation on pattern synonym signatures

haddock-2.18 supports user defined pattern synonym signatures so this
seems like a welcomed addition.

Reviewers: austin, bgamari, mpickering

Reviewed By: bgamari, mpickering

Subscribers: rwbarton, thomie, mpickering

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

2 years agousers-guide: Wibbles in shared libraries discussion
Ben Gamari [Fri, 30 Jun 2017 18:10:35 +0000 (14:10 -0400)] 
users-guide: Wibbles in shared libraries discussion

2 years agorename tcInstBinder(s)X to tcInstBinder(s)
Gabor Greif [Fri, 30 Jun 2017 12:49:03 +0000 (14:49 +0200)] 
rename tcInstBinder(s)X to tcInstBinder(s)

Summary: Simplify naming scheme of tcInstBinder(s)X

Test Plan: Eyeball and compile

Reviewers: austin, goldfire, bgamari

Subscribers: goldfire, rwbarton, thomie

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

2 years agoFix paper link in MVar docs [ci skip]
Ömer Sinan Ağacan [Sun, 2 Jul 2017 06:59:57 +0000 (09:59 +0300)] 
Fix paper link in MVar docs [ci skip]

2 years agoPrevent ApplicativeDo from applying to strict pattern matches (#13875)
Simon Marlow [Thu, 29 Jun 2017 23:39:45 +0000 (19:39 -0400)] 
Prevent ApplicativeDo from applying to strict pattern matches (#13875)

Test Plan:
* New unit tests
* validate

Reviewers: dfeuer, simonpj, niteria, bgamari, austin, erikd

Reviewed By: dfeuer

Subscribers: rwbarton, thomie

GHC Trac Issues: #13875

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

2 years agorts/RetainerProfile: Const-correctness fixes
Ben Gamari [Thu, 29 Jun 2017 23:39:28 +0000 (19:39 -0400)] 
rts/RetainerProfile: Const-correctness fixes

These were found while using Hadrian, which apparently uses slightly
stricter warning flags than the make-based build system.

Test Plan: Validate

Reviewers: austin, erikd, simonmar

Reviewed By: erikd

Subscribers: rwbarton, thomie

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

2 years agoconfigure: Coerce gcc to use $LD instead of system default
Ben Gamari [Thu, 29 Jun 2017 23:38:51 +0000 (19:38 -0400)] 
configure: Coerce gcc to use $LD instead of system default

The configure script will now try to coerce gcc to use the linker
pointed to by $LD instead of the system default (typically bfd ld).
Moreover, we now check for `ld.gold` and `ld.lld` before trying `ld`.

The previous behavior can be reverted to by using the new
--disable-ld-override flag.

On my machine gold seems to trigger an apparent infelicity in
constructor behavior, causing T5435_asm to fail. I've opened #13883 to
record this issue and have accepted the questionable constructor
ordering for the time being.

Test Plan: Validate with `config_args='--enable-ld-override'`

Reviewers: austin, hvr, simonmar

Subscribers: duog, nh2, rwbarton, thomie, erikd, snowleopard

GHC Trac Issues: #13541, #13810, #13883

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

2 years agoAllow optional instance keyword in associated type family instances
Tibor Erdesz [Thu, 29 Jun 2017 23:37:13 +0000 (19:37 -0400)] 
Allow optional instance keyword in associated type family instances

Add the missing branch for parsing the optional 'instance' keyword
in associated type family instance declarations.

Fixes #13747

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: simonpj, RyanGlScott, rwbarton, thomie, mpickering

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

2 years agoconfigure: Check for binutils #17166
Ben Gamari [Thu, 29 Jun 2017 23:37:03 +0000 (19:37 -0400)] 
configure: Check for binutils #17166

This bug affects bfd ld on ARMv7, causing ld to incorrectly emit
R_REL_COPY relocations, breaking tables-next-to-code. We've known about
it for several years now and there is not yet a fix upstream. Previously
we would simply force use of ld.gold on ARM. However, given the rework
of linking configuration, I thought a more principled solution was in
order.

Test Plan: Validate on armv7

Reviewers: austin, hvr

Subscribers: angerman, rwbarton, thomie, erikd

GHC Trac Issues: #4210

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

2 years agousers-guide: Document FFI safety guarantees
Ben Gamari [Thu, 29 Jun 2017 23:36:51 +0000 (19:36 -0400)] 
users-guide: Document FFI safety guarantees

Test Plan: Read it

Reviewers: austin

Subscribers: simonmar, rwbarton, thomie

GHC Trac Issues: #13730, #8281

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

2 years agoFix T13701 allocation for Linux
David Feuer [Thu, 29 Jun 2017 23:36:42 +0000 (19:36 -0400)] 
Fix T13701 allocation for Linux

For some reason, this test seems to allocate rather more under
Linux than under OSX or Windows.

Reviewers: austin, bgamari

Subscribers: rwbarton, thomie

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