Switch to updated compiler_wrapper for latest Clang toolchain.
am: 03113dd6cb
Change-Id: I2bf46abc83f24a840bf23c5256650ce487249ed3
diff --git a/clang-3688880/bin/clang b/clang-3688880/bin/clang
index f770b8e..2ff178b 100755
--- a/clang-3688880/bin/clang
+++ b/clang-3688880/bin/clang
@@ -4,9 +4,15 @@
import shlex
import sys
-import bisect_driver
-
BISECT_STAGE = os.environ.get('BISECT_STAGE')
+
+# We do not need bisect functionality with Goma and clang.
+# Goma server does not have bisect_driver, so we only import
+# bisect_driver when needed. See http://b/34862041
+# We should be careful when doing imports because of Goma.
+if BISECT_STAGE:
+ import bisect_driver
+
DEFAULT_BISECT_DIR = os.path.expanduser('~/ANDROID_BISECT')
BISECT_DIR = os.environ.get('BISECT_DIR') or DEFAULT_BISECT_DIR
@@ -81,21 +87,25 @@
def bisect(self):
self.prepare_compiler_args()
# Handle @file argument syntax with compiler
- for idx, _ in enumerate(self.execargs):
- # @file can be nested in other @file arguments, use While to re-evaluate
- # the first argument of the embedded file.
- while execargs[idx][0] == '@':
- args_in_file = ProcessArgFile(execargs[idx][1:])
+ idx = 0
+ # The length of self.execargs can be changed during the @file argument
+ # expansion, so we need to use while loop instead of for loop.
+ while idx < len(self.execargs):
+ if self.execargs[idx][0] == '@':
+ args_in_file = ProcessArgFile(self.execargs[idx][1:])
self.execargs = self.execargs[0:idx] + args_in_file + self.execargs[idx + 1:]
- bisect_driver.bisect_driver(BISECT_STAGE, BISECT_DIR, execargs)
+ # Skip update of idx, since we want to recursively expand response files.
+ else:
+ idx = idx + 1
+ bisect_driver.bisect_driver(BISECT_STAGE, BISECT_DIR, self.execargs)
def main(argv):
cw = CompilerWrapper(argv[1:])
- if BISECT_STAGE not in bisect_driver.VALID_MODES or '-o' not in argv:
- cw.invoke_compiler()
- else:
+ if BISECT_STAGE and BISECT_STAGE in bisect_driver.VALID_MODES and '-o' in argv:
cw.bisect()
+ else:
+ cw.invoke_compiler()
if __name__ == '__main__':
diff --git a/clang-3688880/bin/clang++ b/clang-3688880/bin/clang++
index f770b8e..2ff178b 100755
--- a/clang-3688880/bin/clang++
+++ b/clang-3688880/bin/clang++
@@ -4,9 +4,15 @@
import shlex
import sys
-import bisect_driver
-
BISECT_STAGE = os.environ.get('BISECT_STAGE')
+
+# We do not need bisect functionality with Goma and clang.
+# Goma server does not have bisect_driver, so we only import
+# bisect_driver when needed. See http://b/34862041
+# We should be careful when doing imports because of Goma.
+if BISECT_STAGE:
+ import bisect_driver
+
DEFAULT_BISECT_DIR = os.path.expanduser('~/ANDROID_BISECT')
BISECT_DIR = os.environ.get('BISECT_DIR') or DEFAULT_BISECT_DIR
@@ -81,21 +87,25 @@
def bisect(self):
self.prepare_compiler_args()
# Handle @file argument syntax with compiler
- for idx, _ in enumerate(self.execargs):
- # @file can be nested in other @file arguments, use While to re-evaluate
- # the first argument of the embedded file.
- while execargs[idx][0] == '@':
- args_in_file = ProcessArgFile(execargs[idx][1:])
+ idx = 0
+ # The length of self.execargs can be changed during the @file argument
+ # expansion, so we need to use while loop instead of for loop.
+ while idx < len(self.execargs):
+ if self.execargs[idx][0] == '@':
+ args_in_file = ProcessArgFile(self.execargs[idx][1:])
self.execargs = self.execargs[0:idx] + args_in_file + self.execargs[idx + 1:]
- bisect_driver.bisect_driver(BISECT_STAGE, BISECT_DIR, execargs)
+ # Skip update of idx, since we want to recursively expand response files.
+ else:
+ idx = idx + 1
+ bisect_driver.bisect_driver(BISECT_STAGE, BISECT_DIR, self.execargs)
def main(argv):
cw = CompilerWrapper(argv[1:])
- if BISECT_STAGE not in bisect_driver.VALID_MODES or '-o' not in argv:
- cw.invoke_compiler()
- else:
+ if BISECT_STAGE and BISECT_STAGE in bisect_driver.VALID_MODES and '-o' in argv:
cw.bisect()
+ else:
+ cw.invoke_compiler()
if __name__ == '__main__':