build: make CC command in -fstrict-aliasing check configurable
authorBen Noordhuis <info@bnoordhuis.nl>
Mon, 5 Mar 2012 15:55:24 +0000 (16:55 +0100)
committerBen Noordhuis <info@bnoordhuis.nl>
Mon, 5 Mar 2012 16:03:15 +0000 (17:03 +0100)
configure

index 71756a6..27ef84e 100755 (executable)
--- a/configure
+++ b/configure
@@ -6,6 +6,8 @@ import re
 import subprocess
 import sys
 
+CC = os.environ.get('CC', 'cc')
+
 root_dir = os.path.dirname(__file__)
 sys.path.insert(0, os.path.join(root_dir, 'deps', 'v8', 'tools'))
 
@@ -147,10 +149,10 @@ def pkg_config(pkg):
 def host_arch():
   """Host architecture. One of arm, ia32 or x64."""
 
-  cc = [os.environ.get('CC', 'cc')]
-
-  cmd = cc + [ '-dM', '-E', '-' ]
-  p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+  p = subprocess.Popen([CC, '-dM', '-E', '-'],
+                       stdin=subprocess.PIPE,
+                       stdout=subprocess.PIPE,
+                       stderr=subprocess.PIPE)
   p.stdin.write('\n')
   out = p.communicate()[0]
 
@@ -187,12 +189,13 @@ def target_arch():
 
 def gcc_version():
   try:
-    proc = subprocess.Popen('gcc -v'.split(), stderr=subprocess.PIPE)
+    proc = subprocess.Popen([CC, '-v'], stderr=subprocess.PIPE)
   except OSError:
     return None
+  # TODO parse clang output
   version = proc.communicate()[1].split('\n')[-2]
   match = re.match('gcc version (\d+)\.(\d+)\.(\d+)', version)
-  assert match, 'Failed to parse gcc version `%s`' % version
+  if not match: return None
   return ['LLVM' in version] + map(int, match.groups())
 
 
@@ -209,8 +212,8 @@ def configure_node(o):
   # turn off strict aliasing if gcc < 4.6.0 unless it's llvm-gcc
   # see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45883
   # see http://code.google.com/p/v8/issues/detail?id=884
-  # TODO handle CC=clang
-  o['variables']['strict_aliasing'] = b(gcc_version() >= [False, 4, 6, 0])
+  o['variables']['strict_aliasing'] = b(
+    'clang' in CC or gcc_version() >= [False, 4, 6, 0])
 
   # TODO move to node.gyp
   if sys.platform == 'sunos5':