Skip to content

Commit

Permalink
brew doctor: add check for outdated compilers
Browse files Browse the repository at this point in the history
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#11518.

Signed-off-by: Misty De Meo <mistydemeo@gmail.com>
  • Loading branch information
mistydemeo committed Apr 11, 2012
1 parent 124cdb6 commit 7b1ad6e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Library/Homebrew/cmd/doctor.rb
Expand Up @@ -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?
Expand Down
19 changes: 19 additions & 0 deletions Library/Homebrew/utils.rb
Expand Up @@ -521,6 +521,25 @@ def mountain_lion?
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
Expand Down

0 comments on commit 7b1ad6e

Please sign in to comment.