redis-rb / redis-client

Simple low level client for Redis 6+
MIT License
125 stars 60 forks source link

Fix conflict when both hiredis-rb and redis-client are loaded #17

Closed casperisfine closed 2 years ago

casperisfine commented 2 years ago

Fix: https://github.com/redis-rb/redis-client/issues/16

Using $libs instead of $LDFLAGS wasn't enough, because the symbols were still exported. So I went farther and took inspiration from what grpc does to only export the required symbols: https://github.com/grpc/grpc/blob/1cd6e69347cbf62a012477fe184ee6fa8f25d32c/src/ruby/ext/grpc/extconf.rb#L87-L89

cc @flavorjones

flavorjones commented 2 years ago

Just writing down what I'm learning from this ... Looking at the symbol table in ./lib/redis_client/hiredis_connection.so, on master:

 128   │ 0000000000006720 T hiredis_connection_free
 129   │ 0000000000007fe0 T hiredis_connection_mark
 130   │ 0000000000007f90 T hiredis_connection_mark_task

on this PR branch:

 129   │ 0000000000003fa0 t hiredis_connection_free
 130   │ 0000000000005860 t hiredis_connection_mark
 131   │ 0000000000005810 t hiredis_connection_mark_task

the lower-case "t" confirms these symbols aren't exported. Thank you for showing me this technique!

casperisfine commented 2 years ago

Thanks @flavorjones ❤️