Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Commit

Permalink
Added --use-gcc flag.
Browse files Browse the repository at this point in the history
This allows you to use llvm as your default compiler and keep the cc symlink
pointed at llvm, while allowing you to build forumla that requires the gcc.

Signed-off-by: Adam Vandenberg <flangy@gmail.com>
  • Loading branch information
stephenallred authored and adamv committed Mar 12, 2011
1 parent feed6a9 commit c19b32d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Library/Contributions/manpages/brew.1.md
Expand Up @@ -275,6 +275,10 @@ Some sample commands ship with Homebrew and are enabled by default.
This issue typically occurs when using FileVault or custom SSD
configurations.

* HOMEBREW\_USE\_GCC:
If set, instructs Homebrew to use gcc, even if the system default
is currently set to LLVM.

* HOMEBREW\_USE\_LLVM:
If set, instructs Homebrew to use the LLVM front-ends to the GCC
compilers.
Expand Down
3 changes: 2 additions & 1 deletion Library/Homebrew/cmd/--env.rb
Expand Up @@ -10,6 +10,7 @@ def __env

def dump_build_env env
puts %["--use-llvm" was specified] if ARGV.include? '--use-llvm'
puts "\"--use-gcc\" was specified" if ARGV.include? '--use-gcc'

%w[ CC CXX LD ].each do |k|
value = env[k]
Expand All @@ -24,7 +25,7 @@ def dump_build_env env
end

%w[ CFLAGS CXXFLAGS CPPFLAGS LDFLAGS MACOSX_DEPLOYMENT_TARGET MAKEFLAGS PKG_CONFIG_PATH
HOMEBREW_DEBUG HOMEBREW_VERBOSE HOMEBREW_USE_LLVM HOMEBREW_SVN ].each do |k|
HOMEBREW_DEBUG HOMEBREW_VERBOSE HOMEBREW_USE_GCC HOMEBREW_USE_LLVM HOMEBREW_SVN ].each do |k|
value = env[k]
puts "#{k}: #{value}" if value
end
Expand Down
3 changes: 3 additions & 0 deletions Library/Homebrew/cmd/doctor.rb
Expand Up @@ -147,6 +147,9 @@ def check_cc_symlink
To force Homebrew to use LLVM, you can set the "HOMEBREW_LLVM" environmental
variable, or pass "--use-llvm" to "brew install".
To force Homebrew to use gcc, you can set the "HOMEBREW_GCC" environmental
variable, or pass "--use-gcc" to "brew install".
EOS
end
end
Expand Down
4 changes: 4 additions & 0 deletions Library/Homebrew/extend/ENV.rb
Expand Up @@ -24,6 +24,10 @@ def setup_build_environment
self['CC'] = "#{xcode_path}/usr/bin/llvm-gcc"
self['CXX'] = "#{xcode_path}/usr/bin/llvm-g++"
cflags = ['-O4'] # link time optimisation baby!
elsif MACOS_VERSION >= 10.6 and (self['HOMEBREW_USE_GCC'] or ARGV.include? '--use-gcc')
self['CC'] = '/usr/bin/gcc'
self['CXX'] = '/usr/bin/g++'
cflags = ['-O3']
else
# If these aren't set, many formulae fail to build
self['CC'] = '/usr/bin/cc'
Expand Down
4 changes: 4 additions & 0 deletions share/man/man1/brew.1
Expand Up @@ -298,6 +298,10 @@ If set, instructs Homebrew to use \fBHOMEBREW_TEMP\fR as the temporary folder fo
This issue typically occurs when using FileVault or custom SSD configurations\.
.
.TP
HOMEBREW_USE_GCC
If set, instructs Homebrew to use gcc, even if the system default is currently set to LLVM\.
.
.TP
HOMEBREW_USE_LLVM
If set, instructs Homebrew to use the LLVM front\-ends to the GCC compilers\.
.
Expand Down

0 comments on commit c19b32d

Please sign in to comment.