diff --git a/Library/ENV/4.3/cc b/Library/ENV/4.3/cc index 39af592666..9a3f81e608 100755 --- a/Library/ENV/4.3/cc +++ b/Library/ENV/4.3/cc @@ -157,7 +157,10 @@ class Cmd args = %w{-pipe -w -Os} # When bottling use the oldest supported CPU type. - if cccfg? 'bi6' + if cccfg? 'bc' + # Custom bottle specified during the build + args << ENV['HOMEBREW_ARCHFLAGS'] + elsif cccfg? 'bi6' args << '-march=core2' elsif cccfg? 'bi' args << '-march=prescott' diff --git a/Library/Homebrew/extend/ARGV.rb b/Library/Homebrew/extend/ARGV.rb index 15ee645f85..67ebb8b30c 100644 --- a/Library/Homebrew/extend/ARGV.rb +++ b/Library/Homebrew/extend/ARGV.rb @@ -133,6 +133,11 @@ module HomebrewArgvExtension include? '--build-bottle' or !ENV['HOMEBREW_BUILD_BOTTLE'].nil? end + def bottle_arch + arch = value 'bottle-arch' + arch.to_sym if arch + end + def build_from_source? include? '--build-from-source' or !ENV['HOMEBREW_BUILD_FROM_SOURCE'].nil? \ or build_head? or build_devel? or build_universal? or build_bottle? diff --git a/Library/Homebrew/extend/ENV/std.rb b/Library/Homebrew/extend/ENV/std.rb index f2cd17115b..cacd04dca7 100644 --- a/Library/Homebrew/extend/ENV/std.rb +++ b/Library/Homebrew/extend/ENV/std.rb @@ -324,7 +324,8 @@ module Stdenv append flags, xarch unless xarch.empty? if ARGV.build_bottle? - append flags, Hardware::CPU.optimization_flags[Hardware.oldest_cpu] + arch = ARGV.bottle_arch || Hardware.oldest_cpu + append flags, Hardware::CPU.optimization_flags[arch] else # Don't set -msse3 and older flags because -march does that for us append flags, map.fetch(Hardware::CPU.family, default) diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb index 13111657be..5cf186b192 100644 --- a/Library/Homebrew/extend/ENV/super.rb +++ b/Library/Homebrew/extend/ENV/super.rb @@ -76,6 +76,12 @@ module Superenv self['CMAKE_LIBRARY_PATH'] = determine_cmake_library_path self['ACLOCAL_PATH'] = determine_aclocal_path + # For custom bottles, need to specify the arch in the environment + # so that the compiler shims have access + if (arch = ARGV.bottle_arch) + self['HOMEBREW_ARCHFLAGS'] = Hardware::CPU.optimization_flags[arch] + end + # The HOMEBREW_CCCFG ENV variable is used by the ENV/cc tool to control # compiler flag stripping. It consists of a string of characters which act # as flags. Some of these flags are mutually exclusive. @@ -83,6 +89,7 @@ module Superenv # u - A universal build was requested # 3 - A 32-bit build was requested # b - Installing from a bottle + # c - Installing from a bottle with a custom architecture # i - Installing from a bottle on Intel # 6 - Installing from a bottle on 64-bit Intel # p - Installing from a bottle on PPC @@ -237,7 +244,9 @@ module Superenv def determine_cccfg s = "" if ARGV.build_bottle? - s << if Hardware::CPU.type == :intel + s << if ARGV.bottle_arch + 'bc' + elsif Hardware::CPU.type == :intel if Hardware::CPU.is_64_bit? 'bi6' else