用-fPIC支持编译ghc [英] Compiling ghc with -fPIC support

查看:163
本文介绍了用-fPIC支持编译ghc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Fedora中安装带有-fPIC支持的GHC。
我已经抓住了一个源代码tarball,因为它似乎没有二进制文件。



在Build.mk中,我将快速构建类型更改为 p>

  ifeq$(BuildFlavour)quick

SRC_HC_OPTS = -H64m -O0 -fasm -fPIC
GhcStage1HcOpts = -O -fasm -fPIC
GhcStage2HcOpts = -O0 -fasm -fPIC
GhcLibHcOpts = -O -fasm -fPIC
SplitObjs = NO
HADDOCK_DOCS = NO
BUILD_DOCBOOK_HTML = NO
BUILD_DOCBOOK_PS = NO
BUILD_DOCBOOK_PDF = NO

endif

不幸的是,编译时我仍然得到ld错误
$ b $ $ pre $ g $ c $ ghc -fglasgow-exts - make -shared -oHs2lib.a /tmp/Hs2lib924498/Hs2lib.hs dllmain.o -static -fno-warn-deprecated-flags -O2 -package ghc -package Hs2lib -i / home / phyx / Documents / Haskell / Hs2lib -optl -Wl,-s -funfolding-use-threshold = 16 -optc-O3 -optc -ffast-math
链接a.out ...
/ usr / bin / ld:/ tmp / Hs2lib924498 / Hs2lib.o:重定位R_X86制作共享对象时,不能使用针对`ghczmprim_GHCziUnit_Z0T_closure'的_64_32;使用-fPIC重新编译
/tmp/Hs2lib924498/Hs2lib.o:无法读取符号:值不正确



所以看起来GHC-prim仍然没有用-FPIC $ b $编译。我还告诉cabal使用-fPIC和共享来构建任何包。



任何人有任何想法?

编辑:
感谢dcouts我已经能够取得一些进展。但是现在我正处于我没有用-fPIC编译libffi的地步。我为它编辑了makefile(.in),但到目前为止,没有运气。



新命令是:

  ghc -fPIC -shared dllmain.o Hs2lib.o /usr/local/lib/ghc-7.0.3/libHSrts.a -o Hs2lib.so 

其中dllmain.c和Hs2lib.hs都使用-fPIC编译。
我得到的错误是:

  / usr / bin / ld:/ usr / local / lib / ghc- 7.0.3 / libHSffi.a(closures.o):在创建共享对象时,不能使用R_X86_64_32 
和`.rodata';使用-fPIC重新编译
/usr/local/lib/ghc-7.0.3/libHSffi.a:无法读取符号:错误值

collect2:ld返回1退出状态

解决方案

如下所示:

  cd / tmp / Hs2lib924498 / 
ghc -fglasgow-exts --make -shared -oHs2lib。 /tmp/Hs2lib924498/Hs2lib.hs dllmain.o -static -fno-warn-deprecated-flags -fPIC -O2 -package ghc -package Hs2lib -i / home / phyx / Documents / Haskell / Hs2lib -optl -Wl, - s -funfolding-use-threshold = 16 -optc-O3 -optc -ffast-math

注意I添加-fPIC到失败的ghc命令中。

命令成功后,继续从tmp目录内编译而不清除已编译的文件。它应该跳过它们并继续它的结束。


I'm trying to install GHC with -fPIC support in Fedora. I've grabbed a source tarball since it seems no binary one has this.

In Build.mk i've changed the quick build type to

ifeq "$(BuildFlavour)" "quick"

SRC_HC_OPTS        = -H64m -O0 -fasm -fPIC
GhcStage1HcOpts    = -O -fasm -fPIC
GhcStage2HcOpts    = -O0 -fasm -fPIC
GhcLibHcOpts       = -O -fasm -fPIC
SplitObjs          = NO
HADDOCK_DOCS       = NO
BUILD_DOCBOOK_HTML = NO
BUILD_DOCBOOK_PS   = NO
BUILD_DOCBOOK_PDF  = NO

endif

unfortunately, when compiling i still get the ld error

ghc -fglasgow-exts --make -shared -oHs2lib.a /tmp/Hs2lib924498/Hs2lib.hs dllmain.o -static -fno-warn-deprecated-flags -O2 -package ghc -package Hs2lib -i/home/phyx/Documents/Haskell/Hs2lib -optl-Wl,-s -funfolding-use-threshold=16 -optc-O3 -optc-ffast-math
Linking a.out ...
/usr/bin/ld: /tmp/Hs2lib924498/Hs2lib.o: relocation R_X86_64_32 against `ghczmprim_GHCziUnit_Z0T_closure' can not be used when making a shared object; recompile with -fPIC
/tmp/Hs2lib924498/Hs2lib.o: could not read symbols: Bad value

So it seems that GHC-prim still isn't compiled with -FPIC I've also told cabal to build any packages with -fPIC and shared.

Anyone have any ideas?

EDIT: Thanks to dcouts I've been able to make some progress. But now i'm at the point where I thnk libffi isn't compiled with -fPIC. I've edited the makefile(.in) for it but so far, no luck.

The new command is:

 ghc -fPIC -shared dllmain.o Hs2lib.o /usr/local/lib/ghc-7.0.3/libHSrts.a -o Hs2lib.so

where dllmain.c and Hs2lib.hs have both been compiled using -fPIC. The error I get is:

/usr/bin/ld: /usr/local/lib/ghc-7.0.3/libHSffi.a(closures.o): relocation R_X86_64_32 
against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/ghc-7.0.3/libHSffi.a: could not read symbols: Bad value

collect2: ld returned 1 exit status

解决方案

After you see this error, do the following:

cd /tmp/Hs2lib924498/
ghc -fglasgow-exts --make -shared -oHs2lib.a /tmp/Hs2lib924498/Hs2lib.hs dllmain.o -static -fno-warn-deprecated-flags -fPIC -O2 -package ghc -package Hs2lib -i/home/phyx/Documents/Haskell/Hs2lib -optl-Wl,-s -funfolding-use-threshold=16 -optc-O3 -optc-ffast-math

Note I added -fPIC to the failed ghc command.

Once the command succeeds, continue the compilation from within the tmp directory without cleaning already compiled files. It should skip them and continue where it ended.

这篇关于用-fPIC支持编译ghc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