summaryrefslogtreecommitdiff
path: root/compiler/main
Commit message (Collapse)AuthorAgeFilesLines
* Break up TcRnTypes, among other modules.wip/rae/split-up-modulesRichard Eisenberg2019-10-082-0/+4
| | | | | | | | | | | | | | | | | | | | | This introduces three new modules: - basicTypes/Predicate.hs describes predicates, moving this logic out of Type. Predicates don't really exist in Core, and so don't belong in Type. - typecheck/TcOrigin.hs describes the origin of constraints and types. It was easy to remove from other modules and can often be imported instead of other, scarier modules. - typecheck/Constraint.hs describes constraints as used in the solver. It is taken from TcRnTypes. No work other than module splitting is in this patch. This is the first step toward homogeneous equality, which will rely more strongly on predicates. And homogeneous equality is the next step toward a dependently typed core language.
* users-guide: Document -XHaskell98 and -XHaskell2010Ben Gamari2019-10-081-0/+3
|
* Refactor, document, and optimize LLVM configuration loadingBen Gamari2019-10-074-20/+43
| | | | | | | | | | | | As described in the new Note [LLVM Configuration] in SysTools, we now load llvm-targets and llvm-passes lazily to avoid the overhead of doing so when -fllvm isn't used (also known as "the common case"). Noticed in #17003. Metric Decrease: T12234 T12150
* Clean up `#include`s in the compilerJohn Ericson2019-10-053-5/+6
| | | | | | | | - 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.
* Always enable the external interpreterJohn Ericson2019-10-043-50/+15
| | | | | | You can always just not use or even build `iserv`. I don't think the maintenance cost of the CPP is worth...I can't even tell what the benefit is.
* Add tryFindTopDir to look for the top dir without blowing up if it isJohn Ericson2019-10-041-11/+17
| | | | not found.
* Pull out the settings file parsing code into it's own module.John Ericson2019-10-042-214/+261
| | | | | | | | | | | This has two benefits: 1. One less hunk of code dependent on DynFlags 2. Add a little bit of error granularity to distrinugish between missing data and bad data. This could someday be shared with ghc-pkg which aims to work even with a missing file. I also am about to to make --supported-extensions use this too.
* Factor out a smaller part of Platform for host fallbackJohn Ericson2019-10-041-1/+1
|
* Deprecate -fwarn-hi-shadowing, because it was never implemented and isDaroc Alden2019-10-041-1/+2
| | | | | | not used. This fixes #10913.
* DynFlags: Only warn when split-sections is ignoredBen Gamari2019-10-031-2/+2
| | | | | Previously we would throw an error which seems a bit harsh. As reported in #17283.
* Refactor iface file generation:Ömer Sinan Ağacan2019-09-304-204/+381
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit refactors interface file generation to allow information from the later passed (NCG, STG) to be stored in interface files. We achieve this by splitting interface file generation into two parts: * Partial interfaces, built based on the result of the core pipeline * A fully instantiated interface, which also contains the final fingerprints and can optionally contain information produced by the backend. This change is required by !1304 and !1530. -dynamic-too handling is refactored too: previously when generating code we'd branch on -dynamic-too *before* code generation, but now we do it after. (Original code written by @AndreasK in !1530) Performance ~~~~~~~~~~~ Before this patch interface files where created and immediately flushed to disk which made space leaks impossible. With this change we instead use NFData to force all iface related data structures to avoid space leaks. In the process of refactoring it was discovered that the code in the ToIface Module allocated a lot of thunks which were immediately forced when writing/forcing the interface file. So we made this module more strict to avoid creating many of those thunks. Bottom line is that allocations go down by about ~0.1% compared to master. Residency is not meaningfully different after this patch. Runtime was not benchmarked. Co-Authored-By: Andreas Klebinger <klebinger.andreas@gmx.at> Co-Authored-By: Ömer Sinan Ağacan <omer@well-typed.com>
* Just get RTS libs from its package confJohn Ericson2019-09-271-19/+0
| | | | | `rts.conf` already contains this exact information in its `extra-libraries` stanza.
* Allow users to disable Unicode with an env varRon Mordechai2019-09-271-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unicode renders funny on my terminal and I like to avoid it where possible. Most applications which print out non-ascii characters allow users to disable such prints with an environment variable (e.g. Homebrew). This diff disables Unicode usage when the environment variable `GHC_NO_UNICODE` is set. To test, set the env var and compile a bad program. Note that GHC does not print Unicode bullets but instead prints out asterisks: ``` $ GHC_NO_UNICODE= _build/stage1/bin/ghc ../Temp.hs [1 of 1] Compiling Temp ( ../Temp.hs, ../Temp.o ) ../Temp.hs:4:23: error: * Couldn't match type `Bool' with `a -> Bool' Expected type: Bool -> a -> Bool Actual type: Bool -> Bool * In the first argument of `foldl', namely `(&& (flip $ elem u))' In the expression: foldl (&& (flip $ elem u)) True v In an equation for `isPermut': isPermut u v = foldl (&& (flip $ elem u)) True v * Relevant bindings include v :: [a] (bound at ../Temp.hs:4:12) u :: [a] (bound at ../Temp.hs:4:10) isPermut :: [a] -> [a] -> Bool (bound at ../Temp.hs:4:1) | 4 | isPermut u v = foldl (&& (flip $ elem u)) True v | ^^^^^^^^^^^^^^^^^^ ``` (Broken code taken from Stack Overflow)
* Make -fbyte-code prevent unboxed tuples/sums from implying object code (#16876)Ryan Scott2019-09-262-6/+13
| | | | | | | | | | | | | | | | | | | | This resolves #16876 by making the explicit use of `-fbyte-code` prevent code that enables `UnboxedTuples` or `UnboxedSums` from automatically compiling to object code. This allows for a nice middle ground where most code that enables `UnboxedTuples`/-`Sums` will still benefit from automatically enabling `-fobject-code`, but allows power users who wish to avoid this behavior in certain corner cases (such as `lens`, whose use case is documented in #16876) to do so. Along the way, I did a little cleanup of the relevant code and documentation: * `enableCodeGenForUnboxedTuples` was only checking for the presence of `UnboxedTuples`, but `UnboxedSums` has the same complications. I fixed this and renamed the function to `enableCodeGenForUnboxedTuplesOrSums`. * I amended the users' guide with a discussion of these issues.
* Standalone kind signatures (#16794)wip/top-level-kind-signaturesVladislav Zavialov2019-09-251-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implements GHC Proposal #54: .../ghc-proposals/blob/master/proposals/0054-kind-signatures.rst With this patch, a type constructor can now be given an explicit standalone kind signature: {-# LANGUAGE StandaloneKindSignatures #-} type Functor :: (Type -> Type) -> Constraint class Functor f where fmap :: (a -> b) -> f a -> f b This is a replacement for CUSKs (complete user-specified kind signatures), which are now scheduled for deprecation. User-facing changes ------------------- * A new extension flag has been added, -XStandaloneKindSignatures, which implies -XNoCUSKs. * There is a new syntactic construct, a standalone kind signature: type <name> :: <kind> Declarations of data types, classes, data families, type families, and type synonyms may be accompanied by a standalone kind signature. * A standalone kind signature enables polymorphic recursion in types, just like a function type signature enables polymorphic recursion in terms. This obviates the need for CUSKs. * TemplateHaskell AST has been extended with 'KiSigD' to represent standalone kind signatures. * GHCi :info command now prints the kind signature of type constructors: ghci> :info Functor type Functor :: (Type -> Type) -> Constraint ... Limitations ----------- * 'forall'-bound type variables of a standalone kind signature do not scope over the declaration body, even if the -XScopedTypeVariables is enabled. See #16635 and #16734. * Wildcards are not allowed in standalone kind signatures, as partial signatures do not allow for polymorphic recursion. * Associated types may not be given an explicit standalone kind signature. Instead, they are assumed to have a CUSK if the parent class has a standalone kind signature and regardless of the -XCUSKs flag. * Standalone kind signatures do not support multiple names at the moment: type T1, T2 :: Type -> Type -- rejected type T1 = Maybe type T2 = Either String See #16754. * Creative use of equality constraints in standalone kind signatures may lead to GHC panics: type C :: forall (a :: Type) -> a ~ Int => Constraint class C a where f :: C a => a -> Int See #16758. Implementation notes -------------------- * The heart of this patch is the 'kcDeclHeader' function, which is used to kind-check a declaration header against its standalone kind signature. It does so in two rounds: 1. check user-written binders 2. instantiate invisible binders a la 'checkExpectedKind' * 'kcTyClGroup' now partitions declarations into declarations with a standalone kind signature or a CUSK (kinded_decls) and declarations without either (kindless_decls): * 'kinded_decls' are kind-checked with 'checkInitialKinds' * 'kindless_decls' are kind-checked with 'getInitialKinds' * DerivInfo has been extended with a new field: di_scoped_tvs :: ![(Name,TyVar)] These variables must be added to the context in case the deriving clause references tcTyConScopedTyVars. See #16731.
* PmCheck: Only ever check constantly many models against a single patternSebastian Graf2019-09-251-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | Introduces a new flag `-fmax-pmcheck-deltas` to achieve that. Deprecates the old `-fmax-pmcheck-iter` mechanism in favor of this new flag. From the user's guide: Pattern match checking can be exponential in some cases. This limit makes sure we scale polynomially in the number of patterns, by forgetting refined information gained from a partially successful match. For example, when matching `x` against `Just 4`, we split each incoming matching model into two sub-models: One where `x` is not `Nothing` and one where `x` is `Just y` but `y` is not `4`. When the number of incoming models exceeds the limit, we continue checking the next clause with the original, unrefined model. This also retires the incredibly hard to understand "maximum number of refinements" mechanism, because the current mechanism is more general and should catch the same exponential cases like PrelRules at the same time. ------------------------- Metric Decrease: T11822 -------------------------
* Add -Wderiving-defaults (#15839)Kari Pahula2019-09-251-0/+3
| | | | | | Enabling both DeriveAnyClass and GeneralizedNewtypeDeriving can cause a warning when no explicit deriving strategy is in use. This change adds an enable/suppress flag for it.
* Add -fkeep-going to make compiler continue despite errors (#15424)Kari Pahula2019-09-232-3/+38
| | | | | Add a new optional failure handling for upsweep which continues the compilation on other modules if any of them has errors.
* Module hierarchy: Hs (#13009)Sylvain Henry2019-09-209-14/+14
| | | | | | | Add GHC.Hs module hierarchy replacing hsSyn. Metric Increase: haddock.compiler
* ErrUtils: split withTiming into withTiming and withTimingSilentAlp Mestanogullari2019-09-192-28/+79
| | | | | | | | | | | | | | | | | | | 'withTiming' becomes a function that, when passed '-vN' (N >= 2) or '-ddump-timings', will print timing (and possibly allocations) related information. When additionally built with '-eventlog' and executed with '+RTS -l', 'withTiming' will also emit both 'traceMarker' and 'traceEvent' events to the eventlog. 'withTimingSilent' on the other hand will never print any timing information, under any circumstance, and will only emit 'traceEvent' events to the eventlog. As pointed out in !1672, 'traceMarker' is better suited for things that we might want to visualize in tools like eventlog2html, while 'traceEvent' is better suited for internal events that occur a lot more often and that we don't necessarily want to visualize. This addresses #17138 by using 'withTimingSilent' for all the codegen bits that are expressed as a bunch of small computations over streams of codegen ASTs.
* Do not throw away backpack instantiations for module lookup cacheJohn Ericson2019-09-121-1/+1
| | | | | | | | | | | | | | | Currently, there is only one home package so this probably doesn't matter. But if we support multiple home packages, they could differ only in arguments (same indef component being applied). It looks like it used to be this way before 4e8a0607140b23561248a41aeaf837224aa6315b, but that commit doesn't seem to comment on this change in the particular. (It's main purpose is creating the InstalledUnitId and recategorizing the UnitId expressions accordingly.) Trying this as a separate commit for testing purposes. I leave it to others to decide whether this is a good change on its own.
* linker: Move -optl flags to end of linker invocation.Niklas Hambüchen2019-09-111-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Until now, giving `-optl` linker flags to `ghc` on the command line placed them in the wrong place in the `ld` command line: They were given before all the Haskell libararies, when they should appear after. Background: Most linkers like `ld.bfd` and `ld.gold`, but not the newer LLVM `lld`, work in a way where the order of `-l` flags given matters; earlier `-lmylib1` flags are supposed to create "holes" for linker symbols that are to be filled with later `lmylib2` flags that "fill the holes" for these symbols. As discovered in https://github.com/haskell/cabal/pull/5451#issuecomment-518001240, the `-optl` flags appeared before e.g. the -lHStext-1.2.3.1 -lHSbinary-0.8.6.0 -lHScontainers-0.6.0.1 flags that GHC added at the very end. Haskell libraries typically depend on C libraries, so `-lHS*` flags will create holes for the C libraries to fill in, but that only works when those libraries' `-l` flags are given **after** the `-lHS*` flags; until now they were given before, which was wrong. This meant that Cabal's `--ld-options` flag and `ld-options` `.cabal` file field were pretty ineffective, unless you used the `--ld-option=--start-group` hack as (https://github.com/haskell/cabal/pull/5451#issuecomment-406761676) that convinces the classical linkers to not be dependent on the order of linker flags given. This commit fixes the problem by simply flipping the order, putting `-optl` flags at the end, after Haskell libraries. The code change is effectively only `args1 ++ args` -> `args ++ args1` but the commit also renames the variables for improved clarity. Simple way to test it: ghc --make Main.hs -fforce-recomp -v -optl-s on a `Main.hs` like: import qualified Data.Set as Set main = print $ Set.fromList "hello"
* Module hierarchy: StgToCmm (#13009)Sylvain Henry2019-09-101-4/+4
| | | | | | Add StgToCmm module hierarchy. Platform modules that are used in several other places (NCG, LLVM codegen, Cmm transformations) are put into GHC.Platform.
* Replace queryCygwinTerminal with Win32's isMinTTYHandleRyan Scott2019-09-091-61/+11
| | | | | | | | | | | | `SysTools.Terminal.queryCygwinTerminal` now exists in the `Win32` library under the name `isMinTTYHandle` since `Win32-2.5.0.0`. (GHC 8.4.4 ships with `Win32-2.6.1.0`, so this is well within GHC's support window.) We can therefore get replace `queryCygwinTerminal` with `isMinTTYHandle` and delete quite a bit of code from `SysTools.Terminal` in the process. Along the way I needed to replace some uses of `#if defined x` with `#if defined(x)` to please the CI linters.
* Add a new flag -dno-typeable-binds for debuggingÖmer Sinan Ağacan2019-09-081-2/+5
| | | | | See the user manual entry -- this helps when debugging as generated Core gets smaller without these bindings.
* Fix LLVM version check yet againÖmer Sinan Ağacan2019-08-292-18/+10
| | | | | | | | | | | | | | | There were two problems with LLVM version checking: - The parser would only parse x and x.y formatted versions. E.g. 1.2.3 would be rejected. - The version check was too strict and would reject x.y formatted versions. E.g. when we support version 7 it'd reject 7.0 ("LLVM version 7.0") and only accept 7 ("LLVM version 7"). We now parse versions with arbitrarily deep minor numbering (x.y.z.t...) and accept versions as long as the major version matches the supported version (e.g. 7.1, 7.1.2, 7.1.2.3 ...).
* Remove Unused flag -ddump-shape [skip ci]luca2019-08-281-4/+0
|
* Return results of Cmm streams in backendsÖmer Sinan Ağacan2019-08-282-20/+19
| | | | | | | | | | | | | | | | | | | This generalizes code generators (outputAsm, outputLlvm, outputC, and the call site codeOutput) so that they'll return the return values of the passed Cmm streams. This allows accumulating data during Cmm generation and returning it to the call site in HscMain. Previously the Cmm streams were assumed to return (), so the code generators returned () as well. This change is required by !1304 and !1530. Skipping CI as this was tested before and I only updated the commit message. [skip ci]
* Make non-streaming LLVM and C backends streamingÖmer Sinan Ağacan2019-08-231-8/+5
| | | | | | | | | This adds a Stream.consume function, uses it in LLVM and C code generators, and removes the use of Stream.collect function which was used to collect streaming Cmm generation results into a list. LLVM and C backends now properly use streamed Cmm generation, instead of collecting Cmm groups into a list before generating LLVM/C code.
* Remove special case in SRT generation with -split-sectionsÖmer Sinan Ağacan2019-08-221-26/+5
| | | | | | | | | Previously we were using an empty ModuleSRTInfo for each Cmm group with -split-section. As far as I can see this has no benefits, and simplifying this makes another patch simpler (!1304). We also remove some outdated comments: we no longer generate one module-level SRT.
* expose ModuleInfo.minf_rdr_env for tooling authorsSam Halliday2019-08-181-0/+4
|
* Remove unused imports of the form 'import foo ()' (Fixes #17065)James Foster2019-08-151-1/+0
| | | | | | | | | | | These kinds of imports are necessary in some cases such as importing instances of typeclasses or intentionally creating dependencies in the build system, but '-Wunused-imports' can't detect when they are no longer needed. This commit removes the unused ones currently in the code base (not including test files or submodules), with the hope that doing so may increase parallelism in the build system by removing unnecessary dependencies.
* Consolidate `TablesNextToCode` and `GhcUnreigsterised` in configure (#15548)Joachim Breitner2019-08-101-10/+4
| | | | | | | | | | | | | | | | | | | | `TablesNextToCode` is now a substituted by configure, where it has the correct defaults and error handling. Nowhere else needs to duplicate that, though we may want the compiler to to guard against bogus settings files. I renamed it from `GhcEnableTablesNextToCode` to `TablesNextToCode` to: - Help me guard against any unfixed usages - Remove any lingering connotation that this flag needs to be combined with `GhcUnreigsterised`. Original reviewers: Original subscribers: TerrorJack, rwbarton, carter Original Differential Revision: https://phabricator.haskell.org/D5082
* Fix bug preventing information about patterns from being serialized in .hie ↵Zubin Duggal2019-08-071-2/+3
| | | | files
* Add a -fprint-axiom-incomps option (#15546)mniip2019-08-071-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Supply branch incomps when building an IfaceClosedSynFamilyTyCon `pprTyThing` now has access to incomps. This also causes them to be written out to .hi files, but that doesn't pose an issue other than a more faithful bijection between `tyThingToIfaceDecl` and `tcIfaceDecl`. The machinery for displaying axiom incomps was already present but not in use. Since this is now a thing that pops up in ghci's :info the format was modified to look like a haskell comment. Documentation and a test for the new feature included. Test Plan: T15546 Reviewers: simonpj, bgamari, goldfire Reviewed By: simonpj Subscribers: rwbarton, carter GHC Trac Issues: #15546 Differential Revision: https://phabricator.haskell.org/D5097
* Introduce a type for "platform word size", use it instead of IntÖmer Sinan Ağacan2019-08-062-12/+10
| | | | | | | | We introduce a PlatformWordSize type and use it in platformWordSize field. This removes to panic/error calls called when platform word size is not 32 or 64. We now check for this when reading the platform config.
* Packages: Add timing for package database initializationBen Gamari2019-08-021-2/+7
|
* Add Note [withTiming] in compiler/main/ErrUtils.hsAlp Mestanogullari2019-08-021-0/+95
|
* compiler: emit finer grained codegen events to eventlogAlp Mestanogullari2019-08-021-22/+23
|
* Change behaviour of -ddump-cmm-verbose to dump each Cmm pass output to a ↵nineonine2019-07-262-3/+8
| | | | separate file and add -ddump-cmm-verbose-by-proc to keep old behaviour (#16930)
* Make sure to load interfaces when running :instancesXavier Denis2019-07-231-1/+3
|
* Fix #8487: Debugger confuses variablesRoland Senn2019-07-211-9/+54
| | | | | | | | | | To display the free variables for a single breakpoint, GHCi pulls out the information from the fields `modBreaks_breakInfo` and `modBreaks_vars` of the `ModBreaks` data structure. For a specific breakpoint this gives 2 lists of types 'Id` (`Var`) and `OccName`. They are used to create the Id's for the free variables and must be kept in sync: If we remove an element from the Names list, then we also must remove the corresponding element from the OccNames list.
* Add module doc for Plugins.Richard Eisenberg2019-07-191-0/+5
| | | | This was requested in #15650.
* Hide "Loading package environment" message with -v0 (fix #16879)Artem Pelenitsyn2019-07-192-169/+170
|
* Fix formatting of --info's "Debug on" fieldBen Gamari2019-07-181-1/+1
| | | | | | As noted in #16914, the value `True` was used instead of `YES` here, in contrast to the other boolean fields emitted by `--info`. This confused the testsuite driver and broke the `ghc_debugged` testsuite predicate.
* Revert "Add support for SIMD operations in the NCG"Ben Gamari2019-07-161-3/+0
| | | | | | | Unfortunately this will require more work; register allocation is quite broken. This reverts commit acd795583625401c5554f8e04ec7efca18814011.
* Expunge #ifdef and #ifndef from the codebaseJohn Ericson2019-07-142-3/+3
| | | | | | | | These are unexploded minds as far as the linter is concerned. I don't want to hit in my MRs by mistake! I did this with `sed`, and then rolled back some changes in the docs, config.guess, and the linter itself.
* Remove LLVM_TARGET platform macrosJohn Ericson2019-07-142-1/+4
| | | | | Instead following @angerman's suggestion put them in the config file. Maybe we could re-key llvm-targets someday, but this is good for now.
* compiler: trace SysTools commands to emit start/stop eventlog markersAlp Mestanogullari2019-07-131-18/+31
| | | | | | | | | | | | | | | | | | | This patch was motivated by some performance characterization work done for #16822, where we suspected that GHC was spending a lot of time waiting on the linker to be done. (That turned out to be true.) The tracing is taken care of by ErrUtils.withTiming, so this patch just defines and uses a little wrapper around that function in all the helpers for calling the various systools (C compiler, linker, unlit, ...). With this patch, assuming a GHC executable linked against an eventlog-capable RTS (RTS ways that contain the debug, profiling or eventlog way units), we can measure how much time is spent in each of the SysTools when building hello.hs by simply doing: ghc hello.hs -ddump-timings +RTS -l The event names are "systool:{cc, linker, as, unlit, ...}".
* Allow reusing temporary object files generated by GHCi by writing to -odir ↵nineonine2019-07-111-5/+7
| | | | in case -fwrite-interface was specified (#16670)