在使用GHC进行编译时耗尽内存

Lib*_*bby 5 haskell ghc haskell-stack

我最近将我的应用程序升级到GHC 8.4,并且我正在尝试将应用程序部署到生产环境中.不幸的是,当我尝试在持续集成服务器上编译应用程序时,每次都会耗尽内存.(这个应用程序多年来一直在同一个服务上编译而没有问题.)有没有办法配置GHC/Stack以使编译使用更少的资源?如果它使编译速度变慢也没关系.

对于上下文,这里是编译器崩溃的地方:

Progress 171/271: aeson-1.2.4.0                               aeson-1.2.4.0: copy/register
Progress 171/271: aeson-1.2.4.0                               Progress 172/271

--  While building custom Setup.hs for package Cabal-2.2.0.1 using:
      /root/.stack/setup-exe-cache/x86_64-linux/Cabal-simple_mPHDZzAJ_2.2.0.1_ghc-8.4.3 --builddir=.stack-work/dist/x86_64-linux/Cabal-2.2.0.1 build --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
    Process exited with code: ExitFailure (-9) (THIS MAY INDICATE OUT OF MEMORY)
Run Code Online (Sandbox Code Playgroud)

ETA:这个问题已被标记为Cabal安装标准内存的重复,但不幸的是,该解决方案对我没有帮助.如果我stack build改为stack build --ghc-options '+RTS -M1500M -RTS',那似乎只会使崩溃稍早发生:

Cabal-2.2.0.1: copy/register
Progress 171/271: Cabal-2.2.0.1                               Progress 172/271

--  While building custom Setup.hs for package tzdata-0.1.20180501.0 using:
      /root/.stack/setup-exe-cache/x86_64-linux/Cabal-simple_mPHDZzAJ_2.2.0.1_ghc-8.4.3 --builddir=.stack-work/dist/x86_64-linux/Cabal-2.2.0.1 build --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
    Process exited with code: ExitFailure (-9) (THIS MAY INDICATE OUT OF MEMORY)
Run Code Online (Sandbox Code Playgroud)