Permalink
Browse files

Fixes #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.
  • Loading branch information...
1 parent b41ba21 commit 7aa496efed02bb7cd59866c1d7954799128832a5 @mxcl mxcl committed Aug 30, 2012
Showing with 37 additions and 40 deletions.
  1. +29 −21 Library/ENV/4.3/cc
  2. +3 −0 Library/ENV/4.3/make
  3. +0 −3 Library/Formula/objective-caml.rb
  4. +0 −4 Library/Homebrew/formula.rb
  5. +5 −12 Library/Homebrew/superenv.rb
View
@@ -44,29 +44,29 @@ class Cmd
end
end
def tool
- case @cmd
- when /gcc/ then 'gcc'
- when /g\+\+/ then 'g++'
- when 'clang', 'clang++'
- @cmd
- when 'ld', 'cpp', 'cc'
- ENV['HOMEBREW_CC'].chuzzle or 'clang'
- when 'c++'
- case ENV['HOMEBREW_CC']
- when /gcc/ then 'g++'
- else 'clang++'
+ @tool ||= if @cmd.include? '++'
+ if ENV['HOMEBREW_CC'].chuzzle =~ /gcc/
+ 'g++'
+ else
+ 'clang++'
end
+ elsif @cmd == 'ld'
+ 'ld'
else
- abort "Unknown command: #{@cmd}"
+ ENV['HOMEBREW_CC'].chuzzle or 'clang'
end
end
def args
- args = if cccfg? 'O'
+ args = if cccfg? 'O' and tool != 'ld'
refurbished_args
else
@args.dup
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
when :cpp
%w{-E} + cppflags + args
@@ -110,13 +110,7 @@ class Cmd
args << arg
end
end
-
- 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
-
+ make_fuss(args)
args
end
def cflags
@@ -141,6 +135,20 @@ class Cmd
# they override the system options.
sys.to_flags('-isystem') + opt.to_flags('-I')
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
####################################################################### sanity
@@ -0,0 +1,3 @@
+#!/bin/sh
+export HOMEBREW_CCCFG="O$HOMEBREW_CCCFG"
+exec xcrun make "$@"
@@ -9,9 +9,6 @@ class ObjectiveCaml < Formula
depends_on :x11
- # Don't strip symbols, so dynamic linking doesn't break.
- skip_clean :all
-
# See http://caml.inria.fr/mantis/view.php?id=5700
def patches
"http://caml.inria.fr/mantis/file_download.php?file_id=722&type=bug"
@@ -470,8 +470,6 @@ def system cmd, *args
removed_ENV_variables = case if args.empty? then cmd.split(' ').first else cmd end
when "xcodebuild"
ENV.remove_cc_etc
- when /^make\b/
- ENV.append 'HOMEBREW_CCCFG', "O", ''
end
if ARGV.verbose?
@@ -502,8 +500,6 @@ def system cmd, *args
rescue
raise BuildError.new(self, cmd, args, $?)
- ensure
- ENV['HOMEBREW_CCCFG'] = ENV['HOMEBREW_CCCFG'].delete('O') if ENV['HOMEBREW_CCCFG']
end
public
@@ -28,7 +28,7 @@ class << ENV
alias_method :x11?, :x11
def reset
- %w{CC CXX LD CPP OBJC MAKE
+ %w{CC CXX CPP OBJC MAKE
CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS LDFLAGS CPPFLAGS
MACOS_DEPLOYMENT_TARGET SDKROOT
CMAKE_PREFIX_PATH CMAKE_INCLUDE_PATH CMAKE_FRAMEWORK_PATH}.
@@ -40,11 +40,7 @@ def reset
def setup_build_environment
reset
- ENV['CC'] = 'cc'
- ENV['CXX'] = 'c++'
- ENV['LD'] = 'ld'
- ENV['CPP'] = 'cpp'
- ENV['MAKE'] = 'make'
+ ENV['LD'] = 'cc'
ENV['MAKEFLAGS'] ||= "-j#{determine_make_jobs}"
ENV['PATH'] = determine_path
ENV['PKG_CONFIG_PATH'] = determine_pkg_config_path
@@ -184,16 +180,13 @@ def deparallelize
end
alias_method :j1, :deparallelize
def gcc
- ENV['CC'] = "gcc"
- ENV['CXX'] = "g++"
+ ENV['HOMEBREW_CC'] = "gcc"
end
def llvm
- ENV['CC'] = "llvm-gcc"
- ENV['CXX'] = "llvm-g++"
+ ENV['HOMEBREW_CC'] = "llvm-gcc"
end
def clang
- ENV['CC'] = "clang"
- ENV['CXX'] = "clang++"
+ ENV['HOMEBREW_CC'] = "clang"
end
def make_jobs
ENV['MAKEFLAGS'] =~ /-\w*j(\d)+/

0 comments on commit 7aa496e

Please sign in to comment.