有没有办法改变宝石的gcc编译选项?

Nic*_*ser 10 gem gcc ruby-on-rails

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

gem install RedCloth
Run Code Online (Sandbox Code Playgroud)

我明白了:

[…]
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 
[…]
Run Code Online (Sandbox Code Playgroud)

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

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

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

如何永久取消设置-Werror选项?


另一个选择是降级到gcc 4.5.2,但它不在我的Fedora 15的存储库中.

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

任何帮助非常感谢.

Oli*_*Sys 21

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

$ sudo gem install RedCloth -- --with-cflags=\"-O2 -pipe -march=native -Wno-unused-but-set-variable\"
Run Code Online (Sandbox Code Playgroud)

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


Max*_*ick 11

如果您正在使用bundler,以下工作:

bundle config build.RedCloth --with-cflags=\"-O2 -pipe -march=native -Wno-unused-but-set-variable\"
Run Code Online (Sandbox Code Playgroud)