aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMisty De Meo2013-08-25 14:14:53 -0700
committerMisty De Meo2013-08-28 20:21:06 -0700
commitc58d707158c365dd9c185b72f5a0003cad25a786 (patch)
tree7bb679082e01c15d4b2006b02e1f3acb532aa6bf /Library
parent8a99ea209478f574a64eabd9e84472b80665e7ca (diff)
downloadbrew-c58d707158c365dd9c185b72f5a0003cad25a786.tar.bz2
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.
Diffstat (limited to 'Library')
-rwxr-xr-xLibrary/ENV/4.3/cc5
-rw-r--r--Library/Homebrew/extend/ARGV.rb5
-rw-r--r--Library/Homebrew/extend/ENV/std.rb3
-rw-r--r--Library/Homebrew/extend/ENV/super.rb11
4 files changed, 21 insertions, 3 deletions
diff --git a/Library/ENV/4.3/cc b/Library/ENV/4.3/cc
index 39af59266..9a3f81e60 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 15ee645f8..67ebb8b30 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 f2cd17115..cacd04dca 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 13111657b..5cf186b19 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