More cpus in rust_optimisation_flags

This commit is contained in:
Tokarak 2023-06-17 12:14:21 +01:00
parent 73c339d82b
commit 40aa41929f

View File

@ -41,13 +41,17 @@ module Hardware
end end
alias generic_optimization_flags optimization_flags alias generic_optimization_flags optimization_flags
# Only give values where it is an improvement over rust cpu defaults
# Rust already defaults to the oldest supported cpu for each target-triple # Rust already defaults to the oldest supported cpu for each target-triple
# Including apple-m1 since Rust 1.71 for aarch64-apple-darwin. # so it's safe to ignore generic archs such as :armv6, etc., here.
# Rust defaults to apple-m1 since Rust 1.71 for aarch64-apple-darwin.
def rust_optimisation_flags def rust_optimisation_flags
@rust_optimisation_flags ||= { @rust_optimisation_flags ||= {
native: "-Ctarget-cpu=native", native: "--codegen target-cpu=native",
nehalem: "-Ctarget-cpu=nehalem", ivybridge: "--codegen target-cpu=ivybridge",
sandybridge: "--codegen target-cpu=sandybridge",
nehalem: "--codegen target-cpu=nehalem",
core2: "--codegen target-cpu=core2",
core: "--codegen target-cpu=prescott",
}.freeze }.freeze
end end
@ -227,9 +231,9 @@ module Hardware
# Returns a _full_ rustflag to set target cpu, if necessary; # Returns a _full_ rustflag to set target cpu, if necessary;
# Defaults to empty string # Defaults to empty string
sig { returns(String) } sig { returns(T.nilable(String)) }
def rustflags_target_cpu def rustflags_target_cpu
CPU.rust_optimisation_flags.fetch(oldest_cpu, "") CPU.rust_optimisation_flags.fetch(oldest_cpu, nil)
end end
end end
end end