From a76e8b4ef77adaa7f202fd445c5245e0c84e9bf8 Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Sat, 2 Aug 2025 12:25:59 +0200 Subject: [PATCH] Use a simpler workaround for platform mixup issue When `linux` and `linux-musl` platforms are both defined in the cross_platform array, then a rake task is defined for `lib/2.7/pg_ext.so` which links to `linux` instead of `linux-musl`. Disabling native tasks for the running ruby platform disables compiling `lib/2.7/pg_ext.so` completely. The mixed platform rake definition otherwise leads to a rake dependency chain like this: ``` rake aborted! Tasks: TOP => pkg/pg-1.6.0-x86_64-linux-musl.gem => lib/2.7/pg_ext.so => copy:pg_ext:x86_64-linux:2.7.8 => tmp/x86_64-linux/pg_ext/2.7.8/pg_ext.so => tmp/x86_64-linux/pg_ext/2.7.8/Makefile ``` --- Rakefile | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Rakefile b/Rakefile index a06ab13bf..49dde03a5 100644 --- a/Rakefile +++ b/Rakefile @@ -70,13 +70,7 @@ Rake::ExtensionTask.new do |ext| ext.lib_dir = 'lib' ext.source_pattern = "*.{c,h}" ext.cross_compile = true - - # Activate current cross compiled platform only. - # This is to work around the issue that `linux` platform is selected in `linux-musl` image. - ext.cross_platform = CrossLibraries.map(&:platform).select do |pl| - m = ENV["RCD_IMAGE"]&.match(/:(?[\d\.]+)-mri-(?[-\w]+)$/) - m && m[:platform] == pl - end + ext.cross_platform = CrossLibraries.map(&:platform) ext.cross_config_options += CrossLibraries.map do |xlib| { @@ -141,7 +135,7 @@ CrossLibraries.each do |xlib| bundle install --local && #{ "rake install_darwin_mig[__arm64__]" if platform =~ /arm64-darwin/ } #{ "rake install_darwin_mig[__x86_64__]" if platform =~ /x86_64-darwin/ } - rake native:#{platform} pkg/#{$gem_spec.full_name}-#{platform}.gem MAKEOPTS=-j`nproc` RUBY_CC_VERSION=#{RakeCompilerDock.ruby_cc_version("~>2.7", "~>3.0")} + rake native:#{platform} pkg/#{$gem_spec.full_name}-#{platform}.gem MAKEOPTS=-j`nproc` RUBY_CC_VERSION=#{RakeCompilerDock.ruby_cc_version("~>2.7", "~>3.0")} RAKE_EXTENSION_TASK_NO_NATIVE=true EOT end desc "Build the native binary gems"