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
 | 
					    if mode == :cxx
 | 
				
			||||||
      args << '-std=c++11' if cccfg? 'x'
 | 
					      args << '-std=c++11' if cccfg? 'x'
 | 
				
			||||||
      args << '-stdlib=libc++' if cccfg? 'g'
 | 
					      args << '-stdlib=libc++' if cccfg? 'g'
 | 
				
			||||||
 | 
					      args << '-stdlib=libstdc++' if cccfg? 'h'
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return args unless cccfg? 'O'
 | 
					    return args unless cccfg? 'O'
 | 
				
			||||||
@ -216,6 +217,7 @@ class Cmd
 | 
				
			|||||||
    when :cxxld
 | 
					    when :cxxld
 | 
				
			||||||
      args << '-Wl,-headerpad_max_install_names'
 | 
					      args << '-Wl,-headerpad_max_install_names'
 | 
				
			||||||
      args << '-stdlib=libc++' if cccfg? 'g'
 | 
					      args << '-stdlib=libc++' if cccfg? 'g'
 | 
				
			||||||
 | 
					      args << '-stdlib=libstdc++' if cccfg? 'h'
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
    args
 | 
					    args
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
				
			|||||||
@ -333,6 +333,18 @@ module Stdenv
 | 
				
			|||||||
    end
 | 
					    end
 | 
				
			||||||
  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
 | 
					  def replace_in_cflags before, after
 | 
				
			||||||
    CC_FLAG_VARS.each do |key|
 | 
					    CC_FLAG_VARS.each do |key|
 | 
				
			||||||
      self[key] = self[key].sub(before, after) if has_key?(key)
 | 
					      self[key] = self[key].sub(before, after) if has_key?(key)
 | 
				
			||||||
 | 
				
			|||||||
@ -99,6 +99,7 @@ module Superenv
 | 
				
			|||||||
    #     make/bsdmake wrappers currently.
 | 
					    #     make/bsdmake wrappers currently.
 | 
				
			||||||
    # x - Enable C++11 mode.
 | 
					    # x - Enable C++11 mode.
 | 
				
			||||||
    # g - Enable "-stdlib=libc++" for clang.
 | 
					    # g - Enable "-stdlib=libc++" for clang.
 | 
				
			||||||
 | 
					    # h - Enable "-stdlib=libstdc++" for clang.
 | 
				
			||||||
    #
 | 
					    #
 | 
				
			||||||
    # On 10.8 and newer, these flags will also be present:
 | 
					    # On 10.8 and newer, these flags will also be present:
 | 
				
			||||||
    # s - apply fix for sed's Unicode support
 | 
					    # s - apply fix for sed's Unicode support
 | 
				
			||||||
@ -123,6 +124,18 @@ module Superenv
 | 
				
			|||||||
    end
 | 
					    end
 | 
				
			||||||
  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.
 | 
					  # m32 on superenv does not add any CC flags. It prevents "-m32" from being erased.
 | 
				
			||||||
  def m32
 | 
					  def m32
 | 
				
			||||||
    append 'HOMEBREW_CCCFG', "3", ''
 | 
					    append 'HOMEBREW_CCCFG', "3", ''
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user