有什么方法可以更改 gem 的 gcc 编译选项吗? [英] Is there any way to change gcc compilation options for a gem?

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

问题描述

我正在努力安装 RedCloth gem.当我输入

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

gem install RedCloth

我明白了:

[…]
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:

$ sudo 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.

这篇关于有什么方法可以更改 gem 的 gcc 编译选项吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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