| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
| |
Also corrected a couple of line 0's to line 1
|
|
|
|
|
|
|
| |
- remove the main: stuff
- show the filenames
- don't clutter the output with imports that aren't involved in
the cycle
|
| |
|
|
|
|
|
|
|
|
| |
Flushing and uncaching a single module is not completely atomic since
both caches a cleared separately. However, flushing is only done when
changing the working directory which shouldn't be done concurrently to
other threads. Uncaching is only done in 'summariseModule' which
requires some more work to become thread-safe anyway.
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
| |
This is a correction to the patch:
* When linking a shared library with --make, always do the link step
which used the wrong flag in making the decision. It used -dynamic
whereas the correct flag is -shared.
|
|
|
|
|
|
|
|
| |
Without -shared, the default target is a binary and in that case
it makes sense for --make to not try and link a binary when there
is no Main module. But for a shared library the user already has
to specify -shared and there's no reason a shared lib should
contain any Main module or main function.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In GHCi if you say 'import Foo' meaning to load a package module Foo,
and Foo.hs is found on the search path, then GHCi replies "module Foo
is not loaded", because it knows Foo refers to the source file rather
than the package module, and you haven't loaded that module with
:load.
This is consistent with the usual module-finding semantics. However,
it isn't particularly useful. And it leads to silly problems like not
being able to start GHCi when you happen to be sitting in
libraries/base, because GHCi thinks the Prelude hasn't been loaded.
So now I've made a slight change to the way that 'import M' works: if
M is loaded, then it refers to the loaded module, otherwise it looks
for a package module M. This does what the reporter of #2682 wanted,
and since it turns an error condition into meaningful behaviour it
can't break anything.
The only undesirable consequence is that 'import M' might refer to a
different M than ':load M'. Hopefully that won't lead to confusion.
|
| |
|
|
|
|
|
|
| |
Not only if there has been an exception. It worked for GHC anyway,
as it was getting an ExitSuccess exception, but GHC API clients
shouldn't be required to do that.
|
| |
|
|
|
|
| |
want to use it.
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
... and use it to make ghc -M generate correct cross-package
dependencies when using package-qualified imports (needed for the new
build system). Since we're already parsing the ImportDecl from the
source file, there seems no good reason not to keep it in the
ModSummary, it might be useful for other things too.
|
|
|
|
|
|
|
| |
With this change it should be possible to perform something similar to
'load' by traversing the module graph in dependency order and calling
'{parse,typecheck,load}Module' on each. Of course, if you want smart
recompilation checking you should still use 'load'.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
part of it.
Part of the GHC API essentially represents a compilation framework.
The difference of a *framework* as opposed to a *library* is that the
overall structure of the functionality is pre-defined but certain
details can be customised via callbacks. (Also known as the Hollywood
Principle: "Don't call us, we'll call you.")
This patch introduces a per-session data structure that contains all
the callbacks instead of adding lots of small function arguments
whenever we want to give the user more control over certain parts of
the API. This should also help with future changes: Adding a new
callback doesn't break old code since code that doesn't know about the
new callback will use the (hopefully sane) default implementation.
Overall, however, we should try and keep the number of callbacks small
and well-defined (and provide useful defaults) and use simple library
routines for the rest.
|
|
|
|
|
|
|
| |
This patch changes 'loadModule' to define a fake linkable. The
previous implementation of providing no linkable at all violated a
pre-condition in the ByteCode linker. This doesn't fix #2739, but it
improves the error message a bit.
|
| |
|
|
|
|
|
|
|
|
|
| |
Previously, loading a set of modules in HscNothing mode and then
switching to HscInterpreted could lead to crashes since modules
compiled with HscNothing were thought to be valid bytecode objects.
This patch forces recompilation in these cases, hence switching between
HscNothing and HscInterpreted should be safe now.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch entails a major restructuring of HscMain and a small bugfix
to MkIface (which required the restructuring in HscMain).
In MkIface:
- mkIface* no longer outputs orphan warnings directly and also no
longer quits GHC when -Werror is set. Instead, errors are
reported using the common IO (Messages, Maybe result) scheme.
In HscMain:
- Get rid of the 'Comp' monad. This monad was mostly GhcMonad + two
reader arguments, a ModSummary for the currently compiled module
and a possible old interface. The latter actually lead to a small
space-leak since only its hash was needed (to check whether the
newly-generated interface file was the same as the original one).
Functions originally of type 'Comp' now only take the arguments
that they actually need. This leads to slighly longer argument
lists in some places, however, it is now much easier to see what
is actually going on.
- Get rid of 'myParseModule'. Rename 'parseFile' to 'hscParse'.
- Join 'deSugarModule' and 'hscDesugar' (keeping the latter).
- Rename 'typecheck{Rename}Module{'}' to 'hscTypecheck{Rename}'.
One variant keeps the renamed syntax, the other doesn't.
- Parameterise 'HscStatus', so that 'InteractiveStatus' is just a
different parameterisation of 'HscStatus'.
- 'hscCompile{OneShot,Batch,Nothing,Interactive}' are now
implemented using a (local) typeclass called 'HsCompiler'. The
idea is to make the common structure more obvious. Using this
typeclass we now have two functions 'genericHscCompile' (original
'hscCompiler') and 'genericHscRecompile' (original 'genComp')
describing the default pipeline. The methods of the typeclass
describe a sort of "hook" interface (in OO-terms this would be
called the "template method" pattern).
One problem with this approach is that we parameterise over the
/result/ type which, in fact, is not actually different for
"nothing" and "batch" mode. To avoid functional dependencies or
associated types, we use type tags to make them artificially
different and parameterise the type class over the result type.
A perhaps better approach might be to use records instead.
- Drop some redundant 'HscEnv' arguments. These were likely
different from what 'getSession' would return because during
compilation we temporarily set the module's DynFlags as well as a
few other fields. We now use the 'withTempSession' combinator to
temporarily change the 'HscEnv' and automatically restore the
original session after the enclosed action has returned (even in
case of exceptions).
- Rename 'hscCompile' to 'hscGenHardCode' (since that is what it
does).
Calls in 'GHC' and 'DriverPipeline' accordingly needed small
adaptions.
|
|
|
|
| |
It now uses the standard warning log and error reporting mechanism.
|
|
|
|
|
| |
Parse errors during dependency analysis or options parsing really
shouldn't kill GHC; this is particularly annoying for GHC API clients.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously, using target HscNothing resulted in unnessesary
recompilation because 'upsweep_mod' treated HscInterface specially.
This patch changes relaxes this.
When running GHC with debug level 5, 'upsweep_mod' will now also be
more verbose about what it is doing.
There is (at least) one possible remaining problem, though: When using
target 'HscNothing' we generate a fake linkable to signal that we have
processed a module. When switching to 'HscInterpreted' this may cause
objects to not be recompiled. Switching from HscNothing to
HscInterpreted is therefore only safe if we unload everything first.
|
|
|
|
|
| |
I don't think errors during dependency analysis should be passed to
the logger.
|
|
|
|
|
|
|
| |
This function returns a list of all modules available through the
package DB.
MERGE TO 6.10
|
|
|
|
| |
MERGE TO 6.10.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch, written by Max Bolingbroke, does two things
1. It adds a new CoreM monad (defined in simplCore/CoreMonad),
which is used as the top-level monad for all the Core-to-Core
transformations (starting at SimplCore). It supports
* I/O (for debug printing)
* Unique supply
* Statistics gathering
* Access to the HscEnv, RuleBase, Annotations, Module
The patch therefore refactors the top "skin" of every Core-to-Core
pass, but does not change their functionality.
2. It adds a completely new facility to GHC: Core "annotations".
The idea is that you can say
{#- ANN foo (Just "Hello") #-}
which adds the annotation (Just "Hello") to the top level function
foo. These annotations can be looked up in any Core-to-Core pass,
and are persisted into interface files. (Hence a Core-to-Core pass
can also query the annotations of imported things.) Furthermore,
a Core-to-Core pass can add new annotations (eg strictness info)
of its own, which can be queried by importing modules.
The design of the annotation system is somewhat in flux. It's
designed to work with the (upcoming) dynamic plug-ins mechanism,
but is meanwhile independently useful.
Do not merge to 6.10!
|
| |
|
|
|
|
| |
So that clients don't need to import SrcLoc
|
| |
|
| |
|
|
|
|
|
|
|
| |
Ifdefs for whether we had extensible exceptions or not were spreading
through GHC's source, and things would only have got worse for the next
2-3 years, so instead we now use an implementation of extensible
exceptions built on top of the old exception type.
|
|
|
|
|
|
|
|
|
| |
To get the ModSummary for a ModuleName getModSummary can be used.
It's not called find* or lookup* because it assumes that the module is
in the module graph and throws an exception if it cannot be found.
Overall, I'm not quite sure about the usefulness of this function
since the user has no control about which filetype to grab (hs or
hs-boot).
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
- Ticket #1995: Unsoundness with newtypes
- Ticket #2475: "Can't unify" error when stopped at an exception
In addition this patch adds the following:
- Unfailingness: RTTI cannot panic anymore.
In case of failure, it recovers gracefully by returning the "I know nothing" type
- A -ddump-rtti flag
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch adds support for raw token streams, that contain more
information than normal token streams (they contains comments at
least). The "lexTokenStream" function brings this support to the
Lexer module. In addition to that, functions have been added to
the GHC module to make easier to recover of the token stream of
a module ("getTokenStream").
Building on that, I added what could be called "rich token
stream": token stream to which have been added the source string
corresponding to each token, the function addSourceToToken takes
a StringBuffer and a starting SrcLoc and a token stream and build
this rich token stream. getRichTokenStream is a convenience
function to get a module rich token stream. "showRichTokenStream"
use the SrcLoc information in such a token stream to get a string
similar to the original source (except unsignificant
whitespaces). Thus "putStrLn . showRichTokenStream =<<
getRichTokenStream s mod" should print a valid module source, the
interesting part being to modify the token stream between the get
and the show of course.
|
|
|
|
|
|
|
|
|
|
| |
Rename function accordingly.
The callback wasn't very flexible to begin with. There's pretty much
no way around to calling 'compile' inside that callback since
'upsweep' depends on certain side effects of compile. It therefore
makes more sense to restrict the callback to its intended use only,
namely to log warnings and errors.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
I'm not sure I covered all the ways of throwing errors in the code.
Some functions throw ProgramErrors, some error messages. It's still
quite a mess, but we're getting closer. The missing cases are mostly
errors that cannot be fixed by the API client either or are a result
of wrong usage, so are in any case fatal.
One function, 'getModuleInfo', still returns a 'Maybe', but the
documentation suggests it should always succeed. So I may change that
soon.
The spit-up of of 'checkModule' has pros and cons. The various forms
of 'checkModule*' now become:
checkAndLoadModule ms False ~~>
loadModule =<< typecheckModule =<< parseModule (ms_mod_name ms)
checkAndLoadModule ms True ~~>
loadModule =<< desugarModule =<< typecheckModule =<< parseModule (ms_mod_name ms)
checkModule mn False ~~>
typecheckModule =<< parseModule mn
checkModule mn True ~~>
desugarModule =<< typecheckModule =<< parseModule mn
The old APIs cannot easily be provided, since the result type would be
different depending on the second argument. However, a more
convenient API can be modelled on top of these four functions
({parse,typecheck,desugar,load}Module).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
New form of :load in GHCi:
> :load *A
forces A to be loaded as byte-code. See the manual for details. The
previous behaviour for specifying filenames vs. module names on the
command line and in :load has been restored.
The Target datatype has a new Bool field, which is True if the target
is allowed to be loaded from compiled code, or False otherwise, so
this functionality is available via the GHC API. guessTarget
understands the *-prefix form for specifying targets.
|
| |
|
|
|
|
|
| |
This allows us to avoid a module import loop:
CmdLineParser -> SrcLoc -> Outputable -> StaticFlags -> CmdLineParser
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Now you can say
import "network" Network.Socket
and get Network.Socket from package "network", even if there are
multiple Network.Socket modules in scope from different packages
and/or the current package.
This is not really intended for general use, it's mainly so that we
can build backwards-compatible versions of packages, where we need to
be able to do
module GHC.Base (module New.GHC.Base) where
import "base" GHC.Base as New.GHC.Base
|
| |
|
| |
|