From ab15352741bf4b2a101cf6c244612a9f9d1f0fbc Mon Sep 17 00:00:00 2001 From: Kouhei Sutou Date: Sun, 8 May 2016 23:27:23 +0900 Subject: [PATCH] Ensure linking bundled libraries If dependency libraries (czmq, libsodium and zeromq) are already installed in system and they exist in Ruby's library path, rbczmq uses headers of bundled libraries and shared objects of system libraries. Because link command generated by mkmf.rb uses `$DEFLIBPATH | $LIBPATH` as library search path. `$DEFLIBPATH` includes Ruby's library path. If dependency libraries already exist in Ruby's library path, they are used instead of bundled libraries. It causes segmentation fault. --- ext/rbczmq/extconf.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/rbczmq/extconf.rb b/ext/rbczmq/extconf.rb index 14ac131..40fba35 100644 --- a/ext/rbczmq/extconf.rb +++ b/ext/rbczmq/extconf.rb @@ -147,7 +147,7 @@ def check_heads heads = [], fatal = false $INCFLAGS << " -I#{zmq_include_path}" if find_header("zmq.h", zmq_include_path) $INCFLAGS << " -I#{czmq_include_path}" if find_header("czmq.h", czmq_include_path) -$LIBPATH << libs_path.to_s +$DEFLIBPATH.unshift(libs_path.to_s) # Special case to prevent Rubinius compile from linking system libzmq if present if defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /rbx/ && RUBY_PLATFORM =~ /linux/