通过makefile传递一个gcc标志 [英] Passing a gcc flag through makefile

查看:135
本文介绍了通过makefile传递一个gcc标志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 llvm 构建通行证,并且已完成构建llvm及其关联组件。但是,当我按照所有步骤构建通行证(包括 makefile )后运行make时,我得到以下的内容:

I am trying to build a pass using llvm and I have finished building llvm and its associated components. However, when I run make after following all the steps to build a pass including the makefile, I get the following


重新定位R_X86_64_32对于`本地符号'不能用于制作共享对象;使用-fPIC重新编译

relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC

在通过搜索错误消息找到修复程序后,我开始知道这不是特定于llvm 。一些解决方案建议我在运行configure时使用--enable-shared,但这对我的情况没有帮助。现在我想用 fPIC 重新构建llvm,如错误所述。但是,如何使用makefile执行此操作?

After tyring to find a fix by googling the error message, I came to know that this is not specific to llvm. A few solutions suggested that I should use "--enable-shared" while running configure but that didn't help my case. Now I want to re-build llvm using fPIC, as the error says. But how do I do this using the makefile?

推荐答案

看起来您可以添加-fPIC(对于位置无关的代码,您可以通过设置shell变量来设置共享库的一些内容:

Looks like you could add the -fPIC (for position-independent code, something you want for a shared library that could be loaded at any address) by setting shell variables:

export CFLAGS="$CFLAGS -fPIC"
export CXXFLAGS="$CXXFLAGS -fPIC"

查看 Makefile.rules ,这些将被拿起并使用。似乎很奇怪,它并不在那里开始。

Looking at Makefile.rules, these will be picked up and used. Seems strange that it wasn't there to begin with.

编辑:

其实,阅读更多makefiles,我发现这个链接到 LLVM Makefile Guide 。从Makefile.rules中,在Makefile中设置SHARED_LIBRARY = 1或LOADABLE_MODULE = 1(这意味着SHARED_LIBRARY)会将-fPIC放入编译器标志中。

Actually, reading more in the makefiles, I found this link to the LLVM Makefile Guide. From Makefile.rules, setting either SHARED_LIBRARY=1 or LOADABLE_MODULE=1 (which implies SHARED_LIBRARY) in Makefile will put -fPIC in the compiler flags.

这篇关于通过makefile传递一个gcc标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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