
On 10/9/06, Jason Dagit
Hello,
I have a program and I'd like to permanently change the default RTS options. According to the GHC manual I can do that by linking with a snippet of C code: http://www.haskell.org/ghc/docs/latest/html/users_guide/runtime-control.html
Look at section 4.14.5 at the bottom of the page.
I can't seem to get cabal to link my program together so that my custom rts options take affect. To help demonstrate I've created a minimal test case:
------------- oom.cabal ------------------- name: OutOfMemory version: 0.1 cabal-version: -any license: AllRightsReserved license-file: "" build-depends: base -any c-sources: rtsoptions.c exposed-modules: Main
Executable: oom Main-is: Main.hs ------------- end oom.cabal -----------
--------------- Main.hs --------------------- module Main where
main :: IO () main = print $ foldl (+) 0 [1..100000000] --------------- End Main.hs --------------
/* rtsoptions.c */ char *ghc_rts_opts = "-M1024M -K256M"; /* end rtsoptions.c */
Also using the standard Setup.lhs: #! /usr/bin/runghc
\begin{code} import Distribution.Simple main = defaultMain \end{code}
When build and run this I get: C:\projects\tmp>runghc Setup.lhs build Preprocessing library OutOfMemory-0.1... Preprocessing executables for OutOfMemory-0.1... Building OutOfMemory-0.1... [1 of 1] Compiling Main ( Main.hs, dist\build\oom\oom-tmp/Main.o ) Linking dist\build\oom\oom.exe ...
C:\projects\tmp>dist\build\oom\oom.exe Heap exhausted; Current maximum heap size is 268435456 bytes (256 Mb); use `+RTS -M<size>' to increase it.
On the other hand, if I build rtsoptions.c manually and add it to the ghc-options line in the .cabal file it does build and run until in needs more than 976Mb (showing that the default RTS options are indeed different).
Add the C source to the executable instead of the library. In other words, move the 'c-sources' under 'main-is'. -- Cheers, Lemmih