brew doctor: add check for outdated compilers

A common source of build problems on Xcode 4.3+ is outdated compilers,
usually when a user has installed over top of an old version and hasn't
installed the CLT. Since the compilers from the previous Xcode are still
around, brew doctor wouldn't complain.

This adds a hash containing a list of the canonical compiler versions
for supported versions of Xcode, and adds a check against that to determine
whether a given installation has any compilers which are out of date.

Closes Homebrew/homebrew#11518.

Signed-off-by: Misty De Meo <mistydemeo@gmail.com>
This commit is contained in:
Misty De Meo 2012-04-08 11:10:22 -05:00
parent 9d172f85c6
commit 4dc1a7bdce
2 changed files with 30 additions and 0 deletions

View File

@ -232,6 +232,17 @@ def check_cc
end
end
def check_standard_compilers
return if check_for_latest_xcode # only check if Xcode is up to date
if !MacOS.compilers_standard? then <<-EOS.undent
Your compilers are different from the standard versions for your Xcode.
If you have Xcode 4.3 or newer, you should install the Command Line Tools for
Xcode from within Xcode's Download preferences.
Otherwise, you should reinstall Xcode.
EOS
end
end
def __check_subdir_access base
target = HOMEBREW_PREFIX+base
return unless target.exist?

View File

@ -521,6 +521,25 @@ module MacOS extend self
def prefer_64_bit?
Hardware.is_64_bit? and not leopard?
end
StandardCompilers = {
"3.1.4" => {:gcc_40_build_version=>5493, :gcc_42_build_version=>5577, :llvm_build_version=>2064},
"3.2.6" => {:gcc_40_build_version=>5494, :gcc_42_build_version=>5666, :llvm_build_version=>2335, :clang_version=>"1.7", :clang_build_version=>77},
"4.0.0" => {:gcc_40_build_version=>5494, :gcc_42_build_version=>5666, :llvm_build_version=>2335, :clang_version=>"2.0", :clang_build_version=>137},
"4.0.1" => {:gcc_40_build_version=>5494, :gcc_42_build_version=>5666, :llvm_build_version=>2335, :clang_version=>"2.0", :clang_build_version=>137},
"4.0.2" => {:gcc_40_build_version=>5494, :gcc_42_build_version=>5666, :llvm_build_version=>2335, :clang_version=>"2.0", :clang_build_version=>137},
"4.2.0" => {:llvm_build_version=>2336, :clang_version=>"3.0", :clang_build_version=>211},
"4.3.0" => {:llvm_build_version=>2336, :clang_version=>"3.1", :clang_build_version=>318},
"4.3.1" => {:llvm_build_version=>2336, :clang_version=>"3.1", :clang_build_version=>318},
"4.3.2" => {:llvm_build_version=>2336, :clang_version=>"3.1", :clang_build_version=>318}
}
def compilers_standard?
xcode = MacOS.xcode_version
return unless StandardCompilers.keys.include? xcode
StandardCompilers[xcode].all? {|k,v| MacOS.send(k) == v}
end
end
module GitHub extend self