From 305600997c5d2a513cf788850faa208f4aecfcb8 Mon Sep 17 00:00:00 2001 From: Andrew Ferk Date: Tue, 11 May 2021 11:05:29 -0700 Subject: [PATCH] Use arm or aarch64 to identify Apple ARM CPU arch Some versions of Ruby are identifying Apple M1 hosts as 'arm-apple-darwin20.3.0' and others 'aarch64-apple-darwin20.3.0'. * Ruby 2.6.5 - `RbConfig::CONFIG['host'] == 'arm-apple-darwin20.3.0'` * Ruby 2.6.7 - `RbConfig::CONFIG['host'] == 'aarch64-apple-darwin20.3.0'` --- ext/ffi_c/extconf.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/ffi_c/extconf.rb b/ext/ffi_c/extconf.rb index cdeaa9bd8..aaf558a74 100644 --- a/ext/ffi_c/extconf.rb +++ b/ext/ffi_c/extconf.rb @@ -57,7 +57,7 @@ def system_libffi_usable? append_ldflags "-Wl,--exclude-libs,ALL" end - ffi_alloc_default = RbConfig::CONFIG['host_os'] =~ /darwin/i && RbConfig::CONFIG['host'] =~ /arm/i + ffi_alloc_default = RbConfig::CONFIG['host_os'] =~ /darwin/i && RbConfig::CONFIG['host'] =~ /arm|aarch64/i if enable_config('libffi-alloc', ffi_alloc_default) $defs << "-DUSE_FFI_ALLOC" end @@ -71,7 +71,7 @@ def system_libffi_usable? File.open("Makefile", "a") do |mf| mf.puts "LIBFFI_HOST=--host=#{RbConfig::CONFIG['host_alias']}" if RbConfig::CONFIG.has_key?("host_alias") if RbConfig::CONFIG['host_os'] =~ /darwin/i - if RbConfig::CONFIG['host'] =~ /arm/i + if RbConfig::CONFIG['host'] =~ /arm|aarch64/i mf.puts "LIBFFI_HOST=--host=aarch64-apple-#{RbConfig::CONFIG['host_os']}" end mf.puts "include ${srcdir}/libffi.darwin.mk"