Commit 6b17e71f authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Add a -with-rtsopts link-time flag

You can now link with
    -with-rtsopts="-H128m -K1m"
parent 373978e7
...@@ -1429,6 +1429,14 @@ linkBinary dflags o_files dep_packages = do ...@@ -1429,6 +1429,14 @@ linkBinary dflags o_files dep_packages = do
"const rtsBool rtsOptsEnabled = rtsTrue;"] "const rtsBool rtsOptsEnabled = rtsTrue;"]
return [fn] return [fn]
else return [] else return []
rtsOptsObj <- case rtsOpts dflags of
Just opts ->
do fn <- mkExtraCObj dflags
-- We assume that the Haskell "show" does
-- the right thing here
["char *ghc_rts_opts = " ++ show opts ++ ";"]
return [fn]
Nothing -> return []
pkg_link_opts <- getPackageLinkOpts dflags dep_packages pkg_link_opts <- getPackageLinkOpts dflags dep_packages
...@@ -1504,6 +1512,7 @@ linkBinary dflags o_files dep_packages = do ...@@ -1504,6 +1512,7 @@ linkBinary dflags o_files dep_packages = do
++ pkg_lib_path_opts ++ pkg_lib_path_opts
++ main_lib ++ main_lib
++ rtsEnabledObj ++ rtsEnabledObj
++ rtsOptsObj
++ pkg_link_opts ++ pkg_link_opts
#ifdef darwin_TARGET_OS #ifdef darwin_TARGET_OS
++ pkg_framework_path_opts ++ pkg_framework_path_opts
......
...@@ -407,6 +407,7 @@ data DynFlags = DynFlags { ...@@ -407,6 +407,7 @@ data DynFlags = DynFlags {
ghcUsagePath :: FilePath, -- Filled in by SysTools ghcUsagePath :: FilePath, -- Filled in by SysTools
ghciUsagePath :: FilePath, -- ditto ghciUsagePath :: FilePath, -- ditto
rtsOpts :: Maybe String,
hpcDir :: String, -- ^ Path to store the .mix files hpcDir :: String, -- ^ Path to store the .mix files
...@@ -641,6 +642,7 @@ defaultDynFlags = ...@@ -641,6 +642,7 @@ defaultDynFlags =
frameworkPaths = [], frameworkPaths = [],
cmdlineFrameworks = [], cmdlineFrameworks = [],
tmpDir = cDEFAULT_TMPDIR, tmpDir = cDEFAULT_TMPDIR,
rtsOpts = Nothing,
hpcDir = ".hpc", hpcDir = ".hpc",
...@@ -1110,6 +1112,7 @@ dynamic_flags = [ ...@@ -1110,6 +1112,7 @@ dynamic_flags = [
------- Miscellaneous ---------------------------------------------- ------- Miscellaneous ----------------------------------------------
, Flag "no-auto-link-packages" (NoArg (unSetDynFlag Opt_AutoLinkPackages)) Supported , Flag "no-auto-link-packages" (NoArg (unSetDynFlag Opt_AutoLinkPackages)) Supported
, Flag "no-hs-main" (NoArg (setDynFlag Opt_NoHsMain)) Supported , Flag "no-hs-main" (NoArg (setDynFlag Opt_NoHsMain)) Supported
, Flag "with-rtsopts" (HasArg setRtsOpts) Supported
, Flag "rtsopts" (NoArg (setDynFlag Opt_RtsOptsEnabled)) Supported , Flag "rtsopts" (NoArg (setDynFlag Opt_RtsOptsEnabled)) Supported
, Flag "no-rtsopts" (NoArg (unSetDynFlag Opt_RtsOptsEnabled)) Supported , Flag "no-rtsopts" (NoArg (unSetDynFlag Opt_RtsOptsEnabled)) Supported
, Flag "main-is" (SepArg setMainIs ) Supported , Flag "main-is" (SepArg setMainIs ) Supported
...@@ -2012,6 +2015,12 @@ setTmpDir dir dflags = dflags{ tmpDir = normalise dir } ...@@ -2012,6 +2015,12 @@ setTmpDir dir dflags = dflags{ tmpDir = normalise dir }
-- we used to fix /cygdrive/c/.. on Windows, but this doesn't -- we used to fix /cygdrive/c/.. on Windows, but this doesn't
-- seem necessary now --SDM 7/2/2008 -- seem necessary now --SDM 7/2/2008
-----------------------------------------------------------------------------
-- RTS opts
setRtsOpts :: String -> DynP ()
setRtsOpts arg = upd $ \ d -> d {rtsOpts = Just arg}
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- Hpc stuff -- Hpc stuff
......
Supports Markdown
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