Merge pull request #5429 from MikeMcQuaid/nehalem-sierra-bottles

hardware: use Nehalem flags on >= Sierra.
This commit is contained in:
Mike McQuaid 2018-12-21 10:29:43 +00:00 committed by GitHub
commit 1a78cc77d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 28 deletions

View File

@ -233,6 +233,9 @@ module Superenv
if ARGV.build_bottle?
arch = ARGV.bottle_arch || Hardware.oldest_cpu
Hardware::CPU.optimization_flags.fetch(arch)
# If the CPU doesn't support SSE4, we cannot trust -march=native or
# -march=<cpu family> to do the right thing because we might be running
# in a VM or on a Hackintosh.
elsif Hardware::CPU.intel? && !Hardware::CPU.sse4?
Hardware::CPU.optimization_flags.fetch(Hardware.oldest_cpu)
elsif ![:gcc_4_0, :gcc_4_2].include?(compiler)

View File

@ -1,4 +1,5 @@
if OS.mac?
require "extend/os/mac/hardware"
require "extend/os/mac/hardware/cpu"
elsif OS.linux?
require "extend/os/linux/hardware/cpu"

View File

@ -0,0 +1,9 @@
module Hardware
def self.oldest_cpu
if MacOS.version >= :sierra
:nehalem
else
generic_oldest_cpu
end
end
end

View File

@ -7,6 +7,7 @@ module Hardware
class << self
OPTIMIZATION_FLAGS = {
nehalem: "-march=nehalem -msse4.2",
core2: "-march=core2",
core: "-march=prescott",
armv6: "-march=armv6",
@ -130,7 +131,8 @@ module Hardware
end
end
def self.cores_as_words
class << self
def cores_as_words
case Hardware::CPU.cores
when 1 then "single"
when 2 then "dual"
@ -143,7 +145,7 @@ module Hardware
end
end
def self.oldest_cpu
def oldest_cpu
if Hardware::CPU.intel?
if Hardware::CPU.is_64_bit?
:core2
@ -160,6 +162,8 @@ module Hardware
Hardware::CPU.family
end
end
alias generic_oldest_cpu oldest_cpu
end
end
require "extend/os/hardware"