1. 07 Nov, 2016 9 commits
    • Tamar Christina's avatar
      Align GHCi's library search order more closely with LDs · 95b6affc
      Tamar Christina authored
      Summary:
      Given a static library and an import library in the same folder. e.g.
      
      ```
      libfoo.a
      libfoo.dll.a
      ```
      
      running `ghci -lfoo` we should prefer the import library `libfoo.dll.a`
      over `libfoo.a` because we prefer having to just load the DLL.
      And not having to do any linking.
      
      This also more closely emulated the behaviour of LD, which has a search order of
      
      ```
      libxxx.dll.a
      xxx.dll.a
      libxxx.a
      cygxxx.dll (*)
      libxxx.dll
      xxx.dll
      ```
      
      Test Plan: ./validate
      
      Reviewers: RyanGlScott, austin, hvr, bgamari, erikd, simonmar
      
      Reviewed By: RyanGlScott
      
      Subscribers: thomie, #ghc_windows_task_force
      
      Differential Revision: https://phabricator.haskell.org/D2651
      
      GHC Trac Issues: #12771
      
      (cherry picked from commit 795be0ea)
      95b6affc
    • Ryan Scott's avatar
      Describe symptoms of (and the cure for) #12768 in 8.0.2 release notes · 411bd2df
      Ryan Scott authored
      GHC 8.0.2 introduced a bugfix involving GeneralizedNewtypeDeriving in
      96d45145. This made typechecking of
      GND-produced code a bit stricter, and an unfortunate side effect of this was
      that there were a couple of corner-case programs that stopped compiling
      when transitioning from GHC 8.0.1 to 8.0.2.
      
      Since the number of affected programs seems quite small, and since the fix
      is so straightforward, we opt to simply note this discrepancy in the 8.0.2
      release notes.
      
      Resolves #12768.
      
      (cherry picked from commit ead83db8)
      411bd2df
    • Simon Peyton Jones's avatar
      Fundeps work even for unary type classes · 8719d871
      Simon Peyton Jones authored
      The functional-dependency improvement functions,
         improveFromAnother
         improveFromInstEnv
      had a side-condition that said the type class has to have at
      least two arguments.  But not so, as Trac #12763 shows:
      
         class C a | -> a where ...
      
      is perfectly legal, albeit a bit of a corner case.
      
      (cherry picked from commit 801c2637)
      8719d871
    • Ryan Scott's avatar
      Update 8.0.2 release notes for #12784 · 2591a4b9
      Ryan Scott authored
      Summary:
      The fix for #12220 exposed some ill-typed programs which passed the typechecker
      in GHC 8.0.1 but now fail to typecheck in GHC 8.0.2. It's a bit difficult to
      characterize what exactly triggers this bug, but we at least have a minimal
      example and a simple fix to illustrate the problem and solution, so let's
      add that the the 8.0.2 release notes to advertise this change.
      
      Resolves #12784.
      
      Reviewers: rwbarton, austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2682
      
      GHC Trac Issues: #12784
      
      (cherry picked from commit 2e8463b2)
      2591a4b9
    • Simon Peyton Jones's avatar
      Fix Trac #12797: approximateWC · 28c62bb5
      Simon Peyton Jones authored
      This patch makes approximateWC a bit more gung-ho when called
      from the defaulting code.  See Note [ApproximateWC], item (1).
      
      (cherry picked from commit 13508bad)
      28c62bb5
    • Ryan Scott's avatar
      Add test for #12732 · 4227f3ea
      Ryan Scott authored
      (cherry picked from commit 60343a41)
      4227f3ea
    • Simon Peyton Jones's avatar
      Fix the in-scope set for extendTvSubstWithClone · cc3a9504
      Simon Peyton Jones authored
      We'd forgotten the variables free in the kind.
      
      Ditto extendCvSubstWithClone
      
      (cherry picked from commit 15fc5281)
      cc3a9504
    • Matthew Pickering's avatar
      Refine ASSERT in buildPatSyn for the nullary case. · c33aad1e
      Matthew Pickering authored
      For a nullary pattern synonym we add an extra void argument to the
      matcher in order to preserve laziness. The check in buildPatSyn
      wasn't aware of this special case which was causing the assertion to
      fail.
      
      Reviewers: austin, simonpj, bgamari
      
      Reviewed By: simonpj, bgamari
      
      Subscribers: simonpj, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2624
      
      GHC Trac Issues: #12746
      
      (cherry picked from commit 23143f60)
      c33aad1e
    • Simon Marlow's avatar
      Omit unnecessary linker flags · 5c91d076
      Simon Marlow authored
      This omits -L and -l flags from the linker command line that shouldn't
      be necessary because GHC will already add them via the -package-id
      flags we pass.
      
      This also reverts part of 90538d86
      that rearranges the linker command line and causes some knock-on
      problems (see D2618).
      
      Test Plan: validate (need to validate on Windows too)
      
      Reviewers: Phyx, bgamari, niteria, austin, erikd
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2639
      
      GHC Trac Issues: #12738
      
      (cherry picked from commit a977c965)
      5c91d076
  2. 04 Nov, 2016 1 commit
    • Simon Marlow's avatar
      Fix failure in setnumcapabilities001 (#12728) · 2722cd55
      Simon Marlow authored
      The value of enabled_capabilities can change across a call to
      requestSync(), and we were erroneously using an old value, causing
      things to go wrong later.  It manifested as an assertion failure, I'm
      not sure whether there are worse consequences or not, but we should
      get this fix into 8.0.2 anyway.
      
      The failure didn't happen for me because it only shows up on machines
      with fewer than 4 processors, due to the new logic to enable -qn
      automatically.  I've bumped the test parameter 8 to make it more
      likely to exercise that code.
      
      Test Plan: Ran setnumcapabilities001 many times
      
      Reviewers: niteria, austin, erikd, rwbarton, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2617
      
      GHC Trac Issues: #12728
      
      (cherry picked from commit acc98510)
      2722cd55
  3. 01 Nov, 2016 1 commit
  4. 22 Oct, 2016 2 commits
    • Duncan Coutts's avatar
      Add and use a new dynamic-library-dirs field in the ghc-pkg info · 9448e627
      Duncan Coutts authored
      Build systems / package managers want to be able to control the file
      layout of installed libraries. In general they may want/need to be able
      to put the static libraries and dynamic libraries in different places.
      The ghc-pkg library regisrtation needs to be able to handle this.
      
      This is already possible in principle by listing both a static lib dir
      and a dynamic lib dir in the library-dirs field (indeed some previous
      versions of Cabal did this for shared libs on ELF platforms).
      
      The downside of listing both dirs is twofold. There is a lack of
      precision, if we're not careful with naming then we could end up
      picking up the wrong library. The more immediate problem however is
      that if we list both directories then both directories get included
      into the ELF and Mach-O shared object runtime search paths. On ELF this
      merely slows down loading of shared libs (affecting prog startup time).
      On the latest OSX versions this provokes a much more serious problem:
      that there is a rather low limit on the total size of the section
      containing the runtime search path (and lib names and related) and thus
      listing any unnecessary directories wastes the limited space.
      
      So the solution in this patch is fairly straightforward: split the
      static and dynamic library search paths in the ghc-pkg db and its use
      within ghc. This is a traditional solution: pkg-config has the same
      static / dynamic split (though it describes in in terms of private and
      public, but it translates into different behaviour for static and
      dynamic linking).
      
      Indeed it would make perfect sense to also have a static/dynamic split
      for the list of the libraries to use i.e. to have dynamic variants of
      the hs-libraries and extra-libraries fields. These are not immediately
      required so this patch does not add it, but it is a reasonable
      direction to follow.
      
      To handle compatibility, if the new dynamic-library-dirs field is not
      specified then its value is taken from the library-dirs field.
      
      Contains Cabal submodule update.
      
      Test Plan:
      Run ./validate
      
      Get christiaanb and carter to test it on OSX Sierra, in combination
      with Cabal/cabal-install changes to the default file layout for
      libraries.
      
      Reviewers: carter, bgamari, hvr, austin, christiaanb
      
      Subscribers: thomie, Phyx, ezyang
      
      Differential Revision: https://phabricator.haskell.org/D2625
      
      GHC Trac Issues: #12479
      9448e627
    • Simon Peyton Jones's avatar
      Test for newtype with unboxed argument · 4c8aab8f
      Simon Peyton Jones authored
      Newtypes cannot (currently) have an unboxed argument type.
      But Trac #12729 showed that this was only being checked for
      newtypes in H98 syntax; in GADT snytax they were let through.
      
      This patch moves the test to checkValidDataCon, where it properly
      belongs.
      
      (cherry picked from commit 1f09c16c)
      4c8aab8f
  5. 18 Oct, 2016 7 commits
    • Ryan Scott's avatar
      Add test for #12411 · d84a824c
      Ryan Scott authored
      The fix for #12584 also fixed the problem in #12411. Let's add a test to ensure
      that it stays fixed.
      
      (cherry picked from commit 184d7cb8)
      d84a824c
    • Ryan Scott's avatar
      Fix Show derivation in the presence of RebindableSyntax/OverloadedStrings · d7a1f682
      Ryan Scott authored
      Summary:
      To fix this issue, we simply disable `RebindableSyntax` whenever we rename
      the code generated from a deriving clause.
      
      Fixes #12688.
      
      Test Plan: make test TEST=T12688
      
      Reviewers: simonpj, austin, bgamari
      
      Reviewed By: simonpj, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2591
      
      GHC Trac Issues: #12688
      
      (cherry picked from commit b501709e)
      d7a1f682
    • Simon Peyton Jones's avatar
      Fix shadowing in mkWwBodies · 8ab454d9
      Simon Peyton Jones authored
      This bug, exposed by Trac #12562 was very obscure, and has been
      lurking for a long time.  What happened was that, in the
      worker/wrapper split
      
        a tyvar binder for a worker function
        accidentally shadowed an in-scope term variable
        that was mentioned in the body of the function
      
      It's jolly hard to provoke, so I have not even attempted to make
      a test case.  There's a Note [Freshen WW arguments] to explain.
      
      Interestingly, fixing the bug (which meant fresher type variables)
      revealed a second lurking bug: I'd failed to apply the substitution to
      the coercion in the second last case of mkWWArgs, which introduces a
      Cast.
      
      (cherry picked from commit 692c8df0)
      8ab454d9
    • Ryan Scott's avatar
      Add test for #12589 · 9467dfa8
      Ryan Scott authored
      Commit af21e388 fixed #12598. Let's add a test
      to make sure it stays fixed.
      
      (cherry picked from commit 042c5930)
      9467dfa8
    • Simon Peyton Jones's avatar
      Don't omit any evidence bindings · be94aebb
      Simon Peyton Jones authored
      This fixes Trac #12156, where we were omitting to make an
      evidence binding (because cec_suppress was on), but yet the
      program was compiled and run.
      
      The fix is easy, and involves deleting code :-).
      
      (cherry picked from commit af21e388)
      be94aebb
    • Simon Peyton Jones's avatar
      Fix wrapping order in matchExpectedConTy · bfaa770f
      Simon Peyton Jones authored
      The wrappers in matchExpectedConTy were being composed back
      to front, resulting in a Core Lint error.  Yikes!  This has
      been here a long time.
      
      Fixes Trac #12676.
      
      (cherry picked from commit f7278a90)
      bfaa770f
    • Simon Peyton Jones's avatar
      Correct order of existentials in pattern synonyms · 5c02b842
      Simon Peyton Jones authored
      Trac #12698 exposed a nasty bug in the typechecking for
      pattern synonmys: the existential type variables weren't
      being put in properly-scoped order.
      
      For some reason TcPatSyn.tcCollectEx was colleting them as a
      set, not as a list!  Easily fixed.
      
      (cherry picked from commit a693d1cb)
      5c02b842
  6. 14 Oct, 2016 4 commits
  7. 13 Oct, 2016 5 commits
    • Ryan Scott's avatar
      Add test for #12456 · 243994c3
      Ryan Scott authored
      Commit f352e5cd fixed #12456. Let's add a test
      to make sure it stays fixed.
      
      (cherry picked from commit fef1df4b)
      243994c3
    • Ben Gamari's avatar
      59741e4f
    • Simon Marlow's avatar
      Fix an assertion that could randomly fail · b7d6e20c
      Simon Marlow authored
      Summary:
      ASSERT_THREADED_CAPABILITY_INVARIANTS was testing properties of the
      returning_tasks queue, but that requires cap->lock to access safely.
      This assertion would randomly fail if stressed enough.
      
      Instead I've removed it from the catch-all
      ASSERT_PARTIAL_CAPABILITIY_INVARIANTS and made it a separate assertion
      only called under cap->lock.
      
      Test Plan:
      ```
      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
      ```
      
      Reviewers: niteria, bgamari, ezyang, austin, erikd
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2440
      
      GHC Trac Issues: #10860
      
      (cherry picked from commit ce13a9a9)
      b7d6e20c
    • Ben Gamari's avatar
      validate: Add --build-only · 5230fa04
      Ben Gamari authored
      This will allow us to split up Harbormaster output for the build and
      test stages of validation.
      
      Test Plan: `./validate --build-only && ./validate --testsuite-only`
      
      Reviewers: thomie, hvr, austin
      
      Differential Revision: https://phabricator.haskell.org/D2553
      
      (cherry picked from commit 4d2b15d5)
      5230fa04
    • Simon Peyton Jones's avatar
      Fix impredicativity (again) · c93ad554
      Simon Peyton Jones authored
      This patch fixes Trac #12616.
      
      Dignosis.  In TcUnify.tc_sub_type_ds we were going to some trouble to
      support co- and contra-variance even for impredicative types.  With
      -XImpredicativeTYpes, this allowed a unification variable to be
      unified with a polytype (probably wrongly) and that caused later
      trouble in the constraint solver, where -XImpredicativeTypes was /not/
      on.  In effect, -XImpredicativeTypes can't be switched on locally.
      
      Why did we want ImpredicativeTypes locally?  Because the program
      generated by GND for a higher-rank method involved impredicative
      instantation of 'coerce':
            op = coerce op   -- where op has a higher rank type
      See Note [Newtype-deriving instances] in TcGenDeriv.
      
      Cure.
      
      1.  It is ghastly to rely on ImpredicativeTypes (a 100% flaky
          feature) to instantiate coerce polymorphically.  Happily we
          now have Visible Type Application, so I've used that instead
          which should be solid and reliable.
      
      2.  I deleted the code in tc_sub_type_ds that allows the constraint
          solver to "look through" a unification variable to find a
          polytype.  That used to be essential in the days of ReturnTv,
          but it's utterly unreliable and should be consigned to the dustbin
          of history.  (We have ExpType now for the essential uses.)
      
      Tests involving ImpredicativeTypes are affected, but I'm not worried
      about them... it's advertised as a feature you can't rely on, and
      I want to reform it outright.
      
      (cherry picked from commit b612da66)
      c93ad554
  8. 12 Oct, 2016 3 commits
    • Simon Peyton Jones's avatar
      Some tiding up in TcGenDeriv · cec50665
      Simon Peyton Jones authored
      ..around newtype deriving instances.
      
      See esp the new Note [Newtype-deriving instances]
      
      No change in behaviour
      
      (cherry picked from commit 96d45145)
      cec50665
    • Simon Peyton Jones's avatar
      Add derived shadows only for Wanted constraints · fefc5301
      Simon Peyton Jones authored
      This patch implements choice (3) of comment:14 on Trac #12660.
      It cures an infinite loop (caused by the creation of an infinite
      type) in in compiling the 'singletons' package.
      
      See Note [Add derived shadows only for Wanteds] in TcSMonad.
      
      (cherry picked from commit 8fa5f5b1)
      fefc5301
    • Ben Gamari's avatar
      RnExpr: Actually fail if patterns found in expression · 47ae01bf
      Ben Gamari authored
      This fixes #12584, where wildcard patterns were snuck into an
      expression, which then crashed the typechecker in TcExpr since EWildPats
      aren't supposed to appear in the AST after renaming.
      
      The problem was that `rnTopSpliceDecl` failed to check for errors from
      `rnSplice` (as done by other callers to `rnSplice`).
      
      Thanks to Shayan for reporting this!
      
      Reviewers: simonpj, austin
      
      Reviewed By: simonpj
      
      Subscribers: simonpj, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2539
      
      GHC Trac Issues: #12584
      
      (cherry picked from commit bce99086)
      47ae01bf
  9. 10 Oct, 2016 8 commits
    • Ben Gamari's avatar
      Fix test output · f168a616
      Ben Gamari authored
      f168a616
    • Facundo Domínguez's avatar
      Don't ignore addTopDecls in module finalizers. · a77bbb8b
      Facundo Domínguez authored
      Summary:
      Module finalizer could call addTopDecls, however, the declarations
      added in this fashion were ignored. This patch makes sure to rename,
      type check and incorporate this declarations.
      
      Because a declaration may include a splice which calls addModFinalizer,
      the list of finalizers is repeteadly checked after adding declarations
      until no more finalizers remain.
      
      Test Plan: ./validate
      
      Reviewers: bgamari, goldfire, simonpj, austin
      
      Reviewed By: bgamari, simonpj
      
      Subscribers: simonmar, mboes, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2505
      
      GHC Trac Issues: #12559
      
      (cherry picked from commit 71dd6e44)
      a77bbb8b
    • Edward Z. Yang's avatar
      Remove reexports from ghc-boot, help bootstrap with GHC 8. · bdfb9012
      Edward Z. Yang authored
      (cherry picked from commit 940ded85)
      bdfb9012
    • Moritz Angermann's avatar
      Do not segfault if no common root can be found · ec055513
      Moritz Angermann authored
      When trying to profile a plugin, ghc mysteriously segfaulted.  Upon
      closer examination the segfault happend due to a `->prevStack` lookup
      on a NULL pointer.
      
      A new CostCentre: Unknown is introduced that is set, if ccsapp and
      ccsfn are of equal depth (e.g. 0), and do not have a common CostCentre
      in their stacks.
      
      Reviewers: bgamari, simonmar, austin, erikd
      
      Reviewed By: simonmar
      
      Subscribers: Phyx, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2551
      
      (cherry picked from commit bcd34451)
      ec055513
    • niteria's avatar
      Fix memory leak from #12664 · b08ffec0
      niteria authored
      This fixes the leak with `setProgArgv`. The problem was
      that `setProgArgv` would not free the objects pointed
      to by `prog_argc`, `prog_argv` when the globals were
      changed resulting in a leak.
      
      The only strictly necessary change is in `rts/RtsFlags.c`, but
      the code in `System.Environment` was a bit confusing and not
      exception safe, so I refactored it.
      
      Test Plan: ./validate
      
      Reviewers: simonmar, ezyang, austin, hvr, bgamari, erikd
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2576
      
      GHC Trac Issues: #12664
      
      (cherry picked from commit e41b9c61)
      b08ffec0
    • Matthew Pickering's avatar
      Add missing test from D2545 · 7643c149
      Matthew Pickering authored
      This was somehow dropped from the original merge.
      
      Differential Revision: https://phabricator.haskell.org/D2545
      
      GHC Trac Issues: #12615
      
      (cherry picked from commit 1851349a)
      7643c149
    • Simon Peyton Jones's avatar
      More tests for Trac #12522 · 801cbb42
      Simon Peyton Jones authored
      These ones test the variations in coment:15 of the ticket
      
      (cherry picked from commit a6111b8c)
      801cbb42
    • Simon Peyton Jones's avatar
      Orient improvement constraints better · 12cfcbeb
      Simon Peyton Jones authored
      This patch fixes an infinite loop in the constraint solver,
      shown up by Trac #12522.
      
      The solution is /very/ simple: just reverse the orientation of the
      derived constraints arising from improvement using type-family
      injectivity.  I'm not very proud of the fix --- it seems fragile
      --- but it has the very great merit of simplicity, and it works
      fine.
      
      See Note [Improvement orientation] in TcInteract, and some
      discussion on the Trac ticket.
      
      (cherry picked from commit b255ae7b)
      12cfcbeb