File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -308,6 +308,28 @@ def match_platforms?(platform, platforms)
308308 end
309309 end
310310
311+ # On universal Rubies, resolve the "universal" arch to the real CPU arch, without changing the extension directory.
312+ class Specification
313+ if /^universal\. (?<arch>.*?)-/ =~ RUBY_PLATFORM
314+ local_platform = Platform . local
315+ if local_platform . cpu == "universal"
316+ ORIGINAL_LOCAL_PLATFORM = local_platform . to_s . freeze
317+
318+ local_platform . cpu = if arch == "arm64e" # arm64e is only permitted for Apple system binaries
319+ "arm64"
320+ else
321+ arch
322+ end
323+
324+ def extensions_dir
325+ Gem . default_ext_dir_for ( base_dir ) ||
326+ File . join ( base_dir , "extensions" , ORIGINAL_LOCAL_PLATFORM ,
327+ Gem . extension_api_version )
328+ end
329+ end
330+ end
331+ end
332+
311333 require "rubygems/util"
312334
313335 Util . singleton_class . module_eval do
You can’t perform that action at this time.
0 commit comments