From 8a79876f5614e1f7f6f3633be8f389f977e62586 Mon Sep 17 00:00:00 2001 From: nmburgan <13688219+nmburgan@users.noreply.github.com> Date: Tue, 16 Sep 2025 16:38:48 -0700 Subject: [PATCH] Use native compilation for macos-all-x86_64 The experiment to use Rosetta on an arm64 host to build macos-all-x86_64 didn't quite work out, so we're going to build on native x86_64 hosts instead. --- configs/components/_base-ruby-augeas.rb | 6 +----- configs/components/openssl-3.0.rb | 6 +----- configs/components/ruby-3.2.rb | 5 ----- configs/components/rubygem-nokogiri.rb | 5 ----- configs/components/runtime-agent.rb | 8 -------- configs/projects/_shared-agent-settings.rb | 6 ------ tasks/build.rake | 6 ------ 7 files changed, 2 insertions(+), 40 deletions(-) diff --git a/configs/components/_base-ruby-augeas.rb b/configs/components/_base-ruby-augeas.rb index f3a1a352..9aaf1c9d 100644 --- a/configs/components/_base-ruby-augeas.rb +++ b/configs/components/_base-ruby-augeas.rb @@ -63,15 +63,11 @@ elsif platform.is_cross_compiled? if platform.is_linux? || platform.is_macos? pkg.environment "RUBY", host_ruby - pkg.environment 'CC', 'clang -target arm64-apple-macos11' if platform.name =~ /osx-11/ - pkg.environment 'CC', 'clang -target arm64-apple-macos12' if platform.name =~ /osx-12/ ruby = "#{host_ruby} -r#{settings[:datadir]}/doc/rbconfig-#{ruby_version}-orig.rb" pkg.environment "LDFLAGS", settings[:ldflags] end elsif platform.is_macos? - if platform.architecture == 'arm64' - pkg.environment "PATH", "$(PATH):/opt/homebrew/bin" - end + pkg.environment "PATH", "$(PATH):/opt/homebrew/bin:/usr/local/bin" pkg.environment 'CC', settings[:cc] pkg.environment 'CFLAGS', settings[:cflags] pkg.environment "LDFLAGS", settings[:ldflags] diff --git a/configs/components/openssl-3.0.rb b/configs/components/openssl-3.0.rb index 2bde2256..d1b960bf 100644 --- a/configs/components/openssl-3.0.rb +++ b/configs/components/openssl-3.0.rb @@ -62,11 +62,7 @@ pkg.environment 'CC', settings[:cc] pkg.environment 'MACOSX_DEPLOYMENT_TARGET', settings[:deployment_target] - target = if platform.architecture == "arm64" - 'darwin64-arm64' - else - 'darwin64-x86_64' - end + target = "darwin64-#{platform.architecture}" elsif platform.is_linux? pkg.environment 'PATH', '/opt/pl-build-tools/bin:$(PATH):/usr/local/bin' diff --git a/configs/components/ruby-3.2.rb b/configs/components/ruby-3.2.rb index 16dec74e..515f7eb2 100644 --- a/configs/components/ruby-3.2.rb +++ b/configs/components/ruby-3.2.rb @@ -118,11 +118,6 @@ # This normalizes the build string to something like AIX 7.1.0.0 rather # than AIX 7.1.0.2 or something special_flags += " --build=#{settings[:platform_triple]} " - elsif platform.is_cross_compiled? && platform.is_macos? - # When the target arch is aarch64, ruby incorrectly selects the 'ucontext' coroutine - # implementation instead of 'arm64', so specify 'amd64' explicitly - # https://github.com/ruby/ruby/blob/c9c2245c0a25176072e02db9254f0e0c84c805cd/configure.ac#L2329-L2330 - special_flags += " --with-coroutine=arm64 " elsif platform.is_solaris? && platform.architecture == "sparc" unless platform.is_cross_compiled? # configure seems to enable dtrace because the executable is present, diff --git a/configs/components/rubygem-nokogiri.rb b/configs/components/rubygem-nokogiri.rb index 50d2f97e..47c56182 100644 --- a/configs/components/rubygem-nokogiri.rb +++ b/configs/components/rubygem-nokogiri.rb @@ -21,10 +21,5 @@ pkg.environment "GEM_HOME", gem_home if platform.is_macos? pkg.environment "PKG_CONFIG_PATH", "#{settings[:libdir]}/pkgconfig" - if platform.is_cross_compiled? - pkg.install do - "rm -r #{gem_home}/gems/nokogiri-#{pkg.get_version}/ext/nokogiri/tmp" - end - end end end diff --git a/configs/components/runtime-agent.rb b/configs/components/runtime-agent.rb index 5b08aa5e..90e71aec 100644 --- a/configs/components/runtime-agent.rb +++ b/configs/components/runtime-agent.rb @@ -13,14 +13,6 @@ "zypper install -y pl-gcc8" end end - elsif platform.is_macos? && platform.is_cross_compiled? - if settings[:ruby_version] =~ /^3\./ - pkg.install do - # These are dependencies of ruby@3.x, remove symlinks from /usr/local - # so our build doesn't use the wrong headers - "cd /etc/homebrew && su test -c '#{platform.brew} unlink openssl libyaml'" - end - end end if platform.is_cross_compiled? diff --git a/configs/projects/_shared-agent-settings.rb b/configs/projects/_shared-agent-settings.rb index a242f619..e7c95ea7 100644 --- a/configs/projects/_shared-agent-settings.rb +++ b/configs/projects/_shared-agent-settings.rb @@ -95,7 +95,6 @@ platform_triple = "powerpc64le-suse-linux" if platform.architecture == "ppc64le" && platform.name =~ /^sles-/ platform_triple = "powerpc64le-linux-gnu" if platform.architecture == "ppc64el" platform_triple = "arm-linux-gnueabihf" if platform.architecture == "armhf" -platform_triple = "aarch64-apple-darwin" if platform.is_cross_compiled? && platform.is_macos? # Ruby's build process needs a functional "baseruby". When native compiling, # ruby will build "miniruby" and use that as "baseruby". When cross compiling, @@ -113,9 +112,6 @@ proj.setting(:host_ruby, "/opt/pl-build-tools/bin/ruby") proj.setting(:host_gem, "/opt/pl-build-tools/bin/gem") end -elsif platform.is_cross_compiled? && platform.is_macos? - proj.setting(:host_ruby, "/usr/local/opt/ruby@#{ruby_version_y}/bin/ruby") - proj.setting(:host_gem, "/usr/local/opt/ruby@#{ruby_version_y}/bin/gem") else proj.setting(:host_ruby, File.join(proj.ruby_bindir, "ruby")) proj.setting(:host_gem, File.join(proj.ruby_bindir, "gem")) @@ -123,8 +119,6 @@ if platform.is_cross_compiled_linux? host = "--host #{platform_triple}" -elsif platform.is_cross_compiled? && platform.is_macos? - host = "--host aarch64-apple-darwin --build x86_64-apple-darwin --target aarch64-apple-darwin" elsif platform.is_solaris? if platform.architecture == 'i386' platform_triple = "#{platform.architecture}-pc-solaris2.#{platform.os_version}" diff --git a/tasks/build.rake b/tasks/build.rake index 813db3ff..6cb0864c 100644 --- a/tasks/build.rake +++ b/tasks/build.rake @@ -11,12 +11,6 @@ namespace :vox do abort 'You must provide a platform.' if args[:platform].nil? || args[:platform].empty? platform = args[:platform] os, _ver, arch = platform.match(/^(\w+)-([\w|\.]+)-(\w+)$/).captures - if os == 'macos' - shell = `uname -m`.chomp - ruby = `ruby -v`.chomp - abort "Detected shell arch: #{shell}. You must run this build from a #{arch} machine or shell. To do this on the current host, run 'arch -#{arch} /bin/bash'" if shell != arch - abort "Detected ruby: #{ruby}. You must run this build with a #{arch} Ruby version. To do this on the current host, install Ruby from an #{arch} shell via 'arch -#{arch} /bin/bash'." unless ruby =~ /#{arch}/ - end engine = platform =~ /^(macos|windows)-/ ? 'local' : 'docker' cmd = "bundle exec build #{project} #{platform} --engine #{engine}"