gollvm: resolve arg[0] path in -v/-### trace output

The go command takes advantage of the -### compiler output to
derive the path to the compiler executable, as part of computing
a checksum / buildid for the compilation. To help with this,
make sure that the -v / -### output emits a resolved executable
path and not just the argv[0] value.

Change-Id: Iab5faa7da57c479e1fb083d4d3797e5ff3a3c93f
Reviewed-on: https://go-review.googlesource.com/110625
Reviewed-by: Ian Lance Taylor <iant@golang.org>
diff --git a/driver/CompileGo.cpp b/driver/CompileGo.cpp
index a3bf0de..c4bc427 100644
--- a/driver/CompileGo.cpp
+++ b/driver/CompileGo.cpp
@@ -67,7 +67,7 @@
 
 class CompileGoImpl {
  public:
-  CompileGoImpl(ToolChain &tc);
+  CompileGoImpl(ToolChain &tc, const std::string &executablePath);
 
   // Perform compilation.
   bool performAction(Compilation &compilation,
@@ -81,6 +81,7 @@
   Driver &driver_;
   LLVMContext context_;
   const char *progname_;
+  std::string executablePath_;
   opt::InputArgList &args_;
   CodeGenOpt::Level cgolvl_;
   unsigned olvl_;
@@ -112,11 +113,12 @@
                           const Artifact &output);
 };
 
-CompileGoImpl::CompileGoImpl(ToolChain &tc)
+CompileGoImpl::CompileGoImpl(ToolChain &tc, const std::string &executablePath)
     : triple_(tc.driver().triple()),
       toolchain_(tc),
       driver_(tc.driver()),
       progname_(tc.driver().progname()),
+      executablePath_(executablePath),
       args_(tc.driver().args()),
       cgolvl_(CodeGenOpt::Default),
       olvl_(2),
@@ -190,7 +192,7 @@
   bool hashHashHash = args_.hasArg(gollvm::options::OPT__HASH_HASH_HASH);
   const char *qu = (hashHashHash ? "\"" : "");
   if (args_.hasArg(gollvm::options::OPT_v) || hashHashHash) {
-    errs() << " " << progname_ << " " << qu << "-S" << qu;
+    errs() << " " << executablePath_ << " " << qu << "-S" << qu;
     for (auto arg : args_) {
       if (arg->getOption().matches(gollvm::options::OPT_v) ||
           arg->getOption().matches(gollvm::options::OPT_c) ||
@@ -602,9 +604,9 @@
 
 //......................................................................
 
-CompileGo::CompileGo(ToolChain &tc)
+CompileGo::CompileGo(ToolChain &tc, const std::string &executablePath)
     : InternalTool("gocompiler", tc),
-      impl_(new CompileGoImpl(tc))
+      impl_(new CompileGoImpl(tc, executablePath))
 {
 }
 
diff --git a/driver/CompileGo.h b/driver/CompileGo.h
index c0e8fa4..49e407f 100644
--- a/driver/CompileGo.h
+++ b/driver/CompileGo.h
@@ -31,7 +31,7 @@
 
 class CompileGo : public InternalTool {
  public:
-  CompileGo(ToolChain &tc);
+  CompileGo(ToolChain &tc, const std::string &executablePath);
   ~CompileGo();
 
   // Perform compilation.
diff --git a/driver/Driver.h b/driver/Driver.h
index 3b3bf9f..a69d888 100644
--- a/driver/Driver.h
+++ b/driver/Driver.h
@@ -80,6 +80,7 @@
   llvm::opt::InputArgList &args() { return args_; }
   llvm::opt::OptTable &opts() { return *opts_; }
   const char *progname() const { return progname_; }
+  const std::string &executablePath() const { return executablePath_; }
 
   // Name of driver (program invoked)
   std::string name();
diff --git a/driver/LinuxToolChain.cpp b/driver/LinuxToolChain.cpp
index 6d22b69..f01c0bc 100644
--- a/driver/LinuxToolChain.cpp
+++ b/driver/LinuxToolChain.cpp
@@ -85,7 +85,7 @@
 
 Tool *Linux::buildCompiler()
 {
-  return new CompileGo(*this);
+  return new CompileGo(*this, driver().executablePath());
 }
 
 Tool *Linux::buildAssembler()