[project @ 2004-11-11 09:46:54 by simonmar]
[ghc-hetmet.git] / ghc / compiler / main / DriverPipeline.hs
index c3ad556..4e9e252 100644 (file)
@@ -137,6 +137,15 @@ compile hsc_env this_mod location src_timestamp
 
    let (basename, _) = splitFilename input_fn
        
+  -- We add the directory in which the .hs files resides) to the import path.
+  -- This is needed when we try to compile the .hc file later, if it
+  -- imports a _stub.h file that we created here.
+   let current_dir = directoryOf basename
+   old_paths <- readIORef v_Include_paths
+   writeIORef v_Include_paths (current_dir : old_paths)
+   -- put back the old include paths afterward.
+   later (writeIORef v_Include_paths old_paths) $ do
+
    -- figure out what lang we're generating
    hsc_lang <- hscMaybeAdjustLang (hscLang dyn_flags)
    -- figure out what the next phase should be
@@ -688,14 +697,6 @@ runPhase cc_phase basename suff input_fn get_output_fn maybe_loc
         pkg_include_dirs <- getPackageIncludePath pkgs
         let include_paths = foldr (\ x xs -> "-I" : x : xs) []
                              (cmdline_include_paths ++ pkg_include_dirs)
-                           ++ ["-I-"]
-               -- We add the flag -I- after all the include paths.
-               -- According to the gcc docs, this causes all -I paths
-               -- up to this point apply only to #include "..."
-               -- style includes.  This prevents accidentally
-               -- shadowing a system include (eg. #include <stdio.h>)
-               -- by putting a file of the same name in the current
-               -- directory, for example.
 
        mangle <- readIORef v_Do_asm_mangling
        (md_c_flags, md_regd_c_flags) <- machdepCCOpts