aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xLibrary/ENV/4.3/cc29
-rw-r--r--Library/Homebrew/build_options.rb7
-rw-r--r--Library/Homebrew/extend/ENV/std.rb11
-rw-r--r--Library/Homebrew/extend/ENV/super.rb13
-rw-r--r--Library/Homebrew/software_spec.rb1
5 files changed, 55 insertions, 6 deletions
diff --git a/Library/ENV/4.3/cc b/Library/ENV/4.3/cc
index d4df6d90f..102f6c64e 100755
--- a/Library/ENV/4.3/cc
+++ b/Library/ENV/4.3/cc
@@ -45,11 +45,19 @@ class Cmd
if @arg0 == 'cpp' or @arg0 == 'ld'
@arg0.to_sym
elsif @args.include? '-c'
- :cc
+ if @arg0 =~ /(?:c|g|clang)\+\+/
+ :cxx
+ else
+ :cc
+ end
elsif @args.include? '-E'
:ccE
else
- :ccld
+ if @arg0 =~ /(?:c|g|clang)\+\+/
+ :cxxld
+ else
+ :ccld
+ end
end
end
def tool
@@ -83,9 +91,9 @@ class Cmd
args << "-syslibroot" << $sdkroot
end if nclt?
allflags = case mode
- when :ccld
+ when :ccld, :cxxld
cflags + args + cppflags + ldflags
- when :cc
+ when :cc, :cxx
cflags + args + cppflags
when :ccE
args + cppflags
@@ -149,9 +157,15 @@ class Cmd
args
end
def cflags
- return [] unless cccfg? 'O'
+ args = []
+ if mode == :cxx
+ args << '-std=c++11' if cccfg? 'x'
+ args << '-stdlib=libc++' if cccfg? 'g'
+ end
+
+ return args unless cccfg? 'O'
- args = %w{-pipe -w -Os}
+ args << '-pipe' << '-w' << '-Os'
# When bottling use the oldest supported CPU type.
if cccfg? 'bc'
@@ -199,6 +213,9 @@ class Cmd
case mode
when :ld then args << '-headerpad_max_install_names'
when :ccld then args << '-Wl,-headerpad_max_install_names'
+ when :cxxld
+ args << '-Wl,-headerpad_max_install_names'
+ args << '-stdlib=libc++' if cccfg? 'g'
end
args
end
diff --git a/Library/Homebrew/build_options.rb b/Library/Homebrew/build_options.rb
index ff2e099fc..83afe362e 100644
--- a/Library/Homebrew/build_options.rb
+++ b/Library/Homebrew/build_options.rb
@@ -7,6 +7,7 @@ class BuildOptions
attr_accessor :args
attr_accessor :universal
+ attr_accessor :cxx11
attr_reader :options
protected :options
@@ -25,6 +26,7 @@ class BuildOptions
description ||= case name.to_s
when "universal" then "Build a universal binary"
when "32-bit" then "Build 32-bit only"
+ when "c++11" then "Build using C++11 mode"
end.to_s
@options << Option.new(name, description)
@@ -94,6 +96,11 @@ class BuildOptions
universal || args.include?('--universal') && has_option?('universal')
end
+ # True if the user requested to enable C++11 mode.
+ def cxx11?
+ cxx11 || args.include?('--c++11') && has_option?('c++11')
+ end
+
# Request a 32-bit only build.
# This is needed for some use-cases though we prefer to build Universal
# when a 32-bit version is needed.
diff --git a/Library/Homebrew/extend/ENV/std.rb b/Library/Homebrew/extend/ENV/std.rb
index bca0df041..0d5613256 100644
--- a/Library/Homebrew/extend/ENV/std.rb
+++ b/Library/Homebrew/extend/ENV/std.rb
@@ -322,6 +322,17 @@ module Stdenv
end
end
+ def cxx11
+ if compiler == :clang
+ append 'CXX', '-std=c++11'
+ append 'CXX', '-stdlib=libc++'
+ elsif compiler =~ /gcc-4\.(8|9)/
+ append 'CXX', '-std=c++11'
+ else
+ raise "The selected compiler doesn't support C++11: #{compiler}"
+ end
+ end
+
def replace_in_cflags before, after
CC_FLAG_VARS.each do |key|
self[key] = self[key].sub(before, after) if has_key?(key)
diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb
index e3f9ed923..2be8a62d4 100644
--- a/Library/Homebrew/extend/ENV/super.rb
+++ b/Library/Homebrew/extend/ENV/super.rb
@@ -97,6 +97,8 @@ module Superenv
# 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.
+ # g - Enable "-stdlib=libc++" for clang.
#
# On 10.8 and newer, these flags will also be present:
# s - apply fix for sed's Unicode support
@@ -110,6 +112,17 @@ module Superenv
append 'HOMEBREW_CCCFG', "u", ''
end
+ def cxx11
+ if self['HOMEBREW_CC'] == 'clang'
+ append 'HOMEBREW_CCCFG', "x", ''
+ append 'HOMEBREW_CCCFG', "g", ''
+ elsif self['HOMEBREW_CC'] =~ /gcc-4\.(8|9)/
+ append 'HOMEBREW_CCCFG', "x", ''
+ else
+ raise "The selected compiler doesn't support C++11: #{self['HOMEBREW_CC']}"
+ end
+ end
+
# m32 on superenv does not add any CC flags. It prevents "-m32" from being erased.
def m32
append 'HOMEBREW_CCCFG', "3", ''
diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb
index 80f92a7c9..3d0664b7d 100644
--- a/Library/Homebrew/software_spec.rb
+++ b/Library/Homebrew/software_spec.rb
@@ -50,6 +50,7 @@ class SoftwareSpec
end
def option name, description=nil
+ name = 'c++11' if name == :cxx11
name = name.to_s if Symbol === name
raise "Option name is required." if name.empty?
raise "Options should not start with dashes." if name[0, 1] == "-"