minad / lmdb

Ruby bindings for the OpenLDAP's Lightning Memory-Mapped Database (LMDB)
https://github.com/minad/lmdb
106 stars 38 forks source link

Gem fails to compile #55

Open dnebdal opened 3 years ago

dnebdal commented 3 years ago

Hi. Using ruby 2.7.2 on Fedora 33, both "gem install lmdb" and a git clone / bundle exec rake fails with very similar errors:

gcc -I. -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I../../../../ext/lmdb_ext -I../../../../ext/lmdb_ext/liblmdb -DRUBY_EXTCONF_H=\"extconf.h\"    -fPIC -std=c99 -Wall -g -m64 -o lmdb_ext.o -c ../../../../ext/lmdb_ext/lmdb_ext.c
../../../../ext/lmdb_ext/lmdb_ext.c: In function ‘call_with_transaction_helper’:
../../../../ext/lmdb_ext/lmdb_ext.c:172:10: error: #error "Not implemented"
  172 |         #error "Not implemented"
      |          ^~~~~

As far as I can tell, this is this block in lmdb_ext.c , starting at line 169:

// Ruby 1.8.7 compatibility
#ifndef HAVE_RB_FUNCALL_PASSING_BLOCK
static VALUE call_with_transaction_helper(VALUE arg) {
        #error "Not implemented"
}
#else
static VALUE call_with_transaction_helper(VALUE arg) {
        HelperArgs* a = (HelperArgs*)arg;
        return rb_funcall_passing_block(a->self, rb_intern(a->name), a->argc, a->argv);
}
#endif

Just removing the entire ifdef and uncritically using the #else version seems to work for me, but I assume it's there for a reason.

doriantaylor commented 3 years ago

hmmm I'm gonna assume that's reeeally old. One moment, I haven't looked at this in a while.

doriantaylor commented 3 years ago

I just successfully compiled on 2.7.0 on Ubuntu 20.04 and 3.0.1 on macOS. It looks like your extconf.rb is not picking the presence of rb_funcall_passing_block. (or not being run at all?)

Is it possible to see what your extconf.h looks like, the one that gets generated when you try to bundle exec rake?

Also since I've taken over maintenance of this gem, can you try building my fork?

dnebdal commented 3 years ago

Same thing from your fork, I'm afraid. It's entirely possible that this is on me; I very rarely use Ruby and I'm going by guesswork and google for how to build gems.

Here's a log of what I did, how it failed, and what's in extconf.rb and extconf.h : https://gist.github.com/dnebdal/1683fdbcc4deb777950aa5b8ba3a96f1

doriantaylor commented 3 years ago

hm, as predicted those defines are missing. eeeeeenteresting.

dnebdal commented 3 years ago

I can try to recreate it in a Fedora VM, just to rule out any weird local variations?

doriantaylor commented 3 years ago

If extconf.rb isn't setting those defines that probably means it can't see the header files, but if you can compile it otherwise it must necessarily be able to see them, so that is really weird. Can you double-check that you have the dev headers for ruby? Also is it possible that your environment variables are getting messed with?

doriantaylor commented 3 years ago

actually, what is -I/usr/include/ruby/backward ? are there old headers in there masking the new ones?

doriantaylor commented 3 years ago

Got somebody on Freenode to reproduce on Fedora with 3.0.1; inclined to chalk this up as a Fedora problem. Something is messing with the execution of that extconf.rb.

fnordfish commented 1 month ago

For me, https://github.com/doriantaylor/rb-lmdb/commit/67e7d1ec8269692ba3618dca87b75d1481e00a00 did the trick for a docker rockylinux:8 install