Minimal haskell (ghc) program installation (deployment without ghc/cabal)
(My problem is about distribute binaries without haskell-platform, ghc, cabal, ...)
I need deploy a well cabal formed haskell application (a Yesod scaffolded) but I have disk space restrictions.
GHC size is about 1Gbytes, store all cabal source code, packages, etc... require more disk space, etc...
Obviously, haskell-platform, ghc, ... is about development (not deployment).
In my specific case I can generate
cabal clean && cabal configure && cabal build
and run succesfully (some like)
./dist/build/MyEntryPoint/MyEntryPoint arg arg arg
But, what about dependencies?, how move it to production environment? (together my "dist" compilation)
Can I put binary dependencies without cabal? How?
Thank you very much!
By default, ghc uses static linking of the Haskell libraries. So the resulting binary is independent of the Haskell ecosystem. If your program does not need any data files, just copy the binary out from ./dist/build/MyEntryPoint/MyEntryPoint
to the host
If you also have data files (eg templates, images, static html pages) that are referenced by the binary using the data path finding logic of Cabal, you can use Setup copy
as follows (using happy as an example):
/tmp/happy-1.18.10 $ ./Setup configure Warning: defaultUserHooks in Setup script is deprecated. Configuring happy-1.18.10... /tmp/happy-1.18.10 $ ./Setup build Building happy-1.18.10... Preprocessing executable 'happy' for happy-1.18.10... [ 1 of 18] Compiling NameSet ( src/NameSet.hs, dist/build/happy/happy-tmp/NameSet.o ) [..] [18 of 18] Compiling Main ( src/Main.lhs, dist/build/happy/happy-tmp/Main.o ) Linking dist/build/happy/happy ... /tmp/happy-1.18.10 $ ./Setup copy --destdir=/tmp/to_be_deployed/ Installing executable(s) in /tmp/to_be_deployed/usr/local/bin /tmp/happy-1.18.10 $ find /tmp/to_be_deployed /tmp/to_be_deployed /tmp/to_be_deployed/usr /tmp/to_be_deployed/usr/local /tmp/to_be_deployed/usr/local/bin /tmp/to_be_deployed/usr/local/bin/happy /tmp/to_be_deployed/usr/local/share /tmp/to_be_deployed/usr/local/share/doc /tmp/to_be_deployed/usr/local/share/doc/happy-1.18.10 /tmp/to_be_deployed/usr/local/share/doc/happy-1.18.10/LICENSE /tmp/to_be_deployed/usr/local/share/happy-1.18.10 /tmp/to_be_deployed/usr/local/share/happy-1.18.10/GLR_Lib-ghc-debug /tmp/to_be_deployed/usr/local/share/happy-1.18.10/GLR_Lib-ghc /tmp/to_be_deployed/usr/local/share/happy-1.18.10/GLR_Lib /tmp/to_be_deployed/usr/local/share/happy-1.18.10/GLR_Base /tmp/to_be_deployed/usr/local/share/happy-1.18.10/HappyTemplate-arrays-coerce-debug /tmp/to_be_deployed/usr/local/share/happy-1.18.10/HappyTemplate-arrays-ghc-debug /tmp/to_be_deployed/usr/local/share/happy-1.18.10/HappyTemplate-arrays-debug /tmp/to_be_deployed/usr/local/share/happy-1.18.10/HappyTemplate-arrays-coerce /tmp/to_be_deployed/usr/local/share/happy-1.18.10/HappyTemplate-arrays-ghc /tmp/to_be_deployed/usr/local/share/happy-1.18.10/HappyTemplate-arrays /tmp/to_be_deployed/usr/local/share/happy-1.18.10/HappyTemplate-coerce /tmp/to_be_deployed/usr/local/share/happy-1.18.10/HappyTemplate-ghc /tmp/to_be_deployed/usr/local/share/happy-1.18.10/HappyTemplate /tmp/happy-1.18.10 $ rsync -rva /tmp/to_be_deployed/ production.host:/ [..]
If you do not want to install into /usr/local
then pass the desired prefix to Setup configure
.
This works well if the target host is otherwise similar (same versions of C libraries such as gmp and ffi installed). If you also need to statically link some C library, see the question that hammar has linked in his comment.
链接地址: http://www.djcxy.com/p/33288.html上一篇: 为什么GHC很难编译?