Problem linking on Win32
Jason Dagit
dagit at codersbase.com
Mon Oct 9 14:40:24 EDT 2006
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).
Below is the trace of the build process:
Preprocessing library OutOfMemory-0.1...
Preprocessing executables for OutOfMemory-0.1...
Building OutOfMemory-0.1...
Building library...
Building C Sources...
C:\Program Files\Visual Haskell\bin\ghc.exe -odir dist\build -hidir
dist\build -c -v rtsoptions.c
Glasgow Haskell Compiler, Version 6.5, for Haskell 98, compiled by GHC
version 6.5
Using package config file: C:\Program Files\Visual Haskell\package.conf
Hsc static flags: -static
*** C Compiler:
C:\Program Files\Visual Haskell\gcc -BC:\Program Files\Visual
Haskell\gcc-lib/ -x c rtsoptions.c -o
C:\DOCUME~1\JASOND~1\LOCALS~1\Temp\ghc528_0.s
-DDONT_WANT_WIN32_DLL_SUPPORT -v -S -Wimplicit -O
-D__GLASGOW_HASKELL__=605 -I C:/Program Files/Visual Haskell\include
-I C:/Program Files/Visual Haskell\include\mingw
Reading specs from C:/Program Files/Visual Haskell/gcc-lib/specs
Configured with: ../gcc/configure --with-gcc --with-gnu-ld
--with-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw
--enable-threads --disable-nls --enable-languages=c++,f77,objc
--disable-win32-registry --disable-shared --enable-sjlj-exceptions
Thread model: win32
gcc version 3.2.3 (mingw special 20030504-1)
C:\Program Files\Visual Haskell\gcc-lib\cc1.exe -lang-c -v -I
C:/Program Files/Visual Haskell\include -I C:/Program Files/Visual
Haskell\include\mingw -iprefix C:\Program Files\Visual
Haskell\../lib/gcc-lib/mingw32/3.2.3/ -isystem C:/Program Files/Visual
Haskell/gcc-lib/include -D__GNUC__=3 -D__GNUC_MINOR__=2
-D__GNUC_PATCHLEVEL__=3 -D__GXX_ABI_VERSION=102 -D_WIN32 -D__WIN32
-D__WIN32__ -DWIN32 -D__MINGW32__ -D__MSVCRT__ -DWINNT -D_X86_=1
-D_WIN32 -D__WIN32 -D__WIN32__ -D__WIN32__ -D__MINGW32__ -D__MSVCRT__
-D__WINNT__ -D_X86_=1 -D__WIN32 -D__WINNT -Asystem=winnt
-D__OPTIMIZE__ -D__STDC_HOSTED__=1 -Acpu=i386 -Amachine=i386 -Di386
-D__i386 -D__i386__ -D__tune_i586__ -D__tune_pentium__
-D__stdcall=__attribute__((__stdcall__))
-D__cdecl=__attribute__((__cdecl__))
-D__fastcall=__attribute__((__fastcall__))
-D_stdcall=__attribute__((__stdcall__))
-D_cdecl=__attribute__((__cdecl__))
-D_fastcall=__attribute__((__fastcall__))
-D__declspec(x)=__attribute__((x)) -DDONT_WANT_WIN32_DLL_SUPPORT
-D__GLASGOW_HASKELL__=605 rtsoptions.c -quiet -dumpbase rtsoptions.c
-O -Wimplicit -version -o
C:\DOCUME~1\JASOND~1\LOCALS~1\Temp\ghc528_0.s
GNU CPP version 3.2.3 (mingw special 20030504-1) (cpplib) (80386, BSD syntax)
GNU C version 3.2.3 (mingw special 20030504-1) (mingw32)
compiled by GNU C version 3.2.3 (mingw special).
ignoring nonexistent directory "C:/Program
Files/lib/gcc-lib/mingw32/3.2.3/../../../../include"
ignoring nonexistent directory "C:/Program
Files/lib/gcc-lib/mingw32/3.2.3/include"
ignoring nonexistent directory "C:/Program
Files/lib/gcc-lib/mingw32/3.2.3/../../../../mingw32/include"
ignoring nonexistent directory "/mingw/lib/gcc-lib/mingw32/3.2.3/include"
ignoring nonexistent directory
"/mingw/lib/gcc-lib/mingw32/3.2.3/../../../../mingw32/include"
ignoring nonexistent directory "/usr/local/mingw32/include"
#include "..." search starts here:
#include <...> search starts here:
C:/Program Files/Visual Haskell/include
C:/Program Files/Visual Haskell/include/mingw
C:/Program Files/Visual Haskell/gcc-lib/include
/mingw/lib/gcc-lib/mingw32/3.2.3/../../../../include
/mingw/include
End of search list.
*** Assembler:
C:\Program Files\Visual Haskell\gcc -BC:\Program Files\Visual
Haskell\gcc-lib/ -c C:\DOCUME~1\JASOND~1\LOCALS~1\Temp\ghc528_0.s -o
dist\build\rtsoptions.o
*** Deleting temp files:
Deleting: C:/DOCUME~1/JASOND~1/LOCALS~1/Temp/ghc528_0.s
cabal-linking...
C:\Program Files\Visual Haskell\bin\ar.exe qv
dist\build\libHSOutOfMemory-0.1.a dist\build\rtsoptions.o
a - dist\build\rtsoptions.o
C:\Program Files\Visual Haskell\gcc-lib\ld.exe -r -x -o
dist\build\HSOutOfMemory-0.1.o dist\build\rtsoptions.o
Building executable: oom...
C:\Program Files\Visual Haskell\bin\ghc.exe -Idist\build -o
dist\build\oom\oom --make -v -hide-all-packages -i
-idist\build\autogen -i. -odir dist\build\oom\oom-tmp -hidir
dist\build\oom\oom-tmp -package base-1.0 Main.hs
Glasgow Haskell Compiler, Version 6.5, for Haskell 98, compiled by GHC
version 6.5
Using package config file: C:\Program Files\Visual Haskell\package.conf
Hsc static flags: -static
*** Chasing dependencies:
Chasing modules from: Main.hs
Stable obj: []
Stable BCO: []
compile: input file Main.hs
*** Checking old interface for Main:
[1 of 1] Compiling Main ( Main.hs, dist\build\oom\oom-tmp/Main.o )
*** Parser:
*** Renamer/typechecker:
*** Desugar:
Result size = 61
*** Simplify:
Result size = 124
Result size = 108
Result size = 108
*** Tidy Core:
Result size = 108
*** CorePrep:
Result size = 118
*** Stg2Stg:
*** CodeGen:
*** CodeOutput:
*** Assembler:
C:\Program Files\Visual Haskell\gcc -BC:\Program Files\Visual
Haskell\gcc-lib/ -I. -Idist\build -c
C:\DOCUME~1\JASOND~1\LOCALS~1\Temp\ghc2924_0.s -o
dist\build\oom\oom-tmp\Main.o
*** Deleting temp files:
Deleting: C:/DOCUME~1/JASOND~1/LOCALS~1/Temp/ghc2924_0.s
Upsweep completely successful.
*** Deleting temp files:
Deleting:
link: linkables are ...
LinkableM (Mon Oct 9 11:28:19 Pacific Standard Time 2006) Main
[DotO dist\build\oom\oom-tmp/Main.o]
Linking dist\build\oom\oom.exe ...
*** Linker:
C:\Program Files\Visual Haskell\gcc -BC:\Program Files\Visual
Haskell\gcc-lib/ -v -o dist\build\oom\oom.exe
-DDONT_WANT_WIN32_DLL_SUPPORT dist\build\oom\oom-tmp/Main.o
-LC:/Program Files/Visual Haskell -LC:/Program Files/Visual
Haskell\gcc-lib -lHSbase -lHSbase_cbits -lwsock32 -lmsvcrt -lkernel32
-luser32 -lshell32 -lHSrts -lm -lgmp -lwsock32 -u
_GHCziBase_Izh_static_info -u _GHCziBase_Czh_static_info -u
_GHCziFloat_Fzh_static_info -u _GHCziFloat_Dzh_static_info -u
_GHCziPtr_Ptr_static_info -u _GHCziWord_Wzh_static_info -u
_GHCziInt_I8zh_static_info -u _GHCziInt_I16zh_static_info -u
_GHCziInt_I32zh_static_info -u _GHCziInt_I64zh_static_info -u
_GHCziWord_W8zh_static_info -u _GHCziWord_W16zh_static_info -u
_GHCziWord_W32zh_static_info -u _GHCziWord_W64zh_static_info -u
_GHCziStable_StablePtr_static_info -u _GHCziBase_Izh_con_info -u
_GHCziBase_Czh_con_info -u _GHCziFloat_Fzh_con_info -u
_GHCziFloat_Dzh_con_info -u _GHCziPtr_Ptr_con_info -u
_GHCziPtr_FunPtr_con_info -u _GHCziStable_StablePtr_con_info -u
_GHCziBase_False_closure -u _GHCziBase_True_closure -u
_GHCziPack_unpackCString_closure -u _GHCziIOBase_stackOverflow_closure
-u _GHCziIOBase_heapOverflow_closure -u
_GHCziIOBase_NonTermination_closure -u
_GHCziIOBase_BlockedOnDeadMVar_closure -u
_GHCziIOBase_BlockedIndefinitely_closure -u
_GHCziIOBase_Deadlock_closure -u _GHCziIOBase_NestedAtomically_closure
-u _GHCziWeak_runFinalizzerBatch_closure
Reading specs from C:/Program Files/Visual Haskell/gcc-lib/specs
Configured with: ../gcc/configure --with-gcc --with-gnu-ld
--with-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw
--enable-threads --disable-nls --enable-languages=c++,f77,objc
--disable-win32-registry --disable-shared --enable-sjlj-exceptions
Thread model: win32
gcc version 3.2.3 (mingw special 20030504-1)
C:\Program Files\Visual Haskell\gcc-lib\ld.exe -Bdynamic -o
dist\build\oom\oom.exe -u _GHCziBase_Izh_static_info -u
_GHCziBase_Czh_static_info -u _GHCziFloat_Fzh_static_info -u
_GHCziFloat_Dzh_static_info -u _GHCziPtr_Ptr_static_info -u
_GHCziWord_Wzh_static_info -u _GHCziInt_I8zh_static_info -u
_GHCziInt_I16zh_static_info -u _GHCziInt_I32zh_static_info -u
_GHCziInt_I64zh_static_info -u _GHCziWord_W8zh_static_info -u
_GHCziWord_W16zh_static_info -u _GHCziWord_W32zh_static_info -u
_GHCziWord_W64zh_static_info -u _GHCziStable_StablePtr_static_info -u
_GHCziBase_Izh_con_info -u _GHCziBase_Czh_con_info -u
_GHCziFloat_Fzh_con_info -u _GHCziFloat_Dzh_con_info -u
_GHCziPtr_Ptr_con_info -u _GHCziPtr_FunPtr_con_info -u
_GHCziStable_StablePtr_con_info -u _GHCziBase_False_closure -u
_GHCziBase_True_closure -u _GHCziPack_unpackCString_closure -u
_GHCziIOBase_stackOverflow_closure -u
_GHCziIOBase_heapOverflow_closure -u
_GHCziIOBase_NonTermination_closure -u
_GHCziIOBase_BlockedOnDeadMVar_closure -u
_GHCziIOBase_BlockedIndefinitely_closure -u
_GHCziIOBase_Deadlock_closure -u _GHCziIOBase_NestedAtomically_closure
-u _GHCziWeak_runFinalizzerBatch_closure C:/Program Files/Visual
Haskell/gcc-lib/crt2.o C:/Program Files/Visual
Haskell/gcc-lib/crtbegin.o -LC:/Program Files/Visual Haskell
-LC:/Program Files/Visual Haskell\gcc-lib -LC:/Program Files/Visual
Haskell/gcc-lib
-L/mingw/lib/gcc-lib/mingw32/3.2.3/../../../../mingw32/lib
-L/mingw/lib/gcc-lib/mingw32/3.2.3/../../..
dist\build\oom\oom-tmp/Main.o -lHSbase -lHSbase_cbits -lwsock32
-lmsvcrt -lkernel32 -luser32 -lshell32 -lHSrts -lm -lgmp -lwsock32
-lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt -luser32 -lkernel32
-ladvapi32 -lshell32 -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt
C:/Program Files/Visual Haskell/gcc-lib/crtend.o
link: done
*** Deleting temp files:
Deleting:
Thanks,
Jason
More information about the cabal-devel
mailing list