[project @ 2000-06-13 15:35:29 by simonm]
[ghc-hetmet.git] / ghc / driver / ghc.lprl
index 7ec0015..0568a0d 100644 (file)
@@ -233,7 +233,6 @@ These are the default values, which may be changed by user flags.
 \begin{code}
 sub setupOptFlags {
    $Oopt_MaxSimplifierIterations  = '-fmax-simplifier-iterations4';
-   $Oopt_PedanticBottoms         = '-fpedantic-bottoms'; # ON by default
    $Oopt_FinalStgProfilingMassage = '';
    $Oopt_StgStats                = '';
    $Oopt_DoSpecialise            = '-fspecialise';
@@ -253,7 +252,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, 
@@ -284,6 +283,7 @@ warnings that you get all the time are
        -fwarn-missing-fields
        -fwarn-deprecations
        -fwarn-duplicate-exports
+       -fwarn-hi-shadowing
 
 these are turned off by -Wnot.
 
@@ -292,6 +292,7 @@ these are turned off by -Wnot.
                     '-fwarn-missing-methods',
                     '-fwarn-missing-fields',
                     '-fwarn-deprecations',
+# DISABLE DUE TO DUPLICATE INCLUDE PATHS (ToDo): '-fwarn-hi-shadowing',
                     '-fwarn-duplicate-exports');
 @MinusWOpts              = (@StandardWarnings, 
                     '-fwarn-unused-binds',
@@ -523,6 +524,9 @@ $NoImplicitPrelude = 0;
 # external main is provided instead.
 $NoHaskellMain=0;
 
+# Hash to keep track of 
+%Syslibs_added = ();
+
 } # end of initDriverGlobals (Sigh)
 
 # we split the argv passed to the driver into three:
