aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharlie Sharpsteen2012-03-07 18:38:04 -0800
committerCharlie Sharpsteen2012-03-09 12:14:08 -0800
commit0f467bbcc9712e44a8168ca0d205144f6f206e2e (patch)
tree0a848a6c67bf708cebeac5a49d59cee984ffa515
parent295116ff722b314f5ef440091314da3b4431352f (diff)
downloadhomebrew-0f467bbcc9712e44a8168ca0d205144f6f206e2e.tar.bz2
ENV.rb: Set GCC-style CPU flags for GFortran
GFortran chokes when it is passed CPU flags specific to Clang. This change ensures the environment variables `FCFLAGS` and `FFLAGS` contain the same CPU flags that would be set for the GCC compiler. Fixes #10424. Fixes #10744. Closes #10774. Signed-off-by: Charlie Sharpsteen <source@sharpsteen.net>
-rw-r--r--Library/Homebrew/extend/ENV.rb18
1 files changed, 14 insertions, 4 deletions
diff --git a/Library/Homebrew/extend/ENV.rb b/Library/Homebrew/extend/ENV.rb
index c67c93800..4db3cd504 100644
--- a/Library/Homebrew/extend/ENV.rb
+++ b/Library/Homebrew/extend/ENV.rb
@@ -176,8 +176,14 @@ module HomebrewEnvExtension
self['F77'] = self['FC'] unless self['F77']
if ARGV.include? '--default-fortran-flags'
- self['FCFLAGS'] = self['CFLAGS'] unless self['FCFLAGS']
- self['FFLAGS'] = self['CFLAGS'] unless self['FFLAGS']
+ flags_to_set = []
+ flags_to_set << 'FCFLAGS' unless self['FCFLAGS']
+ flags_to_set << 'FFLAGS' unless self['FFLAGS']
+
+ flags_to_set.each {|key| self[key] = cflags}
+
+ # Ensure we use architecture optimizations for GCC 4.2.x
+ set_cpu_flags flags_to_set, 'core2 -msse4', :penryn => 'core2 -msse4.1', :core2 => 'core2', :core => 'prescott', :bottle => 'generic'
elsif not self['FCFLAGS'] or self['FFLAGS']
opoo <<-EOS.undent
No Fortran optimization information was provided. You may want to consider
@@ -197,8 +203,9 @@ module HomebrewEnvExtension
self['FC'] = `/usr/bin/which gfortran`.chomp
self['F77'] = self['FC']
- self['FCFLAGS'] = self['CFLAGS']
- self['FFLAGS'] = self['CFLAGS']
+ fc_flag_vars.each {|key| self[key] = cflags}
+ # Ensure we use architecture optimizations for GCC 4.2.x
+ set_cpu_flags fc_flag_vars, 'core2 -msse4', :penryn => 'core2 -msse4.1', :core2 => 'core2', :core => 'prescott', :bottle => 'generic'
else
onoe <<-EOS
@@ -278,6 +285,9 @@ Please take one of the following actions:
def cc_flag_vars
%w{CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS}
end
+ def fc_flag_vars
+ %w{FCFLAGS FFLAGS}
+ end
def m64
append_to_cflags '-m64'