From 95da0d4f6f57673876878b66264d77f8f16db81f Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Mon, 20 Jan 2025 14:58:59 -0800 Subject: [PATCH 1/4] Set RUBY_CC_VERSION using RakeCompilerDock.set_ruby_cc_version This avoids the need to hard-code specific patch-level versions. See https://github.com/rake-compiler/rake-compiler-dock/releases/tag/v1.9.1. --- Rakefile | 2 +- re2.gemspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Rakefile b/Rakefile index 6a6be7f..b58ac7a 100644 --- a/Rakefile +++ b/Rakefile @@ -33,7 +33,7 @@ cross_platforms = %w[ x86_64-linux-musl ].freeze -ENV['RUBY_CC_VERSION'] = '3.4.1:3.3.5:3.2.6:3.1.6:3.0.7:2.7.8:2.6.10' +ENV['RUBY_CC_VERSION'] = RakeCompilerDock.ruby_cc_version("3.4", "3.3", "3.2", "3.1", "3.0", "2.7", "2.6") Gem::PackageTask.new(re2_gemspec).define diff --git a/re2.gemspec b/re2.gemspec index a22ad08..99a7831 100644 --- a/re2.gemspec +++ b/re2.gemspec @@ -41,7 +41,7 @@ Gem::Specification.new do |s| "spec/re2/scanner_spec.rb" ] s.add_development_dependency("rake-compiler", "~> 1.2.7") - s.add_development_dependency("rake-compiler-dock", "~> 1.8.0") + s.add_development_dependency("rake-compiler-dock", "~> 1.9.1") s.add_development_dependency("rspec", "~> 3.2") s.add_runtime_dependency("mini_portile2", "~> 2.8.7") # keep version in sync with extconf.rb end From 876fc8aaf3c9cbcacf2907e572bf74781cda413e Mon Sep 17 00:00:00 2001 From: Paul Mucur Date: Tue, 21 Jan 2025 16:23:42 +0000 Subject: [PATCH 2/4] Use shorthand to specify native Ruby versions --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index b58ac7a..164d2d6 100644 --- a/Rakefile +++ b/Rakefile @@ -33,7 +33,7 @@ cross_platforms = %w[ x86_64-linux-musl ].freeze -ENV['RUBY_CC_VERSION'] = RakeCompilerDock.ruby_cc_version("3.4", "3.3", "3.2", "3.1", "3.0", "2.7", "2.6") +RakeCompilerDock.set_ruby_cc_version("~> 2.6", "~> 3.0") Gem::PackageTask.new(re2_gemspec).define From dafffb6cc492e3ec6e0944e34d82b3fb4158b40c Mon Sep 17 00:00:00 2001 From: Paul Mucur Date: Tue, 21 Jan 2025 16:24:11 +0000 Subject: [PATCH 3/4] Use Ruby 3.1.6 to cross-compile gems --- Rakefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Rakefile b/Rakefile index 164d2d6..112239d 100644 --- a/Rakefile +++ b/Rakefile @@ -70,6 +70,7 @@ namespace :gem do desc "Compile and build native gem for #{platform} platform" task platform do RakeCompilerDock.sh <<~SCRIPT, platform: platform, verbose: true + rbenv shell 3.1.6 && gem install bundler --no-document && bundle && bundle exec rake native:#{platform} pkg/#{re2_gemspec.full_name}-#{Gem::Platform.new(platform)}.gem PATH="/usr/local/bin:$PATH" From ec2fd57169aa7fd04a413e93527d7d2fde9fec41 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Tue, 21 Jan 2025 09:42:06 -0800 Subject: [PATCH 4/4] Ensure libstdc++ exists on Ruby Alpine images Recent images appear to have removed libstdc++ from some Ruby versions. Add it to ensure the re2 shared library can be loaded. --- .github/workflows/tests.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9cc6e75..bd43017 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -335,7 +335,7 @@ jobs: docker run --rm -v "$(pwd):/re2" -w /re2 \ --platform=linux/arm64 \ ruby:${{ matrix.ruby }}-alpine \ - ./scripts/test-gem-install ${{ matrix.rubygems }} + /bin/sh -c "apk update && apk add libstdc++ && ./scripts/test-gem-install ${{ matrix.rubygems }}" test-precompiled-arm-linux-gnu: needs: "precompile-arm-linux-gnu" @@ -393,7 +393,7 @@ jobs: docker run --rm -v "$(pwd):/re2" -w /re2 \ --platform=linux/arm/v7 \ ruby:${{ matrix.ruby }}-alpine \ - ./scripts/test-gem-install ${{ matrix.rubygems }} + /bin/sh -c "apk update && apk add libstdc++ && ./scripts/test-gem-install ${{ matrix.rubygems }}" test-precompiled-x86-linux-gnu: needs: "precompile-x86-linux-gnu" @@ -451,7 +451,7 @@ jobs: docker run --rm -v "$(pwd):/re2" -w /re2 \ --platform=linux/386 \ ruby:${{ matrix.ruby }}-alpine \ - ./scripts/test-gem-install ${{ matrix.rubygems }} + /bin/sh -c "apk update && apk add libstdc++ && ./scripts/test-gem-install ${{ matrix.rubygems }}" test-precompiled-x86_64-linux-gnu: needs: "precompile-x86_64-linux-gnu" @@ -506,6 +506,7 @@ jobs: with: name: cruby-x86_64-linux-musl-gem path: pkg + - run: apk update && apk add libstdc++ - run: ./scripts/test-gem-install ${{ matrix.rubygems }} test-precompiled-arm64-darwin: