ericboesch / bitset

Bitset implementation for Ruby
MIT License
9 stars 7 forks source link

inline methods (and, xor, difference, etc.) not exported #2

Open chickenburgers opened 5 years ago

chickenburgers commented 5 years ago

On some compilers (e.g. g++7.3.0) the library compiles, but doesn't load, because the methods marked inline don't get exported into the .so

e.g. with inline uint64_t xor(uint64_t a, uint64_t b) { return a ^ b; }, nm bitset.so shows:

0000000000000f50 T _init U xor 0000000000002950 T assign_bit 00000000000012d0 T bitset_free 0000000000002030 T bitset_new 0000000000002060 T bitset_setup 0000000000204058 B cBitset U calloc@@GLIBC_2.2.5 0000000000204008 b completed.7696 00000000000011f0 t deregister_tm_clones U difference

The definitions need to be switched to static to ensure they're exported, like so: static uint64_t xor(uint64_t a, uint64_t b) { return a ^ b; }

see https://github.com/QuoineFinancial/bitset which did just that

A-deLuna commented 3 years ago

One way to work around it is to compile with non-standard gnu handling of inline by passing -fgnu89-inline compiler flag.

You can add it to bundler with env var: BUNDLE_BUILD__BITSET="--with-cflags=-fgnu89-inline"

or bundle config set --local build.bitset --with-cflags="-fgnu89-inline"