1. 11 Oct, 2006 1 commit
  2. 27 Jul, 2006 1 commit
  3. 27 Sep, 2006 1 commit
  4. 19 Sep, 2006 1 commit
    • Simon Marlow's avatar
      Packages cleanup, and allow new packages to be loaded with :set again · ee565d46
      Simon Marlow authored
      This cleans up the package subsystem a little.  There are some
      changes to the GHC API as a result.
      
        - GHC.init and GHC.initFromArgs are no longer necessary.
      
        - GHC.newSession takes the root of the GHC tree as an argument
          (previously passed to GHC.init).
      
        - You *must* do GHC.setSessionDynFlags after GHC.newSession,
          this is what loads the package database.
      
        - Several global vars removed from SysTools
      
        - The :set command in GHCi can now cause new packages to be loaded,
          or can hide/ignore existing packages.
      ee565d46
  5. 25 Aug, 2006 1 commit
    • rl@cse.unsw.edu.au's avatar
      Make sure GCC uses the Sparc V9 instruction set · 1777f480
      rl@cse.unsw.edu.au authored
      We only support Sparc V9 and better as V8 lacks an atomic CAS instruction
      which we need for SMP. This means that we have to pass -mcpu=v9 to GCC when
      compiling and assembling. Hardcoding the flag is hackish but seems to be
      our best bet at the moment. It can still be overridden by the user as GCC
      picks the best -mcpu flag regardless of the ordering.
      1777f480
  6. 09 Jul, 2006 1 commit
  7. 25 Jul, 2006 1 commit
    • Simon Marlow's avatar
      Generalise Package Support · 61d2625a
      Simon Marlow authored
      This patch pushes through one fundamental change: a module is now
      identified by the pair of its package and module name, whereas
      previously it was identified by its module name alone.  This means
      that now a program can contain multiple modules with the same name, as
      long as they belong to different packages.
      
      This is a language change - the Haskell report says nothing about
      packages, but it is now necessary to understand packages in order to
      understand GHC's module system.  For example, a type T from module M
      in package P is different from a type T from module M in package Q.
      Previously this wasn't an issue because there could only be a single
      module M in the program.
      
      The "module restriction" on combining packages has therefore been
      lifted, and a program can contain multiple versions of the same
      package.
      
      Note that none of the proposed syntax changes have yet been
      implemented, but the architecture is geared towards supporting import
      declarations qualified by package name, and that is probably the next
      step.
      
      It is now necessary to specify the package name when compiling a
      package, using the -package-name flag (which has been un-deprecated).
      Fortunately Cabal still uses -package-name.
      
      Certain packages are "wired in".  Currently the wired-in packages are:
      base, haskell98, template-haskell and rts, and are always referred to
      by these versionless names.  Other packages are referred to with full
      package IDs (eg. "network-1.0").  This is because the compiler needs
      to refer to entities in the wired-in packages, and we didn't want to
      bake the version of these packages into the comiler.  It's conceivable
      that someone might want to upgrade the base package independently of
      GHC.
      
      Internal changes:
      
        - There are two module-related types:
      
              ModuleName      just a FastString, the name of a module
              Module          a pair of a PackageId and ModuleName
      
          A mapping from ModuleName can be a UniqFM, but a mapping from Module
          must be a FiniteMap (we provide it as ModuleEnv).
      
        - The "HomeModules" type that was passed around the compiler is now
          gone, replaced in most cases by the current package name which is
          contained in DynFlags.  We can tell whether a Module comes from the
          current package by comparing its package name against the current
          package.
      
        - While I was here, I changed PrintUnqual to be a little more useful:
          it now returns the ModuleName that the identifier should be qualified
          with according to the current scope, rather than its original
          module.  Also, PrintUnqual tells whether to qualify module names with
          package names (currently unused).
      
      Docs to follow.
      61d2625a
  8. 11 Jun, 2006 1 commit
  9. 07 Apr, 2006 1 commit
    • Simon Marlow's avatar
      Reorganisation of the source tree · 0065d5ab
      Simon Marlow authored
      Most of the other users of the fptools build system have migrated to
      Cabal, and with the move to darcs we can now flatten the source tree
      without losing history, so here goes.
      
      The main change is that the ghc/ subdir is gone, and most of what it
      contained is now at the top level.  The build system now makes no
      pretense at being multi-project, it is just the GHC build system.
      
      No doubt this will break many things, and there will be a period of
      instability while we fix the dependencies.  A straightforward build
      should work, but I haven't yet fixed binary/source distributions.
      Changes to the Building Guide will follow, too.
      0065d5ab
  10. 06 Apr, 2006 1 commit
  11. 18 Mar, 2006 2 commits
    • David Himmelstrup's avatar
      -fno-code shouldn't be a mode. · 851154f0
      David Himmelstrup authored
      I've removed -fno-code from Main to make it work
      equally well with --make and -c.
      I've also allowed it not to write hi files unless
      -fwrite-iface is given.
      851154f0
    • David Himmelstrup's avatar
      -fno-code shouldn't be a mode. · 4a3042fc
      David Himmelstrup authored
      I've removed -fno-code from Main to make it work
      equally well with --make and -c.
      I've also allowed it not to write hi files unless
      -fwrite-iface is given.
      4a3042fc
  12. 12 Mar, 2006 1 commit
  13. 10 Mar, 2006 1 commit
    • David Himmelstrup's avatar
      Parse OPTIONS properly and cache the result. · d700953c
      David Himmelstrup authored
      Use the lexer to parse OPTIONS, LANGUAGE and INCLUDE pragmas.
      This gives us greater flexibility and far better error
      messages. However, I had to make a few quirks:
        * The token parser is written manually since Happy doesn't
          like lexer errors (we need to extract options before the
          buffer is passed through 'cpp'). Still better than
          manually parsing a String, though.
        * The StringBuffer API has been extended so files can be
          read in blocks.
      I also made a new field in ModSummary called ms_hspp_opts
      which stores the updated DynFlags. Oh, and I took the liberty
      of moving 'getImports' into HeaderInfo together with
      'getOptions'.
      d700953c
  14. 07 Mar, 2006 1 commit
    • David Himmelstrup's avatar
      More work thrown at HscMain. · d1545b69
      David Himmelstrup authored
      MkIface.writeIfaceFile doesn't check GhcMode anymore. All it does
      is what the name say: write an interface to disk.
      I've refactored HscMain so the logic is easier to manage. That means
      we can avoid running the simplifier when typechecking (: And best of
      all, HscMain doesn't use GhcMode at all, anymore!
      
      The new HscMain intro looks like this:
      
      It's the task of the compilation proper to compile Haskell, hs-boot and
      core files to either byte-code, hard-code (C, asm, Java, ect) or to
      nothing at all (the module is still parsed and type-checked. This
      feature is mostly used by IDE's and the likes).
      Compilation can happen in either 'one-shot', 'batch', 'nothing',
      or 'interactive' mode. 'One-shot' mode targets hard-code, 'batch' mode
      targets hard-code, 'nothing' mode targets nothing and 'interactive' mode
      targets byte-code.
      The modes are kept separate because of their different types and meanings.
      In 'one-shot' mode, we're only compiling a single file and can therefore
      discard the new ModIface and ModDetails. This is also the reason it only
      targets hard-code; compiling to byte-code or nothing doesn't make sense
      when we discard the result.
      'Batch' mode is like 'one-shot' except that we keep the resulting ModIface
      and ModDetails. 'Batch' mode doesn't target byte-code since that require
      us to return the newly compiled byte-code.
      'Nothing' mode has exactly the same type as 'batch' mode but they're still
      kept separate. This is because compiling to nothing is fairly special: We
      don't output any interface files, we don't run the simplifier and we don't
      generate any code.
      'Interactive' mode is similar to 'batch' mode except that we return the
      compiled byte-code together with the ModIface and ModDetails.
      d1545b69
  15. 04 Mar, 2006 3 commits
  16. 02 Mar, 2006 1 commit
    • Simon Marlow's avatar
      Make -split-objs work with --make · ec968a32
      Simon Marlow authored
      This turned out to be a lot easier than I thought.  Just moving a few
      bits of -split-objs support from the build system into the compiler
      was enough.  The only thing that Cabal needs to do in order to support
      -split-objs now is to pass the names of the split objects rather than
      the monolithic ones to 'ar'.
      ec968a32
  17. 24 Feb, 2006 1 commit
  18. 06 Jan, 2006 1 commit
    • simonmar's avatar
      [project @ 2006-01-06 16:30:17 by simonmar] · 9d7da331
      simonmar authored
      Add support for UTF-8 source files
      
      GHC finally has support for full Unicode in source files.  Source
      files are now assumed to be UTF-8 encoded, and the full range of
      Unicode characters can be used, with classifications recognised using
      the implementation from Data.Char.  This incedentally means that only
      the stage2 compiler will recognise Unicode in source files, because I
      was too lazy to port the unicode classifier code into libcompat.
      
      Additionally, the following synonyms for keywords are now recognised:
      
        forall symbol 	(U+2200)	forall
        right arrow   	(U+2192)	->
        left arrow   		(U+2190)	<-
        horizontal ellipsis 	(U+22EF)	..
      
      there are probably more things we could add here.
      
      This will break some source files if Latin-1 characters are being used.
      In most cases this should result in a UTF-8 decoding error.  Later on
      if we want to support more encodings (perhaps with a pragma to specify
      the encoding), I plan to do it by recoding into UTF-8 before parsing.
      
      Internally, there were some pretty big changes:
      
        - FastStrings are now stored in UTF-8
      
        - Z-encoding has been moved right to the back end.  Previously we
          used to Z-encode every identifier on the way in for simplicity,
          and only decode when we needed to show something to the user.
          Instead, we now keep every string in its UTF-8 encoding, and
          Z-encode right before printing it out.  To avoid Z-encoding the
          same string multiple times, the Z-encoding is cached inside the
          FastString the first time it is requested.
      
          This speeds up the compiler - I've measured some definite
          improvement in parsing at least, and I expect compilations overall
          to be faster too.  It also cleans up a lot of cruft from the
          OccName interface.  Z-encoding is nicely hidden inside the
          Outputable instance for Names & OccNames now.
      
        - StringBuffers are UTF-8 too, and are now represented as
          ForeignPtrs.
      
        - I've put together some test cases, not by any means exhaustive,
          but there are some interesting UTF-8 decoding error cases that
          aren't obvious.  Also, take a look at unicode001.hs for a demo.
      9d7da331
  19. 23 Nov, 2005 1 commit
  20. 09 Nov, 2005 1 commit
  21. 08 Nov, 2005 2 commits
    • simonmar's avatar
      [project @ 2005-11-08 12:56:04 by simonmar] · 03341842
      simonmar authored
      gcc's -fstrict-aliasing is biting us when we use the stack to store
      different types of objects.  For example:
      
        *((StgDouble*)((W_)Sp-8)) = *((StgDouble*)((W_)Sp+8));
        Sp[1] = (W_)&s1Cx_info;
      
      gcc feels free to reorder these two lines, because they refer to
      differently typed objects, even though the assignment to Sp[1] clearly
      aliases the read from the same location.
      
      Trying to fix this by accessing locations using union types might be
      possible, but I took the sledgehammer approach of
      -fno-strict-aliasing.  This is justified to a certain extent because
      our generated C code is derived from a very weakly-typed internal
      language (C--).
      03341842
    • simonmar's avatar
      [project @ 2005-11-08 12:31:36 by simonmar] · 27249023
      simonmar authored
      unless I'm mistaken, only x86 needs -ffloat-store.  x86_64 certainly
      doesn't need it, because it uses SSE2 with the correct-sized floating
      point registers and doesn't store temporary results with more
      precision than results in memory.
      27249023
  22. 30 Oct, 2005 1 commit
    • krasimir's avatar
      [project @ 2005-10-30 19:12:31 by krasimir] · 6e64c691
      krasimir authored
      Change the way in which the .exe suffix to the output file is added. The reason
      is that "-o main" will generate main.exe on Windows while the doesFileExists "main"
      in DriverPipeline.link will return False.
      6e64c691
  23. 28 Oct, 2005 2 commits
    • simonmar's avatar
      [project @ 2005-10-28 15:22:39 by simonmar] · f2e730f3
      simonmar authored
      Add -stubdir option to control location of generated stub files.  Also
      do some clean up while I'm here - remove hscStubCOut/hscStubHOut from
      DynFlags, and add
      
        mkStubPaths :: DynFlags -> Module -> ModLocation -> (FilePath,FilePath)
      
      to Finder.  (this seemed better than caching the stub paths in every
      ModLocation, because they are rarely needed and only present in home
      modules, and are easily calculated from other available information).
      
      -stubdir behaves in exactly the same way as -odir and -hidir.
      f2e730f3
    • simonmar's avatar
      [project @ 2005-10-28 11:29:19 by simonmar] · d8afca91
      simonmar authored
      Fix double "Linking ..." message, and mention the name of the
      executable in the message.
      d8afca91
  24. 25 Oct, 2005 1 commit
    • simonmar's avatar
      [project @ 2005-10-25 12:48:35 by simonmar] · 78b72ed1
      simonmar authored
      Two changes from Krasimir Angelov, which were required for Visual
      Haskell:
      
        - messaging cleanup throughout the compiler.  DynFlags has a new
          field:
      
          log_action :: Severity -> SrcSpan -> PprStyle -> Message -> IO ()
      
          this action is invoked for every message generated by the
          compiler.  This means a client of the GHC API can direct messages to
          any destination, or collect them up in an IORef for later
          perusal.
      
          This replaces previous hacks to redirect messages in the GHC API
          (hence some changes to function types in GHC.hs).
      
        - The JustTypecheck mode of GHC now does what it says.  It doesn't
          run any of the compiler passes beyond the typechecker for each module,
          but does generate the ModIface in order that further modules can be
          typechecked.
      
      And one change from me:
      
        - implement the LANGUAGE pragma, finally
      78b72ed1
  25. 23 Sep, 2005 1 commit
  26. 03 Aug, 2005 1 commit
    • simonmar's avatar
      [project @ 2005-08-03 10:42:53 by simonmar] · 34495a28
      simonmar authored
      Fix the location of _stub.o files when compiling with -odir.  The
      comment from the source:
      
      -- The _stub.c file is derived from the haskell source file (but stored
      -- in hscStubCOutName in the dflags for some reason, probably historical).
      -- Consequently, we derive the _stub.o filename from the haskell object
      -- filename.
      --
      -- This isn't necessarily the same as the object filename we
      -- would get if we just compiled the _stub.c file using the pipeline.
      -- For example:
      --
      --    ghc src/A.hs -odir obj
      --
      -- results in obj/A.o, and src/A_stub.c.  If we compile src/A_stub.c with
      -- -odir obj, we would get obj/src/A_stub.o, which is wrong; we want
      -- obj/A_stub.o.
      34495a28
  27. 08 Jul, 2005 1 commit
  28. 24 May, 2005 1 commit
  29. 19 May, 2005 1 commit
    • simonpj's avatar
      [project @ 2005-05-19 11:15:40 by simonpj] · 4a587049
      simonpj authored
      Tune up the reporting of unused imports
      
      		Merge to STABLE
      	(I think the earlier change made it across)
      	(PS: the commit also does some trimming of
      	redundant imports.  If they don't merge, just
      	discard them.)
      
      My earlier fixes to the reporting of unused imports still missed
      some obscure cases, some of which are now fixed by this commit.
      I had to make the import-provenance data type yet richer, but in
      fact it has more sharing now, so it may be cheaper on space.
      
      There's still one infelicity. Consider
      		import M( x )
      		imoprt N( x )
      where the same underlying 'x' is involved in both cases.  Currently we
      don't report a redundant import, because dropping either import would
      change the qualified names in scope (M.x, N.x). But if the qualified
      names aren't used, the import is indeed redundant. Sadly we don't know
      that, because we only know what Names are used.  Left for the future!
      There's a comment in RnNames.warnDuplicateImports
      
      This commit also trims quite a few redundant imports disovered
      by the new setup.
      4a587049
  30. 17 May, 2005 1 commit
    • simonmar's avatar
      [project @ 2005-05-17 12:00:04 by simonmar] · 8d6afe74
      simonmar authored
      Improve source locations on error messages from the downsweep.  We now
      keep track of SrcSpans from import declarations, so we can report a
      proper source location for unknown imports (this improves on the
      previous hacky solution of keeping track of the filename that
      contained the original import declaration).
      
      ModSummary now contains (Located Module) for each import instead of Module.
      8d6afe74
  31. 16 May, 2005 1 commit
    • simonmar's avatar
      [project @ 2005-05-16 13:47:57 by simonmar] · 34c2b1b2
      simonmar authored
      Implement -x <suffix> flag to override the suffix of a filename for
      the purposes of determinig how it should be compiled.  The usage is
      similar to gcc, except that we just use a suffix rather than a name
      for the language. eg.
      
         ghc -c -x hs hello.blah
      
      will pretend hello.blah is a .hs file.  Another possible use is -x
      hspp, which skips preprocessing.
      
      This works for one-shot compilation, --make, GHCi, and ghc -e.  The
      original idea was to make it possible to use runghc on a file that
      doesn't end in .hs, so changes to runghc will follow.
      
      Also, I made it possible to specify .c files and other kinds of files
      on the --make command line; these will be compiled to objects as
      normal and linked into the final executable.
      
      GHC API change: I had to extend the Target type to include an optional
      start phase, and also GHC.guessTarget now takes a (Maybe Phase) argument.
      
      I thought this would be half an hour, in fact it took half a day, and
      I still haven't documented it.  Sigh.
      34c2b1b2
  32. 28 Apr, 2005 1 commit
    • simonpj's avatar
      [project @ 2005-04-28 10:09:41 by simonpj] · dd313897
      simonpj authored
      This big commit does several things at once (aeroplane hacking)
      which change the format of interface files.  
      
      	So you'll need to recompile your libraries!
      
      1. The "stupid theta" of a newtype declaration
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Retain the "stupid theta" in a newtype declaration.
      For some reason this was being discarded, and putting it
      back in meant changing TyCon and IfaceSyn slightly.
         
      
      2. Overlap flags travel with the instance
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Arrange that the ability to support overlap and incoherence
      is a property of the *instance declaration* rather than the
      module that imports the instance decl.  This allows a library
      writer to define overlapping instance decls without the
      library client having to know.  
      
      The implementation is that in an Instance we store the
      overlap flag, and preseve that across interface files
      
      
      3. Nuke the "instnce pool" and "rule pool"
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      A major tidy-up and simplification of the way that instances
      and rules are sucked in from interface files.  Up till now
      an instance decl has been held in a "pool" until its "gates" 
      (a set of Names) are in play, when the instance is typechecked
      and added to the InstEnv in the ExternalPackageState.  
      This is complicated and error-prone; it's easy to suck in 
      too few (and miss an instance) or too many (and thereby be
      forced to suck in its type constructors, etc).
      
      Now, as we load an instance from an interface files, we 
      put it straight in the InstEnv... but the Instance we put in
      the InstEnv has some Names (the "rough-match" names) that 
      can be used on lookup to say "this Instance can't match".
      The detailed dfun is only read lazily, and the rough-match
      thing meansn it is'nt poked on until it has a chance of
      being needed.
      
      This simply continues the successful idea for Ids, whereby
      they are loaded straightaway into the TypeEnv, but their
      TyThing is a lazy thunk, not poked on until the thing is looked
      up.
      
      Just the same idea applies to Rules.
      
      On the way, I made CoreRule and Instance into full-blown records
      with lots of info, with the same kind of key status as TyCon or 
      DataCon or Class.  And got rid of IdCoreRule altogether.   
      It's all much more solid and uniform, but it meant touching
      a *lot* of modules.
      
      
      4. Allow instance decls in hs-boot files
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Allowing instance decls in hs-boot files is jolly useful, becuase
      in a big mutually-recursive bunch of data types, you want to give
      the instances with the data type declarations.  To achieve this
      
      * The hs-boot file makes a provisional name for the dict-fun, something
        like $fx9.
      
      * When checking the "mother module", we check that the instance
        declarations line up (by type) and generate bindings for the 
        boot dfuns, such as
      	$fx9 = $f2
        where $f2 is the dfun generated by the mother module
      
      * In doing this I decided that it's cleaner to have DFunIds get their
        final External Name at birth.  To do that they need a stable OccName,
        so I have an integer-valued dfun-name-supply in the TcM monad.
        That keeps it simple.
      
      This feature is hardly tested yet.
      
      
      5. Tidy up tidying, and Iface file generation
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      main/TidyPgm now has two entry points:
      
        simpleTidyPgm is for hi-boot files, when typechecking only
        (not yet implemented), and potentially when compiling without -O.
        It ignores the bindings, and generates a nice small TypeEnv.
      
        optTidyPgm is the normal case: compiling with -O.  It generates a
        TypeEnv rich in IdInfo
      
      MkIface.mkIface now only generates a ModIface.  A separate
      procedure, MkIface.writeIfaceFile, writes the file out to disk.
      dd313897
  33. 19 Apr, 2005 1 commit
    • simonmar's avatar
      [project @ 2005-04-19 15:28:35 by simonmar] · 44eaf25c
      simonmar authored
      - DriverPipeline.compile: report errors in GHC_OPTIONS pragmas using the
        Message callback, and give them a proper line number.
      
      - GHC.checkModule: read the GHC_OPTIONS pragma, and report errors
        appropriately.
      44eaf25c
  34. 13 Apr, 2005 2 commits
    • wolfgang's avatar
      [project @ 2005-04-13 21:42:17 by wolfgang] · 93cc7d22
      wolfgang authored
      Make the status messages from ghc --make display the number of modules
      to be compiled, as in:
      
      [3 of 9] Compiling Foo.hs     ( Foo.hs, Foo.o )
      93cc7d22
    • simonmar's avatar
      [project @ 2005-04-13 13:30:42 by simonmar] · b3302713
      simonmar authored
      Add :
      
        loadMsg :: Session -> LoadHowMuch
      	  -> (Messages-> IO ()) -> IO SuccessFlag
      
      ie. just like load, except it takes a message callback and plumbs it
      down to hscMain.  checkModule now uses loadMsgs.  Better name
      suggestions welcome.
      b3302713