ruby-1.9.1-p0 に ruby-prof 0.7.3 を gemで入れられない件
% ./configure --program-suffix=-1.9.1 --prefix=$HOME/local % make -j 8 % make install-nodoc
のようにごく普通にビルド、インストールしたrubyにて、ruby-profをgemからインストールしようとしたらできなかった。
% gem-1.9.1 install ruby-prof
Building native extensions. This could take a while...
ERROR: Error installing ruby-prof:
ERROR: Failed to build gem native extension.
/home/komuro/local/bin/ruby-1.9.1 extconf.rb install ruby-prof
checking for sys/times.h... yes
checking for rb_os_allocated_objects()... no
checking for rb_gc_allocated_size()... no
checking for rb_gc_collections()... no
checking for rb_gc_time()... no
checking for rb_heap_total_mem()... no
checking for rb_gc_heap_info()... no
checking for rb_gc_malloc_allocations()... no
checking for rb_gc_malloc_allocated_size()... no
creating Makefile
make
gcc -I. -I/home/komuro/local/include/ruby-1.9.1-1.9.1/i686-linux -I/home/komuro/local/include/ruby-1.9.1-1.9.1/ruby/backward -I/home/komuro/local/include/ruby-1.9.1-1.9.1 -I. -DHAVE_SYS_TIMES_H -D_FILE_OFFSET_BITS=64 -fPIC -O2 -g -Wall -Wno-parentheses -o ruby_prof.o -c ruby_prof.c
ruby_prof.c:867: error: expected declaration specifiers or '...' before 'NODE'
ruby_prof.c: In function 'prof_event_hook':
ruby_prof.c:1114: error: 'node' undeclared (first use in this function)
ruby_prof.c:1114: error: (Each undeclared identifier is reported only once
ruby_prof.c:1114: error: for each function it appears in.)
ruby_prof.c:1114: error: too many arguments to function 'get_method'
ruby_prof.c:1120: 警告: passing argument 5 of 'get_method' makes pointer from integer without a cast
ruby_prof.c:1120: error: too many arguments to function 'get_method'
make: *** [ruby_prof.o] エラー 1
Gem files will remain installed in /home/komuro/local/lib/ruby-1.9.1/gems/1.9.1/gems/ruby-prof-0.7.3
for inspection.
Results logged to /home/komuro/local/lib/ruby-1.9.1/gems/1.9.1/gems/ruby-prof-0.7.3/ext/gem_make.outおもいっきしエラーでてます。該当部分見た感じruby-1.9系列ならエラーになりそう。
というわけでruby-profのサイトからリポジトリの最新のコードを入手してビルドしたらちゃんとインストールできました。
% svn checkout svn://rubyforge.org/var/svn/ruby-prof % cd ruby-prof/trunk % rake-1.9.1 (in /home/komuro/lang/ignore/ruby/ruby-prof/trunk) mkdir -p pkg ... Successfully built RubyGem Name: ruby-prof Version: 0.7.3 File: ruby-prof-0.7.3.gem mv ruby-prof-0.7.3.gem pkg/ruby-prof-0.7.3.gem % gem-1.9.1 install pkg/ruby-prof-0.7.3.gem Building native extensions. This could take a while... Successfully installed ruby-prof-0.7.3 1 gem installed Installing ri documentation for ruby-prof-0.7.3... Installing RDoc documentation for ruby-prof-0.7.3...
これでruby -runprof hoge.rbなどとしてプロファイルが取れるようになってるはず。試しにこんなんやってみる。
% ruby-1.9.1 -runprof -e"p (1..10000).inject(1){|x,y|x*y}"
284625968091705451890641321211986889014805140170279923079...
Thread ID: 82288100
Total: 0.440000
%self total self wait child calls name
77.27 0.34 0.34 0.00 0.00 9987 Bignum#*
20.45 0.09 0.09 0.00 0.00 1 Bignum#to_s
2.27 0.35 0.01 0.00 0.34 1 Range#each
0.00 0.09 0.00 0.00 0.09 1 Kernel#p
0.00 0.09 0.00 0.00 0.09 1 Kernel#inspect
0.00 0.35 0.00 0.00 0.35 1 Enumerable#inject
0.00 0.44 0.00 0.00 0.44 1 Global#[No method]
0.00 0.00 0.00 0.00 0.00 1 <Class::Range>#allocateまあそれっぽい結果出てますし大丈夫そうですね。