superenv: --use-gcc should specify gcc-4.2

Since 'gcc' is a symlink to 'llvm-gcc' on Xcode 4.3+, --use-gcc and
--use-llvm were doing exactly the same thing. Combined with the
previous commit, this allows users with either a leftover
/usr/bin/gcc-4.2 or a homebrewed apple-gcc42 to build with gcc.

This doesn't however fix Xcode-only systems with apple-gcc42.

Fixes Homebrew/homebrew#17243.
This commit is contained in:
Misty De Meo 2013-01-22 18:28:13 -06:00
parent 88609dd6ed
commit 2e23e9a22d
4 changed files with 8 additions and 2 deletions

View File

@ -60,8 +60,10 @@ class Cmd
# the work since Makefiles are dumb and include a lot of excess flags. # the work since Makefiles are dumb and include a lot of excess flags.
ENV['HOMEBREW_CC'] ENV['HOMEBREW_CC']
when 'c++' when 'c++'
if ENV['HOMEBREW_CC'] =~ /gcc/ if ENV['HOMEBREW_CC'] =~ /llvm-gcc/
'g++' 'g++'
elsif ENV['HOMEBREW_CC'] =~ /gcc-4.2/
'g++-4.2'
else else
'clang++' 'clang++'
end end

1
Library/ENV/4.3/g++-4.2 Symbolic link
View File

@ -0,0 +1 @@
cc

1
Library/ENV/4.3/gcc-4.2 Symbolic link
View File

@ -0,0 +1 @@
cc

View File

@ -77,7 +77,8 @@ class << ENV
def determine_cc def determine_cc
if ARGV.include? '--use-gcc' if ARGV.include? '--use-gcc'
"gcc" # fall back to something else on systems without Apple gcc
MacOS.locate('gcc-4.2') ? "gcc-4.2" : raise("gcc-4.2 not found!")
elsif ARGV.include? '--use-llvm' elsif ARGV.include? '--use-llvm'
"llvm-gcc" "llvm-gcc"
elsif ARGV.include? '--use-clang' elsif ARGV.include? '--use-clang'
@ -219,6 +220,7 @@ class << ENV
def compiler def compiler
case ENV['HOMEBREW_CC'] case ENV['HOMEBREW_CC']
when "llvm-gcc" then :llvm when "llvm-gcc" then :llvm
when "gcc-4.2" then :gcc
when "gcc", "clang" then ENV['HOMEBREW_CC'].to_sym when "gcc", "clang" then ENV['HOMEBREW_CC'].to_sym
else else
raise raise