Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ext/redis_client/hiredis/export.clang
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
_Init_hiredis_connection
_ruby_abi_version
7 changes: 7 additions & 0 deletions ext/redis_client/hiredis/export.gcc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
hiredis_connection_1.0 {
global:
Init_hiredis_connection;
ruby_abi_version;
local:
*;
};
10 changes: 9 additions & 1 deletion ext/redis_client/hiredis/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,18 @@
end

$CFLAGS << " -I#{hiredis_dir}"
$LDFLAGS << " #{hiredis_dir}/libhiredis.a #{hiredis_dir}/libhiredis_ssl.a -lssl -lcrypto"
$LDFLAGS << " -lssl -lcrypto"
$libs << " #{hiredis_dir}/libhiredis.a #{hiredis_dir}/libhiredis_ssl.a "
$CFLAGS << " -O3"
$CFLAGS << " -std=c99 "

case RbConfig::CONFIG['CC']
when /gcc/i
$LDFLAGS << ' -Wl,--version-script="' << File.join(__dir__, 'export.gcc') << '"'
when /clang/i
$LDFLAGS << ' -Wl,-exported_symbols_list,"' << File.join(__dir__, 'export.clang') << '"'
end

if ENV["EXT_PEDANTIC"]
$CFLAGS << " -Werror"
end
Expand Down
9 changes: 9 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,12 @@
unless ENV["REDIS_CLIENT_RESTART_SERVER"] == "0"
Minitest.after_run { Servers::ALL.shutdown }
end

if ENV["DRIVER"] == "hiredis"
# See: https://github.com/redis-rb/redis-client/issues/16
# The hiredis-rb gems expose all hiredis symbols, so we must be careful
# about how we link against it.
require "redis"
require "hiredis"
Redis.new(host: Servers::HOST, port: Servers::REDIS_TCP_PORT, driver: :hiredis).ping
end