我无法使用RVM和ruby 2.3.0(2.2.1相同)编译ruby扩展,并显示以下消息:city.cc:1:0:错误:您选择的CPU不支持x86-64指令集在64位CPU上使用x86_64 Debian Wheezy,x86_64 ruby和gcc。尽管如此,似乎红宝石使用-march=native
会产生问题。我不知道如何解决此问题。
详情如下:
编译示例扩展:
gem install cityhash
Building native extensions. This could take a while...
ERROR: Error installing cityhash:
ERROR: Failed to build gem native extension.
current directory: /usr/local/rvm/gems/ruby-2.3.0/gems/cityhash-0.8.1/ext/cityhash
/usr/local/rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160317-15208-1shn16g.rb extconf.rb
creating Makefile
current directory: /usr/local/rvm/gems/ruby-2.3.0/gems/cityhash-0.8.1/ext/cityhash
make "DESTDIR=" clean
current directory: /usr/local/rvm/gems/ruby-2.3.0/gems/cityhash-0.8.1/ext/cityhash
make "DESTDIR="
compiling city.cc
cc1plus: warning: command line option ‘-Wdeclaration-after-statement’ is valid for C/ObjC but not for C++ [enabled by default]
cc1plus: warning: command line option ‘-Wimplicit-function-declaration’ is valid for C/ObjC but not for C++ [enabled by default]
city.cc:1:0: error: CPU you selected does not support x86-64 instruction set
make: *** [city.o] Błąd 1
make failed, exit code 2
Gem files will remain installed in /usr/local/rvm/gems/ruby-2.3.0/gems/cityhash-0.8.1 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.3.0/extensions/x86_64-linux/2.3.0/cityhash-0.8.1/gem_make.out
生成文件正在尝试运行以下命令:
$ make -n
echo compiling city.cc
g++ -I. -I/usr/local/rvm/rubies/ruby-2.3.0/include/ruby-2.3.0/x86_64-linux -I/usr/local/rvm/rubies/ruby-2.3.0/include/ruby-2.3.0/ruby/backward -I/usr/local/rvm/rubies/ruby-2.3.0/include/ruby-2.3.0 -I. -g -O3 -Wall -march=native -fPIC -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -o city.o -c city.cc
echo compiling cityhash.cc
g++ -I. -I/usr/local/rvm/rubies/ruby-2.3.0/include/ruby-2.3.0/x86_64-linux -I/usr/local/rvm/rubies/ruby-2.3.0/include/ruby-2.3.0/ruby/backward -I/usr/local/rvm/rubies/ruby-2.3.0/include/ruby-2.3.0 -I. -g -O3 -Wall -march=native -fPIC -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -o cityhash.o -c cityhash.cc
echo linking shared-object cityhash/cityhash.so
rm -f cityhash.so
g++ -shared -o cityhash.so city.o cityhash.o -L. -L/usr/local/rvm/rubies/ruby-2.3.0/lib -Wl,-R/usr/local/rvm/rubies/ruby-2.3.0/lib -L. -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-R/usr/local/rvm/rubies/ruby-2.3.0/lib -L/usr/local/rvm/rubies/ruby-2.3.0/lib -lruby -lpthread -lrt -ldl -lcrypt -lm -lc
uname,ruby,gcc版本-似乎都是64位的:
$ uname -a
Linux bukwica-prod 3.2.0-4-amd64 #1 SMP Debian 3.2.68-1+deb7u6 x86_64 GNU/Linux
$ ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.7.2-5' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.2 (Debian 4.7.2-5)
..虽然我不知道为什么-match = native我得到pentium-m
$ gcc -march=native -Q --help=target |grep march
-march= pentium-m
我没有主意,请帮忙!
它是在gem中显式设置的(错误地)
%w{g O3 Wall march=native}.each do |flag|
flag = "-#{flag}"
$CPPFLAGS += " #{flag}" unless $CPPFLAGS.split.include? flag
end
应该:
%w{g O3 Wall march}.each do |flag|
flag = "-#{flag}"
$CPPFLAGS += " #{flag}" unless $CPPFLAGS.split.include? flag
end
这个拉取请求会更新以完全消除行军,但是它确实很老,所以不要指望那里有什么变化。
您可以通过bundle
将其放在您的位置来覆盖从哪里提取宝石Gemfile
:
gem 'cityhash', :git => 'git://github.com/lyfeyaj/cityhash.git'
这将安装包含拉取请求的分叉版本
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句