diff options
| author | Jack Nagel | 2013-11-20 12:54:34 -0600 |
|---|---|---|
| committer | Jack Nagel | 2013-11-20 13:19:06 -0600 |
| commit | e0d24922474f2a10b82b8dede1b54552ed72ebed (patch) | |
| tree | 495fa11584b16a53d667ad7a8fa682d21a047304 /Library | |
| parent | 78f9b23218a45fd5d5b2237741b0b2bb89dca66b (diff) | |
| download | brew-e0d24922474f2a10b82b8dede1b54552ed72ebed.tar.bz2 | |
Move optimization flag selection out of cc wrapper
The mapping of architectures to optimization flags is now retrieved from
Hardware::CPU and the selected flags are passed as an environmen
variable, rather than duplicated in the cc wrapper and re-calculated on
every invocation of the compiler.
Closes Homebrew/homebrew#24540.
Diffstat (limited to 'Library')
| -rwxr-xr-x | Library/ENV/4.3/cc | 17 | ||||
| -rw-r--r-- | Library/Homebrew/extend/ENV/std.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/extend/ENV/super.rb | 41 |
3 files changed, 12 insertions, 48 deletions
diff --git a/Library/ENV/4.3/cc b/Library/ENV/4.3/cc index 383941807..92b09a48c 100755 --- a/Library/ENV/4.3/cc +++ b/Library/ENV/4.3/cc @@ -184,22 +184,7 @@ class Cmd def optflags args = [] args << "-#{ENV['HOMEBREW_OPTIMIZATION_LEVEL']}" - - # When bottling use the oldest supported CPU type. - 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' - elsif cccfg? 'bpA' - args << '-mcpu=7400' - elsif cccfg? 'bp' - args << '-mcpu=750' - else - args << '-march=native' if tool =~ /clang/ - end + args.concat ENV['HOMEBREW_OPTFLAGS'].split(' ') if ENV['HOMEBREW_OPTFLAGS'] args end def archflags diff --git a/Library/Homebrew/extend/ENV/std.rb b/Library/Homebrew/extend/ENV/std.rb index 633ad9010..1002749d2 100644 --- a/Library/Homebrew/extend/ENV/std.rb +++ b/Library/Homebrew/extend/ENV/std.rb @@ -343,7 +343,7 @@ module Stdenv if ARGV.build_bottle? arch = ARGV.bottle_arch || Hardware.oldest_cpu - append flags, Hardware::CPU.optimization_flags[arch] + append flags, Hardware::CPU.optimization_flags.fetch(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 080745e98..9df429f32 100644 --- a/Library/Homebrew/extend/ENV/super.rb +++ b/Library/Homebrew/extend/ENV/super.rb @@ -76,30 +76,19 @@ module Superenv self['HOMEBREW_SDKROOT'] = "#{MacOS.sdk_path}" if MacOS::Xcode.without_clt? self['HOMEBREW_DEVELOPER_DIR'] = determine_developer_dir # used by our xcrun shim self['HOMEBREW_VERBOSE'] = "1" if ARGV.verbose? + self['HOMEBREW_OPTFLAGS'] = determine_optflags self['CMAKE_PREFIX_PATH'] = determine_cmake_prefix_path self['CMAKE_FRAMEWORK_PATH'] = determine_cmake_frameworks_path self['CMAKE_INCLUDE_PATH'] = determine_cmake_include_path 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. # # 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 - # A - Installing from a bottle on PPC with Altivec # O - Enables argument refurbishing. Only active under the # make/bsdmake wrappers currently. # x - Enable C++11 mode. @@ -214,27 +203,17 @@ module Superenv end end - def determine_cccfg - s = "" + def determine_optflags if ARGV.build_bottle? - s << if ARGV.bottle_arch - 'bc' - elsif Hardware::CPU.type == :intel - if Hardware::CPU.is_64_bit? - 'bi6' - else - 'bi' - end - elsif Hardware::CPU.type == :ppc - if Hardware::CPU.altivec? - 'bpA' - else - 'bp' - end - else - 'b' - end + arch = ARGV.bottle_arch || Hardware.oldest_cpu + Hardware::CPU.optimization_flags.fetch(arch) + elsif compiler == :clang + "-march=native" end + end + + def determine_cccfg + s = "" # Fix issue with sed barfing on unicode characters on Mountain Lion s << 's' if MacOS.version >= :mountain_lion # Fix issue with >= 10.8 apr-1-config having broken paths |
