Fix some "GCC cannot create executables"
This regards Issue Homebrew/homebrew#30. Turns out -march=native isn't supported by Apple's GCC, but while investigating it I found they'd back ported the -march=core2 option, so we win anyway. Logic reverted to how it was yesterday. I moved the gcc options stuff back to brewkit.rb as we manipulate the cflags more later and it seemed bad form to split the logic for this area over two files. Additionally the brew command exits immediately on powerpc now. Brewkit doesn't throw as theoretically it is a useful library file for other projects.
This commit is contained in:
parent
18d9fbee98
commit
a12569699e
@ -29,50 +29,56 @@ require 'hardware'
|
|||||||
# TODO
|
# TODO
|
||||||
# 1. Indeed, there should be an option to build 32 or 64 bit binaries
|
# 1. Indeed, there should be an option to build 32 or 64 bit binaries
|
||||||
# 2. Homebrew will not support building 32 and 64 bit lipo'd binaries, I
|
# 2. Homebrew will not support building 32 and 64 bit lipo'd binaries, I
|
||||||
# want to mind, but the simple fact is it is difficult to force most of the
|
# want to, but the simple fact is it is difficult to force most of the
|
||||||
# build systems we support to do it.
|
# build systems we support to do it.
|
||||||
|
|
||||||
|
|
||||||
`/usr/bin/sw_vers -productVersion` =~ /(10\.\d+)(\.\d+)?/
|
`/usr/bin/sw_vers -productVersion` =~ /(10\.\d+)(\.\d+)?/
|
||||||
MACOS_VERSION=$1.to_f
|
MACOS_VERSION=$1.to_f
|
||||||
|
ENV['MACOSX_DEPLOYMENT_TARGET']=$1
|
||||||
|
|
||||||
ENV['MACOSX_DEPLOYMENT_TARGET']=MACOS_VERSION.to_s
|
cflags=%w[-O3]
|
||||||
ENV['LDFLAGS']='' # to be consistent, we ignore the existing environment
|
|
||||||
|
|
||||||
# this is first, so when you see it in output, you notice it
|
|
||||||
cflags='-O3'
|
|
||||||
|
|
||||||
|
# optimise all the way to eleven, references:
|
||||||
|
# http://en.gentoo-wiki.com/wiki/Safe_Cflags/Intel
|
||||||
|
# http://forums.mozillazine.org/viewtopic.php?f=12&t=577299
|
||||||
|
# http://gcc.gnu.org/onlinedocs/gcc-4.2.1/gcc/i386-and-x86_002d64-Options.html
|
||||||
if MACOS_VERSION >= 10.6
|
if MACOS_VERSION >= 10.6
|
||||||
if Hardware.is_64bit?
|
case Hardware.intel_family
|
||||||
# 64 bits baby!
|
when :penryn
|
||||||
cflags<<" -m64"
|
cflags<<'-march=core2'<<'-msse4.1'
|
||||||
ENV['LDFLAGS']="-arch x86_64"
|
when :core2
|
||||||
|
cflags<<"-march=core2"<<'-msse4'
|
||||||
|
when :core1
|
||||||
|
cflags<<"-march=prescott"<<'-msse3'
|
||||||
end
|
end
|
||||||
|
ENV['LDFLAGS']="-arch x86_64"
|
||||||
|
cflags<<'-m64'<<'-mmmx'
|
||||||
else
|
else
|
||||||
# GCC 4.2.1 is smart and will figure out the right compile flags
|
case Hardware.intel_family
|
||||||
# http://gcc.gnu.org/onlinedocs/gcc-4.2.1/gcc/i386-and-x86_002d64-Options.html
|
when :penryn
|
||||||
cflags<<"-march=native"
|
cflags<<"-march=nocona"<<'-msse4.1'
|
||||||
end
|
when :core2
|
||||||
|
cflags<<"-march=nocona"<<'-msse4'
|
||||||
case Hardware.cpu_type
|
when :core1
|
||||||
when :ppc then abort "Sorry, Homebrew does not support PowerPC architectures"
|
cflags<<"-march=prescott"<<'-msse3'
|
||||||
when :dunno then abort "Sorry, Homebrew cannot determine what kind of Mac this is!"
|
end
|
||||||
|
# to be consistent with cflags, we ignore the existing environment
|
||||||
|
ENV['LDFLAGS']=""
|
||||||
|
cflags<<'-mmmx'<<"-mfpmath=sse"
|
||||||
|
|
||||||
|
# gcc 4.0 is the default on Leopard
|
||||||
|
ENV['CC']='gcc-4.2'
|
||||||
|
ENV['CXX']='g++-4.2'
|
||||||
end
|
end
|
||||||
|
|
||||||
# -w: keep signal to noise high
|
# -w: keep signal to noise high
|
||||||
# -fomit-frame-pointer: we are not debugging this software, we are using it
|
# -fomit-frame-pointer: we are not debugging this software, we are using it
|
||||||
ENV['CFLAGS']="#{cflags} -w -pipe -fomit-frame-pointer -mmacosx-version-min=#{MACOS_VERSION}"
|
ENV['CFLAGS']=ENV['CXXFLAGS']="#{cflags*' '} -w -pipe -fomit-frame-pointer -mmacosx-version-min=#{MACOS_VERSION}"
|
||||||
ENV['CXXFLAGS']=ENV['CFLAGS']
|
|
||||||
|
|
||||||
# lets use gcc 4.2, Xcode does after all
|
|
||||||
if MACOS_VERSION==10.5
|
|
||||||
ENV['CC']='gcc-4.2'
|
|
||||||
ENV['CXX']='g++-4.2'
|
|
||||||
end
|
|
||||||
# compile faster
|
# compile faster
|
||||||
ENV['MAKEFLAGS']="-j#{Hardware.processor_count}"
|
ENV['MAKEFLAGS']="-j#{Hardware.processor_count}"
|
||||||
|
|
||||||
|
|
||||||
# /usr/local is always in the build system path
|
# /usr/local is always in the build system path
|
||||||
unless HOMEBREW_PREFIX.to_s == '/usr/local'
|
unless HOMEBREW_PREFIX.to_s == '/usr/local'
|
||||||
ENV['CPPFLAGS']="-I#{HOMEBREW_PREFIX}/include"
|
ENV['CPPFLAGS']="-I#{HOMEBREW_PREFIX}/include"
|
||||||
@ -88,23 +94,14 @@ module HomebrewEnvExtension
|
|||||||
alias_method :j1, :deparallelize
|
alias_method :j1, :deparallelize
|
||||||
def gcc_4_0_1
|
def gcc_4_0_1
|
||||||
case MACOS_VERSION
|
case MACOS_VERSION
|
||||||
when 10.5
|
when 10.5
|
||||||
self['CC']=nil
|
self['CC']=nil
|
||||||
self['CXX']=nil
|
self['CXX']=nil
|
||||||
when 10.6..11.0
|
when 10.6..11.0
|
||||||
self['CC']='gcc-4.0'
|
self['CC']='gcc-4.0'
|
||||||
self['CXX']='g++-4.0'
|
self['CXX']='g++-4.0'
|
||||||
|
remove_from_cflags '-march=core2' # we *should* add back in stuff but meh for now
|
||||||
end
|
end
|
||||||
|
|
||||||
# argh, we have to figure out the compile options ourselves and get
|
|
||||||
# rid of -march=native, so we optimise all the way to eleven, references:
|
|
||||||
# http://en.gentoo-wiki.com/wiki/Safe_Cflags/Intel
|
|
||||||
# http://forums.mozillazine.org/viewtopic.php?f=12&t=577299
|
|
||||||
# http://gcc.gnu.org/onlinedocs/gcc-4.2.1/gcc/i386-and-x86_002d64-Options.html
|
|
||||||
remove_from_cflags '-march=native'
|
|
||||||
append_to_cflags Hardware.gcc_march
|
|
||||||
append_to_cflags Hardware.gcc_msse
|
|
||||||
append_to_cflags Hardware.gcc_mmx
|
|
||||||
end
|
end
|
||||||
def osx_10_4
|
def osx_10_4
|
||||||
self['MACOSX_DEPLOYMENT_TARGET']=nil
|
self['MACOSX_DEPLOYMENT_TARGET']=nil
|
||||||
|
|||||||
@ -60,41 +60,6 @@ class Hardware
|
|||||||
@@processor_count ||= `/usr/sbin/sysctl -n hw.ncpu`.to_i
|
@@processor_count ||= `/usr/sbin/sysctl -n hw.ncpu`.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.gcc_march # what to pass to gcc
|
|
||||||
@@gcc_march ||= if self.cpu_type == :intel
|
|
||||||
case self.intel_family
|
|
||||||
when :core
|
|
||||||
" -march=prescott"
|
|
||||||
when :core2, :penryn, :nehalem
|
|
||||||
# GCC 4.3 has a -march=core2, but this isn't 4.3 and nocona is correct
|
|
||||||
" -march=nocona"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
""
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.gcc_msse # what to pass to gcc
|
|
||||||
# avoid sse4 for now in case it blows up
|
|
||||||
@@gcc_msse ||= if sysctl_bool("hw.optional.sse3")
|
|
||||||
" -msse3 -mfpmath=sse"
|
|
||||||
else
|
|
||||||
""
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.gcc_mmmx # what to pass to gcc
|
|
||||||
@@gcc_mmmx ||= if sysctl_bool("hw.optional.mmx")
|
|
||||||
" -mmmx"
|
|
||||||
else
|
|
||||||
""
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.is_64bit?
|
|
||||||
@@is_64bit ||= sysctl_bool("hw.cpu64bit_capable")
|
|
||||||
end
|
|
||||||
|
|
||||||
protected
|
protected
|
||||||
def self.sysctl_bool(property)
|
def self.sysctl_bool(property)
|
||||||
result = nil
|
result = nil
|
||||||
|
|||||||
16
bin/brew
16
bin/brew
@ -1,9 +1,9 @@
|
|||||||
#!/usr/bin/ruby
|
#!/usr/bin/ruby
|
||||||
$:.unshift ENV['RUBYLIB']=File.expand_path(__FILE__+'/../../Library/Homebrew')
|
$:.unshift ENV['RUBYLIB']=File.expand_path(__FILE__+'/../../Library/Homebrew')
|
||||||
|
|
||||||
require 'pathname+yeast'
|
require 'pathname+yeast'
|
||||||
require 'ARGV+yeast'
|
require 'ARGV+yeast'
|
||||||
require 'utils'
|
require 'utils'
|
||||||
|
require 'hardware'
|
||||||
require 'brew.h'
|
require 'brew.h'
|
||||||
|
|
||||||
if Process.uid == 0
|
if Process.uid == 0
|
||||||
@ -20,17 +20,19 @@ HOMEBREW_VERSION='0.4'
|
|||||||
HOMEBREW_WWW='http://bit.ly/Homebrew'
|
HOMEBREW_WWW='http://bit.ly/Homebrew'
|
||||||
HOMEBREW_USER_AGENT="Homebrew #{HOMEBREW_VERSION} (Ruby #{VERSION}; Mac OS X 10.5 Leopard)"
|
HOMEBREW_USER_AGENT="Homebrew #{HOMEBREW_VERSION} (Ruby #{VERSION}; Mac OS X 10.5 Leopard)"
|
||||||
|
|
||||||
if %w[/ /usr].include? HOMEBREW_PREFIX.to_s then abort <<-troba
|
if %w[/ /usr].include? HOMEBREW_PREFIX.to_s then abort <<-EOS
|
||||||
You have placed Homebrew at the prefix: #{HOMEBREW_PREFIX}
|
You have placed Homebrew at the prefix: #{HOMEBREW_PREFIX}
|
||||||
This is not currently supported. Voice your support for this feature at:
|
This is not currently supported. Voice your support for this feature at:
|
||||||
#{HOMEBREW_WWW}
|
#{HOMEBREW_WWW}
|
||||||
troba
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
if `sw_vers -productVersion` =~ /10\.(\d)\.(\d+)/ and $1.to_i < 5
|
if `sw_vers -productVersion` =~ /10\.(\d)\.(\d+)/ and $1.to_i < 5
|
||||||
onoe "Homebrew requires Leopard or higher"
|
onoe "Homebrew requires Leopard or higher"
|
||||||
abort "But thanks for your interest anyway!"
|
abort "But thanks for your interest anyway!"
|
||||||
end
|
end
|
||||||
|
if Hardware.cpu_type == :ppc or Hardware.cpu_type == :dunno
|
||||||
|
abort "Sorry, Homebrew does not support your computer's CPU architecture."
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user