Fixes Homebrew/homebrew#14542; ocaml superenv issues

This patch removes most of the settings for CC, CXX etc. because we are trying to be minimal. Then we force the compiler to Homebrew's choice underneath in superenv. We however leave LD because we prefer that build-systems use the c-compiler for linking, it generally works better (copiously tested), however when the build-system explicitly calls ld, we respect that. This gets around the ocaml bug in question, since somehow clang was crashing during link, but the ld tool itself (which is kind of clang, kind of llvm-gcc) is okay with this.

Also moved the setting of O (so that cc-args are refurbished) into a make wrapper. Not sure if this matter much, but seems more consistent.
This commit is contained in:
Max Howell 2012-08-30 10:03:26 -04:00
parent a4ccf68602
commit d4503b1202
4 changed files with 37 additions and 37 deletions

View File

@ -44,29 +44,29 @@ class Cmd
end end
end end
def tool def tool
case @cmd @tool ||= if @cmd.include? '++'
when /gcc/ then 'gcc' if ENV['HOMEBREW_CC'].chuzzle =~ /gcc/
when /g\+\+/ then 'g++' 'g++'
when 'clang', 'clang++' else
@cmd 'clang++'
when 'ld', 'cpp', 'cc'
ENV['HOMEBREW_CC'].chuzzle or 'clang'
when 'c++'
case ENV['HOMEBREW_CC']
when /gcc/ then 'g++'
else 'clang++'
end end
elsif @cmd == 'ld'
'ld'
else else
abort "Unknown command: #{@cmd}" ENV['HOMEBREW_CC'].chuzzle or 'clang'
end end
end end
def args def args
args = if cccfg? 'O' args = if cccfg? 'O' and tool != 'ld'
refurbished_args refurbished_args
else else
@args.dup @args.dup
end end
args.unshift("--sysroot=#$sdkroot") if nclt? if @cmd != 'ld'
args.unshift("--sysroot=#$sdkroot")
else
args.unshift($sdkroot).unshift("-syslibroot")
end if nclt?
case mode case mode
when :cpp when :cpp
%w{-E} + cppflags + args %w{-E} + cppflags + args
@ -110,13 +110,7 @@ class Cmd
args << arg args << arg
end end
end end
make_fuss(args)
rms = @args - args
%w{CPPFLAGS LDFLAGS CXXFLAGS CFLAGS}.each do |flag|
unison = ENV[flag].split(' ') & rms
puts "Warning! #{unison*' '} removed from #{flag.upcase} by superenv" unless unison.empty?
end
args args
end end
def cflags def cflags
@ -141,6 +135,20 @@ class Cmd
# they override the system options. # they override the system options.
sys.to_flags('-isystem') + opt.to_flags('-I') sys.to_flags('-isystem') + opt.to_flags('-I')
end end
def make_fuss args
dels = @args - args
if ENV['VERBOSE']
adds = args - @args
puts "brew: Superenv removed: #{dels*' '}" unless dels.empty?
puts "brew: Superenv added: #{adds*' '}" unless adds.empty?
else
%w{CPPFLAGS LDFLAGS CXXFLAGS CFLAGS}.each do |flag|
next unless ENV[flag]
flags = dels.select{|del| ENV[flag].include? del }.join(' ')
puts "brew: superenv removed `#{flags}' from #{flag}" unless flags.empty?
end
end
end
end end
####################################################################### sanity ####################################################################### sanity

3
Library/ENV/4.3/make Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
export HOMEBREW_CCCFG="O$HOMEBREW_CCCFG"
exec xcrun make "$@"

View File

@ -470,8 +470,6 @@ protected
removed_ENV_variables = case if args.empty? then cmd.split(' ').first else cmd end removed_ENV_variables = case if args.empty? then cmd.split(' ').first else cmd end
when "xcodebuild" when "xcodebuild"
ENV.remove_cc_etc ENV.remove_cc_etc
when /^make\b/
ENV.append 'HOMEBREW_CCCFG', "O", ''
end end
if ARGV.verbose? if ARGV.verbose?
@ -502,8 +500,6 @@ protected
rescue rescue
raise BuildError.new(self, cmd, args, $?) raise BuildError.new(self, cmd, args, $?)
ensure
ENV['HOMEBREW_CCCFG'] = ENV['HOMEBREW_CCCFG'].delete('O') if ENV['HOMEBREW_CCCFG']
end end
public public

View File

@ -28,7 +28,7 @@ class << ENV
alias_method :x11?, :x11 alias_method :x11?, :x11
def reset def reset
%w{CC CXX LD CPP OBJC MAKE %w{CC CXX CPP OBJC MAKE
CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS LDFLAGS CPPFLAGS CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS LDFLAGS CPPFLAGS
MACOS_DEPLOYMENT_TARGET SDKROOT MACOS_DEPLOYMENT_TARGET SDKROOT
CMAKE_PREFIX_PATH CMAKE_INCLUDE_PATH CMAKE_FRAMEWORK_PATH}. CMAKE_PREFIX_PATH CMAKE_INCLUDE_PATH CMAKE_FRAMEWORK_PATH}.
@ -40,11 +40,7 @@ class << ENV
def setup_build_environment def setup_build_environment
reset reset
ENV['CC'] = 'cc' ENV['LD'] = 'cc'
ENV['CXX'] = 'c++'
ENV['LD'] = 'ld'
ENV['CPP'] = 'cpp'
ENV['MAKE'] = 'make'
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
@ -184,16 +180,13 @@ class << ENV
end end
alias_method :j1, :deparallelize alias_method :j1, :deparallelize
def gcc def gcc
ENV['CC'] = "gcc" ENV['HOMEBREW_CC'] = "gcc"
ENV['CXX'] = "g++"
end end
def llvm def llvm
ENV['CC'] = "llvm-gcc" ENV['HOMEBREW_CC'] = "llvm-gcc"
ENV['CXX'] = "llvm-g++"
end end
def clang def clang
ENV['CC'] = "clang" 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)+/