1. 16 Feb, 2021 1 commit
    • Sylvain Henry's avatar
      Don't build extra object with -no-hs-main · a01e78cc
      Sylvain Henry authored
      We don't need to compile/link an additional empty C file when it is not
      This patch may also fix #18938 by avoiding trying to lookup the RTS unit
      when there is none (yet) in the unit database.
  2. 14 Feb, 2021 1 commit
    • Sylvain Henry's avatar
      Refactor Logger · 8e2f85f6
      Sylvain Henry authored
      Before this patch, the only way to override GHC's default logging
      behavior was to set `log_action`, `dump_action` and `trace_action`
      fields in DynFlags. This patch introduces a new Logger abstraction and
      stores it in HscEnv instead.
      This is part of #17957 (avoid storing state in DynFlags). DynFlags are
      duplicated and updated per-module (because of OPTIONS_GHC pragma), so
      we shouldn't store global state in them.
      This patch also fixes a race in parallel "--make" mode which updated
      the `generatedDumps` IORef concurrently.
      Bump haddock submodule
      The increase in MultilayerModules is tracked in #19293.
      Metric Increase:
  3. 14 Dec, 2020 1 commit
    • Sylvain Henry's avatar
      Move Unit related fields from DynFlags to HscEnv · d0e8c10d
      Sylvain Henry authored
      The unit database cache, the home unit and the unit state were stored in
      DynFlags while they ought to be stored in the compiler session state
      (HscEnv). This patch fixes this.
      It introduces a new UnitEnv type that should be used in the future to
      handle separate unit environments (especially host vs target units).
      Related to #17957
      Bump haddock submodule
  4. 03 Nov, 2020 1 commit
    • Sylvain Henry's avatar
      Linker: reorganize linker related code · 14ce454f
      Sylvain Henry authored
      Move linker related code into GHC.Linker. Previously it was scattered
      into GHC.Unit.State, GHC.Driver.Pipeline, GHC.Runtime.Linker, etc.
      Add documentation in GHC.Linker
  5. 01 Nov, 2020 1 commit
  6. 13 Oct, 2020 1 commit
  7. 13 Aug, 2020 1 commit
    • Sylvain Henry's avatar
      Add HomeUnit type · ffc0d578
      Sylvain Henry authored
      Since Backpack the "home unit" is much more involved than what it was
      before (just an identifier obtained with `-this-unit-id`). Now it is
      used in conjunction with `-component-id` and `-instantiated-with` to
      configure module instantiations and to detect if we are type-checking an
      indefinite unit or compiling a definite one.
      This patch introduces a new HomeUnit datatype which is much easier to
      understand. Moreover to make GHC support several packages in the same
      instances, we will need to handle several HomeUnits so having a
      dedicated (documented) type is helpful.
      Finally in #14335 we will also need to handle the case where we have no
      HomeUnit at all because we are only loading existing interfaces for
      plugins which live in a different space compared to units used to
      produce target code. Several functions will have to be refactored to
      accept "Maybe HomeUnit" parameters instead of implicitly querying the
      HomeUnit fields in DynFlags. Having a dedicated type will make this
      Bump had...
  8. 12 Aug, 2020 1 commit
    • Sylvain Henry's avatar
      DynFlags: disentangle Outputable · accbc242
      Sylvain Henry authored
      - put panic related functions into GHC.Utils.Panic
      - put trace related functions using DynFlags in GHC.Driver.Ppr
      One step closer making Outputable fully independent of DynFlags.
      Bump haddock submodule
  9. 13 Jun, 2020 4 commits
    • Sylvain Henry's avatar
      Rename Package into Unit · ed533ec2
      Sylvain Henry authored
      The terminology changed over time and now package databases contain
      "units" (there can be several units compiled from a single Cabal
      package: one per-component, one for each option set, one per
      instantiation, etc.). We should try to be consistent internally and use
      "units": that's what this renaming does. Maybe one day we'll fix the UI
      too (e.g. replace -package-id with -unit-id, we already have
      -this-unit-id and ghc-pkg has -unit-id...) but it's not done in this
      * rename getPkgFrameworkOpts into getUnitFrameworkOpts
      * rename UnitInfoMap into ClosureUnitInfoMap
      * rename InstalledPackageIndex into UnitInfoMap
      * rename UnusablePackages into UnusableUnits
      * rename PackagePrecedenceIndex into UnitPrecedenceMap
      * rename PackageDatabase into UnitDatabase
      * rename pkgDatabase into unitDatabases
      * rename pkgState into unitState
      * rename initPackages into initUnits
      * rename renamePackage into renameUnitInfo
      * rename UnusablePackageReason into UnusableUnitReason
      * rename getPackage* into getUnit*
      * etc.
    • Sylvain Henry's avatar
      Enhance UnitId use · e7272d53
      Sylvain Henry authored
      * use UnitId instead of String to identify wired-in units
      * use UnitId instead of Unit in the backend (Unit are only use by
        Backpack to produce type-checked interfaces, not real code)
      * rename lookup functions for consistency
      * documentation
    • Sylvain Henry's avatar
      Add allowVirtualUnits field in PackageState · f6be6e43
      Sylvain Henry authored
      Instead of always querying DynFlags to know whether we are allowed to
      use virtual units (i.e. instantiated on-the-fly, cf Note [About units]
      in GHC.Unit), we store it once for all in
      This avoids using DynFlags too much (cf #17957) and is preliminary work
      for #14335.
    • Sylvain Henry's avatar
  10. 01 Jun, 2020 2 commits
  11. 01 May, 2020 2 commits
    • Sylvain Henry's avatar
      Remove PprStyle param of logging actions · b3df9e78
      Sylvain Henry authored
      Use `withPprStyle` instead to apply a specific style to a SDoc.
    • Sylvain Henry's avatar
      Refactor PprDebug handling · f8386c7b
      Sylvain Henry authored
      If `-dppr-debug` is set, then PprUser and PprDump styles are silently
      replaced with PprDebug style. This was done in `mkUserStyle` and
      `mkDumpStyle` smart constructors. As a consequence they needed a
      DynFlags parameter.
      Now we keep the original PprUser and PprDump styles until they are used
      to create an `SDocContext`. I.e. the substitution is only performed in
  12. 30 Apr, 2020 3 commits
    • Sylvain Henry's avatar
      Unit: split and rename modules · 8bfb0219
      Sylvain Henry authored
      Introduce GHC.Unit.* hierarchy for everything concerning units, packages
      and modules.
      Update Haddock submodule
    • Sylvain Henry's avatar
      Refactoring unit management code · 10d15f1e
      Sylvain Henry authored
      Over the years the unit management code has been modified a lot to keep
      up with changes in Cabal (e.g. support for several library components in
      the same package), to integrate BackPack, etc. I found it very hard to
      understand as the terminology wasn't consistent, was referring to past
      concepts, etc.
      The terminology is now explained as clearly as I could in the Note
      "About Units" and the code is refactored to reflect it.
      Many names were misleading: UnitId is not an Id but could be a virtual
      unit (an indefinite one instantiated on the fly), IndefUnitId
      constructor may contain a definite instantiated unit, etc.
         * Rename IndefUnitId into InstantiatedUnit
         * Rename IndefModule into InstantiatedModule
         * Rename UnitId type into Unit
         * Rename IndefiniteUnitId constructor into VirtUnit
         * Rename DefiniteUnitId constructor into RealUnit
         * Rename packageConfigId into mkUnit
         * Rename getPackageDetails into unsafeGetUnitInfo
         * Rename InstalledUnitId into UnitId
      Remove references to misleading ComponentId: a ComponentId is just an
      indefinite unit-id to be instantiated.
         * Rename ComponentId into IndefUnitId
         * Rename ComponentDetails into UnitPprInfo
         * Fix display of UnitPprInfo with empty version: this is now used for
           units dynamically generated by BackPack
      Generalize several types (Module, Unit, etc.) so that they can be used
      with different unit identifier types: UnitKey, UnitId, Unit, etc.
         * GenModule: Module, InstantiatedModule and InstalledModule are now
           instances of this type
         * Generalize DefUnitId, IndefUnitId, Unit, InstantiatedUnit,
      Replace BackPack fake "hole" UnitId by a proper HoleUnit constructor.
      Add basic support for UnitKey. They should be used more in the future to
      avoid mixing them up with UnitId as we do now.
      Add many comments.
      Update Haddock submodule
    • Sylvain Henry's avatar
      Refactor UnitInfo · 10a2ba90
      Sylvain Henry authored
      * Rename InstalledPackageInfo into GenericUnitInfo
      The name InstalledPackageInfo is only kept for alleged backward
      compatibility reason in Cabal. ghc-boot has its own stripped down copy
      of this datatype but it doesn't need to keep the name. Internally we
      already use type aliases (UnitInfo in GHC, PackageCacheFormat in
      * Rename UnitInfo fields: add "unit" prefix and fix misleading names
      * Add comments on every UnitInfo field
      * Rename SourcePackageId into PackageId
      "Package" already indicates that it's a "source package". Installed
      package components are called units.
      Update Haddock submodule
  13. 26 Apr, 2020 1 commit
  14. 18 Apr, 2020 1 commit
    • Sylvain Henry's avatar
      Modules (#13009) · 15312bbb
      Sylvain Henry authored
      * SysTools
      * Parser
      * GHC.Builtin
      * GHC.Iface.Recomp
      * Settings
      Update Haddock submodule
      Metric Decrease:
  15. 29 Mar, 2020 1 commit
  16. 15 Mar, 2020 1 commit
    • Sylvain Henry's avatar
      Refactor CmmToAsm (disentangle DynFlags) · 2e82465f
      Sylvain Henry authored
      This patch disentangles a bit more DynFlags from the native code
      generator (CmmToAsm).
      In more details:
      - add a new NCGConfig datatype in GHC.CmmToAsm.Config which contains the
        configuration of a native code generation session
      - explicitly pass NCGConfig/Platform arguments when necessary
      - as a consequence `sdocWithPlatform` is gone and there are only a few
        `sdocWithDynFlags` left
      - remove the use of `unsafeGlobalDynFlags` from GHC.CmmToAsm.CFG
      - remove `sdocDebugLevel` (now we pass the debug level via NCGConfig)
      There are still some places where DynFlags is used, especially because
      of pretty-printing (CLabel), because of Cmm helpers (such as
      `cmmExprType`) and because of `Outputable` instance for the
      instructions. These are left for future refactoring as this patch is
      already big.
  17. 22 Feb, 2020 1 commit
  18. 05 Oct, 2019 1 commit
    • John Ericson's avatar
      Clean up `#include`s in the compiler · ee8118ca
      John Ericson authored
       - Remove unneeded ones
       - Use <..> for inter-package.
         Besides general clean up, helps distinguish between the RTS we link
         against vs the RTS we compile for.
  19. 20 Jun, 2019 1 commit
    • John Ericson's avatar
      Move 'Platform' to ghc-boot · bff2f24b
      John Ericson authored
      ghc-pkg needs to be aware of platforms so it can figure out which
      subdire within the user package db to use. This is admittedly
      roundabout, but maybe Cabal could use the same notion of a platform as
      GHC to good affect too.
  20. 08 Apr, 2019 1 commit
  21. 28 Sep, 2018 1 commit
    • Simon Marlow's avatar
      Add -fkeep-cafs · df67f95b
      Simon Marlow authored
      I noticed while playing around with
      https://github.com/fbsamples/ghc-hotswap/ that the main binary needs to
      have a custom main function to set `config.keep_cafs = true` when
      initialising the runtime. This is pretty annoying, it means an extra
      C file with some cryptic incantations in it, and a `-no-hs-main` flag.
      So I've replaced this with a link-time flag to GHC, `-fkeep-cafs` that
      does the same thing.
      Test Plan:
      New unit test that tests for the RTS's GC'd CAFs assertion, and also
      the -keep-cafs flag.
      Reviewers: bgamari, osa1, erikd, noamz
      Reviewed By: osa1
      Subscribers: rwbarton, carter
      Differential Revision: https://phabricator.haskell.org/D5183
  22. 10 Oct, 2017 1 commit
    • Tamar Christina's avatar
      Split SysTools up some · e51e565d
      Tamar Christina authored
      SysTools and DriverTools have an annoying mutual dependency.
      They also each contain pieces of the linker. In order for
      changes to be shared between the library and the exe linking
      code this dependency needs to be broken in order to avoid
      using hs-boot files.
      Reviewers: austin, bgamari, erikd
      Reviewed By: bgamari
      Subscribers: rwbarton, thomie
      Differential Revision: https://phabricator.haskell.org/D4071