Give a warning when -rtsopts/-with-rtsopts are used with -no-hs-main
authorSimon Marlow <marlowsd@gmail.com>
Wed, 16 Nov 2011 15:51:44 +0000 (15:51 +0000)
committerSimon Marlow <marlowsd@gmail.com>
Wed, 16 Nov 2011 15:52:07 +0000 (15:52 +0000)
compiler/main/DriverPipeline.hs

index 8103f66..aaf9f00 100644 (file)
@@ -1446,6 +1446,15 @@ mkExtraObjToLinkIntoBinary :: DynFlags -> [PackageId] -> IO FilePath
 mkExtraObjToLinkIntoBinary dflags dep_packages = do
    link_info <- getLinkInfo dflags dep_packages
 
+   let have_rts_opts_flags =
+         isJust (rtsOpts dflags) || case rtsOptsEnabled dflags of
+                                        RtsOptsSafeOnly -> False
+                                        _ -> True
+
+   when (dopt Opt_NoHsMain dflags && have_rts_opts_flags) $ do
+      hPutStrLn stderr $ "Warning: -rtsopts and -with-rtsopts have no effect with -no-hs-main.\n" ++
+                         "    Call hs_init_ghc() from your main() function to set these options."
+
    mkExtraCObj dflags (showSDoc (vcat [main,
                                        link_opts link_info]
                                    <> char '\n')) -- final newline, to