Skip to content

Commit eff3a35

Browse files
committed
Use a test for RbConfig RPATHFLAG
1 parent 17dd2e1 commit eff3a35

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

ext/mysql2/extconf.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,13 @@ def asplode lib
6969
if RbConfig::MAKEFILE_CONFIG['CC'] =~ /gcc/
7070
$CFLAGS << ' -Wall -funroll-loops'
7171

72-
if hard_mysql_path = $libs[%r{-L(/[^ ]+)}, 1]
73-
$LDFLAGS << " -Wl,-rpath,#{hard_mysql_path}"
72+
if libdir = $libs[%r{-L(/[^ ]+)}, 1]
73+
# The following comment and test is borrowed from the Pg gem:
74+
# Try to use runtime path linker option, even if RbConfig doesn't know about it.
75+
# The rpath option is usually set implicit by dir_config(), but so far not on Mac OS X.
76+
if RbConfig::CONFIG["RPATHFLAG"].to_s.empty? && try_link('int main() {return 0;}', " -Wl,-rpath,#{libdir}")
77+
$LDFLAGS << " -Wl,-rpath,#{libdir}"
78+
end
7479
end
7580
end
7681

0 commit comments

Comments
 (0)