From a70d15c80d3ba7d674a7062547e30308001aa3bf Mon Sep 17 00:00:00 2001 From: Caleb Xu Date: Tue, 12 Nov 2024 11:34:40 -0500 Subject: [PATCH] shared: only fall back to -march=native on supported architectures --- Library/Homebrew/extend/os/linux/extend/ENV/shared.rb | 4 +++- Library/Homebrew/hardware.rb | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/extend/os/linux/extend/ENV/shared.rb b/Library/Homebrew/extend/os/linux/extend/ENV/shared.rb index 2d42c97b9c652..75ccb956fd408 100644 --- a/Library/Homebrew/extend/os/linux/extend/ENV/shared.rb +++ b/Library/Homebrew/extend/os/linux/extend/ENV/shared.rb @@ -7,8 +7,10 @@ def effective_arch @bottle_arch.to_sym elsif @build_bottle Hardware.oldest_cpu - else + elsif Hardware::CPU.intel? || Hardware::CPU.arm? :native + else + :none end end end diff --git a/Library/Homebrew/hardware.rb b/Library/Homebrew/hardware.rb index d970ced6f2379..138b5e118fe20 100644 --- a/Library/Homebrew/hardware.rb +++ b/Library/Homebrew/hardware.rb @@ -27,6 +27,7 @@ class << self sig { returns(T::Hash[Symbol, String]) } def optimization_flags @optimization_flags ||= T.let({ + none: "", native: arch_flag("native"), ivybridge: "-march=ivybridge", sandybridge: "-march=sandybridge",