ghc.git
2 years agoFix desugaring of pattern bindings (again)
Simon Peyton Jones [Fri, 16 Sep 2016 21:33:20 +0000 (22:33 +0100)] 
Fix desugaring of pattern bindings (again)

This patch fixes Trac #12595.  The problem was with a
pattern binding like
     !x = e
For a start it's silly to match that pattern and build
a unit tuple (the General Case of mkSelectorBinds); but
that's what was happening because the bang fell through
to the general case.  But for a variable pattern building
any auxiliary bindings is stupid.  So the patch
introduces a new case in mkSelectorBinds for variable
patterns.

Then it turned out that if 'e' was a plain variable, and
moreover was imported GlobalId, then matchSinglePat made
it a /bound/ variable, which should never happen.  That
ultimately caused a linker error, but the original bug
was much earlier.

(cherry picked from commit 2fbfbca2d12a8e9a09627529cf4f8284b19023ff)

2 years agoFix interaction of record pattern synonyms and record wildcards
Matthew Pickering [Sat, 1 Oct 2016 21:55:04 +0000 (17:55 -0400)] 
Fix interaction of record pattern synonyms and record wildcards

We were missing an appropiate *ConLike lookup in the case when
the pattern synonym was defined in a different module.

Reviewers: austin, bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, thomie

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

GHC Trac Issues: #11987

(cherry picked from commit 2d6642bd1956edf8b842c07d78e83c500246998a)

