Skip to content

Commit

Permalink
Merge pull request #17597 from git-mann/effective_arch_for_rustflags
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeMcQuaid committed Jul 1, 2024
2 parents 80d0744 + 0147c3f commit 3b4fc69
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Library/Homebrew/extend/ENV/std.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/extend/ENV/super.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions Library/Homebrew/hardware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand Down

0 comments on commit 3b4fc69

Please sign in to comment.