From 22d42efb5cdd201671fee0247b04d70fab6fcb08 Mon Sep 17 00:00:00 2001 From: Henry Date: Sun, 30 Jun 2024 02:23:29 -0400 Subject: [PATCH 1/2] Use effective_arch for rustflags --- Library/Homebrew/extend/ENV/std.rb | 2 +- Library/Homebrew/extend/ENV/super.rb | 2 +- Library/Homebrew/hardware.rb | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/extend/ENV/std.rb b/Library/Homebrew/extend/ENV/std.rb index f03e56c86eecd..d61c75d7d3feb 100644 --- a/Library/Homebrew/extend/ENV/std.rb +++ b/Library/Homebrew/extend/ENV/std.rb @@ -34,7 +34,7 @@ def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_a self["PKG_CONFIG_LIBDIR"] = determine_pkg_config_libdir self["MAKEFLAGS"] = "-j#{make_jobs}" - self["RUSTFLAGS"] = Hardware.rustflags_target_cpu + self["RUSTFLAGS"] = Hardware.rustflags_target_cpu(effective_arch) if HOMEBREW_PREFIX.to_s != "/usr/local" # /usr/local is already an -isystem and -L directory so we skip it diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb index 6be9069013ebd..b3629b790b585 100644 --- a/Library/Homebrew/extend/ENV/super.rb +++ b/Library/Homebrew/extend/ENV/super.rb @@ -62,7 +62,7 @@ def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_a self["HOMEBREW_ENV"] = "super" self["MAKEFLAGS"] ||= "-j#{determine_make_jobs}" - self["RUSTFLAGS"] = Hardware.rustflags_target_cpu + self["RUSTFLAGS"] = Hardware.rustflags_target_cpu(effective_arch) self["PATH"] = determine_path self["PKG_CONFIG_PATH"] = determine_pkg_config_path self["PKG_CONFIG_LIBDIR"] = determine_pkg_config_libdir diff --git a/Library/Homebrew/hardware.rb b/Library/Homebrew/hardware.rb index c5b1eab07d67f..087b497619275 100644 --- a/Library/Homebrew/hardware.rb +++ b/Library/Homebrew/hardware.rb @@ -226,16 +226,16 @@ def oldest_cpu(_version = nil) # Returns a Rust flag to set the target CPU if necessary. # Defaults to nil. - sig { returns(T.nilable(String)) } - def rustflags_target_cpu + sig { params(arch: Symbol).returns(T.nilable(String)) } + def rustflags_target_cpu(arch) # Rust already defaults to the oldest supported cpu for each target-triplet # so it's safe to ignore generic archs such as :armv6 here. # Rust defaults to apple-m1 since Rust 1.71 for aarch64-apple-darwin. - @target_cpu ||= case (cpu = oldest_cpu) + @target_cpu ||= case (arch) when :core :prescott when :native, :ivybridge, :sandybridge, :westmere, :nehalem, :core2 - cpu + arch end return if @target_cpu.blank? From 0147c3f2cb33320d851c57f64d328d9716d9b15f Mon Sep 17 00:00:00 2001 From: Henry Date: Sun, 30 Jun 2024 02:35:29 -0400 Subject: [PATCH 2/2] Fix for 'brew style' --- Library/Homebrew/hardware.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/hardware.rb b/Library/Homebrew/hardware.rb index 087b497619275..1d50182560c46 100644 --- a/Library/Homebrew/hardware.rb +++ b/Library/Homebrew/hardware.rb @@ -231,7 +231,7 @@ def rustflags_target_cpu(arch) # Rust already defaults to the oldest supported cpu for each target-triplet # so it's safe to ignore generic archs such as :armv6 here. # Rust defaults to apple-m1 since Rust 1.71 for aarch64-apple-darwin. - @target_cpu ||= case (arch) + @target_cpu ||= case arch when :core :prescott when :native, :ivybridge, :sandybridge, :westmere, :nehalem, :core2