Allow building bottles with custom architectures

This allows overriding the "oldest CPU" behaviour - for instance, to
build Intel bottles for a newer CPU than Core 2, to build a PPC bottle
with or without Altivec on the same computer, etc.
This commit is contained in:
Misty De Meo 2013-08-25 14:14:53 -07:00
parent 8a99ea2094
commit c58d707158
4 changed files with 21 additions and 3 deletions

View File

@ -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'

View File

@ -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?

View File

@ -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)

View File

@ -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