@@ -714,7 +718,6 @@ sub setupOptimiseFlags {
        '-fcase-of-case',
        '-fcase-merge',
        '-flet-to-case',
-       $Oopt_PedanticBottoms,
 
        # initial simplify: mk specialiser happy: minimum effort please
 
@@ -815,7 +818,7 @@ sub setupOptimiseFlags {
 
 #      ( ($OptLevel != 2)
 #        ? ''
-#      : "-fliberate-case -fsimplify [ $Oopt_FB_Support -ffloat-lets-exposing-whnf -ffloat-primops-ok -fcase-of-case -fdo-case-elim -fcase-merge -fdo-lambda-eta-expansion -freuse-con -flet-to-case $Oopt_PedanticBottoms $Oopt_MaxSimplifierIterations $Oopt_ShowSimplifierProgress ]" ),
+#      : "-fliberate-case -fsimplify [ $Oopt_FB_Support -ffloat-lets-exposing-whnf -ffloat-primops-ok -fcase-of-case -fdo-case-elim -fcase-merge -fdo-lambda-eta-expansion -freuse-con -flet-to-case $Oopt_MaxSimplifierIterations $Oopt_ShowSimplifierProgress ]" ),
 
 #      '-fliberate-case',
 
@@ -1114,6 +1117,7 @@ sub setupLinkOpts {
           ,'-u', "${uscore}PrelException_NonTermination_closure"
           ,'-u', "${uscore}PrelException_PutFullMVar_closure"
           ,'-u', "${uscore}PrelException_BlockedOnDeadMVar_closure"
+          ,'-u', "${uscore}PrelWeak_runFinalizzerBatch_closure"
           ,'-u', "${uscore}__init_Prelude"
           ,'-u', "${uscore}__init_PrelMain"
        ));
@@ -1681,7 +1685,7 @@ sub runHscAndProcessInterfaces {
    # See if it bailed out early, saying nothing needed doing.  
    # We work this out by seeing if it created an output .hi file
 
-    if ( ! -f $hsc_hi && $ProduceHi !~ /-nohifile=/ ) {
+    if ( ! -f $hsc_out ) {
        # Doesn't exist, so we bailed out early.
        # Tell the C compiler and assembler not to run
        $do_cc = 0; $do_as = 0;
@@ -1718,15 +1722,13 @@ sub runHscAndProcessInterfaces {
 
 
        # Interface-handling is important enough to live off by itself
-        if ( $ProduceHi !~ /-nohifile=/ ) { # If we've produced one, process it.
-          require('ghc-iface.prl') || &tidy_up_and_die(1,"$Pgm: panic: can't load ghc-iface.prl!\n");
-          &postprocessHiFile($hsc_hi, $hifile_target, $going_interactive);
+       if ( -f $hsc_hi ) {
+               # print STDERR "Aha! A new hi file\n" ;
+               &run_something( "mv $hsc_hi $hifile_target", "Copy hi file" ) ;
+       } else {
+               # print STDERR "Oh ho! Hi file unchanged\n" ;
        }
-       # if we're going to split up object files,
-       # we inject split markers into the .hc file now
-       if ( $HscLang eq 'C' && $SplitObjFiles ) {
-           &inject_split_markers ( $hsc_out );
-        }
+
 
        # save a copy of the .hc file, even if we are carrying on...
        if ($HscLang eq 'C' && $do_cc && $Keep_hc_file_too) {
@@ -2113,11 +2115,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.
@@ -2507,9 +2505,6 @@ to the syslib family. The info bit consist of the following:
 
 \begin{code}
 
-# Hash to keep track of 
-%Syslibs_added = ();
-
 sub add_syslib {
     local($syslib) = @_;
 
@@ -2621,7 +2616,7 @@ sub add_syslib {
        [  # where to slurp interface files from
          ( $INSTALLING 
               ? "$InstLibDirGhc/imports/text"
-              : "$TopPwd/hslibs/text:$TopPwd/hslibs/text/html:$TopPwd/hslibs/text/haxml/lib"
+              : "$TopPwd/hslibs/text:$TopPwd/hslibs/text/html:$TopPwd/hslibs/text/haxml/lib:$TopPwd/hslibs/text/parsec"
          )
        , # where to find the archive to use when linking
          ( $INSTALLING 
@@ -2655,7 +2650,7 @@ sub add_syslib {
               ? "$InstLibDirGhc"
               : "$TopPwd/hslibs/util/cbits"
          )
-       , 'lang concurrent posix' # Syslib dependencies
+       , 'lang concurrent' . (( $TargetPlatform =~ /^.*(cygwin32|mingw32)$/ ) ? '' : ' posix' ) # Syslib dependencies
        , ''     # extra ghc opts
        , ''     # extra cc opts
        , "$LibsReadline"     # extra ld opts
@@ -2673,12 +2668,30 @@ sub add_syslib {
               : "$TopPwd/hslibs/win32/src"
          )
        , ''
-       , 'lang' # Syslib dependencies
+       , 'lang greencard' # Syslib dependencies
        , ''     # extra ghc opts
        , ''     # extra cc opts
        , '-luser32 -lgdi32'     # extra ld opts
        ],
 
+       greencard,
+        [  # where to slurp interface files from
+          ( $INSTALLING
+               ? "$InstLibDirGhc/imports/greencard"
+               : "$TopPwd/green-card/lib/ghc"
+          )
+        , # where to find the archive to use when linking
+          ( $INSTALLING
+               ? "$InstLibDirGhc"
+               : "$TopPwd/green-card/lib/ghc"
+          )
+        , ''     # No cbits archive
+        , 'lang' # Syslib dependencies
+        , ''     # extra ghc opts
+        , ''     # extra cc opts
+        , ''     # extra ld opts
+        ],
+
        com,
        [  # where to slurp interface files from
          ( $INSTALLING 
@@ -2707,6 +2720,12 @@ sub add_syslib {
        return;
     }
 
+    # Make sure that header file HsFoo.h is included for syslib foo.
+    if ( !exists $Syslibs_added{$syslib} ) {
+      push(@CcInjects, "#include \"Hs\u$syslib.h\"\n");
+      push(@Include_dir, "$TopPwd/hslibs/$syslib/cbits") unless ( $INSTALLING );
+    }
+
     # 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,
@@ -3205,14 +3224,20 @@ arg: while($_ = $Args[0]) {
     /^-fallow-undecidable-instances$/ && do { push(@HsC_flags, $_); next arg; };
     /^-fhistory-size.*$/             && do { push(@HsC_flags, $_); next arg; };
     /^-fdicts-strict$/                       && do { push(@HsC_flags, $_); next arg; };
+
     /^-fglasgow-exts$/
                && do { push(@HsC_flags, $_);
 
-                       # -fglasgow-exts implies -syslib lang
+                       # -fglasgow-exts implies -package lang
                        &add_syslib('lang');
 
                        next arg; };
 
+       # for compiling lib/std we can't add the implicit package lang,
+       # because it isn't built yet.
+    /^-fglasgow-exts-no-lang$/
+               && do { push(@HsC_flags, "-fglasgow-exts"); next arg; };
+
     /^-fspeciali[sz]e$/
                && do { $Oopt_DoSpecialise = '-fspecialise'; next arg; };
     /^-fno-speciali[sz]e$/
@@ -3222,8 +3247,6 @@ arg: while($_ = $Args[0]) {
                 && do {  $Oopt_UsageSPInf = '-fusagesp';
                          push (@HsC_flags, '-fusagesp-on'); next arg; };
 
-    /^-fcompiling-prelude$/ && do { $CompilingPrelude=1; push(@HsC_flags, $_); next arg; };
-
 # Now the foldr/build options, which are *on* by default (for -O).
 
     /^-ffoldr-build$/
@@ -3261,9 +3284,6 @@ arg: while($_ = $Args[0]) {
                    && do { $Oopt_MaxSimplifierIterations = $1 . &grab_arg_arg(*Args,$1, $2);
                            next arg; };
 
-    /^-fno-pedantic-bottoms$/
-                   && do { $Oopt_PedanticBottoms = ''; next arg; };
-
     /^-fno-pre-inlining$/
                    && do { push(@HsC_flags, $_); next arg };
 
@@ -3275,7 +3295,13 @@ arg: while($_ = $Args[0]) {
 
     # --------------- Warnings etc. ------
 
-    /^-fwarn-(.*)$/      && do { push(@HsC_flags, $_); next arg; };
+    /^-fwarn-(.*)$/ && do { if (!grep(/$1/,@MinusWallOpts)) {
+                               print STDERR "$Pgm: unrecognised warning option: $_\n";
+                               $Status++;
+                           } else {                            
+                               push(@HsC_flags, $_); 
+                           }
+                           next arg; };
 
     /^-fno-(.*)$/   && do { push(@HsC_antiflags, "-f$1");
                            &squashHscFlag("-f$1");