Skip to content

Instantly share code, notes, and snippets.

@camillol
Created July 17, 2013 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save camillol/6020834 to your computer and use it in GitHub Desktop.
Save camillol/6020834 to your computer and use it in GitHub Desktop.
Add support for using a homebrew-compiled gcc 4.8 to compile other formulas.
diff --git a/Library/Homebrew/extend/ENV.rb b/Library/Homebrew/extend/ENV.rb
index 8d971eb..47ae246 100644
--- a/Library/Homebrew/extend/ENV.rb
+++ b/Library/Homebrew/extend/ENV.rb
@@ -164,6 +164,16 @@ module HomebrewEnvExtension
end
alias_method :gcc_4_2, :gcc
+ def gcc48
+ self['CC'] = self['OBJC'] = "#{HOMEBREW_PREFIX}/bin/gcc-4.8"
+ self['CXX'] = self['OBJCXX'] = "#{HOMEBREW_PREFIX}/bin/g++-4.8"
+ raise "GCC could not be found" unless File.exist? self['CC']
+
+ replace_in_cflags '-O4', '-O3'
+ set_cpu_cflags
+ @compiler = :gcc48
+ end
+
def llvm
self['CC'] = self['OBJC'] = MacOS.locate("llvm-gcc")
self['CXX'] = self['OBJCXX'] = MacOS.locate("llvm-g++")
@@ -351,6 +361,8 @@ module HomebrewEnvExtension
:llvm
elsif ARGV.include? '--use-clang'
:clang
+ elsif ARGV.include? '--use-gcc48'
+ :gcc48
elsif self['HOMEBREW_USE_CLANG']
:clang
elsif self['HOMEBREW_USE_LLVM']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment