unrecognized command line option "-frame-pointer"解决方法

编译时出现unrecognized command line option "-frame-pointer"的解决办法(陈运文)

报这个错误是因为当前的环境变量不兼容引起的,正在编译的程序不支持编译优化选项-frame-pointer,
这个编译项项在CXXFLAGS这个环境变量中,运行
$echo CXXFLAGS

看看是否里面默认带了这个参数,如果编译遇到unrecognized command line的报错,则运行以下命令:

$CXXFLAGS=""

这时将CXXFLAGS清空,然后重新运行安装程序的 
./configure 
命令,生成环境变量
可以再运行
$echo CXXFLAGS
看看是否更改过来了

然后重新 ./make, 就可以编译通过了

下面补充一些-frame-pointer编译选项的知识:

GCC手册上面是这么说的:


Don't keep the frame pointer in a register for functions that don't need one. This avoids the instructions to save, set up and restore frame pointers; it also makes an extra register available in many functions. It also makes debugging impossible on some machines.


On some machines, such as the VAX, this flag has no effect, because the standard calling sequence automatically handles the frame pointer and nothing is saved by pretending it doesn't exist. The machine-description macro "FRAME_POINTER_REQUIRED" controls whether a target machine supports this flag.


这里,引入了一个"frame pointer"的概念,什么是"stack frame pointer(SFP)"呢?

我们知道,backtrace是利用堆栈中的信息把函数调用关系层层遍历出来的,其中这里的堆栈信息就是SFP。
一般情况下,每一个函数都包含一个堆栈边界指针,也就是说会存在一个栈底和栈顶指针。在X86下,假设堆栈由上往下发展,栈底大地址而栈顶小地址,那么,通常情况下,寄存器ESP为栈顶指针,而EBP就为栈底指针。而EBP和ESP之间的空间就是这个函数的stack frame。

GCC在默认情况下会在每个函数的开始加入一些堆栈设置代码,而在函数退出的时候恢复原来的样子,SFP就是在这个时候设置的。还是看一下这个时候的汇编代码吧 ;-)



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值