Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ext: export only Init_sqlite3_native #371

Merged
merged 1 commit into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 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,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) }
Expand All @@ -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")
Expand Down Expand Up @@ -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
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