From: simonmar Date: Fri, 23 Sep 2005 10:13:33 +0000 (+0000) Subject: [project @ 2005-09-23 10:13:33 by simonmar] X-Git-Tag: Initial_conversion_from_CVS_complete~199 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=4d5a0088afa8432d405ed4a15d6308e631b67379;p=ghc-hetmet.git [project @ 2005-09-23 10:13:33 by simonmar] in --make mode, don't re-link when the executable is up to date. --- diff --git a/ghc/compiler/main/DriverPipeline.hs b/ghc/compiler/main/DriverPipeline.hs index d769bea..025a09b 100644 --- a/ghc/compiler/main/DriverPipeline.hs +++ b/ghc/compiler/main/DriverPipeline.hs @@ -307,11 +307,27 @@ link BatchCompile dflags batch_attempt_linking hpt return Succeeded else do - debugTraceMsg dflags 1 "Linking ..." - let getOfiles (LM _ _ us) = map nameOfObject (filter isObject us) obj_files = concatMap getOfiles linkables + exe_file = exeFileName dflags + + -- if the modification time on the executable is later than the + -- modification times on all of the objects, then omit linking + -- (unless the -no-recomp flag was given). + e_exe_time <- IO.try $ getModificationTime exe_file + let linking_needed + | Left _ <- e_exe_time = True + | Right t <- e_exe_time = + any (t <) (map linkableTime linkables) + + if dopt Opt_RecompChecking dflags && not linking_needed + then do debugTraceMsg dflags 1 (exe_file ++ " is up to date, linking not required.") + return Succeeded + else do + + debugTraceMsg dflags 1 "Linking ..." + -- Don't showPass in Batch mode; doLink will do that for us. staticLink dflags obj_files pkg_deps @@ -1098,18 +1114,12 @@ getHCFilePackages filename = staticLink :: DynFlags -> [FilePath] -> [PackageId] -> IO () staticLink dflags o_files dep_packages = do let verb = getVerbFlag dflags + output_fn = exeFileName dflags -- get the full list of packages to link with, by combining the -- explicit packages with the auto packages and all of their -- dependencies, and eliminating duplicates. - let o_file = outputFile dflags -#if defined(mingw32_HOST_OS) - let output_fn = case o_file of { Just s -> s; Nothing -> "main.exe"; } -#else - let output_fn = case o_file of { Just s -> s; Nothing -> "a.out"; } -#endif - pkg_lib_paths <- getPackageLibraryPath dflags dep_packages let pkg_lib_path_opts = map ("-L"++) pkg_lib_paths @@ -1195,6 +1205,17 @@ staticLink dflags o_files dep_packages = do if success then return () else throwDyn (InstallationError ("cannot move binary to PVM dir"))) + +exeFileName :: DynFlags -> FilePath +exeFileName dflags + | Just s <- outputFile dflags = s + | otherwise = +#if defined(mingw32_HOST_OS) + "main.exe" +#else + "a.out" +#endif + ----------------------------------------------------------------------------- -- Making a DLL (only for Win32)