最小的haskell(ghc)程序安装(没有ghc / cabal的部署)

(我的问题是关于分发没有haskell-platform,ghc,cabal等的二进制文件)

我需要部署一个良好的组合式haskell应用程序(一个Yesod脚手架),但我有磁盘空间限制。

GHC的大小约为1G,存储所有的cabal源代码,软件包等等......需要更多的磁盘空间等等......

显然,haskell-platform,ghc ......是关于开发(而不是部署)的。

在我的具体情况下,我可以生成

cabal clean && cabal configure && cabal build

并成功运行(有些人喜欢)

./dist/build/MyEntryPoint/MyEntryPoint arg arg arg

但是,依赖关系呢,如何将其转移到生产环境? (我的“dist”汇编)

我可以放置二进制依赖没有cabal? 怎么样?

非常感谢你!


默认情况下,ghc使用Haskell库的静态链接。 所以生成的二进制文件独立于Haskell生态系统。 如果您的程序不需要任何数据文件,只需将./dist/build/MyEntryPoint/MyEntryPoint的二进制文件复制到主机

如果您还有使用Cabal的数据路径查找逻辑由二进制文件引用的数据文件(例如模板,图像,静态html页面),则可以按如下方式使用Setup copy (使用happy作为示例):

/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:/
[..]

如果您不想安装到/usr/local则将所需的前缀传递给Setup configure

如果目标主机在其他方面类似(安装了相同版本的C库(例如gmp和ffi)),则此方法运行良好。 如果您还需要静态链接某个C库,请参阅hammar在其评论中链接的问题。

链接地址: http://www.djcxy.com/p/33287.html

上一篇: Minimal haskell (ghc) program installation (deployment without ghc/cabal)

下一篇: Why are Haskell/GHC executables so large in filesize?