isamu / rocksdb-ruby

A simple RocksDB library for Ruby
MIT License
75 stars 24 forks source link

Fix build for MacOS on Ruby 3.1 #33

Closed katafrakt closed 2 years ago

katafrakt commented 2 years ago

This fixes the issue described in #32 - inability to build the gem on MacOS and Ruby 3.1. I tested it on both Intel and M1 Macs and it works.

Details

Between Ruby 3.0 and 3.1 the behaviour of have_library has changed. Now it does not use RbConfig::CONFIG['CPP'], but RbConfig::CONFIG['CC']. To allow the extension to compile on MacOS, the latter needs to be adjusted as well.

This also uses RbConfig::CONFIG['CXX'] instead of hard-coded g++, as using g++ caused me some troubles with unknown flags on MacOS as well (I have gcc installed along clang for reasons).

katafrakt commented 2 years ago

Looks like there might be another, more official way to compile using C++ toolkit - better than this workaround. I need to check it.