Ruby & gprof and thread.so undefined reference to rb_thread

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 C. Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : [email protected]
New Zealand

John C. wrote:

Oh dear!
(LoadError)
/usr/local/lib/ruby/1.8/irb/init.rb:21:in `setup’
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?


M. Edward (Ed) Borasky, FBG, AB, PTA, PGS, MS, MNLP, NST, ACMC(P)
http://borasky-research.blogspot.com/

If God had meant for carrots to be eaten cooked, He would have given
rabbits fire.

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

On Wed, 28 Mar 2007, M. Edward (Ed) Borasky wrote:

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

Alas not.

  1. 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 C. Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : [email protected]
New Zealand

John C. wrote:

configuration parameters on your profiling build.

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

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

Thanks!

John C. Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : [email protected]
New Zealand


M. Edward (Ed) Borasky, FBG, AB, PTA, PGS, MS, MNLP, NST, ACMC(P)
http://borasky-research.blogspot.com/

If God had meant for carrots to be eaten cooked, He would have given
rabbits fire.