From 40aa41929f33ce7f6172b82315e6687fa5c93406 Mon Sep 17 00:00:00 2001 From: Tokarak <63452145+Tokarak@users.noreply.github.com> Date: Sat, 17 Jun 2023 12:14:21 +0100 Subject: [PATCH] More cpus in rust_optimisation_flags --- Library/Homebrew/hardware.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/hardware.rb b/Library/Homebrew/hardware.rb index 3ec3e3599d..43ecb7268d 100644 --- a/Library/Homebrew/hardware.rb +++ b/Library/Homebrew/hardware.rb @@ -41,13 +41,17 @@ module Hardware end 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 - # 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 @rust_optimisation_flags ||= { - native: "-Ctarget-cpu=native", - nehalem: "-Ctarget-cpu=nehalem", + native: "--codegen target-cpu=native", + 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 end @@ -227,9 +231,9 @@ module Hardware # Returns a _full_ rustflag to set target cpu, if necessary; # Defaults to empty string - sig { returns(String) } + sig { returns(T.nilable(String)) } def rustflags_target_cpu - CPU.rust_optimisation_flags.fetch(oldest_cpu, "") + CPU.rust_optimisation_flags.fetch(oldest_cpu, nil) end end end