Invoke the wrapped compiler with the wrapper's invocation path
Bug: http://b/37407093
Test: Following command uses relative paths in clang{,++}.real
invocation and the -resource-dir argument:
prebuilts/clang/host/linux-x86/clang-3859424/bin/clang -no-canonical-prefixes -E -v -xc /dev/null -o /dev/null
Change-Id: Ib1dc4b1b4b66536f6dc42678f6f0fe2c52e2562c
diff --git a/clang-3859424/bin/clang b/clang-3859424/bin/clang
index 2ff178b..384783b 100755
--- a/clang-3859424/bin/clang
+++ b/clang-3859424/bin/clang
@@ -27,7 +27,8 @@
class CompilerWrapper():
def __init__(self, argv):
- self.args = argv
+ self.argv0_current = argv[0]
+ self.args = argv[1:]
self.execargs = []
self.real_compiler = None
self.argv0 = None
@@ -39,7 +40,7 @@
def set_real_compiler(self):
"""Find the real compiler with the absolute path."""
- compiler_path = os.path.dirname(os.path.abspath(__file__))
+ compiler_path = os.path.dirname(self.argv0_current)
if os.path.islink(__file__):
compiler = os.path.basename(os.readlink(__file__))
else:
@@ -101,7 +102,7 @@
def main(argv):
- cw = CompilerWrapper(argv[1:])
+ cw = CompilerWrapper(argv)
if BISECT_STAGE and BISECT_STAGE in bisect_driver.VALID_MODES and '-o' in argv:
cw.bisect()
else:
diff --git a/clang-3859424/bin/clang++ b/clang-3859424/bin/clang++
index 2ff178b..384783b 100755
--- a/clang-3859424/bin/clang++
+++ b/clang-3859424/bin/clang++
@@ -27,7 +27,8 @@
class CompilerWrapper():
def __init__(self, argv):
- self.args = argv
+ self.argv0_current = argv[0]
+ self.args = argv[1:]
self.execargs = []
self.real_compiler = None
self.argv0 = None
@@ -39,7 +40,7 @@
def set_real_compiler(self):
"""Find the real compiler with the absolute path."""
- compiler_path = os.path.dirname(os.path.abspath(__file__))
+ compiler_path = os.path.dirname(self.argv0_current)
if os.path.islink(__file__):
compiler = os.path.basename(os.readlink(__file__))
else:
@@ -101,7 +102,7 @@
def main(argv):
- cw = CompilerWrapper(argv[1:])
+ cw = CompilerWrapper(argv)
if BISECT_STAGE and BISECT_STAGE in bisect_driver.VALID_MODES and '-o' in argv:
cw.bisect()
else: