|
2 | 2 |
|
3 | 3 | have_func('rb_gc_mark_movable') |
4 | 4 |
|
| 5 | +# Check if ruby_abi_version symbol is required |
| 6 | +# Based on grpc's approach: https://github.com/grpc/grpc/blob/master/src/ruby/ext/grpc/extconf.rb |
| 7 | +def have_ruby_abi_version? |
| 8 | + # Only development/preview versions need the symbol |
| 9 | + return false if RUBY_PATCHLEVEL >= 0 |
| 10 | + |
| 11 | + # Ruby 3.2+ development versions require ruby_abi_version |
| 12 | + major, minor = RUBY_VERSION.split('.').map(&:to_i) |
| 13 | + if major > 3 || (major == 3 && minor >= 2) |
| 14 | + puts "Ruby version #{RUBY_VERSION} >= 3.2. Using ruby_abi_version symbol." |
| 15 | + return true |
| 16 | + else |
| 17 | + puts "Ruby version #{RUBY_VERSION} < 3.2. Not using ruby_abi_version symbol." |
| 18 | + return false |
| 19 | + end |
| 20 | +end |
| 21 | + |
| 22 | +# Determine which export file to use based on Ruby version |
| 23 | +def ext_export_filename |
| 24 | + name = 'ext-export' |
| 25 | + name += '-with-ruby-abi-version' if have_ruby_abi_version? |
| 26 | + name |
| 27 | +end |
| 28 | + |
5 | 29 | $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")))\'' |
6 | 30 | $CPPFLAGS += " -fdeclspec" if CONFIG['CXX'] =~ /clang/ |
7 | 31 |
|
8 | 32 | # macOS specific: Use exported_symbols_list to control symbol visibility |
9 | 33 | if RUBY_PLATFORM =~ /darwin/ |
10 | | - $LDFLAGS += " -exported_symbols_list #{File.expand_path('exports.txt', __dir__)}" |
| 34 | + ext_export_file = File.join(__dir__, "#{ext_export_filename}.txt") |
| 35 | + $LDFLAGS += " -exported_symbols_list #{ext_export_file}" |
| 36 | + puts "Using export file: #{ext_export_file}" |
11 | 37 | end |
12 | 38 |
|
13 | 39 | Dir.chdir File.expand_path('..', __FILE__) do |
|
0 commit comments