[project @ 2000-05-31 11:58:27 by panne]
authorpanne <unknown>
Wed, 31 May 2000 11:58:27 +0000 (11:58 +0000)
committerpanne <unknown>
Wed, 31 May 2000 11:58:27 +0000 (11:58 +0000)
Trying to get the whole #include business right: ccalls are unfolded
into interface files, even without -funfold-casms-in-hi-file. Although
this is a good thing performance-wise, the header files should better
be #included during compilation of the .hc files. Solution:

   * Every .hc file #includes "Stg.h" first.

   * For every package `foo' used, "HsFoo.h" is #included, too. This
     means that every package has to come with a corresponding header
     file, even if it is empty.

Downside:

   * Getting #includes right with ghc-inplace is a little bit ugly:
     The boot target in Makefiles must copy the package's header files
     into GHC_INCLUDE_DIR (don't forget the clean target!), and final
     installation of those headers is done there, too.   :-P  Better
     solutions are highly welcome.

   * Possible pollution of the C name spaces.

ghc/driver/ghc.lprl

index b292910..38c8da2 100644 (file)
@@ -253,7 +253,7 @@ problems, so I'm turing on the warnings -- SDM 4/5/98)
 \begin{code}
 $CcRegd                = $GHC_OPT_HILEV_ASM;
 @CcBoth_flags  = ('-S','-Wimplicit');   # flags for *any* C compilation
-@CcInjects     = ();
+@CcInjects     = ("#include \"Stg.h\"\n", "#include \"HsStd.h\"\n");
 
 # GCC flags: 
 #    those for all files, 
@@ -2120,11 +2120,7 @@ sub runGcc {
     # a tmp .c file which #include's the needful.
     open(TMP, "> $cc_help") || &tidy_up_and_die(1,"$Pgm: failed to open `$cc_help' (to write)\n");
     if ( $is_hc_file ) {
-       print TMP <<EOINCL;
-#include "Stg.h"
-EOINCL
-       # user may have asked for #includes to be injected...
-       print TMP @CcInjects if $#CcInjects >= 0;
+       print TMP @CcInjects;
     } else {
        # Straight .c files may want to know that they're being used
        # with a particular version of GHC, so we define __GLASGOW_HASKELL__ for their benefit.
@@ -2714,6 +2710,9 @@ sub add_syslib {
        return;
     }
 
+    # Make sure that header file HsFoo.h is included for syslib foo.
+    push(@CcInjects, "#include \"Hs\u$syslib.h\"\n") unless ( exists $Syslibs_added{$syslib} );
+
     # This check is here to avoid syslib loops from
     # spoiling the party. A side-effect of it is that
     # it disallows multiple mentions of a syslib on a command-line,