Skip to content

Commit

Permalink
ext: export only Init_sqlite3_native
Browse files Browse the repository at this point in the history
This works around new Darwin Ruby 3.2 symbol resolution issues, but
also follows best practices around shipping shared libraries.
  • Loading branch information
flavorjones committed Jan 2, 2023
1 parent 1815290 commit 58441c1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
13 changes: 5 additions & 8 deletions ext/sqlite3/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand All @@ -81,16 +82,12 @@ 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

append_cflags("-fvisibility=hidden") # see https://github.com/rake-compiler/rake-compiler-dock/issues/87
ldflags.each { |ldflag| append_ldflags(ldflag) }
end
end
Expand Down
1 change: 1 addition & 0 deletions ext/sqlite3/sqlite3.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ void init_sqlite3_constants()
#endif
}

RUBY_FUNC_EXPORTED
void Init_sqlite3_native()
{
/*
Expand Down

0 comments on commit 58441c1

Please sign in to comment.