diff options
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/build.rb | 22 | ||||
| -rw-r--r-- | Library/Homebrew/cxxstdlib.rb | 31 | ||||
| -rw-r--r-- | Library/Homebrew/formula_installer.rb | 11 | 
3 files changed, 28 insertions, 36 deletions
| diff --git a/Library/Homebrew/build.rb b/Library/Homebrew/build.rb index 03ff9dac8..2d4674851 100644 --- a/Library/Homebrew/build.rb +++ b/Library/Homebrew/build.rb @@ -182,25 +182,11 @@ class Build    def detect_stdlibs      keg = Keg.new(f.prefix) -    # This first test includes executables because we still -    # want to record the stdlib for something that installs no -    # dylibs. -    stdlibs = keg.detect_cxx_stdlibs -    # This currently only tracks a single C++ stdlib per dep, -    # though it's possible for different libs/executables in -    # a given formula to link to different ones. -    stdlib_in_use = CxxStdlib.create(stdlibs.first, ENV.compiler) -    begin -      stdlib_in_use.check_dependencies(f, deps) -    rescue IncompatibleCxxStdlibs => e -      opoo e.message -    end +    CxxStdlib.check_compatibility(f, deps, keg, ENV.compiler) -    # This second check is recorded for checking dependencies, -    # so executable are irrelevant at this point. If a piece -    # of software installs an executable that links against libstdc++ -    # and dylibs against libc++, libc++-only dependencies can safely -    # link against it. +    # The stdlib recorded in the install receipt is used during dependency +    # compatibility checks, so we only care about the stdlib that libraries +    # link against.      keg.detect_cxx_stdlibs(:skip_executables => true)    end diff --git a/Library/Homebrew/cxxstdlib.rb b/Library/Homebrew/cxxstdlib.rb index 7847552ba..859c1aabb 100644 --- a/Library/Homebrew/cxxstdlib.rb +++ b/Library/Homebrew/cxxstdlib.rb @@ -11,6 +11,18 @@ class CxxStdlib      klass.new(type, compiler)    end +  def self.check_compatibility(formula, deps, keg, compiler) +    return if formula.skip_cxxstdlib_check? + +    stdlib = create(keg.detect_cxx_stdlibs.first, compiler) + +    begin +      stdlib.check_dependencies(formula, deps) +    rescue IncompatibleCxxStdlibs => e +      opoo e.message +    end +  end +    attr_reader :type, :compiler    def initialize(type, compiler) @@ -32,17 +44,14 @@ class CxxStdlib    end    def check_dependencies(formula, deps) -    unless formula.skip_cxxstdlib_check? -      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.build? - -        dep_stdlib = Tab.for_formula(dep.to_formula).cxxstdlib -        if !compatible_with? dep_stdlib -          raise IncompatibleCxxStdlibs.new(formula, dep, dep_stdlib, self) -        end +    deps.each do |dep| +      # Software is unlikely to link against libraries from build-time deps, so +      # it doesn't matter if they link against different C++ stdlibs. +      next if dep.build? + +      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 diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 2e7286404..870bdba08 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -158,13 +158,10 @@ class FormulaInstaller          pour          @poured_bottle = true -        stdlibs = Keg.new(f.prefix).detect_cxx_stdlibs -        stdlib_in_use = CxxStdlib.create(stdlibs.first, MacOS.default_compiler) -        begin -          stdlib_in_use.check_dependencies(f, f.recursive_dependencies) -        rescue IncompatibleCxxStdlibs => e -          opoo e.message -        end +        CxxStdlib.check_compatibility( +          f, f.recursive_dependencies, +          Keg.new(f.prefix), MacOS.default_compiler +        )          tab = Tab.for_keg f.prefix          tab.poured_from_bottle = true | 
