Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. Re: A problem with a simple csv file parser (Aleksandar Dimitrov) 2. Re: A problem with a simple csv file parser (Daniel Fischer) 3. GHC-generated executables size (.) 4. Re: GHC-generated executables size (Aleksandar Dimitrov) 5. Re: GHC-generated executables size (Daniel Fischer) 6. Re: GHC-generated executables size (.) ---------------------------------------------------------------------- Message: 1 Date: Sat, 16 Oct 2010 10:59:10 +0200 From: "Aleksandar Dimitrov" <aleks.dimit...@googlemail.com> Subject: Re: [Haskell-beginners] A problem with a simple csv file parser To: beginners <beginners@haskell.org>, "Andy Elvey" <andy.el...@paradise.net.nz> Message-ID: <op.vknu8uzejdv...@bylha> Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes On Sat, 16 Oct 2010 07:23:04 +0200, Andy Elvey <andy.el...@paradise.net.nz> wrote: > -- A simple csv parser Module parseCSV where > import Text.ParserCombinators.Parsec That's your problem. I'm assuming the newline got chomped up, so your source file reads --A simple csv parser Module parseCSV where That's wrong. Module is *not* to be capitalized, the module *name*, however, *is*. Change it to: module ParseCsv where Runhaskell should be absolutely fine running it that way, no need to remove the module name. GHC (the compiler itself) on the other hand, will just not produce a binary as long as your module name isn't "Main." % runhaskell Test.hs ~ "Hello" % ghc --make -O2 -o Test Test.hs ~ Warning: output was redirected with -o, but no output will be generated because there is no Main module. % cat Test.hs ~ module Test where main = print "Hello" Most programs will typically have a File "Main.hs" which does all the duties of a main executable. Best wishes, Aleks ------------------------------ Message: 2 Date: Sat, 16 Oct 2010 11:39:31 +0200 From: Daniel Fischer <daniel.is.fisc...@web.de> Subject: Re: [Haskell-beginners] A problem with a simple csv file parser To: beginners@haskell.org Message-ID: <201010161139.32672.daniel.is.fisc...@web.de> Content-Type: text/plain; charset="utf-8" On Saturday 16 October 2010 10:59:10, Aleksandar Dimitrov wrote: > . GHC (the compiler itself) on the other hand, will  > just not produce a binary as long as your module name isn't "Main." If your module name isn't Main, you have to tell GHC what to regard as the main module by passing the "-main-is" flag on the command line $ ghc -O2 --make -main-is Test -o Test Test.hs works. And your main function may also have a different name, e.g. $ ghc -O2 --make -main-is MultiMain.main2 -o main2 MultiMain.hs with module MultiMain where main1 :: IO () main1 = putStrLn "main1" main2 :: IO () main2 = putStrLn "You chose main two." ------------------------------ Message: 3 Date: Sat, 16 Oct 2010 12:26:00 +0200 From: "." <ch.go...@googlemail.com> Subject: [Haskell-beginners] GHC-generated executables size To: beginners@haskell.org Message-ID: <1287224760.9018.5.ca...@eddy> Content-Type: text/plain; charset="UTF-8" Hi, I was playing around with ghc again, and I was wondering what makes the executables so large and how I could make them smaller (strip works, but is there anything more I can do?) More specifically, I am compiling a program that uses the GTK+ bindings, HDBC, and some things from Prelude. The program simply displays a window, and reads and writes values from/into a data base file. Not much, really. Anyway, the program size is 20MB without stripping, and 10MB after stripping ... Any hints? Thanks and good night for now .. Christian ------------------------------ Message: 4 Date: Sat, 16 Oct 2010 12:43:59 +0200 From: "Aleksandar Dimitrov" <aleks.dimit...@googlemail.com> Subject: Re: [Haskell-beginners] GHC-generated executables size To: beginners@haskell.org, "." <ch.go...@googlemail.com> Message-ID: <op.vknz3ljkjdv...@bylha> Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Hi Christian, > I was playing around with ghc again, and I was wondering what makes > the executables so large and how I could make them smaller (strip works, > but is there anything more I can do?) > More specifically, I am compiling a program that uses the GTK+ bindings, > HDBC, and some things from Prelude. > The program simply displays a window, and reads and writes values > from/into a data base file. Not much, really. > Anyway, the program size is 20MB without stripping, and 10MB after > stripping ... GHC links statically. There is some effort to bring dynamic linking to GHC: http://hackage.haskell.org/trac/ghc/wiki/SharedLibraries/PlatformSupport?redirectedfrom=DynamicLinking You'll have to ask more knowledgeable people about its status and if it's recommended for current projects. Since the GTK libraries are so vast, even including one call (which forces the libs to be linked into the executable) will dramatically increase the statically linked executable's size. Regards, Aleks ------------------------------ Message: 5 Date: Sat, 16 Oct 2010 13:23:17 +0200 From: Daniel Fischer <daniel.is.fisc...@web.de> Subject: Re: [Haskell-beginners] GHC-generated executables size To: beginners@haskell.org Cc: "." <ch.go...@googlemail.com> Message-ID: <201010161323.19279.daniel.is.fisc...@web.de> Content-Type: text/plain; charset="utf-8" On Saturday 16 October 2010 12:26:00, . wrote: > Hi, > I was playing around with ghc again, and I was wondering what makes > the executables so large and how I could make them smaller (strip works, > but is there anything more I can do?) > More specifically, I am compiling a program that uses the GTK+ bindings, > HDBC, and some things from Prelude. > The program simply displays a window, and reads and writes values > from/into a data base file. Not much, really. > Anyway, the program size is 20MB without stripping, and 10MB after > stripping ... > > Any hints? Two things spring to mind (in addition to the static linking mentioned by Aleksandar). 1) If you didn't compile the packages with -split-objs, when you use one function from a module, the entire object file for the module is linked in. For packages with many modules or many dependencies, that adds up pretty fast. If you set split-objs: True in your ~/.cabal/config, packages installed via cabal-install (the cabal executable) will be built with -split-objs and only the needed functions will be linked in (at least if you compile your programmes with optimisations, I don't know whether -O0 uses split object files or the monolithic ones). (Downside: building the packages takes longer, duh; and you need more disk space for monolithic+split object files, duh again). 2) If it's not (only) that, it's probably the same effect as discussed in http://hackage.haskell.org/trac/ghc/ticket/4387 Simon (PJ) says: "Every module has a module-initialisation routine. Apart from initialising the module, it calls the module-initialisation routine for each imported module. So if M imports module SpecConstr from package ghc, then the module-initialisatin routine for M will call the initialisation routine for SpecConstr. Even though nothing from SpecConstr is ultimately used." So if you import a module (you don't even need to use anything from it) which transitively imports a lot of modules, you get a ton of module- initialisation routines. People are thinking about how to handle this best (since it affects the vector package, on which a lot of other packages depend, it's not unimportant). > > Thanks and good night for now .. > Christian > ------------------------------ Message: 6 Date: Sat, 16 Oct 2010 15:03:52 +0200 From: "." <ch.go...@googlemail.com> Subject: Re: [Haskell-beginners] GHC-generated executables size To: Daniel Fischer <daniel.is.fisc...@web.de> Cc: beginners@haskell.org Message-ID: <1287234232.9018.18.ca...@eddy> Content-Type: text/plain; charset="UTF-8" Hi Daniel, thanks for the explanations. I have tried reinstalling with cabal --reinstall gtk, having set split-objs: True in ~/.cabal/config before. However, the compile yielded a single .o file again, and recompiling and re-linking my little program does not change its size ... Any other idea what I might be doing wrong? Also, I saw in the ghc documentatio about -split-objs that one should only use it "if you know exactly what you're doing". Do you know what the caveats are? Thanks again, Christian On Sat, 2010-10-16 at 13:23 +0200, Daniel Fischer wrote: > On Saturday 16 October 2010 12:26:00, . wrote: > > Hi, > > I was playing around with ghc again, and I was wondering what makes > > the executables so large and how I could make them smaller (strip works, > > but is there anything more I can do?) > > More specifically, I am compiling a program that uses the GTK+ bindings, > > HDBC, and some things from Prelude. > > The program simply displays a window, and reads and writes values > > from/into a data base file. Not much, really. > > Anyway, the program size is 20MB without stripping, and 10MB after > > stripping ... > > > > Any hints? > > Two things spring to mind (in addition to the static linking mentioned by > Aleksandar). > > 1) If you didn't compile the packages with -split-objs, when you use one > function from a module, the entire object file for the module is linked in. > For packages with many modules or many dependencies, that adds up pretty > fast. > > If you set > > > in your ~/.cabal/config, packages installed via cabal-install (the cabal > executable) will be built with -split-objs and only the needed functions > will be linked in (at least if you compile your programmes with > optimisations, I don't know whether -O0 uses split object files or the > monolithic ones). > (Downside: building the packages takes longer, duh; and you need more disk > space for monolithic+split object files, duh again). > > 2) If it's not (only) that, > it's probably the same effect as discussed in > http://hackage.haskell.org/trac/ghc/ticket/4387 > > Simon (PJ) says: > "Every module has a module-initialisation routine. Apart from initialising > the module, it calls the module-initialisation routine for each imported > module. So if M imports module SpecConstr from package ghc, then the > module-initialisatin routine for M will call the initialisation routine for > SpecConstr. Even though nothing from SpecConstr is ultimately used." > > So if you import a module (you don't even need to use anything from it) > which transitively imports a lot of modules, you get a ton of module- > initialisation routines. > People are thinking about how to handle this best (since it affects the > vector package, on which a lot of other packages depend, it's not > unimportant). > > > > > Thanks and good night for now .. > > Christian > > > ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 28, Issue 26 *****************************************