Fix LLVM compilation under OS X 10.6 where cflags was not being defined.

Signed-off-by: Adam Vandenberg <flangy@gmail.com>

* Unshare code between ENV.llvm and ENV.setup_build_environment
This commit is contained in:
Brett Cannon 2010-06-18 14:32:25 -07:00 committed by Adam Vandenberg
parent 43d1f6790b
commit 3a97b2cf67

View File

@ -19,7 +19,12 @@ module HomebrewEnvExtension
end end
if MACOS_VERSION >= 10.6 and (ENV['HOMEBREW_USE_LLVM'] or ARGV.include? '--use-llvm') if MACOS_VERSION >= 10.6 and (ENV['HOMEBREW_USE_LLVM'] or ARGV.include? '--use-llvm')
self.llvm xcode_path = `/usr/bin/xcode-select -print-path`.chomp
xcode_path = "/Developer" if xcode_path.to_s.empty?
ENV['CC'] = "#{xcode_path}/usr/bin/llvm-gcc"
ENV['CXX'] = "#{xcode_path}/usr/bin/llvm-g++"
ENV['LD'] = ENV['CC']
cflags = ['-O4'] # link time optimisation baby!
else else
# if we don't set these, many formula fail to build # if we don't set these, many formula fail to build
ENV['CC'] = '/usr/bin/cc' ENV['CC'] = '/usr/bin/cc'
@ -78,6 +83,11 @@ module HomebrewEnvExtension
remove_from_cflags /-O./ remove_from_cflags /-O./
append_to_cflags '-fast' append_to_cflags '-fast'
end end
def O4
# LLVM link-time optimization
remove_from_cflags /-O./
append_to_cflags '-O4'
end
def O3 def O3
# Sometimes O4 just takes fucking forever # Sometimes O4 just takes fucking forever
remove_from_cflags /-O./ remove_from_cflags /-O./
@ -112,14 +122,12 @@ module HomebrewEnvExtension
end end
def llvm def llvm
# you can install Xcode wherever you like you know.
xcode_path = `/usr/bin/xcode-select -print-path`.chomp xcode_path = `/usr/bin/xcode-select -print-path`.chomp
xcode_path = "/Developer" if xcode_path.to_s.empty? xcode_path = "/Developer" if xcode_path.to_s.empty?
self['CC'] = "#{xcode_path}/usr/bin/llvm-gcc"
ENV['CC'] = "#{xcode_path}/usr/bin/llvm-gcc" self['CXX'] = "#{xcode_path}/usr/bin/llvm-g++"
ENV['CXX'] = "#{xcode_path}/usr/bin/llvm-g++"
cflags = %w{-O4} # link time optimisation baby!
self['LD'] = self['CC'] self['LD'] = self['CC']
self.O4
end end
def osx_10_4 def osx_10_4