Skip to content

Fix symbol collision with other native gems using libzstd #104

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions ext/zstdruby/exports.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_Init_zstdruby
7 changes: 6 additions & 1 deletion ext/zstdruby/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@

have_func('rb_gc_mark_movable')

$CFLAGS = '-I. -O3 -std=c99 -DZSTD_STATIC_LINKING_ONLY -DZSTD_MULTITHREAD -pthread -DDEBUGLEVEL=0'
$CFLAGS = '-I. -O3 -std=c99 -DZSTD_STATIC_LINKING_ONLY -DZSTD_MULTITHREAD -pthread -DDEBUGLEVEL=0 -fvisibility=hidden -DZSTDLIB_VISIBLE=\'__attribute__((visibility("hidden")))\' -DZSTDLIB_HIDDEN=\'__attribute__((visibility("hidden")))\''
$CPPFLAGS += " -fdeclspec" if CONFIG['CXX'] =~ /clang/

# macOS specific: Use exported_symbols_list to control symbol visibility
if RUBY_PLATFORM =~ /darwin/
$LDFLAGS += " -exported_symbols_list #{File.expand_path('exports.txt', __dir__)}"
end

Dir.chdir File.expand_path('..', __FILE__) do
$srcs = Dir['**/*.c', '**/*.S']

Expand Down
2 changes: 1 addition & 1 deletion ext/zstdruby/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ void zstd_ruby_skippable_frame_init(void);
void zstd_ruby_streaming_compress_init(void);
void zstd_ruby_streaming_decompress_init(void);

void
RUBY_FUNC_EXPORTED void
Init_zstdruby(void)
{
#ifdef HAVE_RB_EXT_RACTOR_SAFE
Expand Down