本文共 1267 字,大约阅读时间需要 4 分钟。
编译时出现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就是在这个时候设置的。还是看一下这个时候的汇编代码吧 ;-)
转载地址:http://qnmrb.baihongyu.com/