- -- check for the -no-link flag
- if isNoLink (ghcLink dflags)
- then do debugTraceMsg dflags 3 (text "link(batch): linking omitted (-c flag given).")
- return Succeeded
- else do
-
- 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 not (dopt Opt_ForceRecomp dflags) && not linking_needed
- then do debugTraceMsg dflags 2 (text exe_file <+> ptext SLIT("is up to date, linking not required."))
- return Succeeded
- else do
-
- debugTraceMsg dflags 1 (ptext SLIT("Linking") <+> text exe_file
- <+> text "...")
-
- -- Don't showPass in Batch mode; doLink will do that for us.
- let link = case ghcLink dflags of
- LinkBinary -> linkBinary
- LinkDynLib -> linkDynLib
- link dflags obj_files pkg_deps
+ -- check for the -no-link flag
+ if isNoLink (ghcLink dflags)
+ then do debugTraceMsg dflags 3 (text "link(batch): linking omitted (-c flag given).")
+ return Succeeded
+ else do
+
+ 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
+ extra_ld_inputs <- readIORef v_Ld_inputs
+ extra_times <- mapM (IO.try . getModificationTime) extra_ld_inputs
+ let other_times = map linkableTime linkables
+ ++ [ t' | Right t' <- extra_times ]
+ linking_needed
+ | Left _ <- e_exe_time = True
+ | Right t <- e_exe_time = any (t <) other_times
+
+ if not (dopt Opt_ForceRecomp dflags) && not linking_needed
+ then do debugTraceMsg dflags 2 (text exe_file <+> ptext SLIT("is up to date, linking not required."))
+ return Succeeded
+ else do
+
+ debugTraceMsg dflags 1 (ptext SLIT("Linking") <+> text exe_file
+ <+> text "...")
+
+ -- Don't showPass in Batch mode; doLink will do that for us.
+ let link = case ghcLink dflags of
+ LinkBinary -> linkBinary
+ LinkDynLib -> linkDynLib
+ link dflags obj_files pkg_deps