2 years agoDo not warn about unused underscore-prefixed fields (fixes Trac #12609)
Adam Gundry [Sat, 1 Oct 2016 21:56:58 +0000 (17:56 -0400)] 
Do not warn about unused underscore-prefixed fields (fixes Trac #12609)

When DuplicateRecordFields is enabled, the mangling of selector names
was causing them to be reported as unused even if prefixed by an
underscore. This corrects the OccName used by the check.

Test Plan: New test overloadedrecflds/should_compile/T12609

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

GHC Trac Issues: #12609

(cherry picked from commit 48ff0843eee29313cc2da14c04dc57f6589ab040)

2 years agoDon't warn about name shadowing when renaming the patten in a PatSyn decl
Matthew Pickering [Sat, 1 Oct 2016 21:55:26 +0000 (17:55 -0400)] 
Don't warn about name shadowing when renaming the patten in a PatSyn decl

Previously the renamer assumed that *any* time we renamed a pattern, the
pattern was introducing new binders. This isn't true in pattern synonym
declarations where the pattern is used as part of a definition.

We add a special case to not warn in this situation.

Reviewers: simonpj, austin, bgamari

Reviewed By: simonpj

Subscribers: simonpj, thomie

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

GHC Trac Issues: #12615

(cherry picked from commit 1851349acd9e73f1c18d68f70d5cf7b46a843cb5)

2 years agoPPC/CodeGen: fix lwa instruction generation
Peter Trommler [Sat, 1 Oct 2016 21:56:31 +0000 (17:56 -0400)] 
PPC/CodeGen: fix lwa instruction generation

Opcode lwa is a 64-bit opcode and allows a DS-form only.  This patch
generates lwa opcodes only when the offset is a multiple of 4.

Fixes #12621

Test Plan: validate

Reviewers: erikd, hvr, simonmar, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

GHC Trac Issues: #12621

(cherry picked from commit ce3370e06165690e79a8eb22e5229b515157e00f)

2 years agoCodeGen X86: fix unsafe foreign calls wrt inlining
Sylvain HENRY [Sat, 1 Oct 2016 04:25:49 +0000 (00:25 -0400)] 
CodeGen X86: fix unsafe foreign calls wrt inlining

Foreign calls (unsafe and safe) interact badly with inlining and
register passing ABIs (see #11792 and #12614):
the inlined code to compute a parameter of the call may overwrite a
register already set to pass a preceding parameter.

With this patch, we compute all parameters which are not simple
expressions before assigning them to fixed registers required by the
ABI.

Test Plan:
   - Add test (test both reg and stack parameters)
   - Validate

Reviewers: osa1, bgamari, austin, simonmar

Reviewed By: simonmar

Subscribers: thomie

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

GHC Trac Issues: #11792, #12614

(cherry picked from commit b61b7c2462b919de7eb4c373e2e2145c6d78d04c)

2 years agoBump Haddock submodule
Ben Gamari [Tue, 27 Sep 2016 21:33:24 +0000 (17:33 -0400)] 
Bump Haddock submodule

Fixes #12519.

3 years agoconfigure.ac: fix --host= handling
Sergei Trofimovich [Fri, 2 Sep 2016 07:35:25 +0000 (08:35 +0100)] 
configure.ac: fix --host= handling

The following command fails as:
    $ ./configure --prefix=/usr \
        --build=x86_64-pc-linux-gnu \
        --host=x86_64-pc-linux-gnu \
        --target=x86_64-pc-linux-gnu
    configure: error:
    You've selected:

      BUILD:  x86_64-unknown-linux
      HOST:   x86_64-unknown-linux
      TARGET: x86_64-unknown-linux

    BUILD must equal HOST;

18f06878ed5d8cb0cf366a876f2bfea29647e5f0 changed native
configure $build/$host/$target checks to ghc-mangled ones,
but not completely.

Signed-off-by: Sergei Trofimovich <siarheit@google.com>
Reviewers: rwbarton, erikd, austin, hvr, bgamari, Phyx

Reviewed By: Phyx

Subscribers: thomie

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

GHC Trac Issues: #12487

(cherry picked from commit 0cc3931bd7831fa8d042f968a5a9114534a656e4)

3 years agoFix configure detection.
Tamar Christina [Sat, 13 Aug 2016 15:27:30 +0000 (16:27 +0100)] 
Fix configure detection.

Summary:
GHC's configure script seems to normalize the values returned from config.guess.
So for Windows it turns x86_64-pc-mingw64 into x86_64-unknown-mingw32.
These mangled names are stored in the values $BuildPlatform, $HostPlatform
and $TargetPlatform.

However further down the file when the comparison is done between the stage0
compiler and the host the normalized versions are not used.
So when normalization actually changes the triple this check will fail.

Not sure why it's worked for all this time.. Nor if this is the right fix?
Does it still work for cross compiling correctly?

Test Plan: ./configure

Reviewers: hvr, austin, thomie, bgamari, erikd

Reviewed By: erikd

Subscribers: erikd, #ghc_windows_task_force

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

GHC Trac Issues: #12487

(cherry picked from commit 18f06878ed5d8cb0cf366a876f2bfea29647e5f0)

3 years agoTrim all spaces after 'version:'
Gabor Greif [Fri, 5 Aug 2016 07:42:09 +0000 (09:42 +0200)] 
Trim all spaces after 'version:'

... that we grep out of libraries/Cabal/Cabal/Cabal.cabal

This is necessary because the file got reformatted
in the 'master' branch.

(cherry picked from commit 1101045cbdbd6f240fa7e2438d9488822cd604fb)

3 years agoFix scoping of type variables in instances
Simon Peyton Jones [Fri, 26 Aug 2016 16:32:42 +0000 (17:32 +0100)] 
Fix scoping of type variables in instances

This fixes Trac #12531:

   class Foo x where
     foo :: forall a . x a -> x a
     default foo :: forall b . x b -> x b
     foo x = go
       where go :: x b
             go = undefined

We want 'b' to scope over the code for 'foo', but we were
using 'a' instead.

(cherry picked from commit 0050aff22ba04baca732bf5124002417ab667f8a)

3 years agorts: Fix reference to NUMA-specific field
Ben Gamari [Sun, 18 Sep 2016 17:11:52 +0000 (13:11 -0400)] 
rts: Fix reference to NUMA-specific field

This snuck into c51caafae7669d4246f4efd3d1a6858020780e02.

3 years agoMore testsuite wibbles
Ben Gamari [Sun, 18 Sep 2016 16:57:18 +0000 (12:57 -0400)] 
More testsuite wibbles

The old testsuite driver still requires a relative path to Defer02.

3 years agoTest wibbles for commit 03541cba
Simon Peyton Jones [Mon, 12 Sep 2016 21:21:15 +0000 (22:21 +0100)] 
Test wibbles for commit 03541cba

I must have failed to validate properly, sorry.
These testsuite wibbles belong with

  commit 03541cbae50f0d1cdf99120ab88698f29a278159
  Author: Simon Peyton Jones <simonpj@microsoft.com>
  Date:   Fri Sep 9 17:42:42 2016 +0100

      Be less picky about reporing inaccessible code

(cherry picked from commit 5eeabe250a1de456f70af07bd3f507a32cb8e10e)

3 years agoBe less picky about reporing inaccessible code
Simon Peyton Jones [Fri, 9 Sep 2016 16:42:42 +0000 (17:42 +0100)] 
Be less picky about reporing inaccessible code

Triggered by the discussion on Trac #12466, this patch
makes GHC less aggressive about reporting an error when
there are insoluble Givens.

Being so agressive was making some libraries fail to
compile, and is arguably wrong in at least some cases.
See the discussion on the ticket.

Several test now pass when they failed before; see
the files-modified list for this patch.

(cherry picked from commit 03541cbae50f0d1cdf99120ab88698f29a278159)

3 years agoGet in-scope set right in top_instantiate
Simon Peyton Jones [Sat, 11 Jun 2016 22:55:10 +0000 (23:55 +0100)] 
Get in-scope set right in top_instantiate

...thereby being able to replace substThetaUnchecked
with substTheta

(cherry picked from commit 7afb7adf45216701e4f645676ecc0668f64b424d)

3 years agoFix T12504
Ben Gamari [Thu, 15 Sep 2016 17:30:57 +0000 (13:30 -0400)] 
Fix T12504

This had an extra_files directive, which does not exist in ghc-8.0, from
cherry-picking.

3 years agoImprove typechecking of instance defaults
Simon Peyton Jones [Thu, 23 Jun 2016 13:51:22 +0000 (14:51 +0100)] 
Improve typechecking of instance defaults

In an instance declaration when you don't specify the code for a
method, GHC fills in from the default binding in the class.
The type of the default method can legitmiately be ambiguous ---
see Note [Default methods in instances] in TcInstDcls --- so
typechecking it can be tricky.

Trac #12220 showed that although we were dealing with that ambiguity
for /vanilla/ default methods, we were not doing so for /generic/
default methods.  Moreover we were dealing with it clumsily, by
generating post-typechecked code.

This patch fixes the bug AND deletes code!  We now use the same code
path for both vanilla and generic default methods; and generate
/pre-typechecked/ code in both cases.  The key trick is that we can use
Visible Type Application to deal with the ambiguity, which wasn't
possible before.  Hooray.

There is a small hit to performance in compiler/perf/T1969 which
consists of nothing BUT instance declarations with several default
methods to fill, which we now have to typecheck. The actual hit is
from 724 -> 756 or 4% in that extreme example.  Real world programs
have vastly fewer instance decls.

(cherry picked from commit d2958bd08a049b61941f078e51809c7e63bc3354)

3 years agoFix codegen bug in PIC version of genSwitch (#12433)
Simon Marlow [Thu, 15 Sep 2016 09:11:34 +0000 (10:11 +0100)] 
Fix codegen bug in PIC version of genSwitch (#12433)

Summary:
* getNonClobberedReg instead of getSomeReg, because the reg needs to
  survive across t_code
* Use a new reg for the table offset calculation instead of clobbering
  the reg returned by expr (this was the bug affecting #12433)

Test Plan: New unit test; validate

Reviewers: rwbarton, bgamari, austin, erikd

Subscribers: thomie

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

GHC Trac Issues: #12433

3 years agoAdd failing testcase for #12433
Ben Gamari [Mon, 5 Sep 2016 23:19:10 +0000 (19:19 -0400)] 
Add failing testcase for #12433

Test Plan: Validate

Reviewers: austin

Subscribers: thomie

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

GHC Trac Issues: #11433

(cherry picked from commit dcc49044e8ac5b905955f99b042449635eb47e64)

3 years agorts: Disable -hb with multiple capabilities
Ben Gamari [Mon, 12 Sep 2016 12:44:24 +0000 (08:44 -0400)] 
rts: Disable -hb with multiple capabilities

Biographical profiling is not thread-safe as documented in #12019. Throw
an error when it is used in this way.

Test Plan: Validate

Reviewers: simonmar, austin, erikd

Reviewed By: erikd

Subscribers: thomie

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

GHC Trac Issues: #12019

(cherry picked from commit 6555c6bb8447ed65d5da4bab462ee9da7dc3f97a)

3 years agoMake start address of `osReserveHeapMemory` tunable via command line -xb
Francesco Mazzoli [Fri, 9 Sep 2016 17:15:49 +0000 (18:15 +0100)] 
Make start address of `osReserveHeapMemory` tunable via command line -xb

Summary:
We stumbled upon a case where an external library (OpenCL) does not work
if a specific address (0x200000000) is taken.

It so happens that `osReserveHeapMemory` starts trying to mmap at 0x200000000:

```
        void *hint = (void*)((W_)8 * (1 << 30) + attempt * BLOCK_SIZE);
        at = osTryReserveHeapMemory(*len, hint);
```

This makes it impossible to use Haskell programs compiled with GHC 8
with C functions that use OpenCL.

See this example ​https://github.com/chpatrick/oclwtf for a repro.

This patch allows the user to work around this kind of behavior outside
our control by letting the user override the starting address through an
RTS command line flag.

Reviewers: bgamari, Phyx, simonmar, erikd, austin

Reviewed By: Phyx, simonmar

Subscribers: rwbarton, thomie

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

(cherry picked from commit 1b5f9207a649a64a1bba20b0283253425f9208d7)

3 years agoFix TH ppr output for list comprehensions with only one Stmt
Ryan Scott [Sun, 11 Sep 2016 15:10:36 +0000 (11:10 -0400)] 
Fix TH ppr output for list comprehensions with only one Stmt

A folow-up to D2521 (which addressed #12583), where the `Outputable` `ppr`
output was tweaked to display a list comprehension with only one `Stmt` as
`[Foo]` instead of `[Foo|]` (which isn't valid Haskell). I forgot to update
the corresponding code in `Language.Haskell.TH.Ppr` which pretty-prints
`CompE`, however, so this commit takes care of that.

(cherry picked from commit 0e7ccf6d233c66b23a60de4e35e039f78ea3e162)

3 years agoFix derived Ix instances for one-constructor GADTs
Ryan Scott [Sun, 11 Sep 2016 14:27:36 +0000 (10:27 -0400)] 
Fix derived Ix instances for one-constructor GADTs

Standalone-derived `Ix` instances would panic on GADTs with exactly
one constructor, since the list of fields was being passed to a function that
uses `foldl1` in order to generate an implementation for `inRange`. This adds a
simple check that makes `inRange` be `True` whenever a product type has no
fields.

Fixes #12583.

Test Plan: make test TEST=12583

Reviewers: simonpj, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

GHC Trac Issues: #12583

(cherry picked from commit 7b7ea8f40e7400b8c183595a85bb2c65c9f9bb29)

3 years agoUpdate unix submodule to latest HEAD.
Edward Z. Yang [Thu, 8 Sep 2016 19:05:30 +0000 (12:05 -0700)] 
Update unix submodule to latest HEAD.

Fixes readdir validation error (fixes #12572).

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
(cherry picked from commit a8238a4eb628dcab93e19021b27c0cf2b38ef7d0)

3 years agoAdd platform warning to Foreign.C.Types
Tamar Christina [Sat, 10 Sep 2016 12:04:19 +0000 (13:04 +0100)] 
Add platform warning to Foreign.C.Types

Summary:
The generated documentation for thhe Foreign.C.Types
module is generated based on the platform which ran Haddock.

This is generating incorrect types for e.g. Windows.

Add a disclaimer to the top of the page to ask people to
keep this in mind.

Test Plan: make documentation and inspect Haddock

Reviewers: erikd, austin, hvr, bgamari

Reviewed By: erikd

Subscribers: RyanGlScott, #ghc_windows_task_force, thomie

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

GHC Trac Issues: #12586

(cherry picked from commit 710f21cc3a6f10dac1b31d089458e5fd16f6d3db)

3 years agousers_guide: Add release note for createIservProcessHook
Ben Gamari [Fri, 9 Sep 2016 13:14:15 +0000 (09:14 -0400)] 
users_guide: Add release note for createIservProcessHook

3 years agoAdd hook for creating ghci external interpreter
Alan Zimmerman [Thu, 8 Sep 2016 06:59:48 +0000 (08:59 +0200)] 
Add hook for creating ghci external interpreter

Summary:
The external interpreter is launched by calling
'System.Process.createProcess' with a 'CreateProcess' parameter.

The current value for this has the 'std_in', 'std_out' and 'std_err'
fields use the default of 'Inherit', meaning that the remote interpreter
shares the stdio with the original ghc/ghci process.

This patch introduces a new hook to the DynFlags, which has an
opportunity to override the 'CreateProcess' fields, launch the process,
and retrieve the stdio handles actually used.

So if a ghci external interpreter session is launched from the GHC API
the stdio can be redirected if required, which is useful for tooling/IDE
integration.

Test Plan: ./validate

Reviewers: austin, hvr, simonmar, bgamari

Reviewed By: simonmar, bgamari

Subscribers: thomie

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

(cherry picked from commit 65d9597d98ead78198bb747aed4e1163ee0d60d3)

3 years agoDocument meaning of order of --package-db flags, fixes #12485.
Edward Z. Yang [Mon, 5 Sep 2016 23:19:57 +0000 (19:19 -0400)] 
Document meaning of order of --package-db flags, fixes #12485.

Test Plan: none

Reviewers: austin, niteria, bgamari

Reviewed By: niteria

Subscribers: thomie

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

GHC Trac Issues: #12485

(cherry picked from commit 5eab6a0da5f22a47d04b97a0ec8988346675b33b)

3 years agoClarify pkg selection when multiple versions are available
Harendra Kumar [Tue, 30 Aug 2016 20:55:08 +0000 (16:55 -0400)] 
Clarify pkg selection when multiple versions are available

Reviewers: austin, bgamari, ezyang

Reviewed By: ezyang

Subscribers: thomie

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

(cherry picked from commit 6781f37d1915ab08cdb3846839a1d485a874049b)

3 years agoRemove references to -XRelaxedPolyRec
Ben Gamari [Mon, 5 Sep 2016 23:19:23 +0000 (19:19 -0400)] 
Remove references to -XRelaxedPolyRec

Test Plan: Read it

Reviewers: dfeuer, austin

Subscribers: thomie

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

GHC Trac Issues: #11691

(cherry picked from commit feaa31fbc41685d69045ac8d34be4e18f4f27ffd)

3 years agoFix GHCi perf-llvm build on x86_64
Erik de Castro Lopo [Sat, 13 Aug 2016 21:23:35 +0000 (07:23 +1000)] 
Fix GHCi perf-llvm build on x86_64

With BuildFlavour set to `perf-llvm`, GHCi would fail as soon as it
was run with:

  ghc-stage2: .../ghc-prim/dist-install/build/HSghc-prim-0.5.0.0.o:
  unknown symbol `__udivti3'
  ghc-stage2: unable to load package `ghc-prim-0.5.0.0'

Fix this by adding `__udivti3` and `__umodti3` to RtsSymbols.c.

Test Plan: Validate

Reviewers: simonmar, austin, bgamari, Phyx, trofi

Reviewed By: Phyx, trofi

Subscribers: thomie

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

GHC Trac Issues: #11981

(cherry picked from commit bd0c31063551744d00796219174739216c398da5)

3 years agoInstEnv: Ensure that instance visibility check is lazy
Ben Gamari [Wed, 20 Jul 2016 07:56:03 +0000 (09:56 +0200)] 
InstEnv: Ensure that instance visibility check is lazy

Previously instIsVisible had completely broken the laziness of
lookupInstEnv' since it would examine is_dfun_name to check the name of
the defining module (to know whether it is an interactive module). This
resulted in the visibility check drawing in an interface file
unnecessarily. This contributed to the unnecessary regression in
compiler allocations reported in #12367.

Test Plan: Validate, check nofib changes

Reviewers: simonpj, ezyang, austin

Reviewed By: ezyang

Subscribers: thomie, ezyang

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

GHC Trac Issues: #12367

(cherry picked from commit ed4809813fa51524ae73a4475afe33018a67f87d)

3 years agoBe more aggressive when checking constraints for custom type errors.
Iavor S. Diatchki [Tue, 3 May 2016 20:55:07 +0000 (22:55 +0200)] 
Be more aggressive when checking constraints for custom type errors.

This fixes #11990.

The current rule is simpler than before: if we encounter an unsolved
constraint that contains any mentions of properly applied `TypeError`,
then we report the type error.

If there are multiple `TypeErrors`, then we just report one of them.

Reviewers: simonpj, bgamari, austin

Reviewed By: simonpj

Subscribers: thomie

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

GHC Trac Issues: #11990

(cherry picked from commit b75d1940dd3362382c0bc94018a9045c2def82a9)

3 years agodistrib: Fix libdw bindist check
Ben Gamari [Sun, 4 Sep 2016 17:23:35 +0000 (13:23 -0400)] 
distrib: Fix libdw bindist check

As reported in #12555 this code was terribly broken. Sadly, Autoconf was
none-the-wiser. Thanks to @rwbarton for pointing this out.

Test Plan: Test with libdw version newer and older and 0.158

Reviewers: hvr, austin, rwbarton

Reviewed By: rwbarton

Subscribers: thomie, rwbarton, erikd

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

GHC Trac Issues: #12555

(cherry picked from commit 05b497ece50f508526d0906f675bdb4c8109d46a)

3 years agoLess scary arity mismatch error message when deriving
mniip [Sun, 4 Sep 2016 17:23:03 +0000 (13:23 -0400)] 
Less scary arity mismatch error message when deriving

Test Plan: Corrected a few tests to include the new message.

Reviewers: goldfire, austin, bgamari

Reviewed By: bgamari

Subscribers: goldfire, thomie

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

GHC Trac Issues: #12546

(cherry picked from commit 8d00175f4ba969ca5f4edf26b0e8593a79d4f508)

3 years agoAdded support for deprecated POSIX functions on Windows.
Tamar Christina [Thu, 1 Sep 2016 20:30:07 +0000 (21:30 +0100)] 
Added support for deprecated POSIX functions on Windows.

Summary:
With the introduction of 8.0.1 We've stopped supporting in GHCi
the use of POSIX functions under their deprecated names on Windows.

This to be compatible with object and libraries from the most
popular compilers on the platform (Microsoft and Intel compilers).

However this brings a confusing disparity between the compiled and
interpreted behavior since MingW-W64 does support the deprecated names.

Also It seems clear that package writers won't update their packages to
properly support Windows. As such I have added redirects in the RTS
for the deprecated functions as listed on

https://msdn.microsoft.com/en-us/library/ms235384.aspx.

This won't export the functions (as in, they won't be in the symbol table
of compiled code for the RTS.) but we inject them into the symbol table
of the dynamic linker at startup.

Test Plan:
./validate
and

make test TEST="ffi017 ffi021"

Reviewers: thomie, simonmar, RyanGlScott, bgamari, austin, hvr, erikd

Reviewed By: simonmar, bgamari

Subscribers: RyanGlScott, #ghc_windows_task_force

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

GHC Trac Issues: #12209, #12497, #12496

(cherry picked from commit e5ecb2010514405ac1b9b1285a8a65c00a5fd4e0)

3 years agoTestsuite: fix T12010 for real
Thomas Miedema [Sun, 22 May 2016 12:41:48 +0000 (14:41 +0200)] 
Testsuite: fix T12010 for real

* Don't depend on generated files from build tree
  (libraries/base/include/HsBaseConfig.h). Running
  'make test TEST=T12010' should work, even without building GHC first
  (it will use the system installed ghc).

Test Plan: 'make test TEST=T12010' on Linux and Windows.

Reviewed by: Phyx

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

GHC Trac Issues: #12010

(cherry picked from commit 2230c8822233d6d68f930170cd51d96169649056)

3 years agoFix failing T12010
Tamar Christina [Sat, 21 May 2016 14:23:59 +0000 (10:23 -0400)] 
Fix failing T12010

Summary:
T12010 seems to be failing because it can't find the correct paths.
This gives the test some more qualified paths.

Test Plan: make TEST=12010

Reviewers: hvr, bgamari, austin, thomie

Reviewed By: austin

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

GHC Trac Issues: #12010

(cherry picked from commit a1f3bb8ca454f05fa35cb6b5c64e92f640380802)

3 years agoUse the correct return type for Windows' send()/recv() (Fix #12010)
Tamar Christina [Thu, 19 May 2016 19:48:53 +0000 (21:48 +0200)] 
Use the correct return type for Windows' send()/recv() (Fix #12010)

Summary:
They return signed 32 bit ints on Windows, even on a 64 bit OS, rather than
Linux's 64 bit ssize_t. This means when recv() returned -1 to signal an error we
thought it was 4294967295. It was converted to an int, -1 and the buffer was
memcpy'd which caused a segfault. Other bad stuff happened with send()s.

See also note CSsize in System.Posix.Internals.

Add a test for #12010

Test Plan:
- GHC testsuite (T12010)
- http-conduit test (https://github.com/snoyberg/http-client/issues/191)

Reviewers: austin, hvr, bgamari, Phyx

Reviewed By: Phyx

Subscribers: thomie

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

GHC Trac Issues: #12010

(cherry picked from commit 1ee47c1bfa35c7be435adaec5c1fa9ec92cc776d)

3 years agotestsuite: Add test for #11959
Ben Gamari [Tue, 3 May 2016 20:58:47 +0000 (22:58 +0200)] 
testsuite: Add test for #11959

Test Plan: Validate, expected to fail

Reviewers: goldfire, austin

Reviewed By: austin

Subscribers: thomie

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

GHC Trac Issues: #11959

(cherry picked from commit 4f2afe1e674606230f2dc2f8ce040a2bd345a647)

3 years agoFix binary-trees regression from unnecessary floating in CorePrep.
Edward Z. Yang [Tue, 30 Aug 2016 20:55:58 +0000 (16:55 -0400)] 
Fix binary-trees regression from unnecessary floating in CorePrep.

In the previous patch, I handled lazy @(Int -> Int) f x
correctly, but failed to handle lazy @Int (f x) (we need
to collect arguments in f x).

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

Reviewers: simonpj, austin, bgamari, nomeata

Reviewed By: nomeata

Subscribers: simonmar, thomie

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

(cherry picked from commit 83b326cda759cfd4c538595cf38ee23eb81a4c76)

3 years agoFix #12472 by looking for noinline/lazy inside oversaturated applications.
Edward Z. Yang [Sat, 6 Aug 2016 20:47:05 +0000 (13:47 -0700)] 
Fix #12472 by looking for noinline/lazy inside oversaturated applications.

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

Reviewers: simonpj, austin, bgamari

Subscribers: thomie

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

GHC Trac Issues: #12472

(cherry picked from commit 0d3bf62092de83375025edca6f7242812338542d)

Note that this diverges slightly from the original commit in that the
noinline logic has been removed, since this feature is not present in
ghc-8.0.

3 years agoFix and complete runghc documentation
Harendra Kumar [Tue, 30 Aug 2016 20:54:30 +0000 (16:54 -0400)] 
Fix and complete runghc documentation

Reviewers: austin, thomie, bgamari

Reviewed By: bgamari

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

GHC Trac Issues: #12517

(cherry picked from commit d168c41a231cd92ca993e0bdd621cf554694df1c)

3 years agoRnExpr: Fix ApplicativeDo desugaring with RebindableSyntax
Ben Gamari [Wed, 31 Aug 2016 20:03:33 +0000 (16:03 -0400)] 
RnExpr: Fix ApplicativeDo desugaring with RebindableSyntax

We need to compare against the local return and pure, not returnMName
and pureAName.

Fixes #12490.

Test Plan: Validate, add testcase

Reviewers: austin, simonmar

Reviewed By: simonmar

Subscribers: thomie

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

GHC Trac Issues: #12490

(cherry picked from commit 043604c7232adb698d5008a46d3f29d532acd12d)

3 years agoLinker: Fix Windows codepath
Ben Gamari [Thu, 1 Sep 2016 14:04:41 +0000 (10:04 -0400)] 
Linker: Fix Windows codepath

Thanks to Phyx for the patch.

3 years agoGHC: Expose installSignalHandlers, withCleanupSession
Ben Gamari [Tue, 30 Aug 2016 21:05:43 +0000 (17:05 -0400)] 
GHC: Expose installSignalHandlers, withCleanupSession

Test Plan: Validate

Reviewers: austin, simonmar

Reviewed By: simonmar

Subscribers: thomie

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

GHC Trac Issues: #12398

(cherry picked from commit 0e7492508cefbcabb4cf1398cfb3669edb72db77)

3 years agoTag pointers in interpreted constructors
mniip [Tue, 30 Aug 2016 20:57:47 +0000 (16:57 -0400)] 
Tag pointers in interpreted constructors

Instead of stg_interp_constr_entry there are now 7 functions (one for
each value of the tag bits) that tag the constructor pointer before
returning. This is consistent with compiled constructors' entry code,
and expectations that compiled code places on compiled constructors. The
iserv protocol is extended with an extra field that explains what
pointer tag the constructor should use.

Test Plan: Added tests for #12523

Reviewers: erikd, bgamari, hvr, austin, simonmar

Reviewed By: simonmar

Subscribers: osa1, thomie, rwbarton

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

GHC Trac Issues: #12523

(cherry picked from commit a25bf2673d0f6db5f454619ddf91f974cace4e8b)

3 years agousers_guide: Move -fdefer-out-of-scope-variables note to 8.0.2 relnotes
Ben Gamari [Wed, 31 Aug 2016 21:14:42 +0000 (17:14 -0400)] 
users_guide: Move -fdefer-out-of-scope-variables note to 8.0.2 relnotes

It will be included in 8.0.2

(cherry picked from commit 3cbb60b59e2bb0e2f8985a672b96bac74ca47c5d)

3 years agousers_guide: A few miscellaneous notes in relnotes
Ben Gamari [Wed, 31 Aug 2016 21:15:37 +0000 (17:15 -0400)] 
users_guide: A few miscellaneous notes in relnotes

3 years agousers_guide: Document removal of -Wredundant-constraints from -Wall
Ben Gamari [Wed, 31 Aug 2016 20:42:53 +0000 (16:42 -0400)] 
users_guide: Document removal of -Wredundant-constraints from -Wall

(cherry picked from commit 9661f59be99dcb0767739d6734e66babdc2bfe16)

3 years agoRemove redundant-constraints from -Wall (#10635)
Adam C. Foltzer [Wed, 31 Aug 2016 20:02:53 +0000 (16:02 -0400)] 
Remove redundant-constraints from -Wall (#10635)

Removes -Wredundant-constraints from -Wall, as per the
discussion in #10635.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

GHC Trac Issues: #10635

(cherry picked from commit e9b0bf4ed52114852dbaf6af556514610a895f88)

3 years agoAdd -fdefer-out-of-scope-variables flag (#12170).
Eugene Akentyev [Wed, 31 Aug 2016 20:02:10 +0000 (16:02 -0400)] 
Add -fdefer-out-of-scope-variables flag (#12170).

Reviewers: simonpj, thomie, austin, bgamari

Reviewed By: simonpj, thomie, bgamari

Subscribers: simonpj, thomie

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

GHC Trac Issues: #12170

(cherry picked from commit 75321ffa25ad377fa200485a7d58ad32a87e7d65)

3 years agoDocs: fix links to ghc-flags
Thomas Miedema [Thu, 9 Jun 2016 11:26:35 +0000 (13:26 +0200)] 
Docs: fix links to ghc-flags

(cherry picked from commit e703a232174fd6e6cc42f2b27a2d9a2a17957aa7)

3 years agoPPC NCG: Implement minimal stack frame header.
Peter Trommler [Wed, 31 Aug 2016 19:18:06 +0000 (15:18 -0400)] 
PPC NCG: Implement minimal stack frame header.

According to the ABI specifications a minimal stack frame consists
of a header and a minimum size parameter save area. We reserve the
minimal size for each ABI.

On PowerPC 64-bil Linux and AIX the parameter save area can accomodate
up to eight parameters. So calls with eight parameters and fewer
can be done without allocating a new stack frame and deallocating
that stack frame after the call. On AIX one additional spill slot
is available on the stack.

Code size for all nofib benchmarks is 0.3 % smaller on powerpc64.

Test Plan: validate on AIX

Reviewers: hvr!, erikd, austin, simonmar, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

(cherry picked from commit 010b07aae082cb6b1f2a5db3deecc5997f6d9a6d)

3 years agouser_guide: Move addModFinalizer mention to 8.0.2 release notes
Ben Gamari [Wed, 31 Aug 2016 21:03:46 +0000 (17:03 -0400)] 
user_guide: Move addModFinalizer mention to 8.0.2 release notes

(cherry picked from commit 4e1e7f2b2b3e352bd772339480b67f7c02ba9061)

3 years agoHsExpr: Ensure Type is derived on ThModFinalizers
Ben Gamari [Wed, 31 Aug 2016 19:26:16 +0000 (15:26 -0400)] 
HsExpr: Ensure Type is derived on ThModFinalizers

This is necessary to bootstrap with GHC 7.8.

3 years agoFixes #12504: Double-escape paths used to build call to hsc_line
Richard Cook [Tue, 30 Aug 2016 21:00:36 +0000 (17:00 -0400)] 
Fixes #12504: Double-escape paths used to build call to hsc_line

In outHsLine, paths passed to construct invocations of hsc_line must be
escaped twice in order to generate a properly escaped string literal
that will end up in the eventual LINE pragma emitted by this code. This
is especially important on Windows paths, where backslashes would
otherwise be treated as C escape sequences and result in the incorrect
Windows paths.

Adds test case to verify that hsc2hs properly escapes file paths in LINE
pragmas

Updates the hsc2hs submodule.

See https://ghc.haskell.org/trac/ghc/ticket/12504

Reviewers: erikd, hvr, austin, bgamari, Phyx

Reviewed By: erikd, Phyx

Subscribers: thomie, Phyx, mpickering

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

GHC Trac Issues: #12504

(cherry picked from commit 2ee1db60ab29258fa9f8ab820f778bd0bb7f87a4)

3 years agoFix aggressive cleanup of T1407
Tamar Christina [Sun, 1 May 2016 15:25:48 +0000 (17:25 +0200)] 
Fix aggressive cleanup of T1407

Summary:
The aggressive cleanup routine of T1407 is removing files that don't belong to it.
Constrain the test to only removing files it should by putting all it's generated
binaries in it's own output folder.

Test Plan: make test -C testsuite/tests/ghci/linking/dyn

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie, #ghc_windows_task_force

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

GHC Trac Issues: #1407

(cherry picked from commit e6627d1f8964807f19f8773f09cfaacae7ca8ab8)

3 years agoFix Windows build after Ticky changes
Tamar Christina [Sat, 21 May 2016 09:31:58 +0000 (11:31 +0200)] 
Fix Windows build after Ticky changes

Summary:
Replace hardcoded ld with FMT_Int for
StgInt types.

Test Plan: ./validate

Reviewers: austin, bgamari, simonmar, erikd

Reviewed By: erikd

Subscribers: thomie, #ghc_windows_task_force

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

(cherry picked from commit ae7e9cb574801954c7769c210829b06193fa72ea)

3 years agoErrUtils: Expose accessors of ErrDoc and ErrMsg
Ben Gamari [Wed, 31 Aug 2016 17:50:30 +0000 (13:50 -0400)] 
ErrUtils: Expose accessors of ErrDoc and ErrMsg

Test Plan: Validate

Reviewers: austin

Subscribers: thomie

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

GHC Trac Issues: #12206

(cherry picked from commit 2d220263f6e5f49139f5571b7a5bc1649cb9ac8c)

3 years agoDisable T12031 on linux
Tamar Christina [Sun, 12 Jun 2016 12:41:18 +0000 (14:41 +0200)] 
Disable T12031 on linux

(cherry picked from commit 29e1464319f40fe30fd63d8648f0d0a05541abe0)

3 years agoFix failures of T12031
Ben Gamari [Wed, 31 Aug 2016 18:12:06 +0000 (14:12 -0400)] 
Fix failures of T12031

TEST_HC_OPTS_INTERACTIVE was not defined due to an inconsistent
cherry-pick. In master this was done in
bdc555885b8898684549eca70053c9ce0ec7fa39 but I opted to simply extract
the relevant definition from this commit in the interest of simplicity.

3 years agoClarify scope of `getQ`/`putQ` state.
Francesco Mazzoli [Tue, 30 Aug 2016 21:09:16 +0000 (17:09 -0400)] 
Clarify scope of `getQ`/`putQ` state.

The current haddocks do not specify the scope of the state manipulated
by `getQ`/`putQ`.

Reviewers: austin, goldfire, bgamari, ezyang

Reviewed By: ezyang

Subscribers: ezyang, thomie

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

(cherry picked from commit d1f22396eec4be0a2101de6b7f7b780792acc0a9)

3 years agoStgCmmPrim: Add missing MO_WriteBarrier
Ben Gamari [Tue, 30 Aug 2016 21:08:05 +0000 (17:08 -0400)] 
StgCmmPrim: Add missing MO_WriteBarrier

Test Plan: Good question

Reviewers: austin, trommler, simonmar, rrnewton

Reviewed By: simonmar

Subscribers: RyanGlScott, thomie

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

GHC Trac Issues: #12469

(cherry picked from commit d40d6df74a9fca382a84709ac9bc862897fbec18)

3 years agoiserv: Show usage message on argument parse failure
Ben Gamari [Tue, 30 Aug 2016 21:06:08 +0000 (17:06 -0400)] 
iserv: Show usage message on argument parse failure

Test Plan: validate

Reviewers: simonmar, erikd, austin

Reviewed By: simonmar, erikd

Subscribers: thomie, erikd

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

GHC Trac Issues: #12491

(cherry picked from commit 3005fa5313b6d5fd9d4f47192c84e96e94ee7f17)

3 years agousers_guide: More capabilities than processors considered harmful
Ben Gamari [Tue, 30 Aug 2016 21:05:25 +0000 (17:05 -0400)] 
users_guide: More capabilities than processors considered harmful

Test Plan: None.

Reviewers: austin, simonmar

Reviewed By: simonmar

Subscribers: thomie

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

(cherry picked from commit 28b71c55d057b780d92b351498ec611287dedbd4)

3 years agoFix handling of package-db entries in .ghc.environment files, etc.
Duncan Coutts [Tue, 30 Aug 2016 20:59:17 +0000 (16:59 -0400)] 
Fix handling of package-db entries in .ghc.environment files, etc.

Previously interpreting the content of the .ghc.env files was done
after the step that loaded the available package dbs. This meant that
setting the package db flags was ineffective. This patch moves
interpreting the env files before loading of the package dbs.

Also, the package-db entries refer to files. Allow spaces in these file
names. Also treat as comments lines beginning with "--".

These are pretty minor fixes in a feature that up 'til now has been
essentially unused (witness no bug report about it), so there's very
low risk here. If we can get this into 8.0.2 then cabal can start
generating the .ghc.environment files, otherwise it cannot as it needs
the working package-db entries, to be able to refer to local package
dbs in the build tree (or cabal nix store).

Test Plan:
Manually create example .ghc.env files
run ghci; :show packages
Done this. It works.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

(cherry picked from commit ef784c551ef9b64c3c0b32c73f54bbdb747a8188)

3 years agousers_guide: Add 8.0.2 release notes
Ben Gamari [Wed, 31 Aug 2016 20:42:53 +0000 (16:42 -0400)] 
users_guide: Add 8.0.2 release notes

3 years agoMissing stderr for T12531.
Edward Z. Yang [Tue, 30 Aug 2016 09:43:38 +0000 (02:43 -0700)] 
Missing stderr for T12531.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
(cherry picked from commit 21c2ebf2504125611eec0d24ab3ed60cd9e475be)

3 years agoFix T12177
Ben Gamari [Tue, 30 Aug 2016 18:48:49 +0000 (14:48 -0400)] 
Fix T12177

3 years agoHave addModFinalizer expose the local type environment.
Facundo Domínguez [Wed, 6 Jul 2016 09:48:27 +0000 (06:48 -0300)] 
Have addModFinalizer expose the local type environment.

Summary:
This annotates the splice point with 'HsSpliced ref e' where 'e' is the
result of the splice. 'ref' is a reference that the typechecker will fill with
the local type environment.

The finalizer then reads the ref and uses the local type environment, which
causes 'reify' to find local variables when run in the finalizer.

Test Plan: ./validate

Reviewers: simonpj, simonmar, bgamari, austin, goldfire

Reviewed By: goldfire

Subscribers: simonmar, thomie, mboes

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

GHC Trac Issues: #11832

(cherry picked from commit 567dbd9bcb602accf3184b83050f2982cbb7758b)

3 years agoTestsuite: for tests that use TH, omit *all* prof_ways
Thomas Miedema [Mon, 22 Feb 2016 17:55:30 +0000 (18:55 +0100)] 
Testsuite: for tests that use TH, omit *all* prof_ways

Instead of just profasm and profthreaded. And at least until
-fexternal-interpreter is the default.

Also:
  * WAY=profc doesn't exist anymore.
  * Omit all threaded_ways for conc039, not just a few.

(cherry picked from commit e02b8c8dadcc77c0c40d5346246f6a3b548258c2)

3 years agopass -z wxneeded or -Wl,-zwxneeded for linking on OpenBSD
Karel Gardas [Sat, 13 Aug 2016 16:49:53 +0000 (18:49 +0200)] 
pass -z wxneeded or -Wl,-zwxneeded for linking on OpenBSD

Summary:
This patch fixes issue with abort in GHCi on OpenBSD current
as of Aug 12 2016. The OpenBSD is more and more strict about usage
of writable and executable memory. Programs/applications which
requires such functionality need to be linked with -z wxneeded linker
flag and need to be run from the file-system mounted with wxallowed
mount option. If either of those options in not met, then problematic
program/application usually fail on some mmap/mprotect call which fail.

Reviewers: bgamari, austin, hvr

Subscribers: thomie, erikd

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

(cherry picked from commit f9aa996f0af59f32dc7b1528ff78be41413a9c27)

3 years agoAllow typed holes to be levity-polymorphic
Simon Peyton Jones [Fri, 26 Aug 2016 16:24:10 +0000 (17:24 +0100)] 
Allow typed holes to be levity-polymorphic

This one-line change fixes Trac #12531.  Hooray.

Simple, non-invasive; can merge to 8.0.2

(cherry picked from commit ae66f356fb0dbf79dab1074d71275904c448b329)

3 years agoRtClosureInspect: Fix off-by-one error in cvReconstructType
mniip [Tue, 23 Aug 2016 17:19:02 +0000 (13:19 -0400)] 
RtClosureInspect: Fix off-by-one error in cvReconstructType

Replaced error-prone index manipulation on a pointer array with
a simple fold on the array elements.

Test Plan: Added a test case that triggers the bug

Reviewers: hvr, austin, bgamari

Reviewed By: bgamari

Subscribers: simonpj, thomie

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

GHC Trac Issues: #12458

(cherry picked from commit 1766bb3cfd1460796c78bd5651f89d53603586f9)

3 years agoRelevant Bindings no longer reports shadowed bindings (fixes #12176)
Annie Cherkaev [Mon, 1 Aug 2016 06:30:42 +0000 (23:30 -0700)] 
Relevant Bindings no longer reports shadowed bindings (fixes #12176)

Summary: Modified the RelevantBindings method in TcErrors.hs to only search over
non-shadowed bindings.

Test Plan: Wrote 2 simple test cases, verified that it worked with multiple
shadowed bindings, and also non-shadowed bindings.

Reviewers: austin, bgamari, ezyang

Reviewed By: ezyang

Subscribers: ezyang, thomie

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

GHC Trac Issues: #12177

(cherry picked from commit 89ae1e858f6eed42cebd9af01b30e239d4543faf)

3 years agoFix a performance issue with -fprint-expanded-synonyms
Ömer Sinan Ağacan [Sun, 15 May 2016 11:04:39 +0000 (07:04 -0400)] 
Fix a performance issue with -fprint-expanded-synonyms

The type synonym expander was doing redundant work by looking at same
types again and again. This patch fixes the loop code when both of the
types can be expanded, to do `O(min(n, m))` comparisons and `O(n + m)`
expansions, where `n` is expansions of the first type and `m` is
expansions of the second type.

Reported by sjcjoosten in T10547.

Test Plan:
Added a regression test that was taking several minutes to type check
before this patch.

Reviewers: bgamari, simonpj, austin, ezyang

Reviewed By: bgamari, simonpj, austin, ezyang

Subscribers: simonpj, thomie

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

GHC Trac Issues: #10547

(cherry picked from commit e4834edf4418ace657361649365979e29ebd9daa)

3 years agorts/LdvProfile.c: Fix NULL dereference on shutdown
Erik de Castro Lopo [Thu, 28 Apr 2016 21:15:53 +0000 (07:15 +1000)] 
rts/LdvProfile.c: Fix NULL dereference on shutdown

Test Plan: validate

Reviewers: carter, austin, simonmar, bgamari

Reviewed By: simonmar, bgamari

Subscribers: thomie

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

GHC Trac Issues: #11978

(cherry picked from commit bcfee2181e7b7edfea3473ec408a3a2a1815ecff)

3 years agoMake okConIdOcc recognize unboxed tuples
Ryan Scott [Mon, 18 Jul 2016 17:51:53 +0000 (13:51 -0400)] 
Make okConIdOcc recognize unboxed tuples

Summary:
`okConIdOcc`, which validates that a type or constructor name is valid
for splicing using Template Haskell, has a special case for tuples, but
neglects to look for unboxed tuples, causing some sensible Template Haskell
code involving unboxed tuples to be rejected.

Fixes #12407.

Test Plan: make test TEST=T12407

Reviewers: austin, bgamari, hvr, goldfire

Reviewed By: goldfire

Subscribers: thomie

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

GHC Trac Issues: #12407

(cherry picked from commit 1fc41d3274b5bf62f027aa6c7df57998db494938)

3 years agoFix incorrect calculated relocations on Windows x86_64
Tamar Christina [Sat, 11 Jun 2016 08:18:19 +0000 (10:18 +0200)] 
Fix incorrect calculated relocations on Windows x86_64

Summary:
See #12031 for analysis, but essentially what happens is:

To sum up the issue, the reason this seems to go wrong is because
of how we initialize the `.bss` section for Windows in the runtime linker.

The first issue is where we calculate the zero space for the section:

```
zspace = stgCallocBytes(1, bss_sz, "ocGetNames_PEi386(anonymous bss)");
sectab_i->PointerToRawData = ((UChar*)zspace) - ((UChar*)(oc->image));
```

Where
```
UInt32 PointerToRawData;
```

This means we're stuffing a `64-bit` value into a `32-bit` one. Also `zspace`
can be larger than `oc->image`. In which case it'll overflow and
then get truncated in the cast.

The address of a value in the `.bss` section is then calculated as:

```
addr = ((UChar*)(oc->image))
     + (sectabent->PointerToRawData
     + symtab_i->Value);
```

If it does truncate then this calculation won't be correct (which is what is happening).

We then later use the value of `addr` as the `S` (Symbol) value for the relocations

```
S = (size_t) lookupSymbol_( (char*)symbol );
```

Now the majority of the relocations are `R_X86_64_PC32` etc.
e.g. They are guaranteed to fit in a `32-bit` value.

The `R_X86_64_64` introduced for these pseudo-relocations so they can use
the full `48-bit` addressing space isn't as lucky.
As for why it sometimes work has to do on whether the value is truncated or not.

`PointerToRawData` can't be changed because it's size is fixed by the PE specification.

Instead just like with the other platforms, we now use `section` on Windows as well.
This gives us a `start` parameter of type `void*` which solves the issue.

This refactors the code to use `section.start` and to fix the issues.

Test Plan: ./validate and new test added T12031

Reviewers: RyanGlScott, erikd, bgamari, austin, simonmar

Reviewed By: simonmar

Subscribers: thomie, #ghc_windows_task_force

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

GHC Trac Issues: #12031, #11317

(cherry picked from commit b40e1b4c6746bdc34e6a53548a3925d309201c4d)

3 years agoDo not init record accessors as exported
Ömer Sinan Ağacan [Fri, 27 May 2016 15:02:47 +0000 (11:02 -0400)] 
Do not init record accessors as exported

This was causing redundant code generation when accessors are not
actually exported, as they were being marked as "exported" at
initialization.

Test Plan: validate

Reviewers: simonpj, austin, bgamari

Reviewed By: simonpj

Subscribers: mpickering, thomie

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

(cherry picked from commit 3a00ff92a3ee66c096b85b180d247d1a471a6b6e)

3 years agoExpand given superclasses more eagerly
Simon Peyton Jones [Wed, 22 Jun 2016 13:17:58 +0000 (14:17 +0100)] 
Expand given superclasses more eagerly

This patch fixes Trac #12175, another delicate corner case of
Note [Instance and Given overlap] in TcInteract.

In #12175 we were not expanding given superclasses eagerly
enough. It was easy to fix, and is actually rather neater than
before.

See Note [Eagerly expand given superclasses] in TcCanonical.
The main change is to move the eager expansion of given superclasses
to canClassNC.

(cherry picked from commit ce97b7298d54bdfccd9dcf366a69c5617b4eb43f)

3 years agoKeep the bindings local during defaultCallStacks
Simon Peyton Jones [Wed, 17 Aug 2016 13:35:19 +0000 (14:35 +0100)] 
Keep the bindings local during defaultCallStacks

defaultCallStacks generates evidence bindings for call stacks,
but wasn't setting the binding site correctly.  As a result
they were simply discarded in the case of pattern synonyms,
giving rise to Trac #12489.

The fix is easy; and I added an ASSERT to catch the error earlier.

(cherry picked from commit f352e5cd7bb629fe0ca3b913bfbe7bee43d62f3a)

3 years agoNot-in-scope variables are always errors
Simon Peyton Jones [Wed, 17 Aug 2016 11:04:30 +0000 (12:04 +0100)] 
Not-in-scope variables are always errors

This fixes Trac #12406.  A not-in-scope error shoudl be an error
even if you have -fdefer-typed-holes.

(cherry picked from commit efc0372a157eadeee58bbada77c64d53590e04af)

3 years agoImprove missing-sig warning
Simon Peyton Jones [Fri, 12 Aug 2016 14:52:07 +0000 (15:52 +0100)] 
Improve missing-sig warning

Fixes Trac #12484

(cherry picked from commit ac0e11252af149f085e2262200b7a1638b4a1553)

3 years agocheck that the number of parallel build is greater than 0
Ruey-Lin Hsu [Thu, 4 Aug 2016 11:41:57 +0000 (13:41 +0200)] 
check that the number of parallel build is greater than 0

Fixes #12062.

Reviewers: bgamari, thomie, austin, simonmar

Reviewed By: bgamari, thomie, simonmar

Subscribers: simonmar, thomie

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

GHC Trac Issues: #12062

(cherry picked from commit f09d65474ed042360999cb88221d65b07bfb4b5f)

3 years agoAnother try to get thread migration right
Simon Marlow [Thu, 4 Aug 2016 14:59:43 +0000 (15:59 +0100)] 
Another try to get thread migration right

Summary:
This is surprisingly tricky.  There were linked list bugs in the
previous version (D2430) that showed up as a test failure in
setnumcapabilities001 (that's a great stress test!).

This new version uses a different strategy that doesn't suffer from
the problem that @ezyang pointed out in D2430.  We now pre-calculate
how many threads to keep for this capability, and then migrate any
surplus threads off the front of the queue, taking care to account for
threads that can't be migrated.

Test Plan:
1. setnumcapabilities001 stress test with sanity checking (+RTS -DS) turned on:

```
cd testsuite/tests/concurrent/should_run
make TEST=setnumcapabilities001 WAY=threaded1 EXTRA_HC_OPTS=-with-rtsopts=-DS CLEANUP=0
while true; do ./setnumcapabilities001.run/setnumcapabilities001 4 9 2000 || break; done
```

2. The test case from #12419

Reviewers: niteria, ezyang, rwbarton, austin, bgamari, erikd

Subscribers: thomie, ezyang

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

GHC Trac Issues: #12419

(cherry picked from commit 89fa4e968f47cfb42d0dc33fc3bfffdce31d850e)

3 years agoFix to thread migration
Simon Marlow [Wed, 27 Jul 2016 15:00:08 +0000 (16:00 +0100)] 
Fix to thread migration

Summary:
If we had 2 threads on the run queue, say [A,B], and B is bound to the
current Task, then we would fail to migrate any threads.  This fixes it
so that we would migrate A in that case.

This will help parallelism a bit in programs that have lots of bound
threads.

Test Plan:
Test program in #12419, which is actually not a great program but it
does behave a bit better after this change.

Reviewers: ezyang, niteria, bgamari, austin, erikd

Subscribers: thomie

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

GHC Trac Issues: #12419

(cherry picked from commit 988ad8ba8e709eff3cea59728e481bb269fa6185)

3 years agoTrack the lengths of the thread queues
Simon Marlow [Tue, 2 Aug 2016 08:55:31 +0000 (09:55 +0100)] 
Track the lengths of the thread queues

Summary:
Knowing the length of the run queue in O(1) time is useful: for example
we don't have to traverse the run queue to know how many threads we have
to migrate in schedulePushWork().

Test Plan: validate

Reviewers: ezyang, erikd, bgamari, austin

Subscribers: thomie

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

(cherry picked from commit 55f5aed756cd5d464942dddcb33e0bd19b05f2a4)

3 years agoMove stat_startGCSync
Bartosz Nitka [Wed, 27 Jul 2016 15:25:59 +0000 (08:25 -0700)] 
Move stat_startGCSync

@simonmar told me that it makes more sense this way.

Test Plan: it still builds

Reviewers: bgamari, austin, simonmar, erikd

Reviewed By: simonmar, erikd

Subscribers: thomie, simonmar

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

(cherry picked from commit e98edbd1b8947dcb4a47d20fc854c0a9a6954bea)

3 years agoFix double-free in T5644 (#12208)
Simon Marlow [Mon, 20 Jun 2016 12:33:13 +0000 (13:33 +0100)] 
Fix double-free in T5644 (#12208)

(cherry picked from commit e7e42c838e32ef1e05daf04b0b6afb62ffc4ec97)

3 years agoFix ASSERT failure and re-enable setnumcapabilities001
Simon Marlow [Wed, 11 May 2016 14:38:25 +0000 (15:38 +0100)] 
Fix ASSERT failure and re-enable setnumcapabilities001

The assertion failure was fairly benign, I think, but this fixes it.
I've been running the test repeatedly for the last 30 mins and it hasn't
triggered.

There are other problems exposed by this test (see #12038), but I've
worked around those in the test itself for now.

I also copied the relevant bits of the parallel library here so that we
don't need parallel for the test to run.

(cherry picked from commit cfc5df43a7789832a2789e517d8270650cc31b7f)

3 years agoFix a crash in requestSync()
Simon Marlow [Tue, 10 May 2016 10:22:57 +0000 (03:22 -0700)] 
Fix a crash in requestSync()

It was possible for a thread to read invalid memory after a conflict
when multiple threads were synchronising.

I haven't been successful in constructing a test case that triggers
this, but we have some internal code that ran into it.

(cherry picked from commit ea3d1efb863ca83b28af9056576d47f1abf98fa9)

3 years agoschedulePushWork: avoid unnecessary wakeups
Simon Marlow [Sun, 24 Apr 2016 20:31:55 +0000 (21:31 +0100)] 
schedulePushWork: avoid unnecessary wakeups

This function had some pathalogically bad behaviour: if we had 2 threads
on the current capability and 23 other idle capabilities, we would

* grab all 23 capabilities
* migrate one Haskell thread to one of them
* wake up a worker on *all* 23 other capabilities.

This lead to a lot of unnecessary wakeups when using large -N values.

Now, we

* Count how many capabilities we need to wake up
* Start from cap->no+1, so that we don't overload low-numbered capabilities
* Only wake up capabilities that we migrated a thread to (unless we have
  sparks to steal)

This results in a pretty dramatic improvement in our production system.

(cherry picked from commit 1fa92ca9b1ed4cf44e2745830c9e9ccc2bee12d5)

3 years agoAllow limiting the number of GC threads (+RTS -qn<n>)
Simon Marlow [Sat, 9 Apr 2016 19:45:50 +0000 (20:45 +0100)] 
Allow limiting the number of GC threads (+RTS -qn<n>)

This allows the GC to use fewer threads than the number of capabilities.
At each GC, we choose some of the capabilities to be "idle", which means
that the thread running on that capability (if any) will sleep for the
duration of the GC, and the other threads will do its work.  We choose
capabilities that are already idle (if any) to be the idle capabilities.

The idea is that this helps in the following situation:

* We want to use a large -N value so as to make use of hyperthreaded
  cores
* We use a large heap size, so GC is infrequent
* But we don't want to use all -N threads in the GC, because that
  thrashes the memory too much.

See docs for usage.

(cherry picked from commit 76ee260778991367b8dbf07ecf7afd31f826c824)

3 years agoRevert "Fix Template Haskell reification of unboxed tuple types"
Ben Gamari [Thu, 25 Aug 2016 15:09:31 +0000 (11:09 -0400)] 
Revert "Fix Template Haskell reification of unboxed tuple types"

This reverts commit 3470f82fbd7039f9957761c5a12988fd558d6cb8 which we
decided not to merge afterall. See #12403.

3 years agotestsuite: Remove spurious change from last commit
Ben Gamari [Thu, 25 Aug 2016 15:08:12 +0000 (11:08 -0400)] 
testsuite: Remove spurious change from last commit

3 years agotestsuite: Update performance numbers
Ben Gamari [Thu, 25 Aug 2016 15:02:58 +0000 (11:02 -0400)] 
testsuite: Update performance numbers

3 years agoFix productivity calculation (#12424)
Simon Marlow [Tue, 26 Jul 2016 14:55:37 +0000 (07:55 -0700)] 
Fix productivity calculation (#12424)

(cherry picked from commit 1783011726a355ac7647246699d43bc7d8b6d9f1)