1. 22 Nov, 2018 1 commit
    • David Eichmann's avatar
      Fix unused-import warnings · 6353efc7
      David Eichmann authored
      This patch fixes a fairly long-standing bug (dating back to 2015) in
      RdrName.bestImport, namely
      
         commit 9376249b
         Author: Simon Peyton Jones <simonpj@microsoft.com>
         Date:   Wed Oct 28 17:16:55 2015 +0000
      
         Fix unused-import stuff in a better way
      
      In that patch got the sense of the comparison back to front, and
      thereby failed to implement the unused-import rules described in
        Note [Choosing the best import declaration] in RdrName
      
      This led to Trac #13064 and #15393
      
      Fixing this bug revealed a bunch of unused imports in libraries;
      the ones in the GHC repo are part of this commit.
      
      The two important changes are
      
      * Fix the bug in bestImport
      
      * Modified the rules by adding (a) in
           Note [Choosing the best import declaration] in RdrName
        Reason: the previosu rules made Trac #5211 go bad again.  And
        the new rule (a) makes sense to me.
      
      In unravalling this I also ended up doing a few other things
      
      * Refactor RnNames.ImportDeclUsage to use a [GlobalRdrElt] for the
        things that are used, rather than [AvailInfo]. This is simpler
        and more direct.
      
      * Rename greParentName to greParent_maybe, to follow GHC
        naming conventions
      
      * Delete dead code RdrName.greUsedRdrName
      
      Bumps a few submodules.
      
      Reviewers: hvr, goldfire, bgamari, simonmar, jrtc27
      
      Subscribers: rwbarton, carter
      
      Differential Revision: https://phabricator.haskell.org/D5312
      6353efc7
  2. 12 Nov, 2018 1 commit
    • Alp Mestanogullari's avatar
      compareByPreference: handle the integer-gmp vs -simple case · 86ee74dc
      Alp Mestanogullari authored
      Currently, it assumes the package names are identical and this
      breaks in the case where integer-gmp is in one package db and
      integer-simple in another. This became a problem with
      the commit: fc2ff6dd.
      
      Instead of following the precedence information, leading to
      the right choice, the current code would compare the
      integer-gmp and integer-simple versions and pick integer-gmp
      because it happened to have a greater version, despite having
      a lower precedence. See
      https://github.com/snowleopard/hadrian/issues/702 for
      a comprehensive report about the problem.
      
      This effectively un-breaks integer-simple builds with hadrian.
      
      Test Plan: hadrian/build.sh --integer-simple
      
      Reviewers: snowleopard, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: snowleopard, rwbarton, carter
      
      Differential Revision: https://phabricator.haskell.org/D5266
      86ee74dc
  3. 03 Oct, 2018 1 commit
    • Joachim Breitner's avatar
      Make GHC (the library) flexible in the choice of integer library · fc2ff6dd
      Joachim Breitner authored
      Summary:
      We have more and more users of GHC as a library, for example the
      Haskell-to-WebAssembly-compiler https://github.com/tweag/asterius.
      These need to make different decisions about various aspects of
      code generation than the host compiler, and ideally GHC-the-library
      allows them to set the `DynFlags` as needed.
      
      This patch adds a new `DynFlag` that configures which `integer`
      library to use. This flag is initialized by `cIntegerLibraryType`
      (as before), and is only used in `CorePrep` to decide whether to
      use `S#` or not.
      
      The other code paths that were varying based on `cIntegerLibraryType`
      are no now longer varying: The trick is to use `integer-wired-in`
      as the `-this-unit-id` when compiling either `integer-gmp` or
      `integer-simple`.
      
      Test Plan: Validate is happy.
      
      Reviewers: hvr, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: TerrorJack, adamse, simonpj, rwbarton, carter
      
      GHC Trac Issues: #13477
      
      Differential Revision: https://phabricator.haskell.org/D5079
      fc2ff6dd
  4. 05 Sep, 2018 1 commit
  5. 21 Aug, 2018 1 commit
    • Andreas Klebinger's avatar
      Replace most occurences of foldl with foldl'. · 09c1d5af
      Andreas Klebinger authored
      This patch adds foldl' to GhcPrelude and changes must occurences
      of foldl to foldl'. This leads to better performance especially
      for quick builds where GHC does not perform strictness analysis.
      
      It does change strictness behaviour when we use foldl' to turn
      a argument list into function applications. But this is only a
      drawback if code looks ONLY at the last argument but not at the first.
      And as the benchmarks show leads to fewer allocations in practice
      at O2.
      
      Compiler performance for Nofib:
      
      O2 Allocations:
              -1 s.d.                -----            -0.0%
              +1 s.d.                -----            -0.0%
              Average                -----            -0.0%
      
      O2 Compile Time:
              -1 s.d.                -----            -2.8%
              +1 s.d.                -----            +1.3%
              Average                -----            -0.8%
      
      O0 Allocations:
              -1 s.d.                -----            -0.2%
              +1 s.d.                -----            -0.1%
              Average                -----            -0.2%
      
      Test Plan: ci
      
      Reviewers: goldfire, bgamari, simonmar, tdammers, monoidal
      
      Reviewed By: bgamari, monoidal
      
      Subscribers: tdammers, rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4929
      09c1d5af
  6. 20 Jun, 2018 1 commit
    • Moritz Angermann's avatar
      Fix gcc.exe: error: CreateProcess: No such file or directory · 227ede4a
      Moritz Angermann authored
      When GHC links binaries on windows, we pass a -L and -l flag
      to gcc for each dependency in the transitive dependency
      closure.  As this will usually overflow the command argument
      limit on windows, we use response files to pass all arguments
      to gcc.  gcc however internally passes only the -l flags via
      a response file to the collect2 command, but puts the -L flags
      on the command line. As such if we pass enough -L flags to
      gcc--even via a response file--we will eventually overflow the
      command line argument length limit due to gcc passing them
      to collect2 without resorting to a response file.
      
      To prevent this from happening we move all lirbaries into a
      shared temporary folder, and only need to pass a single -L
      flag to gcc.  Ideally however this was fixed in gcc.
      
      Reviewers: bgamari, Phyx
      
      Reviewed By: bgamari
      
      Subscribers: erikd, rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4762
      227ede4a
  7. 17 Jun, 2018 1 commit
    • sgillespie's avatar
      Improve error message when importing an unusable package · df0f148f
      sgillespie authored
      If a module cannot be found because it is ignored or from an unusable
      package, report this to the user and the reason it is unusable.
      
      Currently, GHC displays the standard "Cannot find module error". For
      example:
      
      ```
      <no location info>: error:
          Could not find module ‘Control.Monad.Random’
          Perhaps you meant
            Control.Monad.Reader (from mtl-2.2.2)
            Control.Monad.Cont (from mtl-2.2.2)
            Control.Monad.Error (from mtl-2.2.2)
      ```
      
      GHC does, however, indicate unusable/ignored packages with the -v flag:
      
      ```
      package MonadRandom-0.5.1-1421RgpXdhC8e8UI7D3emA is unusable due to
      missing dependencies:
        fail-4.9.0.0-BAHmj60kS5K7NVhhKpm9J5
      ```
      
      With this change, I took that message and added it to the output of the
      "Cannot find module" message.
      
      Reviewers: bgamari, dfeuer
      
      Reviewed By: bgamari
      
      Subscribers: Phyx, dfeuer, rwbarton, thomie, carter
      
      GHC Trac Issues: #4806
      
      Differential Revision: https://phabricator.haskell.org/D4783
      df0f148f
  8. 02 Jun, 2018 1 commit
    • Ben Gamari's avatar
      vectorise: Put it out of its misery · faee23bb
      Ben Gamari authored
      Poor DPH and its vectoriser have long been languishing; sadly it seems there is
      little chance that the effort will be rekindled. Every few years we discuss
      what to do with this mass of code and at least once we have agreed that it
      should be archived on a branch and removed from `master`. Here we do just that,
      eliminating heaps of dead code in the process.
      
      Here we drop the ParallelArrays extension, the vectoriser, and the `vector` and
      `primitive` submodules.
      
      Test Plan: Validate
      
      Reviewers: simonpj, simonmar, hvr, goldfire, alanz
      
      Reviewed By: simonmar
      
      Subscribers: goldfire, rwbarton, thomie, mpickering, carter
      
      Differential Revision: https://phabricator.haskell.org/D4761
      faee23bb
  9. 25 May, 2018 1 commit
  10. 06 Feb, 2018 1 commit
  11. 01 Dec, 2017 1 commit
  12. 15 Nov, 2017 1 commit
  13. 03 Oct, 2017 1 commit
  14. 26 Sep, 2017 1 commit
  15. 19 Sep, 2017 1 commit
    • Herbert Valerio Riedel's avatar
      compiler: introduce custom "GhcPrelude" Prelude · f63bc730
      Herbert Valerio Riedel authored
      This switches the compiler/ component to get compiled with
      -XNoImplicitPrelude and a `import GhcPrelude` is inserted in all
      modules.
      
      This is motivated by the upcoming "Prelude" re-export of
      `Semigroup((<>))` which would cause lots of name clashes in every
      modulewhich imports also `Outputable`
      
      Reviewers: austin, goldfire, bgamari, alanz, simonmar
      
      Reviewed By: bgamari
      
      Subscribers: goldfire, rwbarton, thomie, mpickering, bgamari
      
      Differential Revision: https://phabricator.haskell.org/D3989
      f63bc730
  16. 13 Sep, 2017 1 commit
  17. 31 Aug, 2017 1 commit
  18. 29 Aug, 2017 1 commit
    • Tamar Christina's avatar
      Remove dll-split. · 5266ab90
      Tamar Christina authored
      This patch removes dll-split from the code base, the reason is dll-split
      no longer makes any sense. It was designed to split a dll in two, but we
      now already have many more symbols than would fit inside two dlls. So we
      need a third one. This means there's no point in having to maintain this
      list as it'll never work anyway and the solution isn't scalable.
      
      Test Plan: ./validate
      
      Reviewers: austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie, #ghc_windows_task_force
      
      GHC Trac Issues: #5987
      
      Differential Revision: https://phabricator.haskell.org/D3882
      5266ab90
  19. 01 Aug, 2017 1 commit
    • Ryan Scott's avatar
      Drop GHC 7.10 compatibility · c13720c8
      Ryan Scott authored
      GHC 8.2.1 is out, so now GHC's support window only extends back to GHC
      8.0. This means we can delete gobs of code that was only used for GHC
      7.10 support. Hooray!
      
      Test Plan: ./validate
      
      Reviewers: hvr, bgamari, austin, goldfire, simonmar
      
      Reviewed By: bgamari
      
      Subscribers: Phyx, rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3781
      c13720c8
  20. 27 Jul, 2017 1 commit
  21. 26 Apr, 2017 1 commit
  22. 02 Apr, 2017 1 commit
  23. 01 Apr, 2017 1 commit
    • Simon Marlow's avatar
      Optimise common cases of GHC.setProgramDynFlags · 3b5f786c
      Simon Marlow authored
      * If the package flags haven't changed, don't do initPackages (which
        might take multiple seconds in extreme cases)
      
      * Provide a way to change the log_action without invalidating the
        summary cache.
      
      Test Plan: validate
      
      Reviewers: niteria, bgamari, austin, erikd, ezyang
      
      Reviewed By: bgamari
      
      Subscribers: mpickering, rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3392
      3b5f786c
  24. 20 Mar, 2017 1 commit
    • Edward Z. Yang's avatar
      Correctly account for -package-db ordering when picking packages. · e0eaea91
      Edward Z. Yang authored
      Summary:
      When I originally implemented ABI-based shadowing as per
      ee4e1654, I switched our strategy
      from pasting together lists to creating a map of all units first,
      and then selecting packages from this.  However, what I did
      not realize when doing this was that we actually depended
      on the *ordering* of these lists later, when we selected
      a preferred package to use.
      
      The crux is if I have -package-db db1 -package-db db2 -package p-0.1,
      and p-0.1 is provided by both db1 and db2, which one does the
      -package flag select?  Previously, this was undetermined; now
      we always select the instance from the LATEST package database.
      (If p-0.1 shows up multiple times in the same database, once again
      the chosen package is undefined.)
      
      The reason why cabal08 intermittently failed was that, in practice,
      we were sorting on the UnitId, so when we bumped version numbers,
      that often wibbled the UnitIds so that they compared oppositely.
      I've extended the test so that we check that the relation is
      antisymmetric.
      
      Fixes #13313
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: validate
      
      Reviewers: bgamari, austin
      
      Subscribers: rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3369
      e0eaea91
  25. 03 Mar, 2017 1 commit
  26. 02 Mar, 2017 1 commit
  27. 21 Dec, 2016 1 commit
    • Edward Z. Yang's avatar
      Support for abi-depends for computing shadowing. · ee4e1654
      Edward Z. Yang authored
      Summary:
      This is a complete fix based off of
      ed7af26606b3a605a4511065ca1a43b1c0f3b51d for handling
      shadowing and out-of-order -package-db flags simultaneously.
      
      The general strategy is we first put all databases together,
      overriding packages as necessary.  Once this is done, we successfully
      prune out broken packages, including packages which depend on a package
      whose ABI differs from the ABI we need.
      
      Our check gracefully degrades in the absence of abi-depends, as
      we only check deps which are recorded in abi-depends.
      
      Contains time and Cabal submodule update.
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: validate
      
      Reviewers: niteria, austin, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2846
      
      GHC Trac Issues: #12485
      ee4e1654
  28. 16 Dec, 2016 1 commit
  29. 22 Oct, 2016 1 commit
    • Duncan Coutts's avatar
      Add and use a new dynamic-library-dirs field in the ghc-pkg info · f41a8a36
      Duncan Coutts authored
      Summary:
      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, austin, hvr, christiaanb, bgamari
      
      Reviewed By: christiaanb, bgamari
      
      Subscribers: ezyang, Phyx, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2611
      
      GHC Trac Issues: #12479
      f41a8a36
  30. 08 Oct, 2016 3 commits
  31. 30 Aug, 2016 1 commit
    • Duncan Coutts's avatar
      Fix handling of package-db entries in .ghc.environment files, etc. · ef784c55
      Duncan Coutts authored
      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
      ef784c55
  32. 16 Jul, 2016 1 commit
  33. 06 Jun, 2016 1 commit
    • niteria's avatar
      Make UnitIdMap a deterministic map · 1937ef1c
      niteria authored
      This impacts at least the order in which version macros are
      generated. It's pretty hard to track what kind of nondeterminism
      is benign and this should have no performance impact as the number
      of packages should be relatively small.
      
      Test Plan: ./validate
      
      Reviewers: simonmar, austin, bgamari, ezyang
      
      Reviewed By: ezyang
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2308
      
      GHC Trac Issues: #4012
      1937ef1c
  34. 11 Mar, 2016 1 commit
  35. 05 Mar, 2016 1 commit
  36. 01 Feb, 2016 1 commit
    • Edward Z. Yang's avatar
      Simplify ghc-boot database representation with new type class. · 0d601657
      Edward Z. Yang authored
      Previously, we had an 'OriginalModule' type in ghc-boot which
      was basically identical to 'Module', and we had to do a bit of
      gyrating to get it converted into the right form.  This commit
      introduces a new typeclass, 'DbModuleRep' which represents types
      which we know how to serialize to and from the (now renamed) 'DbModule'
      type.
      
      The upshot is that we can just store 'Module's DIRECTLY in
      the 'InstalledPackageInfo', no conversion needed.
      
      I took the opportunity to clean up ghc-pkg to make its use of
      the 'BinaryStringRep' classes more type safe.
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: validate
      
      Reviewers: austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1811
      0d601657
  37. 18 Jan, 2016 2 commits
    • Edward Z. Yang's avatar
      Switch from -this-package-key to -this-unit-id. · 240ddd7c
      Edward Z. Yang authored
      A small cosmetic change, but we have to do a bit of work to
      actually support it:
      
          - Cabal submodule update, so that Cabal passes us
            -this-unit-id when we ask for it.  This includes
            a Cabal renaming to be consistent with Unit ID, which
            makes ghc-pkg a bit more scrutable.
      
          - Build system is updated to use -this-unit-id rather than
            -this-package-key, to avoid deprecation warnings.  Needs
            a version test so I resurrected the old test we had
            (sorry rwbarton!)
      
          - I've *undeprecated* -package-name, so that we are in the same
            state as GHC 7.10, since the "correct" flag will have only
            entered circulation in GHC 8.0.
      
          - I removed -package-key.  Since we didn't deprecate -package-id
            I think this should not cause any problems for users; they
            can just change their code to use -package-id.
      
          - The package database is indexed by UNIT IDs, not component IDs.
            I updated the naming here.
      
          - I dropped the signatures field from ExposedModule; nothing
            was using it, and instantiatedWith from the package database
            field.
      
          - ghc-pkg was updated to use unit ID nomenclature, I removed
            the -package-key flags but I decided not to add any new flags
            for now.
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: validate
      
      Reviewers: austin, hvr, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: 23Skidoo, thomie, erikd
      
      Differential Revision: https://phabricator.haskell.org/D1780
      240ddd7c
    • Jan Stolarek's avatar
      Replace calls to `ptext . sLit` with `text` · b8abd852
      Jan Stolarek authored
      Summary:
      In the past the canonical way for constructing an SDoc string literal was the
      composition `ptext . sLit`.  But for some time now we have function `text` that
      does the same.  Plus it has some rules that optimize its runtime behaviour.
      This patch takes all uses of `ptext . sLit` in the compiler and replaces them
      with calls to `text`.  The main benefits of this patch are clener (shorter) code
      and less dependencies between module, because many modules now do not need to
      import `FastString`.  I don't expect any performance benefits - we mostly use
      SDocs to report errors and it seems there is little to be gained here.
      
      Test Plan: ./validate
      
      Reviewers: bgamari, austin, goldfire, hvr, alanz
      
      Subscribers: goldfire, thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D1784
      b8abd852