有没有办法改变gcc的gcc编译选项? [英] Is there any way to change gcc compilation options for a gem?

查看:680
本文介绍了有没有办法改变gcc的gcc编译选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力安装RedCloth的宝石。当我输入

I'm struggling to install the RedCloth gem. When I type

gem install RedCloth

我得到:

I get :

[…]
ragel/redcloth_attributes.c.rl: In function ‘redcloth_attribute_parser’:
ragel/redcloth_attributes.c.rl:26:11: error: variable ‘act’ set but not used [-Werror=unused-but-set-variable]
cc1: all warnings being treated as errors

make: *** [redcloth_attributes.o] Error 1 
[…]

原因是在RedCloth gem的extconf.rb中传递给gcc的-Werror编译选项:

The reason is the -Werror compilation option passed to gcc in the extconf.rb of the RedCloth gem:

require 'mkmf'
CONFIG['warnflags'].gsub!(/-Wshorten-64-to-32/, '') if CONFIG['warnflags']
$CFLAGS << ' -O0 -Wall -Werror' if CONFIG['CC'] =~ /gcc/
[…]

问题是,当我从文件中删除-Werror选项时,它会在下次启动gem install命令时自动重新出现。

The problem is that when I remove the -Werror option from the file, it reappears automatically next time I launch the "gem install" command.

我怎样才能永久取消-Werror选项?

How can I permanently unset the -Werror option?

另一个选择是降级到gcc 4.5.2,但它是不在Fedora 15的仓库中。

Another option would be to downgrade to gcc 4.5.2, but it's not in the repositories of my Fedora 15.

我宁愿避免从源代码编译它...

And I'd rather avoid to compile it from source…

任何帮助,非常感谢。

推荐答案

有同样的问题,这里是解决方案:

Had the same problem and here is the solution:

#gem install RedCloth -- --with-cflags=\"-O2 -pipe -march=native -Wno-unused-but-set-variable\"

如果您有多个参数,则必须将引号转义。

You have to escape the quotes if you have more than one argument.

这篇关于有没有办法改变gcc的gcc编译选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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