为ghc编译器指定自定义临时目录

Specify custom temporary directory for ghc compiler

我在我的网络服务器上使用 ghc 运行 Ubuntu 14.04 LTS。由于某些限制,我无法提供对 /tmp 文件夹的写入权限。

ghc 编译器在删除对 /tmp 文件夹的权限后抛出此错误

/tmp/ghc12032_0: createDirectory: permission denied (Permission denied)

有没有办法为ghc 提供自定义的临时目录?我没有找到任何可以帮助解决这个问题的编译器标志。每次调用 ghc 时我都需要提供一个自定义目录。任何帮助将不胜感激。

这个怎么样?

https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/separate_compilation.html#redirecting-temporary-files

-tmpdir

If you have trouble because of running out of space in /tmp (or wherever your installation thinks temporary files should go), you may use the -tmpdir option to specify an alternate directory. For example, -tmpdir . says to put temporary files in the current working directory.

Alternatively, use your TMPDIR environment variable. Set it to the name of the directory where temporary files should be put. GCC and other programs will honour the TMPDIR variable as well.

Even better idea: Set the DEFAULT_TMPDIR make variable when building GHC, and never worry about TMPDIR again. (see the build documentation).