Fix --build-bottle CFLAGS.

The CFLAGS were previously not generic enough.

References Homebrew/homebrew#18944.
References Homebrew/homebrew#19179.
This commit is contained in:
Mike McQuaid 2013-05-11 12:18:25 +01:00
parent 1bf8fbfe9a
commit ad5c1b81cd
4 changed files with 38 additions and 11 deletions

View File

@ -148,17 +148,22 @@ class Cmd
args args
end end
def cflags def cflags
if cccfg? 'Ob' return [] unless cccfg? 'O'
%w{-mtune=generic -Oz}
elsif cccfg? 'O' args = %w{-pipe -w -Os}
args = %w{-pipe -w -Os}
args << '-march=native' if tool =~ /clang/ # When bottling use the oldest supported CPU type.
args += %w{-arch i386 -arch x86_64} if cccfg? 'u' if cccfg? 'bi6'
args << "-std=#{@arg0}" if @arg0 =~ /c[89]9/ args << '-march=core2'
args elsif cccfg? 'bi'
args << '-march=prescott'
else else
[] args << '-march=native' if tool =~ /clang/
end end
args += %w{-arch i386 -arch x86_64} if cccfg? 'u'
args << "-std=#{@arg0}" if @arg0 =~ /c[89]9/
args
end end
def syslibpath def syslibpath
# We reject brew's lib as we explicitly add this as a -L flag, thus it # We reject brew's lib as we explicitly add this as a -L flag, thus it

View File

@ -326,7 +326,7 @@ module HomebrewEnvExtension
append flags, xarch unless xarch.empty? append flags, xarch unless xarch.empty?
if ARGV.build_bottle? if ARGV.build_bottle?
append flags, '-mtune=generic' append flags, Hardware::CPU.optimization_flags[MacOS.oldest_cpu]
else else
# Don't set -msse3 and older flags because -march does that for us # Don't set -msse3 and older flags because -march does that for us
append flags, map.fetch(Hardware::CPU.family, default) append flags, map.fetch(Hardware::CPU.family, default)

View File

@ -34,6 +34,18 @@ module MacOS extend self
cat.to_s.gsub('_', '').to_sym cat.to_s.gsub('_', '').to_sym
end end
def oldest_cpu
if Hardware::CPU.type == :intel
if Hardware::CPU.is_64_bit?
:core2
else
:core
end
else
Hardware::CPU.family
end
end
def locate tool def locate tool
# Don't call tools (cc, make, strip, etc.) directly! # Don't call tools (cc, make, strip, etc.) directly!
# Give the name of the binary you look for as a string to this method # Give the name of the binary you look for as a string to this method

View File

@ -182,7 +182,17 @@ class << ENV
def determine_cccfg def determine_cccfg
s = "" s = ""
s << 'b' if ARGV.build_bottle? if ARGV.build_bottle?
s << if Hardware::CPU.type == :intel
if Hardware::CPU.is_64_bit?
'bi6'
else
'bi'
end
else
'b'
end
end
# Fix issue with sed barfing on unicode characters on Mountain Lion # Fix issue with sed barfing on unicode characters on Mountain Lion
s << 's' if MacOS.version >= :mountain_lion s << 's' if MacOS.version >= :mountain_lion
# Fix issue with 10.8 apr-1-config having broken paths # Fix issue with 10.8 apr-1-config having broken paths