Ruby & gprof and thread.so undefined reference torb_thread_critical

J

John Carter

So I was sitting there glaring at the screen whilst my script went off
and did lots and lots.....
....and started to think wonder how I could make it a little faster....

After all, I have thrown every trick in the
http://www.rubygarden.org:3000/Ruby/page/show/RubyOptimization
book at the Ruby level (indeed I wrote a most of that)

Now I started to wonder if I could tweak Ruby itself to run a little faster...

So profile first...

CFLAGS='-p -pg -O2' LDFLAGS='-p -pg' ./configure --program-suffix=-profile
make CFLAGS='-p -pg -O2' LDFLAGS='-p -pg'
su
make install CFLAGS='-p -pg -O2' LDFLAGS='-p -pg'

It seems to work and run for the basic stuff, lets hit the Big Script...

Oh dear!
undefined reference to rb_thread_critical in thread.so

Oh, dear.

Here's the shortest bit that triggers it...

irb-profile -rthread
/usr/local/lib/ruby/1.8/i686-linux/thread.so: /usr/local/lib/ruby/1.8/i686-linux/thread.so: undefined symbol: rb_thread_critical - /usr/local/lib/ruby/1.8/i686-linux/thread.so (LoadError)
from /usr/local/lib/ruby/1.8/thread.rb:5
from /usr/local/lib/ruby/1.8/irb/init.rb:252:in `require'
from /usr/local/lib/ruby/1.8/irb/init.rb:252:in `load_modules'
from /usr/local/lib/ruby/1.8/irb/init.rb:250:in `each'
from /usr/local/lib/ruby/1.8/irb/init.rb:250:in `load_modules'
from /usr/local/lib/ruby/1.8/irb/init.rb:21:in `setup'
from /usr/local/lib/ruby/1.8/irb.rb:54:in `start'
from /usr/local/bin/irb-profile:13

Anyone with any guesses what to do?


John Carter Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : (e-mail address removed)
New Zealand
 
M

M. Edward (Ed) Borasky

John said:
So I was sitting there glaring at the screen whilst my script went off
and did lots and lots.....
....and started to think wonder how I could make it a little faster....

After all, I have thrown every trick in the
http://www.rubygarden.org:3000/Ruby/page/show/RubyOptimization
book at the Ruby level (indeed I wrote a most of that)

Now I started to wonder if I could tweak Ruby itself to run a little
faster...

So profile first...

CFLAGS='-p -pg -O2' LDFLAGS='-p -pg' ./configure
--program-suffix=-profile
make CFLAGS='-p -pg -O2' LDFLAGS='-p -pg'
su
make install CFLAGS='-p -pg -O2' LDFLAGS='-p -pg'

It seems to work and run for the basic stuff, lets hit the Big Script...

Oh dear!
undefined reference to rb_thread_critical in thread.so

Oh, dear.

Here's the shortest bit that triggers it...

irb-profile -rthread
/usr/local/lib/ruby/1.8/i686-linux/thread.so:
/usr/local/lib/ruby/1.8/i686-linux/thread.so: undefined symbol:
rb_thread_critical - /usr/local/lib/ruby/1.8/i686-linux/thread.so
(LoadError)
from /usr/local/lib/ruby/1.8/thread.rb:5
from
/usr/local/lib/ruby/1.8/irb/init.rb:252:in `require'
from
/usr/local/lib/ruby/1.8/irb/init.rb:252:in `load_modules'
from
/usr/local/lib/ruby/1.8/irb/init.rb:250:in `each'
from
/usr/local/lib/ruby/1.8/irb/init.rb:250:in `load_modules'
from
/usr/local/lib/ruby/1.8/irb/init.rb:21:in `setup'
from /usr/local/lib/ruby/1.8/irb.rb:54:in
`start'
from /usr/local/bin/irb-profile:13

Anyone with any guesses what to do?


John Carter Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : (e-mail address removed)
New Zealand
1. Recompile without the -O2 and see if it goes away. "Normally", when
one compiles for profiling, one uses "-g -pg" which forces *no*
optimization.
2. If the recompiled (and stock Ruby) work, it's a GCC problem. If the
recompiled doesn't work and the stock Ruby does, check your
configuration parameters on your profiling build.

Incidentally, I've done a few tests with a profiling Ruby and I've never
hit anything like this, but nothing I've done goes anywhere near threading.

By the way, what version of GCC are you using? And are you building the
non-profiling Ruby from source too?
 
J

John Carter

Thanks for your suggestions, alas, it didn't resolve the issue.

1. Recompile without the -O2 and see if it goes away.

Alas not.
2. If the recompiled (and stock Ruby) work, it's a GCC problem. If the
recompiled doesn't work and the stock Ruby does, check your configuration
parameters on your profiling build.

Compiling without -pg works fine. Compiling with -pg and --disable-shared fails.
By the way, what version of GCC are you using?
gcc-4.1.2 ubuntu edgy eft
And are you building the non-profiling Ruby from source too?
Yip, works fine.
If God had meant for carrots to be eaten cooked, He would have given rabbits
fire.

He gave us fire so we can eat carrots in the form of cooked rabbits?

Thanks!

John Carter Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : (e-mail address removed)
New Zealand
 
M

M. Edward (Ed) Borasky

John said:
Thanks for your suggestions, alas, it didn't resolve the issue.



Alas not.


Compiling without -pg works fine. Compiling with -pg and
--disable-shared fails.
I'm not familiar with "disable-shared", but I suspect it builds static
libraries instead of shared ones. I think you *want* shared libraries.
But if "-pg" is the problem, it's probably GCC. I've got 4.1.2 on my
(Gentoo) systems and I've never seen a problem like this with "-pg". The
only issue I've had at all is that both Ruby and Tcl/Tk have to be built
either with threads or without threads -- you can't mix them.

This works on my box:


# build profiling Ruby
mkdir profiling-ruby-build
cd profiling-ruby-build
CFLAGS='-g -pg' ../ruby/configure --disable-install-doc --enable-pthread
--prefix=/home/test/profiling-ruby
make; make install
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top