gollvm: add wrapper -A option to enable testing of new driver
New wrapper "-A" option available via GOLLVM_WRAP_OPTIONS; this
effectively turns off the wrapper and just immediately invokes
llvm-goc regardless of the command line.
Change-Id: Ifc18899cee1b9607337008cd1b971a8db71e8890
Reviewed-on: https://go-review.googlesource.com/110624
Reviewed-by: Ian Lance Taylor <iant@golang.org>
diff --git a/tools/gollvm-wrap.py b/tools/gollvm-wrap.py
index 5247f63..2a5844f 100755
--- a/tools/gollvm-wrap.py
+++ b/tools/gollvm-wrap.py
@@ -51,6 +51,9 @@
# gccgo only mode
flag_nollvm = False
+# never invoke the real gccgo
+flag_alwaysllvm = False
+
# trace llvm-goc invocations
flag_trace_llinvoc = False
@@ -89,6 +92,17 @@
if not lines:
u.error("no 'llvm-goc' in PATH -- can't proceed")
+ # Bypass the whole mess if -A
+ if flag_alwaysllvm:
+ a = sys.argv
+ a[0] = "llvm-goc"
+ driver = "llvm-goc"
+ rc = subprocess.call(a)
+ if rc != 0:
+ u.verbose(1, "return code %d from %s" % (rc, " ".join(a)))
+ return 1
+ return 0
+
# Perform a walk of the command line arguments looking for Go files.
reg = re.compile(r"^(\S+)\.go$")
gofile = None
@@ -329,6 +343,7 @@
def parse_env_options():
"""Option parsing from env var."""
global flag_echo, flag_dryrun, flag_nollvm, flag_trace_llinvoc
+ global flag_alwaysllvm
optstr = os.getenv("GOLLVM_WRAP_OPTIONS")
if not optstr:
@@ -336,7 +351,7 @@
args = optstr.split()
try:
- optlist, _ = getopt.getopt(args, "detDG")
+ optlist, _ = getopt.getopt(args, "detDAG")
except getopt.GetoptError as err:
# unrecognized option
usage(str(err))
@@ -352,6 +367,8 @@
flag_dryrun = True
elif opt == "-G":
flag_nollvm = True
+ elif opt == "-A":
+ flag_alwaysllvm = True
u.verbose(1, "env var options parsing complete")