Add cxxstdlib_check method to request changing C++ stdlib checking.

* In certain cases, a C++ software may result in linking to a different
  and incompatible C++ standard library than its dependencies and still
  works fine because it is by design. Examples include GCC, which will
  bootstrap itself and self-host after finish.

* Add a cxxstdlib_check method to formula to request changing the C++
  standard library checking. Currently using "cxxstdlib_check :skip"
  will let a formula skip such checking. This should only be used on
  rare occasions and be very careful.

Closes Homebrew/homebrew#23687.
This commit is contained in:
Xiyue Deng 2013-10-28 02:16:42 -07:00
parent 6fc6dd791b
commit 917b94df98
2 changed files with 22 additions and 7 deletions

View File

@ -33,14 +33,17 @@ class CxxStdlib
end
def check_dependencies(formula, deps)
deps.each do |dep|
# Software is unlikely to link against anything from its buildtime deps,
# so it doesn't matter at all if they link against different C++ stdlibs
next if dep.tags.include? :build
unless formula.cxxstdlib.include? :skip
deps.each do |dep|
# Software is unlikely to link against anything from its
# buildtime deps, so it doesn't matter at all if they link
# against different C++ stdlibs
next if dep.tags.include? :build
dep_stdlib = Tab.for_formula(dep.to_formula).cxxstdlib
if !compatible_with? dep_stdlib
raise IncompatibleCxxStdlibs.new(formula, dep, dep_stdlib, self)
dep_stdlib = Tab.for_formula(dep.to_formula).cxxstdlib
if !compatible_with? dep_stdlib
raise IncompatibleCxxStdlibs.new(formula, dep, dep_stdlib, self)
end
end
end
end

View File

@ -25,6 +25,10 @@ class Formula
attr_accessor :local_bottle_path
# Flag for marking whether this formula needs C++ standard library
# compatibility check
attr_reader :cxxstdlib
# Homebrew determines the name
def initialize name='__UNKNOWN__', path=nil
@name = name
@ -52,6 +56,8 @@ class Formula
@build = determine_build_options
@pin = FormulaPin.new(self)
@cxxstdlib ||= Set.new
end
def set_spec(name)
@ -643,6 +649,12 @@ class Formula
end
end
# Explicitly request changing C++ standard library compatibility check
# settings. Use with caution!
def cxxstdlib_check check_type
@cxxstdlib << check_type
end
def self.method_added method
case method
when :brew