Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['2.7', '3.0', '3.1', '3.2', '3.3', '3.4']
ruby-version: ['2.7', '3.0', '3.1', '3.2', '3.3', '3.4', 'ruby-head']

steps:
- uses: actions/checkout@v5
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions ext/zstdruby/ext-export.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_Init_zstdruby
28 changes: 27 additions & 1 deletion ext/zstdruby/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,38 @@

have_func('rb_gc_mark_movable')

# Check if ruby_abi_version symbol is required
# Based on grpc's approach: https://github.com/grpc/grpc/blob/master/src/ruby/ext/grpc/extconf.rb
def have_ruby_abi_version?
# Only development/preview versions need the symbol
return false if RUBY_PATCHLEVEL >= 0

# Ruby 3.2+ development versions require ruby_abi_version
major, minor = RUBY_VERSION.split('.').map(&:to_i)
if major > 3 || (major == 3 && minor >= 2)
puts "Ruby version #{RUBY_VERSION} >= 3.2. Using ruby_abi_version symbol."
return true
else
puts "Ruby version #{RUBY_VERSION} < 3.2. Not using ruby_abi_version symbol."
return false
end
end

# Determine which export file to use based on Ruby version
def ext_export_filename
name = 'ext-export'
name += '-with-ruby-abi-version' if have_ruby_abi_version?
name
end

$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__)}"
ext_export_file = File.join(__dir__, "#{ext_export_filename}.txt")
$LDFLAGS += " -exported_symbols_list #{ext_export_file}"
puts "Using export file: #{ext_export_file}"
end

Dir.chdir File.expand_path('..', __FILE__) do
Expand Down