Have_func() does not find a func in the given .h file

Hi, in my extconf.rb I check some Ruby functions (since I'm trying
Ruby trunk with rvm). I understand that the method have_func() does
not look into Ruby sources within my .rvm/ directory, so I call the
method by passing the exact file as argument:

/home/ibc/.rvm/repos/ruby$ grep ruby_thread_has_gvl_p vm_core.h
int ruby_thread_has_gvl_p(void);

But have_func() does not find it:

require "mkmf"
have_func("ruby_thread_has_gvl_p", "/home/ibc/.rvm/repos/ruby/vm_core.h")

checking for ruby_thread_has_gvl_p() in
/home/ibc/.rvm/repos/ruby/vm_core.h... no

Am I doint something wrong?
Thanks a lot.

···

--
Iñaki Baz Castillo
<ibc@aliax.net>

Hi, in my extconf.rb I check some Ruby functions (since I'm trying
Ruby trunk with rvm). I understand that the method have_func() does
not look into Ruby sources within my .rvm/ directory, so I call the
method by passing the exact file as argument:

/home/ibc/.rvm/repos/ruby$ grep ruby_thread_has_gvl_p vm_core.h
int ruby_thread_has_gvl_p(void);

This is a private function, Ruby uses gcc -fvisibility=hidden to
hide them and only exposes certain functions in vm_core.h
via "#pragma GCC visibility ..."

But have_func() does not find it:

ave_func() doesn't parse C headers to find functions, but instead
tries to link a C program to find the function.

> require "mkmf"
> have_func("ruby_thread_has_gvl_p", "/home/ibc/.rvm/repos/ruby/vm_core.h")
checking for ruby_thread_has_gvl_p() in
/home/ibc/.rvm/repos/ruby/vm_core.h... no

Am I doint something wrong?

You're relying too much on ever-changing Ruby internals :slight_smile:

···

Iñaki Baz Castillo <ibc@aliax.net> wrote:

/home/ibc/.rvm/repos/ruby$ grep ruby_thread_has_gvl_p vm_core.h
int ruby_thread_has_gvl_p(void);

This is a private function, Ruby uses gcc -fvisibility=hidden to
hide them and only exposes certain functions in vm_core.h
via "#pragma GCC visibility ..."

Good to know.

But have_func() does not find it:

have_func() doesn't parse C headers to find functions, but instead
tries to link a C program to find the function.

Even better to know :slight_smile:

Am I doint something wrong?

You're relying too much on ever-changing Ruby internals :slight_smile:

Well, it's just for temporal debugging purposes. I've
detected/experienced some changes in GVL stuf from 1.9.3 to trunk
version and ruby_thread_has_gvl_p() seems an useful debugging
function.

Thanks a lot.

···

2012/6/25 Eric Wong <normalperson@yhbt.net>:

Iñaki Baz Castillo <ibc@aliax.net> wrote:

--
Iñaki Baz Castillo
<ibc@aliax.net>