Commit 948e7f38 authored by simonmar's avatar simonmar
Browse files

[project @ 2003-10-22 14:31:09 by simonmar]

- In GHCi & Template Haskell, give a warning for things mentioned
  on the command line that we don't recognise, and then ignore them.
  In batch mode, these are still passed to the linker as before.

- Clean up & rename the filename-suffix recognising functions in
  DriverPhases. There's probably a better place for these, but I've left
  them where they are for now.
parent a35a6325
......@@ -1032,7 +1032,7 @@ downsweep roots old_summaries
where
getRootSummary :: FilePath -> IO ModSummary
getRootSummary file
| haskellish_src_file file
| isHaskellSrcFilename file
= do exists <- doesFileExist file
if exists then summariseFile file else do
throwDyn (CmdLineError ("can't find file `" ++ file ++ "'"))
......
......@@ -30,6 +30,7 @@ import ByteCodeAsm ( CompiledByteCode(..), bcoFreeNames, UnlinkedBCO(..))
import Packages
import DriverState ( v_Library_paths, v_Opt_l, v_Ld_inputs, getStaticOpts, v_ExplicitPackages )
import DriverPhases ( isObjectFilename, isDynLibFilename )
import DriverUtil ( getFileSuffix )
#ifdef darwin_TARGET_OS
import DriverState ( v_Cmdline_frameworks, v_Framework_paths )
......@@ -214,7 +215,7 @@ reallyInitDynLinker
; lib_paths <- readIORef v_Library_paths
; cmdline_ld_inputs <- readIORef v_Ld_inputs
; let (cmdline_libs, cmdline_objs) = partition libish cmdline_ld_inputs
; classified_ld_inputs <- mapM classifyLdInput cmdline_ld_inputs
-- (e) Link any MacOS frameworks
#ifdef darwin_TARGET_OS
......@@ -225,8 +226,7 @@ reallyInitDynLinker
; let framework_paths = []
#endif
-- Finally do (c),(d),(e)
; let cmdline_lib_specs = map Object cmdline_objs
++ map DLLPath cmdline_libs
; let cmdline_lib_specs = [ l | Just l <- classified_ld_inputs ]
++ map DLL minus_ls
++ map Framework frameworks
; if null cmdline_lib_specs then return ()
......@@ -240,16 +240,13 @@ reallyInitDynLinker
else throwDyn (InstallationError "linking extra libraries/objects failed")
}}
libish :: String -> Bool
libish f = getFileSuffix f `elem` dynlib_suffixes
#ifdef mingw32_TARGET_OS
dynlib_suffixes = ["dll", "DLL"]
#elif defined(darwin_TARGET_OS)
dynlib_suffixes = ["dylib"]
#else
dynlib_suffixes = ["so"]
#endif
classifyLdInput :: FilePath -> IO (Maybe LibrarySpec)
classifyLdInput f
| isObjectFilename f = return (Just (Object f))
| isDynLibFilename f = return (Just (DLLPath f))
| otherwise = do
hPutStrLn stderr ("Warning: ignoring unrecognised input `" ++ f ++ "'")
return Nothing
preloadLib :: DynFlags -> [String] -> [String] -> LibrarySpec -> IO ()
preloadLib dflags lib_paths framework_paths lib_spec
......
-----------------------------------------------------------------------------
-- $Id: DriverPhases.hs,v 1.27 2003/06/26 21:55:47 sof Exp $
-- $Id: DriverPhases.hs,v 1.28 2003/10/22 14:31:09 simonmar Exp $
--
-- GHC Driver
--
......@@ -15,13 +15,14 @@ module DriverPhases (
startPhase, -- :: String -> Phase
phaseInputExt, -- :: Phase -> String
haskellish_file, haskellish_suffix,
haskellish_src_file, haskellish_src_suffix,
objish_file, objish_suffix,
cish_file, cish_suffix,
isExtCore_file, extcoreish_suffix,
haskellish_user_src_file,
isSourceFile -- :: FilePath -> Bool
isHaskellishFilename,
isHaskellSrcFilename,
isObjectFilename,
isCishFilename,
isExtCoreFilename,
isDynLibFilename,
isHaskellUserSrcFilename,
isSourceFilename -- :: FilePath -> Bool
) where
import DriverUtil
......@@ -107,28 +108,37 @@ phaseInputExt Ilx2Il = "ilx"
phaseInputExt Ilasm = "il"
#endif
haskellish_suffix = (`elem` [ "hs", "lhs", "hspp", "hscpp", "hcr", "hc", "raw_s" ])
haskellish_src_suffix = (`elem` [ "hs", "lhs", "hspp", "hscpp", "hcr"])
cish_suffix = (`elem` [ "c", "cpp", "C", "cc", "cxx", "s", "S" ])
extcoreish_suffix = (`elem` [ "hcr" ])
haskellish_user_src_suffix = (`elem` [ "hs", "lhs" ])
haskellish_suffixes = [ "hs", "lhs", "hspp", "hscpp", "hcr", "hc", "raw_s" ]
haskellish_src_suffixes = [ "hs", "lhs", "hspp", "hscpp", "hcr"]
cish_suffixes = [ "c", "cpp", "C", "cc", "cxx", "s", "S" ]
extcoreish_suffixes = [ "hcr" ]
haskellish_user_src_suffixes = [ "hs", "lhs" ]
-- Use the appropriate suffix for the system on which
-- the GHC-compiled code will run
#if mingw32_TARGET_OS || cygwin32_TARGET_OS
objish_suffix = (`elem` [ "o", "O", "obj", "OBJ" ])
objish_suffixes = [ "o", "O", "obj", "OBJ" ]
#else
objish_suffix = (`elem` [ "o" ])
objish_suffixes = [ "o" ]
#endif
haskellish_file = haskellish_suffix . getFileSuffix
haskellish_src_file = haskellish_src_suffix . getFileSuffix
cish_file = cish_suffix . getFileSuffix
isExtCore_file = extcoreish_suffix . getFileSuffix
objish_file = objish_suffix . getFileSuffix
haskellish_user_src_file = haskellish_user_src_suffix . getFileSuffix
isSourceFile :: FilePath -> Bool
isSourceFile f =
haskellish_file f ||
cish_file f
#ifdef mingw32_TARGET_OS
dynlib_suffixes = ["dll", "DLL"]
#elif defined(darwin_TARGET_OS)
dynlib_suffixes = ["dylib"]
#else
dynlib_suffixes = ["so"]
#endif
isHaskellishFilename f = getFileSuffix f `elem` haskellish_suffixes
isHaskellSrcFilename f = getFileSuffix f `elem` haskellish_src_suffixes
isCishFilename f = getFileSuffix f `elem` cish_suffixes
isExtCoreFilename f = getFileSuffix f `elem` extcoreish_suffixes
isObjectFilename f = getFileSuffix f `elem` objish_suffixes
isHaskellUserSrcFilename f = getFileSuffix f `elem` haskellish_user_src_suffixes
isDynLibFilename f = getFileSuffix f `elem` dynlib_suffixes
isSourceFilename :: FilePath -> Bool
isSourceFilename f =
isHaskellishFilename f ||
isCishFilename f
......@@ -70,7 +70,7 @@ import Maybe
preprocess :: FilePath -> IO FilePath
preprocess filename =
ASSERT(haskellish_src_file filename)
ASSERT(isHaskellSrcFilename filename)
do restoreDynFlags -- Restore to state of last save
runPipeline (StopBefore Hsc) ("preprocess")
False{-temporary output file-}
......@@ -562,7 +562,7 @@ runPhase Hsc basename suff input_fn get_output_fn _maybe_loc = do
-- gather the imports and module name
(_,_,mod_name) <-
if extcoreish_suffix suff
if isExtCoreFilename ('.':suff)
then do
-- no explicit imports in ExtCore input.
m <- getCoreModuleName input_fn
......
......@@ -61,7 +61,7 @@ import CodeGen ( codeGen )
import CodeOutput ( codeOutput )
import CmdLineOpts
import DriverPhases ( isExtCore_file )
import DriverPhases ( isExtCoreFilename )
import ErrUtils ( dumpIfSet, dumpIfSet_dyn, showPass )
import UniqSupply ( mkSplitUniqSupply )
......@@ -197,7 +197,7 @@ hscRecomp hsc_env have_object
; let dflags = hsc_dflags hsc_env
; let toInterp = dopt_HscLang dflags == HscInterpreted
; let toCore = isJust (ml_hs_file location) &&
isExtCore_file (fromJust (ml_hs_file location))
isExtCoreFilename (fromJust (ml_hs_file location))
; when (not one_shot && verbosity dflags >= 1) $
hPutStrLn stderr ("Compiling " ++
......
{-# OPTIONS -fno-warn-incomplete-patterns -optc-DNON_POSIX_SOURCE #-}
-----------------------------------------------------------------------------
-- $Id: Main.hs,v 1.134 2003/10/09 11:58:57 simonpj Exp $
-- $Id: Main.hs,v 1.135 2003/10/22 14:31:10 simonmar Exp $
--
-- GHC Driver program
--
......@@ -44,7 +44,7 @@ import DriverFlags ( buildStaticHscOpts,
dynamic_flags, processArgs, static_flags)
import DriverMkDepend ( beginMkDependHS, endMkDependHS )
import DriverPhases ( isSourceFile )
import DriverPhases ( isSourceFilename )
import DriverUtil ( add, handle, handleDyn, later, unknownFlagsErr )
import CmdLineOpts ( dynFlag, restoreDynFlags,
......@@ -212,7 +212,7 @@ main =
Everything else is considered to be a linker object, and passed
straight through to the linker.
-}
looks_like_an_input m = isSourceFile m
looks_like_an_input m = isSourceFilename m
|| looksLikeModuleName m
|| '.' `notElem` m
......
......@@ -65,7 +65,7 @@ module SysTools (
#include "HsVersions.h"
import DriverUtil
import DriverPhases ( haskellish_user_src_file )
import DriverPhases ( isHaskellUserSrcFilename )
import Config
import Outputable
import Panic ( progName, GhcException(..) )
......@@ -701,7 +701,7 @@ removeTmpFiles verb fs
hPutStrLn stderr ("WARNING - NOT deleting source files: " ++ unwords non_deletees)
act
(non_deletees, deletees) = partition haskellish_user_src_file fs
(non_deletees, deletees) = partition isHaskellUserSrcFilename fs
rm f = removeFile f `IO.catch`
(\_ignored ->
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment