Merge pull request #7945 from claui/oldest_cpu

Make Homebrew work with Xcode 12 Beta 2 on Apple Silicon
This commit is contained in:
Claudia Pellegrino 2020-07-08 22:29:04 +02:00 committed by GitHub
commit 0735915dc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 9 deletions

View File

@ -2,7 +2,9 @@
module Hardware
def self.oldest_cpu(version = MacOS.version)
if version >= :mojave
if CPU.arch == :arm64
:arm_vortex_tempest
elsif version >= :mojave
:nehalem
else
generic_oldest_cpu

View File

@ -16,6 +16,7 @@ module Hardware
nehalem: "-march=nehalem",
core2: "-march=core2",
core: "-march=prescott",
arm_vortex_tempest: "",
armv6: "-march=armv6",
armv8: "-march=armv8-a",
ppc64: "-mcpu=powerpc64",

View File

@ -43,6 +43,10 @@ module OS
# For OS::Mac::Version compatibility
def requires_nehalem_cpu?
unless Hardware::CPU.intel?
raise "Unexpected architecture: #{Hardware::CPU.arch}. This only works with Intel architecture."
end
Hardware.oldest_cpu(self) == :nehalem
end
# https://en.wikipedia.org/wiki/Nehalem_(microarchitecture)

View File

@ -50,6 +50,7 @@ describe OS::Mac::Version do
end
specify "#requires_nehalem_cpu?" do
expect(Hardware::CPU).to receive(:type).at_least(:twice).and_return(:intel)
expect(described_class.new("10.14").requires_nehalem_cpu?).to be true
expect(described_class.new("10.12").requires_nehalem_cpu?).to be false
end