Re: [Haskell-cafe] Ghc / cgi static linking
peteg42: > On 02/06/2008, at 5:26 AM, Don Stewart wrote: > > >pieter: > >Yes, it is entirely possible to statically link entire CGI apps. > > You might want to watch out for a bug in GHC 6.8.2 that means GHC's "- > static" flag doesn't work. (At least for me, at least on Debian: the "- > lpthread" flag is passed before the "-lrt" one, and symbols are left > unresolved as a result.) Apparently the near-to-release 6.8.3 will fix > this issue. > > Presumably dons is using a more recent GHC than 6.8.2, or other (BSD?) > platforms are not affected. Yeah, that's the case. > Note also you may have to tweak sundry .cabal files to add "extra- > libraries" fields. As an example, I added this to HSQL's PostgreSQL > backend to get it to statically link: > > extra-libraries: pq, crypt, pthread > > (If anyone cares you need to build PostgreSQL without kerberos as that > doesn't seem to statically link any more.) > Hey Pete, Can you add these caveats to the wiki page? haskell.org/haskellwiki/Practical_web_programming_in_Haskell#Deploying_statically_linked_applications ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Ghc / cgi static linking
On 02/06/2008, at 5:26 AM, Don Stewart wrote: pieter: Yes, it is entirely possible to statically link entire CGI apps. You might want to watch out for a bug in GHC 6.8.2 that means GHC's "- static" flag doesn't work. (At least for me, at least on Debian: the "- lpthread" flag is passed before the "-lrt" one, and symbols are left unresolved as a result.) Apparently the near-to-release 6.8.3 will fix this issue. Presumably dons is using a more recent GHC than 6.8.2, or other (BSD?) platforms are not affected. Note also you may have to tweak sundry .cabal files to add "extra- libraries" fields. As an example, I added this to HSQL's PostgreSQL backend to get it to statically link: extra-libraries: pq, crypt, pthread (If anyone cares you need to build PostgreSQL without kerberos as that doesn't seem to statically link any more.) cheers peter -- http://peteg.org/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Ghc / cgi static linking
pieter: > Hello, > > I'm researching the use of Haskell to replace some perl scripts (in a web > app). > The app is deployed with a webhosting provider. > > CGI scripts can be executed => I can use Haskell. I've tried some > hello world cgi scripts, compiled them on the same linux > the hosting company uses and deployed them. It worked! > > But I would like to implement a search feature for the website. For > Java/php/perl there 's lucene. > For haskell there 's holumbus. Unfortunately, sqlite is a requirement > for holumbus. It is not installed at the server of the > hosting company. > > Is it possible to staticly link the sqlite3 library using ghc ? Yes, it is entirely possible to statically link entire CGI apps. For example, this simple program, import Database.SQLite main = print "hey, test this" when compiled as $ ghc A.hs --make is dynamically linked against: $ ldd A A: StartEnd Type Open Ref GrpRef Name exe 10 0 A 41a85000 41ee5000 rlib 01 0 /usr/local/lib/libsqlite3.so.9.0 49b04000 49f1d000 rlib 01 0 /usr/lib/libm.so.2.3 42213000 4264f000 rlib 01 0 /usr/local/lib/libgmp.so.7.0 47d0e000 481e rlib 01 0 /usr/lib/libc.so.42.0 4790 4790 rtld 01 0 /usr/libexec/ld.so Now, we can just pass some linker flags through to statically link this lot, $ ghc A.hs --make -optl-static -no-recomp $ ldd A ldd: A: not a dynamic executable $ file A A: ELF 64-bit LSB executable, AMD64, version 1, for OpenBSD, statically linked, not stripped I've added this information to the web programming FAQ, haskell.org/haskellwiki/Practical_web_programming_in_Haskell#Deploying_statically_linked_applications Note it also works for fastcgi, which when combined with Haskell's lightweight threads, makes a good option for performance-oriented web apps. -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe