From b89ad0e9ba8633987a0163aa94fed82f7cd56c67 Mon Sep 17 00:00:00 2001 From: panne Date: Sun, 3 Oct 2004 16:28:06 +0000 Subject: [PATCH] [project @ 2004-10-03 16:28:02 by panne] Improved #include path handling: * Don't use '-I-', it breaks a lot of system headers, e.g. #include fails (when using freeglut), because /usr/include/GL/glut.h contains #include "freeglut_std.h" but /usr/include/GL/freeglut_std.h will not be found. It is a bit debatable if the header is broken and should use #include "GL/freeglut_std.h" instead. Anyway, a grep through the SuSE 9.1 system headers shows that there seems to be no real common practice, so let's play safe and don't use '-I-'. * Don't use '-I .', #include stub headers "locally" instead, e.g. use #include "Concurrent_stub.h" instead of #include "Control/Concurrent_stub.h" Note that "Control" is still in the #include path, because the *.hc file is normally in /tmp and the stub header is in the directory where *.hs is. We could remove this path element, too, if the stub header would be copied to the directory of the *.hc file during compilation. SimonM? --- ghc/compiler/main/CodeOutput.lhs | 3 ++- ghc/compiler/main/DriverPipeline.hs | 8 -------- ghc/compiler/main/DriverState.hs | 2 +- ghc/compiler/main/DriverUtil.hs | 11 ++++++++--- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/ghc/compiler/main/CodeOutput.lhs b/ghc/compiler/main/CodeOutput.lhs index edf56d5..a1e4a08 100644 --- a/ghc/compiler/main/CodeOutput.lhs +++ b/ghc/compiler/main/CodeOutput.lhs @@ -28,6 +28,7 @@ import PprC ( writeCs ) import CmmLint ( cmmLint ) import Packages import DriverState ( getExplicitPackagesAnd, getPackageCIncludes ) +import DriverUtil ( filenameOf ) import FastString ( unpackFS ) import Cmm ( Cmm ) import HscTypes @@ -151,7 +152,7 @@ outputC dflags filenm flat_absC hPutStr h ("/* GHC_PACKAGES " ++ unwords pkg_names ++ "\n*/\n") hPutStr h cc_injects when stub_h_exists $ - hPutStrLn h ("#include \"" ++ (hscStubHOutName dflags) ++ "\"") + hPutStrLn h ("#include \"" ++ (filenameOf (hscStubHOutName dflags)) ++ "\"") writeCs h flat_absC \end{code} diff --git a/ghc/compiler/main/DriverPipeline.hs b/ghc/compiler/main/DriverPipeline.hs index c3ad556..0116aee 100644 --- a/ghc/compiler/main/DriverPipeline.hs +++ b/ghc/compiler/main/DriverPipeline.hs @@ -688,14 +688,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 ) - -- 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 diff --git a/ghc/compiler/main/DriverState.hs b/ghc/compiler/main/DriverState.hs index a34d4a1..1efafd2 100644 --- a/ghc/compiler/main/DriverState.hs +++ b/ghc/compiler/main/DriverState.hs @@ -202,7 +202,7 @@ split_marker = ':' -- not configurable (ToDo) v_Import_paths, v_Include_paths, v_Library_paths :: IORef [String] GLOBAL_VAR(v_Import_paths, ["."], [String]) -GLOBAL_VAR(v_Include_paths, ["."], [String]) +GLOBAL_VAR(v_Include_paths, [], [String]) GLOBAL_VAR(v_Library_paths, [], [String]) #ifdef darwin_TARGET_OS diff --git a/ghc/compiler/main/DriverUtil.hs b/ghc/compiler/main/DriverUtil.hs index f1d61e4..484c024 100644 --- a/ghc/compiler/main/DriverUtil.hs +++ b/ghc/compiler/main/DriverUtil.hs @@ -1,5 +1,5 @@ ----------------------------------------------------------------------------- --- $Id: DriverUtil.hs,v 1.44 2004/09/30 10:37:11 simonpj Exp $ +-- $Id: DriverUtil.hs,v 1.45 2004/10/03 16:28:06 panne Exp $ -- -- Utils for the driver -- @@ -15,8 +15,8 @@ module DriverUtil ( split, add, addNoDups, Suffix, splitFilename, getFileSuffix, splitFilename3, remove_suffix, split_longest_prefix, - replaceFilenameSuffix, directoryOf, replaceFilenameDirectory, - remove_spaces, escapeSpaces, + replaceFilenameSuffix, directoryOf, filenameOf, + replaceFilenameDirectory, remove_spaces, escapeSpaces, ) where #include "../includes/ghcconfig.h" @@ -212,6 +212,11 @@ replaceFilenameSuffix s suf = remove_suffix '.' s ++ suf directoryOf :: FilePath -> String directoryOf = fst . splitFilenameDir +-- filenameOf strips the directory off the input string, returning +-- the filename. +filenameOf :: FilePath -> String +filenameOf = snd . splitFilenameDir + replaceFilenameDirectory :: FilePath -> String -> FilePath replaceFilenameDirectory s dir = dir ++ '/':drop_longest_prefix s isPathSeparator -- 1.7.10.4