about summary refs log tree commit diff
path: root/pkgs/development/interpreters/ruby
diff options
context:
space:
mode:
authorJörg Thalheim <Mic92@users.noreply.github.com>2022-12-10 17:21:25 +0000
committerGitHub <noreply@github.com>2022-12-10 17:21:25 +0000
commit34342e25cfaac781886279d39d29b01983b7924e (patch)
tree7452f2643ef24639ddcec71567143db06b8c6650 /pkgs/development/interpreters/ruby
parentf252845f339ec3ea946307dfe01e6286700b9e18 (diff)
parentf5b5432450264c8a2c571061259d9cfe0f65a1ee (diff)
Merge pull request #202041 from Mic92/ruby
ruby: fix cross compiling extensions
Diffstat (limited to 'pkgs/development/interpreters/ruby')
-rw-r--r--pkgs/development/interpreters/ruby/default.nix12
1 files changed, 12 insertions, 0 deletions
diff --git a/pkgs/development/interpreters/ruby/default.nix b/pkgs/development/interpreters/ruby/default.nix
index c7e01ea0f94d8..bc93190490e09 100644
--- a/pkgs/development/interpreters/ruby/default.nix
+++ b/pkgs/development/interpreters/ruby/default.nix
@@ -187,6 +187,18 @@ let
               sed -i '/CC_VERSION_MESSAGE/d' $rbConfig
             ''
           }
+
+          # Allow to override compiler. This is important for cross compiling as
+          # we need to set a compiler that is different from the build one.
+          awk -i inplace -F' = ' \
+            ' # operate on the line starting with
+              /^  CONFIG\["CC"\]/ {
+                # replace the right hand side
+                sub($2, "ENV[\"CC\"] || \"1\"")
+              }; { print }' "$rbConfig"
+          # test that the line isn't mangled in case upstream made the above unnecessary
+          grep -qx '  CONFIG\["CC"\] = ENV\["CC"\] || "1"' "$rbConfig"
+
           # Remove unnecessary external intermediate files created by gems
           extMakefiles=$(find $out/${passthru.gemPath} -name Makefile)
           for makefile in $extMakefiles; do