[project @ 2000-05-16 09:08:03 by simonmar]
[ghc-hetmet.git] / ghc / driver / ghc.lprl
index 5d42b0c..7ec0015 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..
@@ -469,9 +476,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       = '';
@@ -1144,7 +1150,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}
@@ -1414,8 +1419,8 @@ Again, we'll do the post-recompilation-checker parts of this later.
                                "" ;
     
     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_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 +1503,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 +1510,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 +1522,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.
@@ -2541,7 +2549,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
@@ -3408,7 +3416,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>