Some more sanity with ENV.compiler
Deprecated use_clang? etc. since the logic was such that multiple states could be set, when in reality only one compiler can be set. Changed fails_with_llvm handling so if HOMEBREW_USE_LLVM is set then it tries to build even if the formula has fails_with_llvm set. Rationale: mostly they will no longer fail and we need to catch these cases.
This commit is contained in:
parent
c659829f29
commit
0822907d6d
@ -25,14 +25,10 @@ module HomebrewEnvExtension
|
|||||||
self['CC'] = '/usr/bin/cc'
|
self['CC'] = '/usr/bin/cc'
|
||||||
self['CXX'] = '/usr/bin/c++'
|
self['CXX'] = '/usr/bin/c++'
|
||||||
|
|
||||||
if MACOS_VERSION >= 10.6
|
case self.compiler
|
||||||
if self.use_clang?
|
when :clang then self.clang
|
||||||
self.clang
|
when :llvm then self.llvm
|
||||||
elsif self.use_llvm?
|
when :gcc then self.gcc
|
||||||
self.llvm
|
|
||||||
elsif self.use_gcc?
|
|
||||||
self.gcc
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# In rare cases this may break your builds, as the tool for some reason wants
|
# In rare cases this may break your builds, as the tool for some reason wants
|
||||||
@ -141,7 +137,9 @@ module HomebrewEnvExtension
|
|||||||
alias_method :gcc_4_2, :gcc
|
alias_method :gcc_4_2, :gcc
|
||||||
|
|
||||||
def llvm
|
def llvm
|
||||||
if MacOS.xcode_version < '4.1'
|
if MacOS.xcode_version < '4'
|
||||||
|
self.gcc
|
||||||
|
elsif MacOS.xcode_version < '4.1'
|
||||||
self['CC'] = "#{MacOS.xcode_prefix}/usr/bin/llvm-gcc"
|
self['CC'] = "#{MacOS.xcode_prefix}/usr/bin/llvm-gcc"
|
||||||
self['CXX'] = "#{MacOS.xcode_prefix}/usr/bin/llvm-g++"
|
self['CXX'] = "#{MacOS.xcode_prefix}/usr/bin/llvm-g++"
|
||||||
else
|
else
|
||||||
@ -151,8 +149,12 @@ module HomebrewEnvExtension
|
|||||||
end
|
end
|
||||||
|
|
||||||
def clang
|
def clang
|
||||||
self['CC'] = "#{MacOS.xcode_prefix}/usr/bin/clang"
|
if MacOS.xcode_version > '4'
|
||||||
self['CXX'] = "#{MacOS.xcode_prefix}/usr/bin/clang++"
|
self['CC'] = "#{MacOS.xcode_prefix}/usr/bin/clang"
|
||||||
|
self['CXX'] = "#{MacOS.xcode_prefix}/usr/bin/clang++"
|
||||||
|
else
|
||||||
|
self.gcc
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def fortran
|
def fortran
|
||||||
@ -310,14 +312,42 @@ Please take one of the following actions:
|
|||||||
remove 'CXXFLAGS', f
|
remove 'CXXFLAGS', f
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def compiler
|
||||||
|
# TODO seems that ENV.clang in a Formula.install should warn when called
|
||||||
|
# if the user has set something that is tested here
|
||||||
|
|
||||||
|
# test for --flags first so that installs can be overridden on a per
|
||||||
|
# install basis
|
||||||
|
if ARGV.include? '--use-gcc'
|
||||||
|
:gcc
|
||||||
|
elsif ARGV.include? '--use-llvm'
|
||||||
|
:llvm
|
||||||
|
elsif ARGV.include? '--use-clang'
|
||||||
|
:clang
|
||||||
|
end
|
||||||
|
|
||||||
|
# test for ENVs in inverse order to flags, this is sensible, trust me
|
||||||
|
if self['HOMEBREW_USE_CLANG']
|
||||||
|
:clang
|
||||||
|
elsif self['HOMEBREW_USE_LLVM']
|
||||||
|
:llvm
|
||||||
|
elsif self['HOMEBREW_USE_GCC']
|
||||||
|
:gcc
|
||||||
|
else
|
||||||
|
:gcc
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# don't use in new code
|
||||||
|
# don't remove though, but do add to compatibility.rb
|
||||||
def use_clang?
|
def use_clang?
|
||||||
self['HOMEBREW_USE_CLANG'] or ARGV.include? '--use-clang'
|
compiler == :clang
|
||||||
end
|
end
|
||||||
def use_gcc?
|
def use_gcc?
|
||||||
self['HOMEBREW_USE_GCC'] or ARGV.include? '--use-gcc'
|
compiler == :gcc
|
||||||
end
|
end
|
||||||
def use_llvm?
|
def use_llvm?
|
||||||
self['HOMEBREW_USE_LLVM'] or ARGV.include? '--use-llvm'
|
compiler == :llvm
|
||||||
end
|
end
|
||||||
|
|
||||||
def make_jobs
|
def make_jobs
|
||||||
|
|||||||
@ -296,23 +296,18 @@ class Formula
|
|||||||
end
|
end
|
||||||
|
|
||||||
def handle_llvm_failure llvm
|
def handle_llvm_failure llvm
|
||||||
unless ENV.use_llvm? or ENV.use_clang?
|
case ENV.compiler
|
||||||
ENV.gcc_4_2 if MacOS.default_cc =~ /llvm/
|
case :llvm, :clang
|
||||||
|
opoo "LLVM was requested, but this formula is reported to not work with LLVM:"
|
||||||
|
puts llvm.reason
|
||||||
|
puts
|
||||||
|
puts "We are continuing anyway so the build succeeds, please let us know so we can"
|
||||||
|
puts "update the formula. If it doesn't work you can: brew install --use-gcc"
|
||||||
|
puts
|
||||||
|
else
|
||||||
|
ENV.gcc if MacOS.default_cc =~ /llvm/
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
opoo "LLVM was requested, but this formula is reported as not working with LLVM:"
|
|
||||||
puts llvm.reason
|
|
||||||
|
|
||||||
if ARGV.force?
|
|
||||||
puts "Continuing anyway.\n" +
|
|
||||||
"If this works, let us know so we can update the formula to remove the warning."
|
|
||||||
else
|
|
||||||
puts "Continuing with GCC 4.2 instead.\n"+
|
|
||||||
"(Use `brew install --force #{name}` to force use of LLVM.)"
|
|
||||||
ENV.gcc_4_2
|
|
||||||
end
|
|
||||||
puts
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.class_s name
|
def self.class_s name
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user