Set CC and CXX with superenv (again)
It was dumb to have make call different compilers to configure depending on the `servile?` flag. This is not a route to reliability. Instead now we set CC (formula that break if CC is set like Jack be damned, their build-systems are just plain broken and should not be supported). When cc is called we examine HOMEBREW_CC, otherwise we instantiate the tool that was called, just like the formula's build-system will expect. Fixes Homebrew/homebrew#14659 (though the build fails later for me, with the same error for stdenv and superenv).
This commit is contained in:
parent
af06c75d72
commit
c35f6cb9d5
@ -1,13 +1,9 @@
|
|||||||
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -W0
|
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -W0
|
||||||
|
|
||||||
#TODO make it work with homebrew/dupes/gcc
|
#TODO make it work with homebrew/dupes/gcc
|
||||||
#TODO? If we find -mmacosx-version-min=10.8, change sdkroot? warn visibly if no such SDK?
|
#TODO? If we find -mmacosx-version-min=10.8, change sdkroot? warn visibly if no such SDK?
|
||||||
#TODO fix pkg-config files, should point to /usr/local or /usr/local/opt
|
#TODO fix pkg-config files, should point to /usr/local or /usr/local/opt
|
||||||
#TODO for easier to understand code, don't monkey-patch ENV, just set via a hash from a helper class
|
|
||||||
#TODO create mechanism to specify build effects like %w{-O0 -O4 vanilla-arg-parsing sdk=10.6} etc.
|
#TODO create mechanism to specify build effects like %w{-O0 -O4 vanilla-arg-parsing sdk=10.6} etc.
|
||||||
#TODO DSL for lame-env (and rename to typical-env or something better)
|
|
||||||
#TODO consider always setting CC to cc and instead having HOMEBREW_CC to force cc choice in end toolchain
|
|
||||||
# in verbose mode print out things like "gcc called, but redirecting to clang" if that happens
|
|
||||||
#TODO `brew sh`: https://github.com/mxcl/homebrew/issues/14381#issuecomment-8017538
|
|
||||||
|
|
||||||
require "#{File.dirname __FILE__}/../libsuperenv"
|
require "#{File.dirname __FILE__}/../libsuperenv"
|
||||||
require 'set'
|
require 'set'
|
||||||
@ -15,13 +11,6 @@ require 'set'
|
|||||||
def cccfg? flags
|
def cccfg? flags
|
||||||
flags.split('').all?{|c| ENV['HOMEBREW_CCCFG'].include? c } if ENV['HOMEBREW_CCCFG']
|
flags.split('').all?{|c| ENV['HOMEBREW_CCCFG'].include? c } if ENV['HOMEBREW_CCCFG']
|
||||||
end
|
end
|
||||||
def servile?
|
|
||||||
# we are servile when we are called from configure etc.
|
|
||||||
# * we give the callee the tools it asks for
|
|
||||||
# * we leave ARGV alone
|
|
||||||
# when callee is make we optimize and force HOMEBREW_CC
|
|
||||||
not cccfg? 'O'
|
|
||||||
end
|
|
||||||
def nclt?
|
def nclt?
|
||||||
$sdkroot != nil
|
$sdkroot != nil
|
||||||
end
|
end
|
||||||
@ -51,20 +40,21 @@ class Cmd
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
def tool
|
def tool
|
||||||
@tool ||= if servile? or @arg0 == 'ld'
|
@tool ||= case @arg0
|
||||||
@arg0
|
when 'ld' then 'ld'
|
||||||
elsif @arg0.include? '++'
|
when 'cc' then ENV['HOMEBREW_CC']
|
||||||
if ENV['HOMEBREW_CC'].chuzzle =~ /gcc/
|
when 'c++'
|
||||||
|
if ENV['HOMEBREW_CC'] =~ /gcc/
|
||||||
'g++'
|
'g++'
|
||||||
else
|
else
|
||||||
'clang++'
|
'clang++'
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
ENV['HOMEBREW_CC'].chuzzle or 'clang'
|
@arg0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def args
|
def args
|
||||||
args = if servile? or tool == 'ld'
|
args = if not cccfg? 'O' or tool == 'ld'
|
||||||
@args.dup
|
@args.dup
|
||||||
else
|
else
|
||||||
refurbished_args
|
refurbished_args
|
||||||
@ -158,6 +148,11 @@ end
|
|||||||
####################################################################### sanity
|
####################################################################### sanity
|
||||||
abort "The build-tool has reset ENV. --env=std required." unless ENV['HOMEBREW_BREW_FILE']
|
abort "The build-tool has reset ENV. --env=std required." unless ENV['HOMEBREW_BREW_FILE']
|
||||||
|
|
||||||
|
case ENV['HOMEBREW_CC'].chuzzle when 'cc', nil
|
||||||
|
# those values are not allowed
|
||||||
|
ENV['HOMEBREW_CC'] = 'clang'
|
||||||
|
end
|
||||||
|
|
||||||
######################################################################### main
|
######################################################################### main
|
||||||
cmd = Cmd.new($0, ARGV)
|
cmd = Cmd.new($0, ARGV)
|
||||||
exec "xcrun", cmd.tool, *cmd.args
|
exec "xcrun", cmd.tool, *cmd.args
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
export HOMEBREW_CCCFG="O$HOMEBREW_CCCFG"
|
export HOMEBREW_CCCFG="O$HOMEBREW_CCCFG"
|
||||||
if [ $(basename "$0") == "bsdmake" ]; then
|
if [ $(basename "$0") == "bsdmake" ]; then
|
||||||
pwd="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
pwd="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|||||||
@ -41,7 +41,8 @@ class << ENV
|
|||||||
def setup_build_environment
|
def setup_build_environment
|
||||||
reset
|
reset
|
||||||
check
|
check
|
||||||
ENV['LD'] = 'cc'
|
ENV['CC'] = ENV['LD'] = 'cc'
|
||||||
|
ENV['CXX'] = 'c++'
|
||||||
ENV['MAKEFLAGS'] ||= "-j#{determine_make_jobs}"
|
ENV['MAKEFLAGS'] ||= "-j#{determine_make_jobs}"
|
||||||
ENV['PATH'] = determine_path
|
ENV['PATH'] = determine_path
|
||||||
ENV['PKG_CONFIG_PATH'] = determine_pkg_config_path
|
ENV['PKG_CONFIG_PATH'] = determine_pkg_config_path
|
||||||
@ -198,13 +199,16 @@ class << ENV
|
|||||||
end
|
end
|
||||||
alias_method :j1, :deparallelize
|
alias_method :j1, :deparallelize
|
||||||
def gcc
|
def gcc
|
||||||
ENV['HOMEBREW_CC'] = "gcc"
|
ENV['CC'] = ENV['HOMEBREW_CC'] = "gcc"
|
||||||
|
ENV['CXX'] = "g++"
|
||||||
end
|
end
|
||||||
def llvm
|
def llvm
|
||||||
ENV['HOMEBREW_CC'] = "llvm-gcc"
|
ENV['CC'] = ENV['HOMEBREW_CC'] = "llvm-gcc"
|
||||||
|
ENV['CXX'] = "g++"
|
||||||
end
|
end
|
||||||
def clang
|
def clang
|
||||||
ENV['HOMEBREW_CC'] = "clang"
|
ENV['CC'] = ENV['HOMEBREW_CC'] = "clang"
|
||||||
|
ENV['CXX'] = "clang++"
|
||||||
end
|
end
|
||||||
def make_jobs
|
def make_jobs
|
||||||
ENV['MAKEFLAGS'] =~ /-\w*j(\d)+/
|
ENV['MAKEFLAGS'] =~ /-\w*j(\d)+/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user