Build optimisations for 64 bit Snow Leopard
Specifying -v/--verbose shows the build environment before the build MACOS_VERSION contains the floating point value of the OS X version A test for some floating point assumptions I make
This commit is contained in:
parent
f6743bbfd7
commit
fbda4b45d6
@ -22,13 +22,26 @@
|
|||||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#
|
#
|
||||||
require 'osx/cocoa' # to get number of cores
|
require 'osx/cocoa' # to get number of cores
|
||||||
|
require 'fileutils'
|
||||||
require 'formula'
|
require 'formula'
|
||||||
require 'download_strategy'
|
require 'download_strategy'
|
||||||
require 'hw.model'
|
require 'hw.model'
|
||||||
|
|
||||||
ENV['MACOSX_DEPLOYMENT_TARGET']='10.5'
|
# TODO
|
||||||
ENV['CFLAGS']='-O3 -w -pipe -fomit-frame-pointer -mmacosx-version-min=10.5'
|
# 1. Indeed, there should be an option to build 32 or 64 bit binaries
|
||||||
ENV['LDFLAGS']='' # to be consistent, we ignore the environment usually already
|
# 2. Homebrew will not support building 32 and 64 bit lipo'd binaries, I
|
||||||
|
# want to mind, but the simple fact is it is difficult to force most of the
|
||||||
|
# build systems we support to do it.
|
||||||
|
|
||||||
|
|
||||||
|
`sw_vers -productVersion` =~ /(10\.\d+)(\.\d+)?/
|
||||||
|
MACOS_VERSION=$1.to_f
|
||||||
|
|
||||||
|
ENV['MACOSX_DEPLOYMENT_TARGET']=MACOS_VERSION.to_s
|
||||||
|
ENV['LDFLAGS']='' # to be consistent, we ignore the existing environment
|
||||||
|
|
||||||
|
# this is first, so when you see it in output, you notice it
|
||||||
|
cflags='-O3'
|
||||||
|
|
||||||
# optimise all the way to eleven, references:
|
# optimise all the way to eleven, references:
|
||||||
# http://en.gentoo-wiki.com/wiki/Safe_Cflags/Intel
|
# http://en.gentoo-wiki.com/wiki/Safe_Cflags/Intel
|
||||||
@ -37,17 +50,21 @@ ENV['LDFLAGS']='' # to be consistent, we ignore the environment usually already
|
|||||||
case hw_model
|
case hw_model
|
||||||
when :core1
|
when :core1
|
||||||
# Core DUO is a 32 bit chip
|
# Core DUO is a 32 bit chip
|
||||||
ENV['CFLAGS']="#{ENV['CFLAGS']} -march=prescott -mfpmath=sse -msse3 -mmmx"
|
# NOTE technically we can do -msse4 with gcc 4.2, but I can't test it, so
|
||||||
|
# haven't tried it, if you have a core1 chip, then please test and commit --mxcl
|
||||||
|
cflags<<" -march=prescott -mfpmath=sse -msse3 -mmmx"
|
||||||
when :core2
|
when :core2
|
||||||
# Core 2 DUO is a 64 bit chip
|
# Core 2 DUO is a 64 bit chip
|
||||||
# GCC 4.3 will have a -march=core2, but for now nocona is correct
|
if MACOS_VERSION >= 10.6
|
||||||
ENV['CFLAGS']="#{ENV['CFLAGS']} -march=nocona -mfpmath=sse -msse3 -mmmx"
|
# 64 bits baby! -mfpmath=sse is automatically switched on by -m64
|
||||||
|
# GCC 4.3 has a -march=core2, but this is 4.2 and nocona is correct
|
||||||
# OK so we're not doing 64 bit yet... but we will with Snow Leopard
|
cflags<<" -m64 -march=nocona -msse4 -mmmx"
|
||||||
# -mfpmath=sse defaults to on for the x64 compiler
|
ENV['LDFLAGS']="-arch x86_64"
|
||||||
#ENV['CFLAGS']="#{ENV['CFLAGS']} -march=nocona -msse3 -mmmx -m64"
|
else
|
||||||
#ENV['LDFLAGS']="-arch x86_64"
|
# We don't build 64 bit before 10.6 as nothing else is 64 bit, so any
|
||||||
|
# libraries we build would be unusable by 32 bit software
|
||||||
|
cflags<<" -march=nocona -mfpmath=sse -msse3 -mmmx"
|
||||||
|
end
|
||||||
when :xeon
|
when :xeon
|
||||||
# TODO what optimisations for xeon?
|
# TODO what optimisations for xeon?
|
||||||
|
|
||||||
@ -55,15 +72,22 @@ case hw_model
|
|||||||
when :dunno then abort "Sorry, Homebrew cannot determine what kind of Mac this is!"
|
when :dunno then abort "Sorry, Homebrew cannot determine what kind of Mac this is!"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# -w: keep signal to noise high
|
||||||
|
# -fomit-frame-pointer: we are not debugging this software, we are using it
|
||||||
|
ENV['CFLAGS']="#{cflags} -w -pipe -fomit-frame-pointer -mmacosx-version-min=#{MACOS_VERSION}"
|
||||||
ENV['CXXFLAGS']=ENV['CFLAGS']
|
ENV['CXXFLAGS']=ENV['CFLAGS']
|
||||||
|
|
||||||
# lets use gcc 4.2, it is newer and "better", at least I believe so, mail me
|
# lets use gcc 4.2, it is newer and "better", at least I believe so, mail me
|
||||||
# if I'm wrong
|
# if I'm wrong
|
||||||
ENV['CC']='gcc-4.2'
|
if MACOS_VERSION==10.5
|
||||||
ENV['CXX']='g++-4.2'
|
ENV['CC']='gcc-4.2'
|
||||||
|
ENV['CXX']='g++-4.2'
|
||||||
|
end
|
||||||
|
# compile faster
|
||||||
ENV['MAKEFLAGS']="-j#{OSX::NSProcessInfo.processInfo.processorCount}"
|
ENV['MAKEFLAGS']="-j#{OSX::NSProcessInfo.processInfo.processorCount}"
|
||||||
|
|
||||||
|
|
||||||
|
# /usr/local is always in the build system path
|
||||||
unless HOMEBREW_PREFIX.to_s == '/usr/local'
|
unless HOMEBREW_PREFIX.to_s == '/usr/local'
|
||||||
ENV['CPPFLAGS']="-I#{HOMEBREW_PREFIX}/include"
|
ENV['CPPFLAGS']="-I#{HOMEBREW_PREFIX}/include"
|
||||||
ENV['LDFLAGS']="-L#{HOMEBREW_PREFIX}/lib"
|
ENV['LDFLAGS']="-L#{HOMEBREW_PREFIX}/lib"
|
||||||
@ -76,8 +100,14 @@ module HomebrewEnvExtension
|
|||||||
remove 'MAKEFLAGS', /-j\d+/
|
remove 'MAKEFLAGS', /-j\d+/
|
||||||
end
|
end
|
||||||
def gcc_4_0_1
|
def gcc_4_0_1
|
||||||
|
case MACOS_VERSION
|
||||||
|
when 10.5
|
||||||
self['CC']=nil
|
self['CC']=nil
|
||||||
self['CXX']=nil
|
self['CXX']=nil
|
||||||
|
when 10.6..11.0
|
||||||
|
self['CC']='gcc-4.0'
|
||||||
|
self['CXX']='g++-4.0'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
def osx_10_4
|
def osx_10_4
|
||||||
self['MACOSX_DEPLOYMENT_TARGET']=nil
|
self['MACOSX_DEPLOYMENT_TARGET']=nil
|
||||||
@ -89,6 +119,7 @@ module HomebrewEnvExtension
|
|||||||
def libxml2
|
def libxml2
|
||||||
self['CXXFLAGS']=self['CFLAGS']+=' -I/usr/include/libxml2'
|
self['CXXFLAGS']=self['CFLAGS']+=' -I/usr/include/libxml2'
|
||||||
end
|
end
|
||||||
|
# TODO rename or alias to x11
|
||||||
def libpng
|
def libpng
|
||||||
append 'CPPFLAGS', '-I/usr/X11R6/include'
|
append 'CPPFLAGS', '-I/usr/X11R6/include'
|
||||||
append 'LDFLAGS', '-L/usr/X11R6/lib'
|
append 'LDFLAGS', '-L/usr/X11R6/lib'
|
||||||
@ -120,6 +151,7 @@ end
|
|||||||
|
|
||||||
ENV.extend HomebrewEnvExtension
|
ENV.extend HomebrewEnvExtension
|
||||||
|
|
||||||
|
|
||||||
# remove MacPorts and Fink from the PATH, this prevents issues like:
|
# remove MacPorts and Fink from the PATH, this prevents issues like:
|
||||||
# http://github.com/mxcl/homebrew/issues/#issue/13
|
# http://github.com/mxcl/homebrew/issues/#issue/13
|
||||||
paths=ENV['PATH'].split(':').reject do |p|
|
paths=ENV['PATH'].split(':').reject do |p|
|
||||||
|
@ -351,4 +351,15 @@ class BeerTasting <Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_my_float_assumptions
|
||||||
|
# this may look ridiculous but honestly there's code in brewit that depends on
|
||||||
|
# this behaviour so I wanted to be certain Ruby floating points are behaving
|
||||||
|
f='10.6'.to_f
|
||||||
|
assert_equal 10.6, f
|
||||||
|
assert f >= 10.6
|
||||||
|
assert f <= 10.6
|
||||||
|
assert_equal 10.5, f-0.1
|
||||||
|
assert_equal 10.7, f+0.1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
8
bin/brew
8
bin/brew
@ -73,6 +73,14 @@ begin
|
|||||||
exit 0
|
exit 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if ARGV.verbose?
|
||||||
|
require 'brewkit'
|
||||||
|
ohai "Build Environment"
|
||||||
|
%w[CFLAGS LDFLAGS CPPFLAGS MAKEFLAGS CC CXX].each do |f|
|
||||||
|
puts "#{f}: #{ENV[f]}" unless ENV[f].to_s.empty?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# we need to ensure a pristine ENV for each process or the formula
|
# we need to ensure a pristine ENV for each process or the formula
|
||||||
# will start with the ENV from the previous build
|
# will start with the ENV from the previous build
|
||||||
ARGV.formulae.each do |f|
|
ARGV.formulae.each do |f|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user