Closed jfredett closed 3 years ago
It is worth noting I'm not a great C programmer, I tested the change on my ruby 3.0.1 installation and this corrected the compilation error. I also tested on v2.7.2 (the other version I happen to have installed) and I get the same set of warnings as without my change. Specs pass in both cases.
I considered trying to do this conditionally, but I am unfamiliar with the C side of the ruby ecosystem so I did the dumb-but-working thing rather than the smart-but-harder thing.
For reference (and for google), this was the error I was shown when trying to compile the exts initially in my target project:
(12:01) (dev) (ruby/lasker) (master:d85da99:Joe M) (T:3|F:0|B:0) (ruby-3.0.1) (/home/jfredett/code/ruby/lasker:5)
≈≈≈ bundle
Fetching gem metadata from https://rubygems.org/...
Resolving dependencies...
Using rake 12.3.3
Using amq-protocol 2.3.2
Using whittle 0.0.8
Using diff-lcs 1.4.4
Fetching rocksdb-ruby 1.0.0
Using rfuse 1.2.3
Using bundler 2.2.17
Using bunny 2.17.0
Using pgn 0.3.0
Using rfusefs 1.1.3
Using rspec-support 3.10.2
Using rspec-core 3.10.1
Using rspec-mocks 3.10.2
Using rspec-expectations 3.10.1
Using rspec 3.10.0
Installing rocksdb-ruby 1.0.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /home/jfredett/.gem/ruby/3.0.1/gems/rocksdb-ruby-1.0.0/ext/rocksdb
/home/jfredett/.rubies/ruby-3.0.1/bin/ruby -I /home/jfredett/.rubies/ruby-3.0.1/lib/ruby/3.0.0 -r ./siteconf20210519-851747-d0olog.rb extconf.rb
checking for -lrocksdb_debug... no
checking for rocksdb/db.h... yes
checking for -lrocksdb... yes
creating Makefile
current directory: /home/jfredett/.gem/ruby/3.0.1/gems/rocksdb-ruby-1.0.0/ext/rocksdb
make DESTDIR\= clean
current directory: /home/jfredett/.gem/ruby/3.0.1/gems/rocksdb-ruby-1.0.0/ext/rocksdb
make DESTDIR\=
compiling rocksdb_batch_rb.cc
In file included from /home/jfredett/.rubies/ruby-3.0.1/include/ruby-3.0.0/ruby/backward/2/stdalign.h:23,
from /home/jfredett/.rubies/ruby-3.0.1/include/ruby-3.0.0/ruby/defines.h:77,
from /home/jfredett/.rubies/ruby-3.0.1/include/ruby-3.0.0/ruby/ruby.h:23,
from /home/jfredett/.rubies/ruby-3.0.1/include/ruby-3.0.0/ruby.h:38,
from rocksdb_batch_rb.h:6,
from rocksdb_batch_rb.cc:1:
/home/jfredett/.rubies/ruby-3.0.1/include/ruby-3.0.0/ruby/internal/stdalign.h:93:1: error: template with C linkage
93 | template<typename T>
| ^~~~~~~~
In file included from rocksdb_batch_rb.cc:1:
rocksdb_batch_rb.h:4:1: note: ‘extern "C"’ linkage started here
4 | extern "C" {
| ^~~~~~~~~~
make: *** [Makefile:213: rocksdb_batch_rb.o] Error 1
make failed, exit code 2
Gem files will remain installed in /home/jfredett/.gem/ruby/3.0.1/gems/rocksdb-ruby-1.0.0 for inspection.
Results logged to /home/jfredett/.gem/ruby/3.0.1/extensions/x86_64-linux/3.0.0-static/rocksdb-ruby-1.0.0/gem_make.out
An error occurred while installing rocksdb-ruby (1.0.0), and Bundler cannot continue.
Make sure that `gem install rocksdb-ruby -v '1.0.0' --source 'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
lasker was resolved to 0.1.0, which depends on
rocksdb-ruby
Bit of an opaque error, but rapidly revealed after some judicious stackoverflowing.
I also notice ruby 2.7 and 3.0 aren't in the travis for this project, I didn't want to add them to the CI list since that's indicating a bigger maintenance burden than you may be interested in taking, but if you like I'm happy to add the changes to this PR
@jfredett Thank you for good patch. By result of travis CI, this patch looks good. I would be grateful if you could add ruby 2.7 and 3.0 to your CI. After I see the result, I will merge this PR.
Thanks.
Thank you!!
In versions of ruby prior to v3.0.1, this appeared to have been benign, but ruby 3.0.1, it complains of the presence of the
template
call in that header. By moving it outside the extern call, the gem properly compiles on this version. More details in the PR comments.