【问题标题】:Installing zlib using stack: recompile with -fPIC使用堆栈安装 zlib:使用 -fPIC 重新编译
【发布时间】:2016-12-28 16:17:25
【问题描述】:

当我跑步时

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

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


我在 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:gcc (Ubuntu 6.2.0-5ubuntu12) 6.2.0 20161005

堆栈:版本 1.3.0,Git 修订版 99b910d3c8e183aa376cb1e6f0341d86aed6d00e(4372 次提交)x86_64 hpack-0.15.0

操作系统:Ubuntu 16.10


好像是bug

我发现了一个 hack:

我换了

("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

现在它可以编译并工作了。我在我的项目中对其进行了测试。

【问题讨论】:

  • 试试--ghc-options -fPIC,和/或查看堆栈常见问题解答。
  • Possibly related 您使用的是什么堆栈/gcc 版本,以及什么操作系统?
  • @MichaelFoukarakis 更新问题
  • @ppb 确实,我在那里发现了 hack:将 .stack 中的 ghc 设置从 ("C compiler flags", "-fno-PIE -fno-stack-protector") 更改为 ("C compiler flags", "-fPIC -fno-stack-protector")

标签: haskell haskell-stack


【解决方案1】:

问题在于 Cabal 如何调用 hsc2hs。您需要从 Cabal 1.24.1.0 开始提交 https://github.com/haskell/cabal/commit/c993a0c6660aa10d8c79ed0cc4961c59acfc91c8

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-08-25
    • 1970-01-01
    • 2016-09-12
    • 1970-01-01
    • 1970-01-01
    • 2012-11-28
    • 1970-01-01
    相关资源
    最近更新 更多