Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os/mac/hardware: use Westmere on >= Ventura #16392

Merged
merged 1 commit into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion Library/Homebrew/extend/os/mac/hardware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ def self.oldest_cpu(version = nil)
end
if CPU.arch == :arm64
:arm_vortex_tempest
# This cannot use a newer CPU e.g. ivybridge because Rosetta 2 does not
# This cannot use a newer CPU e.g. haswell because Rosetta 2 does not
# support AVX instructions in bottles:
# https://github.com/Homebrew/homebrew-core/issues/67713
elsif version >= :ventura
:westmere
elsif version >= :mojave
:nehalem
else
Expand Down
5 changes: 3 additions & 2 deletions Library/Homebrew/hardware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ def optimization_flags
native: arch_flag("native"),
ivybridge: "-march=ivybridge",
sandybridge: "-march=sandybridge",
westmere: "-march=westmere",
nehalem: "-march=nehalem",
core2: "-march=core2",
core: "-march=prescott",
arm_vortex_tempest: "",
arm_vortex_tempest: "", # TODO: -mcpu=apple-m1 when we've patched all our GCCs to support it
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some earlier versions of Xcode may barf on this too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In terms of LLVM: added in LLVM 13, though we don't support versioned LLVM as a compiler yet.

That would equate to Xcode 13.3 but it's very possible Apple had it in their internal Clang earlier. If we find any of Xcode 12.2-13.2 don't support it, we could probably swap it on shim level to -mcpu=apple-a13 or something (not quite the same but close enough). We don't support 12.2-12.4 in the CLT so we could drop that on the Xcode side should -mcpu=apple-m1 only be a problem there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, Apple clang supported the flag earlier than upstream LLVM did IIRC. ("earlier" in a corresponding upstream LLVM version sense -- I think it was the latest released version of Xcode when upstream LLVM 13 dropped.)

NBD to enable this flag as-is as soon as we have sufficient GCC support -- we can fix any problems that come up as they emerge.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked Apple's OSS LLVM fork but it wasn't there prior to it landing in LLVM so it seems they kept it in their private builds initially.

I can easily test with some CLT versions when the time arrives. The ones to test really are Xcode/CLT 12.2, 12.5 and 13.0 as those are the main big Clang branches, narrowing down further if necessary.

armv6: "-march=armv6",
armv8: "-march=armv8-a",
ppc64: "-mcpu=powerpc64",
Expand Down Expand Up @@ -225,7 +226,7 @@ def rustflags_target_cpu
@target_cpu ||= case (cpu = oldest_cpu)
when :core
:prescott
when :native, :ivybridge, :sandybridge, :nehalem, :core2
when :native, :ivybridge, :sandybridge, :westmere, :nehalem, :core2
cpu
end
return if @target_cpu.blank?
Expand Down