Use effective_arch for rustflags

This commit is contained in:
Henry 2024-06-30 02:23:29 -04:00
parent 09223c700a
commit 22d42efb5c
No known key found for this signature in database
GPG Key ID: 03108A8D9159E2AE
3 changed files with 6 additions and 6 deletions

View File

@ -34,7 +34,7 @@ module Stdenv
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

View File

@ -62,7 +62,7 @@ module Superenv
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

View File

@ -226,16 +226,16 @@ module Hardware
# 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?