From 497ccdc41c11411184f36a2e0d0626fb9df9b99b Mon Sep 17 00:00:00 2001 From: Misty De Meo Date: Thu, 19 Sep 2013 23:35:53 -0700 Subject: [PATCH] ENV: Ensure @compiler is set If @compiler isn't set/checked by ENV.compiler and the ENV.clang/etc. methods, ENV.compiler may return unexpected results after fails_with picks a fallback compiler. See Homebrew/homebrew#22674. --- Library/Homebrew/extend/ENV/shared.rb | 2 +- Library/Homebrew/extend/ENV/super.rb | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/extend/ENV/shared.rb b/Library/Homebrew/extend/ENV/shared.rb index de5c143849..33f2ee5a83 100644 --- a/Library/Homebrew/extend/ENV/shared.rb +++ b/Library/Homebrew/extend/ENV/shared.rb @@ -82,7 +82,7 @@ module SharedEnvExtension def fcflags; self['FCFLAGS']; end def compiler - if (cc = ARGV.cc) + @compiler ||= if (cc = ARGV.cc) COMPILER_SYMBOL_MAP.fetch(cc) do |other| if other =~ GNU_GCC_REGEXP then other else diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb index d02013bd40..5a7b4bd896 100644 --- a/Library/Homebrew/extend/ENV/super.rb +++ b/Library/Homebrew/extend/ENV/super.rb @@ -263,16 +263,19 @@ module Superenv alias_method :j1, :deparallelize def gcc self['HOMEBREW_CC'] = "gcc-4.2" + @compiler = :gcc end def llvm self['HOMEBREW_CC'] = "llvm-gcc" + @compiler = :llvm end def clang self['HOMEBREW_CC'] = "clang" + @compiler = :clang end GNU_GCC_VERSIONS.each do |n| define_method(:"gcc-4.#{n}") do - self['HOMEBREW_CC'] = "gcc-4.#{n}" + @compiler = self['HOMEBREW_CC'] = "gcc-4.#{n}" end end def make_jobs