Merge pull request #7945 from claui/oldest_cpu
Make Homebrew work with Xcode 12 Beta 2 on Apple Silicon
This commit is contained in:
		
						commit
						0735915dc5
					
				@ -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
 | 
			
		||||
 | 
			
		||||
@ -12,14 +12,15 @@ module Hardware
 | 
			
		||||
    class << self
 | 
			
		||||
      def optimization_flags
 | 
			
		||||
        @optimization_flags ||= {
 | 
			
		||||
          native:  arch_flag("native"),
 | 
			
		||||
          nehalem: "-march=nehalem",
 | 
			
		||||
          core2:   "-march=core2",
 | 
			
		||||
          core:    "-march=prescott",
 | 
			
		||||
          armv6:   "-march=armv6",
 | 
			
		||||
          armv8:   "-march=armv8-a",
 | 
			
		||||
          ppc64:   "-mcpu=powerpc64",
 | 
			
		||||
          ppc64le: "-mcpu=powerpc64le",
 | 
			
		||||
          native:             arch_flag("native"),
 | 
			
		||||
          nehalem:            "-march=nehalem",
 | 
			
		||||
          core2:              "-march=core2",
 | 
			
		||||
          core:               "-march=prescott",
 | 
			
		||||
          arm_vortex_tempest: "",
 | 
			
		||||
          armv6:              "-march=armv6",
 | 
			
		||||
          armv8:              "-march=armv8-a",
 | 
			
		||||
          ppc64:              "-mcpu=powerpc64",
 | 
			
		||||
          ppc64le:            "-mcpu=powerpc64le",
 | 
			
		||||
        }.freeze
 | 
			
		||||
      end
 | 
			
		||||
      alias generic_optimization_flags optimization_flags
 | 
			
		||||
 | 
			
		||||
@ -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)
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user