Refactor to use oldest_cpu
This commit is contained in:
parent
9a99b932e8
commit
9a19f5bcd2
@ -24,21 +24,4 @@ module Hardware
|
||||
generic_oldest_cpu
|
||||
end
|
||||
end
|
||||
|
||||
# Override
|
||||
# Mirrors version-dependent logic of oldest_cpu
|
||||
sig { params(version: T.nilable(Version)).returns(String) }
|
||||
def self.rustflags_target_cpu(version = nil)
|
||||
version = if version
|
||||
MacOSVersion.new(version.to_s)
|
||||
else
|
||||
MacOS.version
|
||||
end
|
||||
|
||||
if Hardware::CPU.intel? && version >= :mojave
|
||||
"-Ctarget-cpu=nehalem"
|
||||
else
|
||||
generic_rustflags_target_cpu
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -41,6 +41,14 @@ module Hardware
|
||||
end
|
||||
alias generic_optimization_flags optimization_flags
|
||||
|
||||
def rust_optimisation_flags
|
||||
# Only give values where it is an improvement over rust cpu defaults
|
||||
@rust_optimisation_flags ||= {
|
||||
native: "-Ctarget-cpu=native",
|
||||
nehalem: "-Ctarget-cpu=nehalem",
|
||||
}.freeze
|
||||
end
|
||||
|
||||
sig { returns(Symbol) }
|
||||
def arch_32_bit
|
||||
if arm?
|
||||
@ -221,11 +229,10 @@ module Hardware
|
||||
# But only where it is version dependent.
|
||||
# Rust already defaults to the oldest supported cpu for the target-triple
|
||||
# Including apple-m1 since 1.71.
|
||||
sig { params(_version: T.nilable(Version)).returns(String) }
|
||||
def rustflags_target_cpu(_version = nil)
|
||||
""
|
||||
sig { returns(String) }
|
||||
def rustflags_target_cpu
|
||||
CPU.rust_optimisation_flags.fetch(oldest_cpu, "")
|
||||
end
|
||||
alias generic_rustflags_target_cpu rustflags_target_cpu
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user