由于rubygem依赖,需要安装eventmachine
版本1.0.0.beta.3。按如下方式安装rubygem会导致错误。为方便起见,附上一个片段。
$ sudo gem install eventmachine -v '1.0.0.beta.3'
Building native extensions. This could take a while...
ERROR: Error installing eventmachine:
ERROR: Failed to build gem native extension.
/usr/bin/ruby2.0 extconf.rb
checking for rb_trap_immediate in ruby.h,rubysig.h... no
checking for rb_thread_blocking_region()... yes
checking for inotify_init() in sys/inotify.h... yes
checking for writev() in sys/uio.h... yes
checking for rb_thread_check_ints()... yes
checking for rb_time_new()... yes
checking for sys/event.h... no
checking for epoll_create() in sys/epoll.h... yes
creating Makefile
make "DESTDIR="
compiling cmain.cpp
compiling kb.cpp
kb.cpp: In member function ‘virtual void KeyboardDescriptor::Read()’:
kb.cpp:77:27: warning: ignoring return value of ‘ssize_t read(int, void*, size_t)’, declared with attribute warn_unused_result [-Wunused-result]
read (GetSocket(), &c, 1);
^
compiling pipe.cpp
compiling binder.cpp
compiling ed.cpp
compiling page.cpp
compiling rubymain.cpp
rubymain.cpp: In function ‘VALUE t_connect_server(VALUE, VALUE, VALUE)’:
rubymain.cpp:504:42: error: format not a string literal and no format arguments [-Werror=format-security]
rb_raise (EM_eConnectionError, e.what());
^
rubymain.cpp: In function ‘VALUE t_bind_connect_server(VALUE, VALUE, VALUE, VALUE, VALUE)’:
rubymain.cpp:525:42: error: format not a string literal and no format arguments [-Werror=format-security]
rb_raise (EM_eConnectionError, e.what());
^
rubymain.cpp: In function ‘VALUE t_watch_filename(VALUE, VALUE)’:
rubymain.cpp:798:38: error: format not a string literal and no format arguments [-Werror=format-security]
rb_raise (EM_eUnsupported, e.what());
^
rubymain.cpp: In function ‘VALUE t_watch_pid(VALUE, VALUE)’:
rubymain.cpp:824:38: error: format not a string literal and no format arguments [-Werror=format-security]
rb_raise (EM_eUnsupported, e.what());
^
rubymain.cpp: In function ‘VALUE t_start_proxy(VALUE, VALUE, VALUE, VALUE, VALUE)’:
rubymain.cpp:1024:42: error: format not a string literal and no format arguments [-Werror=format-security]
rb_raise (EM_eConnectionError, e.what());
^
rubymain.cpp: In function ‘VALUE t_stop_proxy(VALUE, VALUE)’:
rubymain.cpp:1039:42: error: format not a string literal and no format arguments [-Werror=format-security]
rb_raise (EM_eConnectionError, e.what());
^
cc1plus: some warnings being treated as errors
make: *** [rubymain.o] Error 1
Gem files will remain installed in /var/lib/gems/2.0.0/gems/eventmachine-1.0.0.beta.3 for inspection.
Results logged to /var/lib/gems/2.0.0/gems/eventmachine-1.0.0.beta.3/ext/gem_make.out
我尝试修改/var/lib/gems/2.0.0/gems/eventmachine-1.0.0.beta.3/ext/Makefile
,将-Werror=format-security
替换为-Wformat-security
,然后运行make
。虽然在尝试检查rubygem安装是否具有一致的行为时,它安装了rubygem。因此,我试图再次调用上面的命令(gem install...
),但它再次失败。
这里有关于该系统的更多细节:
$ ruby --version
ruby 2.0.0p299 (2013-08-29) [x86_64-linux-gnu]
$ cat /etc/*release* | grep -i distrib
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=13.10
DISTRIB_CODENAME=saucy
DISTRIB_DESCRIPTION="Ubuntu 13.10"
$ uname -a
Linux user 3.11.0-15-generic #23-Ubuntu SMP Mon Dec 9 18:17:04 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
$ gcc --version | grep gcc
gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
我也熟悉this fix solution和this one,但它对我不起作用。 任何帮助将不胜感激。
更新
我也尝试了以下内容:
$ sudo gem install eventmachine -v '1.0.0.beta.3' -- --with-cflags=\"-Wno-error=format-security\"
Building native extensions with: '--with-cflags="-Wno-error=format-security"'
This could take a while...
ERROR: Error installing eventmachine:
ERROR: Failed to build gem native extension.
/usr/bin/ruby2.0 extconf.rb --with-cflags="-Wno-error=format-security"
checking for rb_trap_immediate in ruby.h,rubysig.h... no
checking for rb_thread_blocking_region()... yes
checking for inotify_init() in sys/inotify.h... yes
checking for writev() in sys/uio.h... yes
checking for rb_thread_check_ints()... yes
checking for rb_time_new()... yes
checking for sys/event.h... no
checking for epoll_create() in sys/epoll.h... yes
creating Makefile
make "DESTDIR="
compiling cmain.cpp
compiling kb.cpp
kb.cpp: In member function ‘virtual void KeyboardDescriptor::Read()’:
kb.cpp:77:27: warning: ignoring return value of ‘ssize_t read(int, void*, size_t)’, declared with attribute warn_unused_result [-Wunused-result]
read (GetSocket(), &c, 1);
^
compiling pipe.cpp
compiling binder.cpp
compiling ed.cpp
compiling page.cpp
compiling rubymain.cpp
rubymain.cpp: In function ‘VALUE t_connect_server(VALUE, VALUE, VALUE)’:
rubymain.cpp:504:42: error: format not a string literal and no format arguments [-Werror=format-security]
rb_raise (EM_eConnectionError, e.what());
^
rubymain.cpp: In function ‘VALUE t_bind_connect_server(VALUE, VALUE, VALUE, VALUE, VALUE)’:
rubymain.cpp:525:42: error: format not a string literal and no format arguments [-Werror=format-security]
rb_raise (EM_eConnectionError, e.what());
^
rubymain.cpp: In function ‘VALUE t_watch_filename(VALUE, VALUE)’:
rubymain.cpp:798:38: error: format not a string literal and no format arguments [-Werror=format-security]
rb_raise (EM_eUnsupported, e.what());
^
rubymain.cpp: In function ‘VALUE t_watch_pid(VALUE, VALUE)’:
rubymain.cpp:824:38: error: format not a string literal and no format arguments [-Werror=format-security]
rb_raise (EM_eUnsupported, e.what());
^
rubymain.cpp: In function ‘VALUE t_start_proxy(VALUE, VALUE, VALUE, VALUE, VALUE)’:
rubymain.cpp:1024:42: error: format not a string literal and no format arguments [-Werror=format-security]
rb_raise (EM_eConnectionError, e.what());
^
rubymain.cpp: In function ‘VALUE t_stop_proxy(VALUE, VALUE)’:
rubymain.cpp:1039:42: error: format not a string literal and no format arguments [-Werror=format-security]
rb_raise (EM_eConnectionError, e.what());
^
cc1plus: some warnings being treated as errors
make: *** [rubymain.o] Error 1
Gem files will remain installed in /var/lib/gems/2.0.0/gems/eventmachine-1.0.0.beta.3 for inspection.
Results logged to /var/lib/gems/2.0.0/gems/eventmachine-1.0.0.beta.3/ext/gem_make.out
你可以看到该标志没有传播到rubygem的编译。
更新2:
还尝试了以下内容:
$ sudo gem install eventmachine -v '1.0.0.beta.3' -- --with-cppflags=\"-Wno-error=format-security\"
Building native extensions with: '--with-cppflags="-Wno-error=format-security"'
This could take a while...
ERROR: Error installing eventmachine:
ERROR: Failed to build gem native extension.
/usr/bin/ruby2.0 extconf.rb --with-cppflags="-Wno-error=format-security"
checking for rb_trap_immediate in ruby.h,rubysig.h... no
checking for rb_thread_blocking_region()... yes
checking for inotify_init() in sys/inotify.h... yes
checking for writev() in sys/uio.h... yes
checking for rb_thread_check_ints()... yes
checking for rb_time_new()... yes
checking for sys/event.h... no
checking for epoll_create() in sys/epoll.h... yes
creating Makefile
make "DESTDIR="
compiling cmain.cpp
compiling kb.cpp
kb.cpp: In member function ‘virtual void KeyboardDescriptor::Read()’:
kb.cpp:77:27: warning: ignoring return value of ‘ssize_t read(int, void*, size_t)’, declared with attribute warn_unused_result [-Wunused-result]
read (GetSocket(), &c, 1);
^
compiling pipe.cpp
compiling binder.cpp
compiling ed.cpp
compiling page.cpp
compiling rubymain.cpp
rubymain.cpp: In function ‘VALUE t_connect_server(VALUE, VALUE, VALUE)’:
rubymain.cpp:504:42: error: format not a string literal and no format arguments [-Werror=format-security]
rb_raise (EM_eConnectionError, e.what());
^
rubymain.cpp: In function ‘VALUE t_bind_connect_server(VALUE, VALUE, VALUE, VALUE, VALUE)’:
rubymain.cpp:525:42: error: format not a string literal and no format arguments [-Werror=format-security]
rb_raise (EM_eConnectionError, e.what());
^
rubymain.cpp: In function ‘VALUE t_watch_filename(VALUE, VALUE)’:
rubymain.cpp:798:38: error: format not a string literal and no format arguments [-Werror=format-security]
rb_raise (EM_eUnsupported, e.what());
^
rubymain.cpp: In function ‘VALUE t_watch_pid(VALUE, VALUE)’:
rubymain.cpp:824:38: error: format not a string literal and no format arguments [-Werror=format-security]
rb_raise (EM_eUnsupported, e.what());
^
rubymain.cpp: In function ‘VALUE t_start_proxy(VALUE, VALUE, VALUE, VALUE, VALUE)’:
rubymain.cpp:1024:42: error: format not a string literal and no format arguments [-Werror=format-security]
rb_raise (EM_eConnectionError, e.what());
^
rubymain.cpp: In function ‘VALUE t_stop_proxy(VALUE, VALUE)’:
rubymain.cpp:1039:42: error: format not a string literal and no format arguments [-Werror=format-security]
rb_raise (EM_eConnectionError, e.what());
^
cc1plus: some warnings being treated as errors
make: *** [rubymain.o] Error 1
Gem files will remain installed in /var/lib/gems/2.0.0/gems/eventmachine-1.0.0.beta.3 for inspection.
Results logged to /var/lib/gems/2.0.0/gems/eventmachine-1.0.0.beta.3/ext/gem_make.out
更新3:
$ sudo gem install eventmachine -v '1.0.0.beta.3' 2>&1 | grep -i inspection
Gem files will remain installed in /var/lib/gems/2.0.0/gems/eventmachine-1.0.0.beta.3 for inspection.
$ grep -i error /var/lib/gems/2.0.0/gems/eventmachine-1.0.0.beta.3/ext/Makefile
CFLAGS = $(CCDLFLAGS) -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -fPIC $(ARCH_FLAG)
CXXFLAGS = $(CCDLFLAGS) -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security $(ARCH_FLAG)
$ sudo gem install eventmachine -v '1.0.0.beta.3' -- --with-cflags=\"-Wno-error=format-security\" --with-cppflags=\"-Wno-error=format-security\" --with-cxxflags=\"-Wno-error=format-security\" 2>&1 | grep -i inspection
Gem files will remain installed in /var/lib/gems/2.0.0/gems/eventmachine-1.0.0.beta.3 for inspection.
$ grep -i error /var/lib/gems/2.0.0/gems/eventmachine-1.0.0.beta.3/ext/Makefile
CFLAGS = $(CCDLFLAGS) -Wno-error=format-security $(ARCH_FLAG)
CPPFLAGS = -DWITH_SSL -DBUILD_FOR_RUBY -DHAVE_RB_THREAD_BLOCKING_REGION -DHAVE_TBR -DHAVE_INOTIFY_INIT -DHAVE_INOTIFY -DHAVE_WRITEV -DHAVE_WRITEV -DHAVE_RB_THREAD_CHECK_INTS -DHAVE_RB_TIME_NEW -DOS_UNIX -DHAVE_EPOLL_CREATE -DHAVE_EPOLL -DHAVE_MAKE_PAIR -Wno-error=format-security
CXXFLAGS = $(CCDLFLAGS) -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security $(ARCH_FLAG)
请参考CXXFLAGS
,为什么传递给comiplation的标志没有被传播?
答案 0 :(得分:2)