Support core GCC formula as a GCC compiler.
It is activated by the same mechanism as the Homebrew/versions compilers which now check if the GCC formula uses the same, correct version. References Homebrew/homebrew#28418.
This commit is contained in:
parent
593702c70b
commit
55d277c335
@ -185,11 +185,29 @@ module SharedEnvExtension
|
|||||||
append "LDFLAGS", "-B#{ld64.bin}/"
|
append "LDFLAGS", "-B#{ld64.bin}/"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def gcc_version_formula(version)
|
||||||
|
gcc_formula = Formulary.factory("gcc")
|
||||||
|
return gcc_formula if gcc_formula.version.to_s.include?(version)
|
||||||
|
|
||||||
|
gcc_name = 'gcc' + version.delete('.')
|
||||||
|
Formulary.factory(gcc_name)
|
||||||
|
end
|
||||||
|
|
||||||
def warn_about_non_apple_gcc(gcc)
|
def warn_about_non_apple_gcc(gcc)
|
||||||
begin
|
|
||||||
gcc_name = 'gcc' + gcc.delete('.')
|
gcc_name = 'gcc' + gcc.delete('.')
|
||||||
gcc = Formulary.factory(gcc_name)
|
|
||||||
if !gcc.opt_prefix.exist?
|
begin
|
||||||
|
gcc_formula = gcc_version_formula(gcc)
|
||||||
|
if gcc_formula.name == "gcc"
|
||||||
|
return if gcc_formula.opt_prefix.exist?
|
||||||
|
raise <<-EOS.undent
|
||||||
|
The Homebrew GCC was not installed.
|
||||||
|
You must:
|
||||||
|
brew install gcc
|
||||||
|
EOS
|
||||||
|
end
|
||||||
|
|
||||||
|
if !gcc_formula.opt_prefix.exist?
|
||||||
raise <<-EOS.undent
|
raise <<-EOS.undent
|
||||||
The requested Homebrew GCC, #{gcc_name}, was not installed.
|
The requested Homebrew GCC, #{gcc_name}, was not installed.
|
||||||
You must:
|
You must:
|
||||||
|
|||||||
@ -73,9 +73,8 @@ module Stdenv
|
|||||||
|
|
||||||
if cc =~ GNU_GCC_REGEXP
|
if cc =~ GNU_GCC_REGEXP
|
||||||
warn_about_non_apple_gcc($1)
|
warn_about_non_apple_gcc($1)
|
||||||
gcc_name = 'gcc' + $1.delete('.')
|
gcc_formula = gcc_version_formula($1)
|
||||||
gcc = Formulary.factory(gcc_name)
|
self.append_path('PATH', gcc_formula.opt_prefix/'bin')
|
||||||
self.append_path('PATH', gcc.opt_prefix/'bin')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add lib and include etc. from the current macosxsdk to compiler flags:
|
# Add lib and include etc. from the current macosxsdk to compiler flags:
|
||||||
|
|||||||
@ -135,9 +135,8 @@ module Superenv
|
|||||||
end
|
end
|
||||||
|
|
||||||
if self['HOMEBREW_CC'] =~ GNU_GCC_REGEXP
|
if self['HOMEBREW_CC'] =~ GNU_GCC_REGEXP
|
||||||
gcc_name = 'gcc' + $1.delete('.')
|
gcc_formula = gcc_version_formula($1)
|
||||||
gcc = Formulary.factory(gcc_name)
|
paths << gcc_formula.opt_prefix/'bin'
|
||||||
paths << gcc.opt_prefix/'bin'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
paths.to_path_s
|
paths.to_path_s
|
||||||
|
|||||||
@ -131,8 +131,9 @@ module OS
|
|||||||
def gcc_42_build_version
|
def gcc_42_build_version
|
||||||
@gcc_42_build_version ||=
|
@gcc_42_build_version ||=
|
||||||
begin
|
begin
|
||||||
gcc = MacOS.locate('gcc-4.2') || Formula.factory('apple-gcc42').opt_prefix/'bin/gcc-4.2'
|
gcc = MacOS.locate('gcc-4.2')
|
||||||
raise unless gcc.exist?
|
gcc ||= Formula.factory('apple-gcc42').opt_prefix/'bin/gcc-4.2' rescue nil
|
||||||
|
raise if gcc.nil? || !gcc.exist?
|
||||||
rescue
|
rescue
|
||||||
gcc = nil
|
gcc = nil
|
||||||
end
|
end
|
||||||
@ -167,13 +168,16 @@ module OS
|
|||||||
end
|
end
|
||||||
|
|
||||||
def non_apple_gcc_version(cc)
|
def non_apple_gcc_version(cc)
|
||||||
return unless path = locate(cc)
|
path = Formula.factory("gcc").opt_prefix/"bin/#{cc}"
|
||||||
|
path = nil unless path.exist?
|
||||||
|
|
||||||
|
return unless path ||= locate(cc)
|
||||||
|
|
||||||
ivar = "@#{cc.gsub(/(-|\.)/, '')}_version"
|
ivar = "@#{cc.gsub(/(-|\.)/, '')}_version"
|
||||||
return instance_variable_get(ivar) if instance_variable_defined?(ivar)
|
return instance_variable_get(ivar) if instance_variable_defined?(ivar)
|
||||||
|
|
||||||
`#{path} --version` =~ /gcc-\d.\d \(GCC\) (\d\.\d\.\d)/
|
`#{path} --version` =~ /gcc(-\d\.\d \(GCC\))? (\d\.\d\.\d)/
|
||||||
instance_variable_set(ivar, $1)
|
instance_variable_set(ivar, $2)
|
||||||
end
|
end
|
||||||
|
|
||||||
# See these issues for some history:
|
# See these issues for some history:
|
||||||
|
|||||||
@ -23,6 +23,7 @@ class CxxStdlibTests < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_compatibility_same_compilers_and_type
|
def test_compatibility_same_compilers_and_type
|
||||||
|
assert @gcc.compatible_with?(@gcc)
|
||||||
assert @gcc48.compatible_with?(@gcc48)
|
assert @gcc48.compatible_with?(@gcc48)
|
||||||
assert @clang.compatible_with?(@clang)
|
assert @clang.compatible_with?(@clang)
|
||||||
end
|
end
|
||||||
@ -33,8 +34,8 @@ class CxxStdlibTests < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_gnu_cross_version_incompatibility
|
def test_gnu_cross_version_incompatibility
|
||||||
assert !@clang.compatible_with?(@gcc48)
|
assert !@gcc48.compatible_with?(@gcc49)
|
||||||
assert !@gcc48.compatible_with?(@clang)
|
assert !@gcc49.compatible_with?(@gcc48)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_libstdcxx_libcxx_incompatibility
|
def test_libstdcxx_libcxx_incompatibility
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user