From f7d457cd1f89e056b0b43106f1ae7508a399cb40 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Tue, 23 Sep 2008 14:49:56 +0000 Subject: [PATCH] #2566: emit a warning for 'ghc -c foo.bar' $ ghc -c foo.bar Warning: the following files would be used as linker inputs, but linking is not being done: foo.bar ghc: no input files Usage: For basic information, try the `--help' option. --- ghc/Main.hs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ghc/Main.hs b/ghc/Main.hs index c80ca78..0ef2173 100644 --- a/ghc/Main.hs +++ b/ghc/Main.hs @@ -261,7 +261,7 @@ checkOptions cli_mode dflags srcs objs = do when (notNull (filter isRTSWay (wayNames dflags)) && isInterpretiveMode cli_mode) $ - putStrLn ("Warning: -debug, -threaded and -ticky are ignored by GHCi") + hPutStrLn stderr ("Warning: -debug, -threaded and -ticky are ignored by GHCi") -- -prof and --interactive are not a good combination when (notNull (filter (not . isRTSWay) (wayNames dflags)) @@ -280,9 +280,14 @@ checkOptions cli_mode dflags srcs objs = do then ghcError (UsageError "can't apply -o to multiple source files") else do + let not_linking = not (isLinkMode cli_mode) || isNoLink (ghcLink dflags) + + when (not_linking && not (null objs)) $ + hPutStrLn stderr ("Warning: the following files would be used as linker inputs, but linking is not being done: " ++ unwords objs) + -- Check that there are some input files -- (except in the interactive case) - if null srcs && null objs && needsInputsMode cli_mode + if null srcs && (null objs || not_linking) && needsInputsMode cli_mode then ghcError (UsageError "no input files") else do @@ -360,6 +365,8 @@ needsInputsMode _ = False isLinkMode :: CmdLineMode -> Bool isLinkMode (StopBefore StopLn) = True isLinkMode DoMake = True +isLinkMode DoInteractive = True +isLinkMode (DoEval _) = True isLinkMode _ = False isCompManagerMode :: CmdLineMode -> Bool -- 1.7.10.4