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 module Hardware
def self.oldest_cpu(version = MacOS.version) def self.oldest_cpu(version = MacOS.version)
if version >= :mojave if CPU.arch == :arm64
:arm_vortex_tempest
elsif version >= :mojave
:nehalem :nehalem
else else
generic_oldest_cpu generic_oldest_cpu

View File

@ -12,14 +12,15 @@ module Hardware
class << self class << self
def optimization_flags def optimization_flags
@optimization_flags ||= { @optimization_flags ||= {
native: arch_flag("native"), native: arch_flag("native"),
nehalem: "-march=nehalem", nehalem: "-march=nehalem",
core2: "-march=core2", core2: "-march=core2",
core: "-march=prescott", core: "-march=prescott",
armv6: "-march=armv6", arm_vortex_tempest: "",
armv8: "-march=armv8-a", armv6: "-march=armv6",
ppc64: "-mcpu=powerpc64", armv8: "-march=armv8-a",
ppc64le: "-mcpu=powerpc64le", ppc64: "-mcpu=powerpc64",
ppc64le: "-mcpu=powerpc64le",
}.freeze }.freeze
end end
alias generic_optimization_flags optimization_flags alias generic_optimization_flags optimization_flags

View File

@ -43,6 +43,10 @@ module OS
# For OS::Mac::Version compatibility # For OS::Mac::Version compatibility
def requires_nehalem_cpu? 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 Hardware.oldest_cpu(self) == :nehalem
end end
# https://en.wikipedia.org/wiki/Nehalem_(microarchitecture) # https://en.wikipedia.org/wiki/Nehalem_(microarchitecture)

View File

@ -50,6 +50,7 @@ describe OS::Mac::Version do
end end
specify "#requires_nehalem_cpu?" do 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.14").requires_nehalem_cpu?).to be true
expect(described_class.new("10.12").requires_nehalem_cpu?).to be false expect(described_class.new("10.12").requires_nehalem_cpu?).to be false
end end