HASKELL:尝试构建静态库,w/ llvm throws“可以创建动态重新定位”尽管使用了-fpic
我正在尝试使用GHC生成静态库的LLVM比特码,遵循其他SO答案和指南在线,我到达了:
FILE = lib
compile:
ghc -fllvm -keep-llvm-files -fforce-recomp -static -shared -flink-rts -fPIC $(FILE).hs
llvm-as $(FILE).ll -o $(FILE).bc
-- lib.hs
module Lib where
add x y = x + y
但是运行此操作给出了:
$ ghc -fllvm -keep-llvm-files -fforce-recomp -static -shared -flink-rts -fPIC lib.hs
[1 of 1] Compiling Lib ( lib.hs, lib.o )
You are using an unsupported version of LLVM!
Currently only 9 to 13 is supported. System LLVM version: 13.0.0
We will try though...
Linking a.out ...
ld.lld: error: cant create dynamic relocation R_X86_64_32S against symbol:
stg_bh_upd_frame_info in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
>>> defined in /home/user/.ghcup/ghc/9.2.1/lib/ghc-9.2.1/rts/libHSrts.a(Updates.o)
>>> referenced by Base.o:(.text+0x3A) in archive /home/user/.ghcup/ghc/9.2.1/lib/ghc-9.2.1/base-4.16.0.0/libHSbase-4.16.0.0.a
我应该注意:使用 no-pie的GHC选项
在设置中启用
文件
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论