Clang standard library selection.
* Add new ENV function for selecting stdlib for Clang. - The selection is no-op for non-system-clang compilers. - Both superenv and stdenv are handled. * Add new HOMEBREW_CCCFG flag and ccwrapper handling.
This commit is contained in:
parent
f2132c47bd
commit
15e5fe4384
@ -161,6 +161,7 @@ class Cmd
|
||||
if mode == :cxx
|
||||
args << '-std=c++11' if cccfg? 'x'
|
||||
args << '-stdlib=libc++' if cccfg? 'g'
|
||||
args << '-stdlib=libstdc++' if cccfg? 'h'
|
||||
end
|
||||
|
||||
return args unless cccfg? 'O'
|
||||
@ -216,6 +217,7 @@ class Cmd
|
||||
when :cxxld
|
||||
args << '-Wl,-headerpad_max_install_names'
|
||||
args << '-stdlib=libc++' if cccfg? 'g'
|
||||
args << '-stdlib=libstdc++' if cccfg? 'h'
|
||||
end
|
||||
args
|
||||
end
|
||||
|
||||
@ -333,6 +333,18 @@ module Stdenv
|
||||
end
|
||||
end
|
||||
|
||||
def libcxx
|
||||
if compiler == :clang
|
||||
append 'CXX', '-stdlib=libc++'
|
||||
end
|
||||
end
|
||||
|
||||
def libstdcxx
|
||||
if compiler == :clang
|
||||
append 'CXX', '-stdlib=libstdc++'
|
||||
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)
|
||||
|
||||
@ -99,6 +99,7 @@ module Superenv
|
||||
# make/bsdmake wrappers currently.
|
||||
# x - Enable C++11 mode.
|
||||
# g - Enable "-stdlib=libc++" for clang.
|
||||
# h - Enable "-stdlib=libstdc++" for clang.
|
||||
#
|
||||
# On 10.8 and newer, these flags will also be present:
|
||||
# s - apply fix for sed's Unicode support
|
||||
@ -123,6 +124,18 @@ module Superenv
|
||||
end
|
||||
end
|
||||
|
||||
def libcxx
|
||||
if self['HOMEBREW_CC'] == 'clang'
|
||||
append 'HOMEBREW_CCCFG', "g", ''
|
||||
end
|
||||
end
|
||||
|
||||
def libstdcxx
|
||||
if self['HOMEBREW_CC'] == 'clang'
|
||||
append 'HOMEBREW_CCCFG', "h", ''
|
||||
end
|
||||
end
|
||||
|
||||
# m32 on superenv does not add any CC flags. It prevents "-m32" from being erased.
|
||||
def m32
|
||||
append 'HOMEBREW_CCCFG', "3", ''
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user