Skip to content

Commit 921ea17

Browse files
authored
Merge pull request #104 from SpringMT/fix/symbol-collision-issue-102
Fix symbol collision with other native gems using libzstd
2 parents 5894b22 + 331a4ab commit 921ea17

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

ext/zstdruby/exports.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_Init_zstdruby

ext/zstdruby/extconf.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22

33
have_func('rb_gc_mark_movable')
44

5-
$CFLAGS = '-I. -O3 -std=c99 -DZSTD_STATIC_LINKING_ONLY -DZSTD_MULTITHREAD -pthread -DDEBUGLEVEL=0'
5+
$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")))\''
66
$CPPFLAGS += " -fdeclspec" if CONFIG['CXX'] =~ /clang/
77

8+
# macOS specific: Use exported_symbols_list to control symbol visibility
9+
if RUBY_PLATFORM =~ /darwin/
10+
$LDFLAGS += " -exported_symbols_list #{File.expand_path('exports.txt', __dir__)}"
11+
end
12+
813
Dir.chdir File.expand_path('..', __FILE__) do
914
$srcs = Dir['**/*.c', '**/*.S']
1015

ext/zstdruby/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ void zstd_ruby_skippable_frame_init(void);
88
void zstd_ruby_streaming_compress_init(void);
99
void zstd_ruby_streaming_decompress_init(void);
1010

11-
void
11+
RUBY_FUNC_EXPORTED void
1212
Init_zstdruby(void)
1313
{
1414
#ifdef HAVE_RB_EXT_RACTOR_SAFE

0 commit comments

Comments
 (0)