diff --git a/ext/sqlite3/extconf.rb b/ext/sqlite3/extconf.rb index bd453a0b..e25b2e0f 100644 --- a/ext/sqlite3/extconf.rb +++ b/ext/sqlite3/extconf.rb @@ -55,6 +55,7 @@ def configure_packaged_libraries additional_cflags = [ "-fPIC", # needed for linking the static library into a shared library "-O2", # see https://github.com/sparklemotion/sqlite3-ruby/issues/335 for some benchmarks + "-fvisibility=hidden", # see https://github.com/rake-compiler/rake-compiler-dock/issues/87 ] env["CFLAGS"] = [env["CFLAGS"], additional_cflags].flatten.join(" ") recipe.configure_options += env.select { |k,v| ENV_ALLOWLIST.include?(k) } @@ -81,14 +82,9 @@ def configure_packaged_libraries abort_pkg_config("xpopen") unless $?.success? ldflags = ldflags.split - if needs_darwin_linker_hack - ldflags.delete("-lsqlite3") - ldflags.prepend("-Wl,-flat_namespace", "-Wl,-hidden-lsqlite3") - else - # see https://github.com/flavorjones/mini_portile/issues/118 - "-L#{lib_path}".tap do |lib_path_flag| - ldflags.prepend(lib_path_flag) unless ldflags.include?(lib_path_flag) - end + # see https://github.com/flavorjones/mini_portile/issues/118 + "-L#{lib_path}".tap do |lib_path_flag| + ldflags.prepend(lib_path_flag) unless ldflags.include?(lib_path_flag) end ldflags.each { |ldflag| append_ldflags(ldflag) } @@ -100,6 +96,8 @@ def configure_extension append_cppflags("-DTAINTING_SUPPORT") end + append_cflags("-fvisibility=hidden") # see https://github.com/rake-compiler/rake-compiler-dock/issues/87 + if find_header("sqlite3.h") # noop elsif sqlcipher? && find_header("sqlcipher/sqlite3.h") @@ -177,13 +175,6 @@ def download minimal_recipe.download end - def needs_darwin_linker_hack - # See https://github.com/rake-compiler/rake-compiler-dock/issues/87 for more info. - cross_build? && - darwin? && - RbConfig::CONFIG["ruby_version"] >= "3.2" - end - def darwin? RbConfig::CONFIG["target_os"].include?("darwin") end diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index 70612f1e..0e562728 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -127,6 +127,7 @@ void init_sqlite3_constants() #endif } +RUBY_FUNC_EXPORTED void Init_sqlite3_native() { /*