aboutsummaryrefslogtreecommitdiffstats
path: root/Library/ENV
diff options
context:
space:
mode:
authorMax Howell2012-09-13 11:28:06 -0400
committerMax Howell2012-09-13 11:30:11 -0400
commit514b1b54cdb346e06ab137f7084b8a9d4ae361cd (patch)
tree3bb8b3fc022d29c03e7bc361b51a75f1a7c0fc74 /Library/ENV
parentffc6423d7344cab3f9ca4dda9a4e982582175d99 (diff)
downloadbrew-514b1b54cdb346e06ab137f7084b8a9d4ae361cd.tar.bz2
Support c99/c89 compiles properly
We can't really execute c89/99 explicitly as these POSIX compliant tools support very few args. Best to execute clang or gcc with the --std=cx9 argument appended. Fixes Homebrew/homebrew#14724.
Diffstat (limited to 'Library/ENV')
-rwxr-xr-xLibrary/ENV/4.3/cc19
1 files changed, 14 insertions, 5 deletions
diff --git a/Library/ENV/4.3/cc b/Library/ENV/4.3/cc
index 158c187bb..5b7753de8 100755
--- a/Library/ENV/4.3/cc
+++ b/Library/ENV/4.3/cc
@@ -41,7 +41,12 @@ class Cmd
def tool
@tool ||= case @arg0
when 'ld' then 'ld'
- when 'cc' then ENV['HOMEBREW_CC']
+ when 'cc', 'c99', 'c89'
+ # Ideally we would run `cx9`, however these tools are POSIX compliant
+ # and don't support many flags. We need -isystem for instance, but also
+ # reliability is generally much higher if we just get clang/gcc to do
+ # the work since Makefiles are dumb and include a lot of excess flags.
+ ENV['HOMEBREW_CC']
when 'c++'
if ENV['HOMEBREW_CC'] =~ /gcc/
'g++'
@@ -120,12 +125,14 @@ class Cmd
if cccfg? 'Ob'
%w{-mtune=generic -Oz}
elsif cccfg? 'O'
- u = %w{-arch i386 -arch x86_64} if cccfg? 'u'
- c = '-march=native' if tool =~ /clang/
- %w{-pipe -w -Os} << u << c
+ args = %w{-pipe -w -Os}
+ args << '-march=native' if tool =~ /clang/
+ args += %w{-arch i386 -arch x86_64} if cccfg? 'u'
+ args << "--std=#{@arg0}" if @arg0 =~ /c[89]9/
+ args
else
[]
- end.flatten
+ end
end
def syslibpath
# We reject brew's lib as we explicitly add this as a -L flag, thus it
@@ -160,7 +167,9 @@ class Cmd
def make_fuss args
dels = @args - args
adds = args - @args
+ dups = dels & args
puts "brew: Superenv removed: #{dels*' '}" unless dels.empty?
+ puts "brew: Superenv deduped: #{dels}" unless dups.empty?
puts "brew: Superenv added: #{adds*' '}" unless adds.empty?
end
end