rake-compiler / rake-compiler-dock

Easy to use and reliable cross compiler environment for building Windows, Linux, Mac and JRuby binary gems.
MIT License
77 stars 30 forks source link

update to "3.2.0" final #92

Closed flavorjones closed 1 year ago

flavorjones commented 1 year ago

and update the CI pipeline to test with 3.2.

When this goes green, I'll merge it and build snapshot images that can be retrieved from https://github.com/rake-compiler/rake-compiler-dock/pkgs/container/rake-compiler-dock-snapshot/versions

flavorjones commented 1 year ago

@larskanis Please note that we need to figure out how to resolve symbol resolution on Darwin on 3.2.

Here's a failing job showing what happens if we do nothing: https://github.com/rake-compiler/rake-compiler-dock/actions/runs/3788284793/jobs/6440944327#step:7:21

One option is to add -flat_namespace to the link arguments:

diff --git a/test/rcd_test/ext/mri/extconf.rb b/test/rcd_test/ext/mri/extconf.rb
index 2ac6dae..f97fbd1 100644
--- a/test/rcd_test/ext/mri/extconf.rb
+++ b/test/rcd_test/ext/mri/extconf.rb
@@ -23,6 +23,11 @@
     # https://github.com/rake-compiler/rake-compiler-dock/issues/69
     puts "Linking with '-static' flag"
     $LDFLAGS << ' -static'
+  else
+    if RbConfig::CONFIG["target_os"].include?("darwin")
+      puts "Adding flat_namespace"
+      $LDFLAGS << ' -flat_namespace'
+    end
   end

Here's a passing job after with that flag added: https://github.com/rake-compiler/rake-compiler-dock/actions/runs/3788445720/jobs/6441253927#step:7:27

The other option is to remove the -bundle_loader link arguments:

diff --git a/test/rcd_test/ext/mri/extconf.rb b/test/rcd_test/ext/mri/extconf.rb
index f97fbd1..a61cf10 100644
--- a/test/rcd_test/ext/mri/extconf.rb
+++ b/test/rcd_test/ext/mri/extconf.rb
@@ -25,8 +25,16 @@
     $LDFLAGS << ' -static'
   else
     if RbConfig::CONFIG["target_os"].include?("darwin")
-      puts "Adding flat_namespace"
-      $LDFLAGS << ' -flat_namespace'
+      # puts "Adding flat_namespace"
+      # $LDFLAGS << ' -flat_namespace'
+
+      extdldflags = RbConfig::MAKEFILE_CONFIG["EXTDLDFLAGS"].split
+      if found = extdldflags.index("-bundle_loader")
+        removed_1 = extdldflags.delete_at(found) # flag
+        removed_2 = extdldflags.delete_at(found) # and its argument
+        puts "Removing #{removed_1} #{removed_2} from EXTDLDFLAGS"
+      end
+      RbConfig::MAKEFILE_CONFIG["EXTDLDFLAGS"] = extdldflags.join(" ")
     end
   end

Here's a link to the job passing with that flag removed: https://github.com/rake-compiler/rake-compiler-dock/actions/runs/3788506852/jobs/6441377209#step:7:27

flavorjones commented 1 year ago

Generating snapshots at https://github.com/rake-compiler/rake-compiler-dock/actions/runs/3788674697 based on this branch.

flavorjones commented 1 year ago

I've updated this PR with a lengthy comment in extconf.rb to explain the options for gem maintainers. I think it's probably OK to merge onto master until we figure out a better way to work around the darwin behavior.