summaryrefslogtreecommitdiff
path: root/ghc/compiler/compMan/CmLink.lhs
Commit message (Collapse)AuthorAgeFilesLines
* [project @ 2002-09-13 15:02:25 by simonpj]simonpj2002-09-131-326/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -------------------------------------- Make Template Haskell into the HEAD -------------------------------------- This massive commit transfers to the HEAD all the stuff that Simon and Tim have been doing on Template Haskell. The meta-haskell-branch is no more! WARNING: make sure that you * Update your links if you are using link trees. Some modules have been added, some have gone away. * Do 'make clean' in all library trees. The interface file format has changed, and you can get strange panics (sadly) if GHC tries to read old interface files: e.g. ghc-5.05: panic! (the `impossible' happened, GHC version 5.05): Binary.get(TyClDecl): ForeignType * You need to recompile the rts too; Linker.c has changed However the libraries are almost unaltered; just a tiny change in Base, and to the exports in Prelude. NOTE: so far as TH itself is concerned, expression splices work fine, but declaration splices are not complete. --------------- The main change --------------- The main structural change: renaming and typechecking have to be interleaved, because we can't rename stuff after a declaration splice until after we've typechecked the stuff before (and the splice itself). * Combine the renamer and typecheker monads into one (TcRnMonad, TcRnTypes) These two replace TcMonad and RnMonad * Give them a single 'driver' (TcRnDriver). This driver replaces TcModule.lhs and Rename.lhs * The haskell-src library package has a module Language/Haskell/THSyntax which defines the Haskell data type seen by the TH programmer. * New modules: hsSyn/Convert.hs converts THSyntax -> HsSyn deSugar/DsMeta.hs converts HsSyn -> THSyntax * New module typecheck/TcSplice type-checks Template Haskell splices. ------------- Linking stuff ------------- * ByteCodeLink has been split into ByteCodeLink (which links) ByteCodeAsm (which assembles) * New module ghci/ObjLink is the object-code linker. * compMan/CmLink is removed entirely (was out of place) Ditto CmTypes (which was tiny) * Linker.c initialises the linker when it is first used (no need to call initLinker any more). Template Haskell makes it harder to know when and whether to initialise the linker. ------------------------------------- Gathering the LIE in the type checker ------------------------------------- * Instead of explicitly gathering constraints in the LIE tcExpr :: RenamedExpr -> TcM (TypecheckedExpr, LIE) we now dump the constraints into a mutable varabiable carried by the monad, so we get tcExpr :: RenamedExpr -> TcM TypecheckedExpr Much less clutter in the code, and more efficient too. (Originally suggested by Mark Shields.) ----------------- Remove "SysNames" ----------------- Because the renamer and the type checker were entirely separate, we had to carry some rather tiresome implicit binders (or "SysNames") along inside some of the HsDecl data structures. They were both tiresome and fragile. Now that the typechecker and renamer are more intimately coupled, we can eliminate SysNames (well, mostly... default methods still carry something similar). ------------- Clean up HsPat ------------- One big clean up is this: instead of having two HsPat types (InPat and OutPat), they are now combined into one. This is more consistent with the way that HsExpr etc is handled; there are some 'Out' constructors for the type checker output. So: HsPat.InPat --> HsPat.Pat HsPat.OutPat --> HsPat.Pat No 'pat' type parameter in HsExpr, HsBinds, etc Constructor patterns are nicer now: they use HsPat.HsConDetails for the three cases of constructor patterns: prefix, infix, and record-bindings The *same* data type HsConDetails is used in the type declaration of the data type (HsDecls.TyData) Lots of associated clean-up operations here and there. Less code. Everything is wonderful.
* [project @ 2002-09-04 11:04:45 by simonmar]simonmar2002-09-041-1/+1
| | | | Exception => Control.Exception
* [project @ 2002-08-29 15:44:11 by simonmar]simonmar2002-08-291-8/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Housekeeping: - The main goal is to remove dependencies on hslibs for a bootstrapped compiler, leaving only a requirement that the packages base, haskell98 and readline are built in stage 1 in order to bootstrap. We're almost there: Posix is still required for signal handling, but all other dependencies on hslibs are now gone. Uses of Addr and ByteArray/MutableByteArray array are all gone from the compiler. PrimPacked defines the Ptr type for GHC 4.08 (which didn't have it), and it defines simple BA and MBA types to replace uses of ByteArray and MutableByteArray respectively. - Clean up import lists. HsVersions.h now defines macros for some modules which have moved between GHC versions. eg. one now imports 'GLAEXTS' to get at unboxed types and primops in the compiler. Many import lists have been sorted as per the recommendations in the new style guidelines in the commentary. I've built the compiler with GHC 4.08.2, 5.00.2, 5.02.3, 5.04 and itself, and everything still works here. Doubtless I've got something wrong, though.
* [project @ 2002-05-01 17:56:52 by sof]sof2002-05-011-1/+1
| | | | mapM ~> mapM_
* [project @ 2002-02-18 12:41:01 by sewardj]sewardj2002-02-181-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Make foreign export dynamic work in GHCi. Main changes: * Allow literal labels to propagate through the bytecode generator and eventually be linked by the runtime linker. * Minor mods to driver plumbing so that GHCi produces the relevant *_stub.[ch] files, compiles them with gcc, and loads the resulting .o's * Dereference the stable pointer in the generated C stub, rather than passing it to a Haskell-world helper. This seems simpler and removes the need to have a H-world helper, which in turn means the stub .o doesn't refer to any H-world entities. This is important because our linker can't deal with mutual recursion between BCOs and loaded objects. Still ToDo: * Make it thread/GC safe. (Sigbjorn?) * Get rid of the bits of code in DsForeign which generate the Haskell helper. I had a go but it wasn't obvious how to do it, so have deferred.
* [project @ 2001-08-29 18:12:19 by sof]sof2001-08-291-1/+1
| | | | emptyPLS: warning removal
* [project @ 2001-08-13 15:44:38 by simonmar]simonmar2001-08-131-4/+9
| | | | | The compilation manager now continues gracefully (by unloading all the modules) if the link step fails.
* [project @ 2001-08-02 08:29:42 by simonmar]simonmar2001-08-021-0/+3
| | | | | oops, only import Exception.block when compiling GHCi (and we know we're bootstrapping)
* [project @ 2001-08-01 12:07:50 by simonmar]simonmar2001-08-011-108/+140
| | | | | | | | | | | | | | | | Signification cleanup & rewrite of CmLink. Fixes at least one bug: the PersistentLinkerState could sometimes get out of step with the RTS's idea of which modules were loaded, leading to an unloadObj failure when we try to unload the same module twice. This could happen if a ^C exception is received in the middle of a :load. Fixed by keeping the part of the linker's state that must match up with the RTS's internal state entirely private to CmLink, stored in a global variable. The operations in CmLink which manipulate this state are now wrapped by Exception.block, and so are safe from ^C exceptions.
* [project @ 2001-06-15 08:29:57 by simonpj]simonpj2001-06-151-1/+1
| | | | | | | | | | | | Some tidying up * Remove CmStaticInfo - GhciMode moves to HscTypes - The package stuff moves to new module main/Packages.lhs [put any package-related stuff in the new module] * Add Outputable.docToSDoc
* [project @ 2001-06-14 12:50:05 by simonpj]simonpj2001-06-141-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ---------------------- Installation packaging ---------------------- GHC runs various system programs like cp, touch gcc, as, ld etc On Windows we plan to deliver these programs along with GHC, so we have to be careful about where to find them. This commit isolates all these dependencies in a single module main/SysTools.lhs Most of the #ifdefery for mingw has moved into this module. There's some documentation in SysTools.lhs Along the way I did lots of other cleanups. In particular * There is no more 'globbing' needed when calling runSomething * All file removal goes via the standard Directory.removeFile * TmpFiles.hs has gone; absorbed into SysTools * Some DynFlag stuff has moved from DriverFlags to CmdLineOpts Still to do: ** I'm a bit concerned that calling removeFile one at a time when deleting masses of split-object files is going to be rather slow ** GHC now expects to find split,mangle,unlit in libdir/extra-bin instead of just libdir So something needs to change in the Unix installation scripts ** The "ineffective C preprocessor" is a perversion and should die
* [project @ 2001-03-28 18:53:39 by qrczak]qrczak2001-03-281-1/+1
| | | | Typo.
* [project @ 2001-03-28 11:01:19 by simonmar]simonmar2001-03-281-2/+1
| | | | | | | | | | | | | | Clean up GHC's error reporting. - the GhcException type has some more constructors: CmdLineError, UserError, and InstallationError. OtherError has gone. - most error messages should begin with "<location>:". When the error is on the command-line or in GHC itself, <location> is "ghc", for consistency with std Unix semantics. - GHCi no longer prints a superfluous "ghc: " before certain error messages.
* [project @ 2001-03-19 16:22:00 by simonmar]simonmar2001-03-191-3/+9
| | | | | | | | | | | | Fix a problem with the 'it' variable in GHCi. New bindings for 'it' were getting confused with old bindings, because we always used the same 'it' name. Now, we generate a new unique for 'it' each time around. Also, make sure that any existing variables shadowed by new command-line bindings are correctly removed from the environments to avoid space leaks.
* [project @ 2001-03-01 16:56:44 by simonpj]simonpj2001-03-011-1/+4
| | | | Move import
* [project @ 2001-03-01 14:26:00 by simonmar]simonmar2001-03-011-0/+1
| | | | | | | | | | | | | | | | | GHCi fixes: - expressions are now compiled in a pseudo-module "$Interactive", which avoids some problems with storage of demand-loaded declarations. - compilation manager now detects when it needs to read the interace for a module, even if it is already compiled. GHCi never demand-loads interfaces now. - (from Simon PJ) fix a problem with the recompilation checker, which meant that modules were sometimes not recompiled when they should have been. - ByteCodeGen/Link: move linker related stuff into ByteCodeLink.
* [project @ 2001-02-26 16:59:17 by simonmar]simonmar2001-02-261-1/+0
| | | | lookupClosure not used.
* [project @ 2001-02-26 16:42:48 by simonmar]simonmar2001-02-261-0/+1
| | | | Unload temporary bindings from the ClosureEnv properly at cmLoadModule time.
* [project @ 2001-02-26 15:40:54 by simonpj]simonpj2001-02-261-1/+3
| | | | Make it build without GHCI
* [project @ 2001-02-26 15:06:57 by simonmar]simonmar2001-02-261-0/+7
| | | | | | | | | | | | | | | | | Implement do-style bindings on the GHCi command line. The syntax for a command-line is exactly that of a do statement, with the following meanings: - `pat <- expr' performs expr, and binds each of the variables in pat. - `let pat = expr; ...' binds each of the variables in pat, doesn't do any evaluation - `expr' behaves as `it <- expr' if expr is IO-typed, or `let it = expr' followed by `print it' otherwise.
* [project @ 2001-02-07 16:17:26 by sewardj]sewardj2001-02-071-2/+3
| | | | Always have (unload Batch) work, regardless if definedness of GHCI.
* [project @ 2001-02-07 13:47:03 by sewardj]sewardj2001-02-071-2/+4
| | | | #ifndef GHCI wibbles.
* [project @ 2001-02-07 11:53:00 by simonmar]simonmar2001-02-071-2/+4
| | | | | Don't re-link interpreted modules if they haven't changed. Now :r is almost instantaneous when nothing changes (as it should be).
* [project @ 2001-02-06 12:03:10 by simonmar]simonmar2001-02-061-48/+75
| | | | | | | | | | | | | | | | Try to get the stable modules story right. Things now work much better: objects aren't unloaded and reloaded unnecessarily, and compiling modules from with GHCi works: > :! ghc -c A.hs > :r Compiling A ... compilation IS NOT required (using ./A.o) Compiling B ... compilation IS NOT required Compiling C ... compilation IS NOT required Compiling Main ... compilation IS NOT required Compiled module must not depend on interpreted modules, but we currently don't enforce this restriction properly.
* [project @ 2001-02-05 11:14:28 by simonmar]simonmar2001-02-051-21/+31
| | | | Add a list of objects currently loaded to the persistent linker state.
* [project @ 2000-12-18 12:43:04 by sewardj]sewardj2000-12-181-7/+5
| | | | Wire in the bytecode interpreter and delete the old one.
* [project @ 2000-12-13 12:19:00 by sewardj]sewardj2000-12-131-1/+1
| | | | import wibbles
* [project @ 2000-11-27 10:48:10 by simonmar]simonmar2000-11-271-2/+2
| | | | rename filterNameEnv-->filterNameMap to avoid clash with Name.filterNameEnv.
* [project @ 2000-11-24 17:09:52 by simonmar]simonmar2000-11-241-2/+2
| | | | | | | | | | | - Bug fixes to the interpreter. Now much more stable - it hasn't crashed all day. - Many improvements to the user interface (eg. :set +t and :set +s work just like Hugs). - Several wibbles & message improvements: the interpreter now informs you when it's loading the object code for a given module.
* [project @ 2000-11-21 16:19:15 by sewardj]sewardj2000-11-211-4/+6
| | | | Message wibbles.
* [project @ 2000-11-21 14:31:58 by simonmar]simonmar2000-11-211-13/+24
| | | | | | | | | | | | | | | | | | | Mostly verbosity changes. GONE AWAY: -dshow-passes, -ddump-all, -ddump-most. NEW: -v<n>, where <n> is 0 | print errors & warnings only 1 | minimal verbosity: print "compiling M ... done." for each module. 2 | equivalent to -dshow-passes 3 | equivalent to existing "ghc -v" 4 | "ghc -v -ddump-most" 5 | "ghc -v -ddump-all" 4 & 5 are the same at the moment. -dshow-passes also prints out the passes in the driver, and some in the compilation manager.
* [project @ 2000-11-20 14:48:52 by simonpj]simonpj2000-11-201-0/+2
| | | | | | | | | | When renaming, typechecking an expression from the user interface, we may suck in declarations from interface files (e.g. the Prelude). This commit takes account of that. To do so, I did some significant restructuring in TcModule, with consequential changes and tidy ups elsewhere in the type checker. I think there should be fewer lines in total than before.
* [project @ 2000-11-20 13:39:26 by sewardj]sewardj2000-11-201-10/+10
| | | | Redo the source-up-to-date logic (in CompManager.upsweep_mod).
* [project @ 2000-11-20 11:39:57 by sewardj]sewardj2000-11-201-5/+6
| | | | | | * (CompManager) recompile if in interactive mode and no old linkable exists * (HscMain) don't write interface files in interactive mode * (everywhere) switch arg order to unJust for PAP purposes
* [project @ 2000-11-17 16:53:27 by simonmar]simonmar2000-11-171-7/+5
| | | | | | | | | | | | | | | | Results of today's hacking: - We can now execute expressions from the GHCi prompt. However, a problem with the typechecker environment means that identifiers from outside the current module aren't resolved :-( - loading up a multi-module program in the interpreter seems to work. Interpreting is kinda slow (ok, very slow), but I'm hoping it'll get better when I compile the interpreter w/ optimisation. - :set sort of works - you can do ":set -dshow-passes", for example - lots of bugfixes, etc.
* [project @ 2000-11-17 10:13:21 by sewardj]sewardj2000-11-171-2/+3
| | | | Make file up-to-dateness checking work in batch mode.
* [project @ 2000-11-16 16:54:36 by simonmar]simonmar2000-11-161-13/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | WOOHOO! GHCi interprets "Hello World": _____ __ __ ____ _________________________________________________ (| || || (| |) GHC Interactive, version 5.00 || __ ||___|| || () For Haskell 98. || |) ||---|| || || http://www.haskell.org/ghc || || || || || (| Bug reports to: glasgow-haskell-bugs@haskell.org (|___|| || || (|__|) \\______________________________________________________ Loading package std ... resolving ... done. Prelude> :l Main cmLoadModule: downsweep begins getSummary: Main after tsort: NONREC ModSummary { ms_mod = Main, ms_imps = [] ms_srcimps = [] } CHECKING OLD IFACE for hs = Just "./Main.hs", hspp = Just "/tmp/ghc25011.hspp" COMPILATION IS REQUIRED UPSWEEP COMPLETELY SUCCESSFUL CmLink.link: linkables are ... LinkableM Main [Trees [Main.main = letP stg_cIM = (@PP Native PrelShow.$fShow[] Native PrelShow.$fShowChar) in letP stg_cIL = (@IP Native PrelBase.unpackCString# 141613256#) in (@PP (@PP Native PrelIO.print stg_cIM) stg_cIL)]] Main.main CmLink.link: done Prelude> Main.main Run expression: Main.main evalI: 141613256# "Hello, world!" done.
* [project @ 2000-11-16 16:23:03 by sewardj]sewardj2000-11-161-0/+1
| | | | | | * Move along the source-changed checkery. * Make the driver put object files in the right place when using CM. * Don't do hscNoRecomp in one-shot mode.
* [project @ 2000-11-16 15:57:05 by simonmar]simonmar2000-11-161-86/+93
| | | | | | Moving things around a bit to avoid cycles. Further progress on interactive linker.
* [project @ 2000-11-16 11:39:36 by simonmar]simonmar2000-11-161-1/+1
| | | | Current state of the interactive system; can load packages (in theory).
* [project @ 2000-11-15 15:43:30 by sewardj]sewardj2000-11-151-8/+15
| | | | | | Overhaul of CM, reducing the complexity of recursive module machinery. Also, don't compute package dependencies at all, and don't pass them to the linker.
* [project @ 2000-11-15 10:49:53 by sewardj]sewardj2000-11-151-2/+1
| | | | Fix up the Batch vs Interactive plumbing.
* [project @ 2000-11-14 13:59:44 by sewardj]sewardj2000-11-141-7/+18
| | | | Only do batch linking if the upsweep succeeds and someone exports Main.main.
* [project @ 2000-11-13 17:08:36 by sewardj]sewardj2000-11-131-4/+29
| | | | | | First shot at batch linking. Does not attempt linking if upsweep was not completely successful. Always attempts linking if upsweep successful, even if there's no 'main' to be found anywhere.
* [project @ 2000-11-08 15:14:03 by simonmar]simonmar2000-11-081-2/+6
| | | | fix heavy-handed merge-o :(
* [project @ 2000-11-08 14:52:06 by simonpj]simonpj2000-11-081-7/+3
| | | | Compiles most of the Prelude; versioning still not good
* [project @ 2000-11-08 13:51:58 by simonmar]simonmar2000-11-081-0/+10
| | | | Fixes for compiling w/ 4.08.1
* [project @ 2000-11-07 16:39:15 by simonmar]simonmar2000-11-071-3/+1
| | | | small fixes
* [project @ 2000-11-07 16:03:38 by simonmar]simonmar2000-11-071-2/+1
| | | | Fix compilation with 4.08.1
* [project @ 2000-11-02 14:27:01 by simonmar]simonmar2000-11-021-0/+144
Cleaning up the configuration/build process. - New build.mk option: GhcWithInterpreter. It has reasonable defaults, and shouldn't need to be overriden (you get the interpreter if you're bootstrapping with ghc 4.09+ on an ELF architecture, at the moment). - compilation manager now lives in compiler/compMan. compiler/ghci contains only interpreter-related files. - WithGhcHc has gone, it now defaults to $(GHC). This is so that we can reliably determine the version of $(GHC) using the stuff that configure tells us. configure gets a new --with-ghc option so you can specify which ghc to use.