使用堆栈安装zlib:使用-fPIC重新编译

时间:2016-12-28 16:17:25

标签: haskell haskell-stack

当我跑步时

stack --resolver=lts-7.14 install zlib

我收到消息说应该用-fPIC标志重新编译包:

Configuring zlib-0.6.1.2...
Building zlib-0.6.1.2...
Preprocessing library zlib-0.6.1.2...
/usr/bin/ld: .stack-work/dist/x86_64-linux-nopie/Cabal-1.24.0.0/build/Codec/Compression/Zlib/Stream_hsc_make.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC

如何告诉堆栈使用zlib标志重新编译-fPIC

我在yaml文件中添加了ghc-options:

ghc-options:
  zlib: -fPIC

apply-ghc-options: locals
rebuild-ghc-options: true

另外,我在cabal文件中为ghc-options添加了-fPIC标志。

但是,我仍然得到相同的输出:

--  While building package zlib-0.6.1.2 using:
  /home/vladimir/.stack/setup-exe-cache/x86_64-linux-nopie/Cabal-simple_mPHDZzAJ_1.24.0.0_ghc-8.0.1 --builddir=.stack-work/dist/x86_64-linux-nopie/Cabal-1.24.0.0 build --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
Logs have been written to: /home/vladimir/Desktop/ffmpeg-light/.stack-work/logs/zlib-0.6.1.2.log

其中ghc-options为-ddump-hi-ddump-to-file且无-fPIC。我错过了什么吗?

GCC,堆栈和操作系统版本:

海湾合作委员会:gcc(Ubuntu 6.2.0-5ubuntu12)6.2.0 20161005

Stack:版本1.3.0,Git版本99b910d3c8e183aa376cb1e6f0341d86aed6d00e(4372提交)x86_64 hpack-0.15.0

操作系统:Ubuntu 16.10

看起来像是bug

我找到了一个黑客:

我替换了

("C compiler flags", "-fno-PIE -fno-stack-protector")

通过

("C compiler flags", "-fPIC -fno-stack-protector")

在文件

/home/you/.stack/programs/x86_64-linux/ghc-8.0.1/lib/ghc-8.0.1/settings

现在它编译并运作。我在我的项目上测试了它。

1 个答案:

答案 0 :(得分:1)

问题在于Cabal如何调用hsc2hs。您需要提交自Cabal 1.24.1.0以来的https://github.com/haskell/cabal/commit/c993a0c6660aa10d8c79ed0cc4961c59acfc91c8提交。