[project @ 2000-05-31 10:13:57 by lewie]
[ghc-hetmet.git] / ghc / driver / ghc.lprl
index 299798d..b292910 100644 (file)
@@ -158,7 +158,14 @@ $SIG{'QUIT'} = 'quit_upon_signal';
                           : "$TopPwd/${CURRENT_DIR}" );
 
 if ( $ENV{'TMPDIR'} ) { # where to make tmp file names
-    $Tmp_prefix = ($ENV{'TMPDIR'} . "/ghc$$");
+    # Try to find a $Tmp_prefix which isn't being used...
+    $tmp = $$;
+    do {
+      $Tmp_prefix = ($ENV{'TMPDIR'} . "/ghc$tmp");
+      $tmp++;
+    } while ( -e "$Tmp_prefix.hc" ||
+             -e "$Tmp_Prefix.s"  || 
+             -e "$Tmp_Prefix.hi" );
 } else {
     print STDERR "TMPDIR has not been set to anything useful!\n" if (${TMPDIR} eq '');
     $Tmp_prefix ="${TMPDIR}/ghc$$"; # TMPDIR set via Makefile when booting..
@@ -277,6 +284,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.
 
@@ -285,6 +293,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',
@@ -469,9 +478,8 @@ $HscLang = 'C';     # 'C'    ==> .hc output;
                        # 'java' ==> .java output
                        # 'none' ==> no code output
 $HscLang = 'asm'
-    if ($HaveNativeCodeGen ne 'YES') && $TargetPlatform =~ /^(alpha)-/;
+    if ($HaveNativeCodeGen eq 'YES') && $TargetPlatform =~ /^(i386)-/;
 
-# TEMP: disable x86 & Sparc if $HaveNativeCodeGen && $TargetPlatform =~ /^(i386|alpha|sparc)-/;
 $ProduceHi    = '-hifile=';
 $HiOnStdout   = 0;
 $HiWith       = '';
@@ -1108,6 +1116,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"
        ));
@@ -1144,7 +1153,6 @@ sub setupIncPaths {
       push (@Include_dir, "$TopPwd/${CURRENT_DIR}/${GHC_INCLUDE_DIR}");
   } else {
       push (@Include_dir, "$InstLibDirGhc/includes");
-      push (@Include_dir, "$InstLibDirGhc/includes");
   }
 } # end of setupIncPaths
 \end{code}
@@ -1413,9 +1421,9 @@ Again, we'll do the post-recompilation-checker parts of this later.
                             ( $HscLang eq 'java' ) ? "java" : 
                                "" ;
     
-    local($hsc_out)       = $Tmp_prefix.$hsc_out_suffix ;
-    local($hsc_out_c_stub) = ( $HscLang eq 'C' ) ? "${Tmp_prefix}_stb.c" : "";
-    local($hsc_out_h_stub) = ( $HscLang eq 'C' ) ? "${Tmp_prefix}_stb.h" : "";
+    local($hsc_out)       = "$Tmp_prefix.$hsc_out_suffix" ;
+    local($hsc_out_c_stub) = "${Tmp_prefix}_stb.c";
+    local($hsc_out_h_stub) = "${Tmp_prefix}_stb.h";
 
     if ($Only_preprocess_hc) { # stop after having run $Cc -E
        $do_as=0;
@@ -1498,17 +1506,6 @@ Now the Haskell compiler, C compiler, and assembler
     }
 
     if (-f $hsc_out_c_stub) {
-       &run_something("rm -f $ofile_c_stub_target && echo '#include \"${ofile_h_stub_target}\"' > $ofile_c_stub_target && cat $hsc_out_c_stub >> $ofile_c_stub_target", 'Copy foreign export C stubs');
-       local ($hsc_out_s_stub);
-       local ($hsc_out_o_stub);
-       ($ofile_s_stub_target = $ofile_c_stub_target) =~ s/\.(.*)$/\.s/;
-       ($ofile_o_stub_target = $ofile_c_stub_target) =~ s/\.(.*)$//;
-
-        $ofile_o_stub_target = &osuf_ify($ofile_o_stub_target, "o");
-       if ($do_cc) {
-         &runGcc    (0, $ofile_c_stub_target, $ofile_s_stub_target);
-          &runAs     ($ofile_o_stub_target, $ofile_s_stub_target);
-       }
        #
        # Bring the C stub protos into scope when compiling the .hc file.
        #
@@ -1516,7 +1513,6 @@ Now the Haskell compiler, C compiler, and assembler
        # Hack - ensure that the stub .h file is included in the OPTIONS section
        #        if the .hc file is saved.
        push (@File_options, "-#include \"${ofile_h_stub_target}\"\n");
-       
     }
 
     if ($do_cc) {
@@ -1529,6 +1525,21 @@ Now the Haskell compiler, C compiler, and assembler
     # save a copy of the .s file..
     &saveIntermediate($ifile_root , "s" , $cc_as) if ($do_as && $Keep_s_file_too);
     &runAs($as_out, $ifile_root) if $do_as;
+
+    if (-f $hsc_out_c_stub) {
+       &run_something("rm -f $ofile_c_stub_target && echo '#include \"${ofile_h_stub_target}\"' > $ofile_c_stub_target && cat $hsc_out_c_stub >> $ofile_c_stub_target", 'Copy foreign export C stubs');
+       local ($hsc_out_s_stub);
+       local ($hsc_out_o_stub);
+       ($ofile_s_stub_target = $ofile_c_stub_target) =~ s/\.(.*)$/\.s/;
+       ($ofile_o_stub_target = $ofile_c_stub_target) =~ s/\.(.*)$//;
+
+        $ofile_o_stub_target = &osuf_ify($ofile_o_stub_target, "o");
+       if ($do_cc || $do_as) {  # might be using NCG, so check $do_as
+         &runGcc    (0, $ofile_c_stub_target, $ofile_s_stub_target);
+          &runAs     ($ofile_o_stub_target, $ofile_s_stub_target);
+       }
+    }
+
 \end{code}
 
 Finally, decide what to queue up for linker input.
@@ -1673,7 +1684,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;
@@ -1710,10 +1721,14 @@ 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 ) {
@@ -2541,7 +2556,7 @@ sub add_syslib {
               : "$TopPwd/hslibs/concurrent"
          )
        , '' # where to find the cbits archive to use when linking
-       , '' # Syslib dependencies
+       , 'lang' # Syslib dependencies
        , '' # extra ghc opts
        , '' # extra cc opts
        , '' # extra ld opts
@@ -2613,7 +2628,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 
@@ -2647,7 +2662,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
@@ -3267,7 +3282,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");
@@ -3408,7 +3429,7 @@ arg: while($_ = $Args[0]) {
                local($opt_lev) = ( /^-O2$/ ) ? 2 : 1; # max 'em
                $OptLevel = ( $opt_lev > $OptLevel ) ? $opt_lev : $OptLevel;
 
-               $HscLang = 'C' if $OptLevel == 2; # force use of C compiler
+               $HscLang = 'C';  # force use of C compiler
                next arg; };
 
     /^-Onot$/  && do { $OptLevel = 0; next arg; }; # # set it to <no opt>