@@ -77,16 +77,21 @@ def configure_packaged_libraries
77
77
abort_pkg_config ( "pkg_config" ) unless pkg_config ( pcfile )
78
78
79
79
# see https://bugs.ruby-lang.org/issues/18490
80
- flags = xpopen ( [ "pkg-config" , "--libs" , "--static" , pcfile ] , err : [ :child , :out ] , &:read )
80
+ ldflags = xpopen ( [ "pkg-config" , "--libs" , "--static" , pcfile ] , err : [ :child , :out ] , &:read )
81
81
abort_pkg_config ( "xpopen" ) unless $?. success?
82
- flags = flags . split
82
+ ldflags = ldflags . split
83
83
84
- # see https://github.com/flavorjones/mini_portile/issues/118
85
- "-L#{ lib_path } " . tap do |lib_path_flag |
86
- flags . prepend ( lib_path_flag ) unless flags . include? ( lib_path_flag )
84
+ if needs_darwin_linker_hack
85
+ ldflags . delete ( "-lsqlite3" )
86
+ ldflags . prepend ( "-Wl,-flat_namespace" , "-Wl,-hidden-lsqlite3" )
87
+ else
88
+ # see https://github.com/flavorjones/mini_portile/issues/118
89
+ "-L#{ lib_path } " . tap do |lib_path_flag |
90
+ ldflags . prepend ( lib_path_flag ) unless ldflags . include? ( lib_path_flag )
91
+ end
87
92
end
88
93
89
- flags . each { |flag | append_ldflags ( flag ) }
94
+ ldflags . each { |ldflag | append_ldflags ( ldflag ) }
90
95
end
91
96
end
92
97
@@ -172,6 +177,17 @@ def download
172
177
minimal_recipe . download
173
178
end
174
179
180
+ def needs_darwin_linker_hack
181
+ # See https://github.com/rake-compiler/rake-compiler-dock/issues/87 for more info.
182
+ cross_build? &&
183
+ darwin? &&
184
+ RbConfig ::CONFIG [ "ruby_version" ] >= "3.2"
185
+ end
186
+
187
+ def darwin?
188
+ RbConfig ::CONFIG [ "target_os" ] . include? ( "darwin" )
189
+ end
190
+
175
191
def print_help
176
192
print ( <<~TEXT )
177
193
USAGE: ruby #{ $PROGRAM_NAME} [options]
0 commit comments