1. 31 Jan, 2005 5 commits
    • simonpj's avatar
      [project @ 2005-01-31 13:53:29 by simonpj] · c269f662
      simonpj authored
      Wibble to hoistForAllTys
      c269f662
    • simonpj's avatar
      [project @ 2005-01-31 13:25:33 by simonpj] · f25b9225
      simonpj authored
      ---------------------------
      	Types and evaluated-ness in
      	  CoreTidy and CorePrep
      	---------------------------
      
      This commmit fixes two problems.
      
      1.  DataToTagOp requires its argument to be evaluated, otherwise it silently
          gives the wrong answer.  This was not happening because we had
      	case (tag2Enum x) of y -> ...(dataToTag y)...
          and the tag2Enum was being inlined (it's non-speculative), giving
      	...(dataToTag (tag2Enum x))...
      
          Rather than relying on a somewhat-delicate global invariant, CorePrep
          now establishes the invariant that DataToTagOp's argument is evaluated.
          It does so by putting up-to-date is-evaluated information into each
          binder's UnfoldingInfo; not a full unfolding, just the (OtherCon [])
          for evaluated binders.
      
          Then there's a special case for DataToTag where applications are dealt with.
      
          Finally, we make DataToTagOp strict, which it really is.
      
      
      2.  CoreTidy now does GADT refinement as it goes. This is important to ensure that
          each variable occurrence has informative type information, which in turn is
          essential to make exprType work (otherwise it can simply crash).
          [This happened in test gadt/tdpe]
      
          CorePrep has the same problem, but the solution is a little different:
          when looking up in the cloning environment, use the type at the occurrence
          site if we're inside a GADT.  It might be cleaner to use the same story as
          CoreTidy, but then we'd need to keep an in-scope set for type variables.
          No big deal either way.
      f25b9225
    • simonpj's avatar
      [project @ 2005-01-31 13:22:57 by simonpj] · 04612d54
      simonpj authored
      Rename mkTvSubst to mkOpenTvSubst; add new mkTvSubst
      04612d54
    • simonpj's avatar
      [project @ 2005-01-31 13:21:01 by simonpj] · 94df1013
      simonpj authored
      Name evaldUnfolding = OtherCon [], and use it
      94df1013
    • wolfgang's avatar
      [project @ 2005-01-31 05:27:14 by wolfgang] · c560ae86
      wolfgang authored
      Reorganise handling of -fPIC flags passed to C compiler.
      The flags expected by gcc differ only slightly per platform
      (basically depending whether you are on a Mac or not), we don't need
      separate cases for every processor.
      
      TODO: Display an error message for platforms where -fPIC -fvia-C is not
            supported.
      c560ae86
  2. 28 Jan, 2005 5 commits
    • ross's avatar
      [project @ 2005-01-28 18:50:25 by ross] · 5500fa8f
      ross authored
      add missing underscores
      5500fa8f
    • simonpj's avatar
      [project @ 2005-01-28 17:44:55 by simonpj] · c51fdf44
      simonpj authored
      Arrange that when seeking instance decls in GHCi, in response
      to a :info command, we only print ones whose types are in scope
      unqualified.  This eliminates an alarmingly long list when
      simply typing ':info Show', say.
      
      On the way, I reorganised a bit.  GHCi printing happens by
      converting a TyThing to an IfaceDecl, and printing that.
      I now arrange to generate unqualifed IfaceExtNames directly
      during this conversion, based on what is in scope.  Previously
      it was done during the pretty-printing part via the UserStyle.
      But this is nicer.
      c51fdf44
    • simonmar's avatar
      [project @ 2005-01-28 14:27:00 by simonmar] · b4b792b5
      simonmar authored
      add an INCLUDE pragma, as a compiler-independent alternative to
      -#include.
      b4b792b5
    • simonmar's avatar
      [project @ 2005-01-28 14:21:12 by simonmar] · a02314bd
      simonmar authored
      Fix -no-recomp
      a02314bd
    • simonmar's avatar
      [project @ 2005-01-28 12:55:17 by simonmar] · 153b9cb9
      simonmar authored
      Rationalise the BUILD,HOST,TARGET defines.
      
      Recall that:
      
        - build is the platform we're building on
        - host is the platform we're running on
        - target is the platform we're generating code for
      
      The change is that now we take these definitions as applying from the
      point of view of the particular source code being built, rather than
      the point of view of the whole build tree.
      
      For example, in RTS and library code, we were previously testing the
      TARGET platform.  But under the new rule, the platform on which this
      code is going to run is the HOST platform.  TARGET only makes sense in
      the compiler sources.
      
      In practical terms, this means that the values of BUILD, HOST & TARGET
      may vary depending on which part of the build tree we are in.
      
      Actual changes:
      
       - new file: includes/ghcplatform.h contains platform defines for
         the RTS and library code.
      
       - new file: includes/ghcautoconf.h contains the autoconf settings
         only (HAVE_BLAH).  This is so that we can get hold of these
         settings independently of the platform defines when necessary
         (eg. in GHC).
      
       - ghcconfig.h now #includes both ghcplatform.h and ghcautoconf.h.
      
       - MachRegs.h, which is included into both the compiler and the RTS,
         now has to cope with the fact that it might need to test either
         _TARGET_ or _HOST_ depending on the context.
      
       - the compiler's Makefile now generates
           stage{1,2,3}/ghc_boot_platform.h
         which contains platform defines for the compiler.  These differ
         depending on the stage, of course: in stage2, the HOST is the
         TARGET of stage1.  This was wrong before.
      
       - The compiler doesn't get platform info from Config.hs any more.
         Previously it did (sometimes), but unless we want to generate
         a new Config.hs for each stage we can't do this.
      
       - GHC now helpfully defines *_{BUILD,HOST}_{OS,ARCH} automatically
         in CPP'd Haskell source.
      
       - ghcplatform.h defines *_TARGET_* for backwards compatibility
         (ghcplatform.h is included by ghcconfig.h, which is included by
         config.h, so code which still #includes config.h will get the TARGET
         settings as before).
      
       - The Users's Guide is updated to mention *_HOST_* rather than
         *_TARGET_*.
      
       - coding-style.html in the commentary now contains a section on
         platform defines.  There are further doc updates to come.
      
      Thanks to Wolfgang Thaller for pointing me in the right direction.
      153b9cb9
  3. 27 Jan, 2005 10 commits
    • simonpj's avatar
      [project @ 2005-01-27 15:55:38 by simonpj] · b5dbb387
      simonpj authored
      Make -no-recomp a dynamic flag
      b5dbb387
    • simonpj's avatar
      [project @ 2005-01-27 15:53:38 by simonpj] · 8ec76b05
      simonpj authored
      Comments
      8ec76b05
    • simonpj's avatar
      [project @ 2005-01-27 15:53:08 by simonpj] · 2ec5498e
      simonpj authored
      Remove redundant parens in pretty print
      2ec5498e
    • simonpj's avatar
      [project @ 2005-01-27 15:52:09 by simonpj] · dd08967f
      simonpj authored
      Wibble
      dd08967f
    • simonpj's avatar
      [project @ 2005-01-27 15:51:11 by simonpj] · a4124cf4
      simonpj authored
      Add a rule for dataToTag (tagToEnum x)
      a4124cf4
    • simonmar's avatar
      [project @ 2005-01-27 14:38:29 by simonmar] · 2cf37ff9
      simonmar authored
      Fix explicit layout
      2cf37ff9
    • simonpj's avatar
      [project @ 2005-01-27 11:51:56 by simonpj] · 56f5bc18
      simonpj authored
      Import trimming
      56f5bc18
    • simonpj's avatar
      [project @ 2005-01-27 11:50:58 by simonpj] · 281bcf70
      simonpj authored
      Make sure that the interactive context can see home-package instances;
      I forgot to do this when making tcRnModule find the appropriate intances
      (TcRnDriver rev 1.91)
      
      This was causing SourceForge [ghc-Bugs-1106171].
      281bcf70
    • simonpj's avatar
      [project @ 2005-01-27 11:12:52 by simonpj] · 04864fb7
      simonpj authored
      Remove redundant .hi-boot files.  The earliest compiler we claim to be able
      to compile GHC with is GHC 5, and that needs hi-boot-5 boot files.  So the
      plain hi-boot files are dead.
      
      Reason for removing them now is that my big commit accidentally splatted
      them with binary data; so if you ever want to recover them, go back
      one revision beore the one I'm deleting.
      04864fb7
    • simonpj's avatar
      [project @ 2005-01-27 10:44:00 by simonpj] · 508a505e
      simonpj authored
      --------------------------------------------
                Replace hi-boot files with hs-boot files
        	--------------------------------------------
      
      This major commit completely re-organises the way that recursive modules
      are dealt with.
      
        * It should have NO EFFECT if you do not use recursive modules
      
        * It is a BREAKING CHANGE if you do
      
      ====== Warning: .hi-file format has changed, so if you are
      ======		updating into an existing HEAD build, you'll
      ======		need to make clean and re-make
      
      
      The details:  [documentation still to be done]
      
      * Recursive loops are now broken with Foo.hs-boot (or Foo.lhs-boot),
        not Foo.hi-boot
      
      * An hs-boot files is a proper source file.  It is compiled just like
        a regular Haskell source file:
      	ghc Foo.hs		generates Foo.hi, Foo.o
      	ghc Foo.hs-boot		generates Foo.hi-boot, Foo.o-boot
      
      * hs-boot files are precisely a subset of Haskell. In particular:
      	- they have the same import, export, and scoping rules
      	- errors (such as kind errors) in hs-boot files are checked
        You do *not* need to mention the "original" name of something in
        an hs-boot file, any more than you do in any other Haskell module.
      
      * The Foo.hi-boot file generated by compiling Foo.hs-boot is a machine-
        generated interface file, in precisely the same format as Foo.hi
      
      * When compiling Foo.hs, its exports are checked for compatibility with
        Foo.hi-boot (previously generated by compiling Foo.hs-boot)
      
      * The dependency analyser (ghc -M) knows about Foo.hs-boot files, and
        generates appropriate dependencies.  For regular source files it
        generates
      	Foo.o : Foo.hs
      	Foo.o : Baz.hi		-- Foo.hs imports Baz
      	Foo.o : Bog.hi-boot	-- Foo.hs source-imports Bog
      
        For a hs-boot file it generates similar dependencies
      	Bog.o-boot : Bog.hs-boot
      	Bog.o-boot : Nib.hi	-- Bog.hs-boto imports Nib
      
      * ghc -M is also enhanced to use the compilation manager dependency
        chasing, so that
      	ghc -M Main
        will usually do the job.  No need to enumerate all the source files.
      
      * The -c flag is no longer a "compiler mode". It simply means "omit the
        link step", and synonymous with -no-link.
      508a505e
  4. 26 Jan, 2005 3 commits
    • simonpj's avatar
      [project @ 2005-01-26 16:10:02 by simonpj] · 8254dcf1
      simonpj authored
      -----------------------
      	Fixup to hoistForAllTys
      	-----------------------
      
      * hoistForAllTys moves from TcHsType to TcType
      
      hoistForAllTys was being too vigorous and breaking up type synonyms,
      even when it was entirely unnecessary to do so.
      
      Not only does this make error messsages less good, but it's actually
      wrong for Haskell 98, because we are meant to report under-applied
      type synonyms, and that check doesn't happen until after hoistForAllTys.
      This led to a very obscure bug, immortalised as tcfail129.
      8254dcf1
    • simonmar's avatar
      [project @ 2005-01-26 15:04:08 by simonmar] · ed009da3
      simonmar authored
      Remove System.FilePath, use System.Directory.Internals for now.
      ed009da3
    • simonmar's avatar
      [project @ 2005-01-26 12:58:09 by simonmar] · 66797dc0
      simonmar authored
      fileLoop: catch InvalidArgument and behave as for EOF (i.e. terminate
      the session).  This means that the user can close stdin to end a GHCi
      session, but it also means that the tests that run programs which use
      getContents inside GHCi won't crash because stdin has been closed.
      66797dc0
  5. 23 Jan, 2005 2 commits
    • wolfgang's avatar
      [project @ 2005-01-23 18:50:40 by wolfgang] · e171a977
      wolfgang authored
      Make the NCG distinguish between the read-only data section and the
      "relocatable read-only data" section.
      Read-only data is supposed to be _really_ read-only, whereas "relrodata"
      can have relocations, but should not be modified by the program at runtime.
      
      For Linux, put relrodata into ".data" by default, as the dynamic linker
      tends to do evil things to avoid relocating things in read-only sections.
      e171a977
    • wolfgang's avatar
      [project @ 2005-01-23 06:10:15 by wolfgang] · 6f985ae8
      wolfgang authored
      Add support for the dead code stripping feature of recent Apple linkers.
      If your code is compiled using the NCG, you can now specify
      -optl-W,-dead_strip on the GHC command line when linking.
      It will have basically the same effect as using split-objs to build the
      libraries.
      
      Advantages over split-objs:
          * No evil perl script involved
          * Requires no special handling when building libraries
      
      Disadvantages:
          * The current version of Apple's linker is slow when given the
            -dead_strip flag. _REALLY_ slow.
          * Mac OS X only.
      
      This works by making the NCG emit the .subsections_via_symbols directive.
      Additionally, we have to add an extra label at the top of every info table,
      and make sure that the entry code references it (otherwise the info table
      will be considered part of the preceding entry code).
      The mangler just removes the .subsections_via_symbols directive.
      6f985ae8
  6. 21 Jan, 2005 1 commit
    • simonmar's avatar
      [project @ 2005-01-21 16:02:47 by simonmar] · 3f205c43
      simonmar authored
      Don't try to run finalizers at program exit.  This turned out to be
      hard if not impossible to do in general, so now we don't attempt it at
      all.
      
      The Main.main wrapper, previously called runIO and now called
      runMainIO, flushes stdout and stderr before exiting.  This should
      catch most cases where programs rely on Handles being flushed at
      program exit, but note that now if you simply drop a Handle in your
      program, there's no guarantee it'll be flushed on exit.  If the
      punters complain enough, I suppose we could implement a global
      Handle table and flush them all at exit... I'd rather not do this if
      possible, though.  Better to teach people to close their Handles
      properly.
      3f205c43
  7. 20 Jan, 2005 2 commits
    • simonmar's avatar
      [project @ 2005-01-20 14:22:19 by simonmar] · c830ae13
      simonmar authored
      Fill in the haddock-interfaces and haddock-html fields in the
      package.conf files.
      
      To do this I had to make some changes:
      
        - haddock-interfaces requires the value of $(datadir).  We can't
          just plug this in, because $(datadir) might change at install-time
          (eg. a Windows installer can be placed anywhere, as can a Unix
          binary .tar.gz distribution).  The current trick is for the
          compiler to splice in the value of $libdir in package.conf at
          runtime.  So we could extend this mechanism and tell the compiler
          the value of $datadir via a command-line option, but that seems
          ugly.
      
          On Windows, $datadir==$libdir, so we don't need any changes:
          package.conf still uses $libdir, and a Windows installation is
          independent of its absolute location.  Even 'make install' on
          Windows should have this property.
      
          On Unix:
      	- for 'make install' and in-place execution, we just use
                absolute paths in package.conf
      
      	- for a binary dist, we generate a package.conf that refers
      	  to $libdir and $datadir, and splice in the values at
      	  install-time (distrib/Makefile-bin.in).
      
        - Also, I renamed $libdir to $topdir to more closely reflect its
          actual meaning.  This is somewhat malicious in that it will flush
          out all those clients using $libdir when they really shouldn't
          be :-)
      c830ae13
    • simonpj's avatar
      [project @ 2005-01-20 12:02:06 by simonpj] · 850ee50c
      simonpj authored
      Fix syntax error
      850ee50c
  8. 18 Jan, 2005 3 commits
    • simonpj's avatar
      [project @ 2005-01-18 15:58:12 by simonpj] · 4a667166
      simonpj authored
      Wibble
      4a667166
    • simonmar's avatar
      [project @ 2005-01-18 13:51:28 by simonmar] · 79a733f5
      simonmar authored
      Update a comment
      79a733f5
    • simonpj's avatar
      [project @ 2005-01-18 12:18:11 by simonpj] · ac80e0de
      simonpj authored
      ------------------------
          Reorganisation of hi-boot files
        	------------------------
      
      The main point of this commit is to arrange that in the Compilation
      Manager's dependendency graph, hi-boot files are proper nodes. This
      is important to make sure that we compile everything in the right
      order.  It's a step towards hs-boot files.
      
      * The fundamental change is that CompManager.ModSummary has a new
        field, ms_boot :: IsBootInterface
      
        I also tided up CompManager a bit.  No change to the Basic Plan.
      
        ModSummary is now exported abstractly from CompManager (was concrete)
      
      * Hi-boot files now have import declarations.  The idea is they are
        compulsory, so that the dependency analyser can find them
      
      * I changed an invariant: the Compilation Manager used to ensure that
        hscMain was given a HomePackageTable only for the modules 'below' the
        one being compiled.  This was really only important for instances and
        rules, and it was a bit inconvenient.  So I moved the filter to the
        compiler itself: see HscTypes.hptInstances and hptRules.
      
      * Module Packages.hs now defines
          data PackageIdH
          = HomePackage 		-- The "home" package is the package
       				-- curently being compiled
          | ExtPackage PackageId	-- An "external" package is any other package
      
         It was just a Maybe type before, so this makes it a bit clearer.
      
      * I tried to add a bit better location info to the IfM monad, so that
        errors in interfaces come with a slightly more helpful error message.
        See the if_loc field in TcRnTypes --- and follow-on consequences
      
      * Changed Either to Maybes.MaybeErr in a couple of places (more perspicuous)
      ac80e0de
  9. 17 Jan, 2005 1 commit
  10. 16 Jan, 2005 2 commits
    • wolfgang's avatar
      [project @ 2005-01-16 05:31:39 by wolfgang] · 7a1b0a6c
      wolfgang authored
      A first stab at position independent code generation for i386-linux.
      It doesn't work yet, but it shouldn't break anything.
      
      What we need now is one or both of the following:
      a) A volunteer to implement PIC for x86 -fvia-C
          (I definitely refuse to touch any piece of code that contains
           both Perl and x86 assembly).
      b) A volunteer to improve the NCG to the point where it can compile
         the RTS (so we won't need point a).
      7a1b0a6c
    • wolfgang's avatar
      [project @ 2005-01-16 02:50:16 by wolfgang] · e195ea85
      wolfgang authored
      pprExpr: add cases for CmmPicBaseReg and CmmRegOff
      so that we can do -fPIC -ddump-opt-cmm
      e195ea85
  11. 14 Jan, 2005 6 commits
    • wolfgang's avatar
      [project @ 2005-01-14 22:47:29 by wolfgang] · 05990bef
      wolfgang authored
      Fix a typo in the previous commit.
      05990bef
    • wolfgang's avatar
      [project @ 2005-01-14 22:12:54 by wolfgang] · acea64ed
      wolfgang authored
      When -dynamic is specified but -fPIC is not, generate code that works around
      the ELF dynamic linker's misguided attempts to keep the main program unaware
      of dynamic linking.
      
      This involves generating indirect references and computed jumps for position
      dependent code, too, and making all constant data sections writable in order
      to persuade ld to not use "COPY" relocations.
      
      Tested on powerpc-linux; in theory, it also applies to i386-linux, but other
      parts of the PIC story are missing there.
      
      Note that the writable-const-data hack could be improved a bit by
      distinguishing between "really" constant data and "relocatable" constant data,
      which would be a nice thing to do anyway.
      acea64ed
    • simonmar's avatar
      [project @ 2005-01-14 17:57:41 by simonmar] · c464eda3
      simonmar authored
      HEADS UP!  You now need to use an up to date Happy from CVS to build
      GHC.  Happy version 1.15 will be released shortly.
      
      Replace the slow hacked up String-based GetImports with one based on
      the real Haskell parser.  This requires a new addition to Happy to
      support parsing partial files.  We now avoid reading each source file
      off the disk twice: once to get its module name and imports, and again
      to parse it.  Instead we just slurp it once, and cache the StringBuffer.
      
      This should result in improved startup times for ghc --make,
      especially when there are lots of source files.
      c464eda3
    • simonmar's avatar
      [project @ 2005-01-14 11:46:24 by simonmar] · 5155d694
      simonmar authored
      hGetStringBuffer: hClose the file after we've read it (duh).  This
      causes a real problem on Windows, where the file remains locked in
      GHCi, and cannot be modified until after the finalizer has closed it
      (bug #1047408).
      5155d694
    • simonmar's avatar
      [project @ 2005-01-14 11:34:44 by simonmar] · 20b21f5b
      simonmar authored
      retire $(compiling_with_4xx): we don't support compiling with 4.x any more
      20b21f5b
    • wolfgang's avatar
      [project @ 2005-01-14 08:01:26 by wolfgang] · 4f457f34
      wolfgang authored
      Dynamic Linking, Part 2:
      
      Hack the Makefiles to build dynamic libraries.
      This allows you to actually use dynamic libraries to greatly reduce binary
      sizes on Darwin/PowerPC and on powerpc64-linux (for now).
      
      To use this, add the following to your build.mk
      
      SplitObjs=NO
      GhcBuildDylibs=YES
      GhcStage2HcOpts=-dynamic
      GhcLibHcOpts+=-fPIC -dynamic
      GhcRtsHcOpts+=-fPIC -dynamic
      GHC_CC_OPTS+=-fPIC
      
      (You can leave out the last three lines on powerpc64-linux).
      
      Then, to compile a program using dynamic libraries, pass the -dynamic option to GHC.
      To make GHCi use the dynamic libraries instead of .o files, just delete the HS*.o files.
      
      The dynamic library files are named libHSfoo_dyn.dylib or libHSfoo_dyn.so.
      
      Note that the dynamic and static libraries are build from the same .o files,
      but we really want to build the static libraries with SplitObjs and without
      -fPIC -dynamic to achieve better code size and performance.
      
      ghc/compiler/ghci/Linker.lhs:
          When looking for a library, look for HSfoo.o first (as before),
          then look for libHSfoo_dyn.[so/dylib] before looking for
          libHSfoo.[so/dylib].
      
      ghc/compiler/main/DriverPipeline.hs:
          Main.dll_o and PrelMain.dll_o are dead, at least for now.
      
      ghc/compiler/main/Packages.lhs:
          When -dynamic is specified, add "_dyn" to all libraries specified in
          hs-libraries (not to the extra-libs).
      
      ghc/lib/compat/Makefile:
          Never build libghccompat as a dynamic lib.
      
      mk/package.mk:
          if GhcBuildDylibs is set to YES, build dynamic libraries.
      
      mk/target.mk:
          When installing .dylibs (Darwin only), update the install_name to point
          to the final location.
          (Somebody please read Apple's documentation on what install_names are,
          and then comment on whether this is a useful feature or whether it should
          be done the "normal" unix way).
      4f457f34