From 514b1b54cdb346e06ab137f7084b8a9d4ae361cd Mon Sep 17 00:00:00 2001 From: Max Howell Date: Thu, 13 Sep 2012 11:28:06 -0400 Subject: [PATCH] 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. --- Library/ENV/4.3/cc | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Library/ENV/4.3/cc b/Library/ENV/4.3/cc index 158c187bb6..5b7753de89 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