summaryrefslogtreecommitdiff
path: root/compiler/GHC/Unit
Commit message (Collapse)AuthorAgeFilesLines
* Move Unit related fields from DynFlags to HscEnvSylvain Henry2020-12-145-404/+287
| | | | | | | | | | | | | 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
* Refactor -dynamic-too handlingSylvain Henry2020-11-061-7/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | 1) Don't modify DynFlags (too much) for -dynamic-too: now when we generate dynamic outputs for "-dynamic-too", we only set "dynamicNow" boolean field in DynFlags instead of modifying several other fields. These fields now have accessors that take dynamicNow into account. 2) Use DynamicTooState ADT to represent -dynamic-too state. It's much clearer than the undocumented "DynamicTooConditional" that was used before. As a result, we can finally remove the hscs_iface_dflags field in HscRecomp. There was a comment on this field saying: "FIXME (osa): I don't understand why this is necessary, but I spent almost two days trying to figure this out and I couldn't .. perhaps someone who understands this code better will remove this later." I don't fully understand the details, but it was needed because of the changes made to the DynFlags for -dynamic-too. There is still something very dubious in GHC.Iface.Recomp: we have to disable the "dynamicNow" flag at some point for some Backpack's "heinous hack" to continue to work. It may be because interfaces for indefinite units are always non-dynamic, or because we mix and match dynamic and non-dynamic interfaces (#9176), or something else, who knows?
* Linker: reorganize linker related codeSylvain Henry2020-11-034-122/+4
| | | | | | | 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
* Add the proper HLint rules and remove redundant keywords from compilerHécate2020-11-014-28/+14
|
* Split GHC.Driver.TypesSylvain Henry2020-10-2913-0/+2631
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I was working on making DynFlags stateless (#17957), especially by storing loaded plugins into HscEnv instead of DynFlags. It turned out to be complicated because HscEnv is in GHC.Driver.Types but LoadedPlugin isn't: it is in GHC.Driver.Plugins which depends on GHC.Driver.Types. I didn't feel like introducing yet another hs-boot file to break the loop. Additionally I remember that while we introduced the module hierarchy (#13009) we talked about splitting GHC.Driver.Types because it contained various unrelated types and functions, but we never executed. I didn't feel like making GHC.Driver.Types bigger with more unrelated Plugins related types, so finally I bit the bullet and split GHC.Driver.Types. As a consequence this patch moves a lot of things. I've tried to put them into appropriate modules but nothing is set in stone. Several other things moved to avoid loops. * Removed Binary instances from GHC.Utils.Binary for random compiler things * Moved Typeable Binary instances into GHC.Utils.Binary.Typeable: they import a lot of things that users of GHC.Utils.Binary don't want to depend on. * put everything related to Units/Modules under GHC.Unit: GHC.Unit.Finder, GHC.Unit.Module.{ModGuts,ModIface,Deps,etc.} * Created several modules under GHC.Types: GHC.Types.Fixity, SourceText, etc. * Split GHC.Utils.Error (into GHC.Types.Error) * Finally removed GHC.Driver.Types Note that this patch doesn't put loaded plugins into HscEnv. It's left for another patch. Bump haddock submodule
* Initial ShortText code and conversion of package db codeWander Hillen2020-10-132-26/+28
| | | | | | | | | | | | | | | | | | | | | | | | | Metric Decrease: Naperian T10421 T10421a T10547 T12150 T12234 T12425 T13035 T18140 T18304 T5837 T6048 T13253-spj T18282 T18223 T3064 T9961 Metric Increase T13701 HFSKJH
* Lint the compiler for extraneous LANGUAGE pragmasHécate2020-10-101-8/+5
|
* Expose RTS-only ways (#18651)Sylvain Henry2020-10-091-2/+2
| | | | | Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself.
* DynFlags: add UnfoldingOpts and SimpleOptsSylvain Henry2020-09-091-1/+2
| | | | | Milestone: after this patch, we only use 'unsafeGlobalDynFlags' for the state hack and for debug in Outputable.
* Remove "Ord FastString" instanceSylvain Henry2020-09-014-17/+14
| | | | | | | | | | | | | | | | | | | FastStrings can be compared in 2 ways: by Unique or lexically. We don't want to bless one particular way with an "Ord" instance because it leads to bugs (#18562) or to suboptimal code (e.g. using lexical comparison while a Unique comparison would suffice). UTF-8 encoding has the advantage that sorting strings by their encoded bytes also sorts them by their Unicode code points, without having to decode the actual code points. BUT GHC uses Modified UTF-8 which diverges from UTF-8 by encoding \0 as 0xC080 instead of 0x00 (to avoid null bytes in the middle of a String so that the string can still be null-terminated). This patch adds a new `utf8CompareShortByteString` function that performs sorting by bytes but that also takes Modified UTF-8 into account. It is much more performant than decoding the strings into [Char] to perform comparisons (which we did in the previous patch). Bump haddock submodule
* Don't store HomeUnit in UnitConfigSylvain Henry2020-08-311-17/+22
| | | | | Allow the creation of a UnitConfig (hence of a UnitState) without having a HomeUnit. It's required for #14335.
* Refactor UnitId pretty-printingSylvain Henry2020-08-266-66/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When we pretty-print a UnitId for the user, we try to map it back to its origin package name, version and component to print "package-version:component" instead of some hash. The UnitId type doesn't carry these information, so we have to look into a UnitState to find them. This is why the Outputable instance of UnitId used `sdocWithDynFlags` in order to access the `unitState` field of DynFlags. This is wrong for several reasons: 1. The DynFlags are accessed when the message is printed, not when it is generated. So we could imagine that the unitState may have changed in-between. Especially if we want to allow unit unloading. 2. We want GHC to support several independent sessions at once, hence several UnitState. The current approach supposes there is a unique UnitState as a UnitId doesn't indicate which UnitState to use. See the Note [Pretty-printing UnitId] in GHC.Unit for the new approach implemented by this patch. One step closer to remove `sdocDynFlags` field from `SDocContext` (#10143). Fix #18124. Also fix some Backpack code to use SDoc instead of String.
* NCG: Dwarf configurationSylvain Henry2020-08-211-3/+3
| | | | | | * remove references to DynFlags in GHC.CmmToAsm.Dwarf * add specific Dwarf options in NCGConfig instead of directly querying the debug level
* Expose UnitInfoMap as it is part of the public APIFendor2020-08-181-0/+1
|
* Add HomeUnit typeSylvain Henry2020-08-136-137/+351
| | | | | | | | | | | | | | | | | | | | | | | 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 easier. Bump haddock submodule
* DynFlags: disentangle OutputableSylvain Henry2020-08-121-2/+0
| | | | | | | | | - 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
* Use a type alias for WaysSylvain Henry2020-08-061-1/+1
|
* Move GHC.Platform into the compilerSylvain Henry2020-07-251-3/+3
| | | | | | | Previously it was in ghc-boot so that ghc-pkg could use it. However it wasn't necessary because ghc-pkg only uses a subset of it: reading target arch and OS from the settings file. This is now done via GHC.Platform.ArchOS (was called PlatformMini before).
* Rename GHC.Driver.Ways into GHC.Platform.WaysSylvain Henry2020-07-251-1/+1
|
* Minor refactoring of Unit displaySylvain Henry2020-07-225-46/+50
| | | | | | | | * for consistency, try to always use UnitPprInfo to display units to users * remove some uses of `unitPackageIdString` as it doesn't show the component name and it uses String
* Give Uniq[D]FM a phantom type for its key.Andreas Klebinger2020-07-122-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM.
* DynFlags: factor out pprUnitId from "Outputable UnitId" instanceSylvain Henry2020-07-071-7/+14
|
* Fix duplicated words and typos in comments and user guideJan Hrček2020-06-281-1/+1
|
* Clean up haddock hyperlinks of GHC.* (part2)Takenobu Tani2020-06-252-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Iface.* - GHC.Llvm.* - GHC.Rename.* - GHC.Tc.* - GHC.HsToCore.* - GHC.StgToCmm.* - GHC.CmmToAsm.* - GHC.Runtime.* - GHC.Unit.* - GHC.Utils.* - GHC.SysTools.*
* Update compilerSylvain Henry2020-06-172-34/+7
| | | | | | | | | | | | | | | | Thanks to ghc-bignum, the compiler can be simplified: * Types and constructors of Integer and Natural can be wired-in. It means that we don't have to query them from interfaces. It also means that numeric literals don't have to carry their type with them. * The same code is used whatever ghc-bignum backend is enabled. In particular, conversion of bignum literals into final Core expressions is now much more straightforward. Bignum closure inspection too. * GHC itself doesn't depend on any integer-* package anymore * The `integerLibrary` setting is gone.
* Doc: fix some commentsSylvain Henry2020-06-131-58/+52
|
* Don't return preload units when we set DyNFlagsSylvain Henry2020-06-131-2/+2
| | | | Preload units can be retrieved in UnitState when needed (i.e. in GHCi)
* Put database cache in UnitConfigSylvain Henry2020-06-131-43/+34
|
* Create helper upd_wired_in_home_instantiationsSylvain Henry2020-06-131-9/+17
|
* Move distrustAll into mkUnitStateSylvain Henry2020-06-131-13/+12
|
* DynFlags: add UnitConfig datatypeSylvain Henry2020-06-131-112/+172
| | | | | | Avoid directly querying flags from DynFlags to build the UnitState. Instead go via UnitConfig so that we could reuse this to make another UnitState for plugins.
* DynFlags: merge_databasesSylvain Henry2020-06-131-9/+11
|
* DynFlags: reportCycles, reportUnusableSylvain Henry2020-06-131-8/+8
|
* DynFlags: findWiredInUnitsSylvain Henry2020-06-131-6/+6
|
* Refactor and document closeUnitDepsSylvain Henry2020-06-131-30/+26
|
* Refactor and document add_packageSylvain Henry2020-06-131-25/+26
|
* DynFlags: make listVisibleModuleNames take a UnitStateSylvain Henry2020-06-131-3/+3
|
* DynFlags: remove useless add_package parameterSylvain Henry2020-06-131-9/+7
|
* Document getPreloadUnitsAndSylvain Henry2020-06-131-4/+5
|
* DynFlags: refactor unwireUnitSylvain Henry2020-06-131-3/+3
|
* Remove preload parameter of mkUnitStateSylvain Henry2020-06-131-12/+8
| | | | | | * Remove preload parameter (unused) * Don't explicitly return preloaded units: redundant because already returned as "preloadUnits" field of UnitState
* Avoid timing module map dump in initUnitsSylvain Henry2020-06-131-18/+24
|
* Move wiring of homeUnitInstantiations outside of mkUnitStateSylvain Henry2020-06-131-8/+16
|
* Move dump_mod_map into initUnitsSylvain Henry2020-06-131-8/+8
|
* Rename Package into Unit (2)Sylvain Henry2020-06-134-83/+83
| | | | | | | * rename PackageState into UnitState * rename findWiredInPackages into findWiredInUnits * rename lookupModuleInAll[Packages,Units] * etc.
* Remove ClosureUnitInfoMapSylvain Henry2020-06-135-180/+165
|
* Make ClosureUnitInfoMap uses UnitInfoMapSylvain Henry2020-06-132-18/+37
|
* Rename Package into UnitSylvain Henry2020-06-134-170/+168
| | | | | | | | | | | | | | | | | | | | | | | | | 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 patch. * 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.
* Rename listUnitInfoMap into listUnitInfoSylvain Henry2020-06-131-5/+5
| | | | There is no Map involved
* Remove PreloadUnitId type aliasSylvain Henry2020-06-131-17/+15
|