gollvm: report that gollvm doesn't support cross compilation

Since gollvm doesn't support cross compiling yet, this CL will aborts compilation
if the default triple is different with the triple specified by "--target" option,
and prints some prompt message.

Updates golang/go#42388

Change-Id: Iaf88456e85280b133261c42938d9295809f95a3a
Reviewed-on: https://go-review.googlesource.com/c/gollvm/+/270677
Reviewed-by: eric fang <eric.fang@arm.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Trust: eric fang <eric.fang@arm.com>
diff --git a/driver/Driver.cpp b/driver/Driver.cpp
index e8aa35a..8debbab 100644
--- a/driver/Driver.cpp
+++ b/driver/Driver.cpp
@@ -412,10 +412,15 @@
     emitVersion();
 
   // Set triple.
+  // TODO: add cross compiling support.
+  llvm::Triple defaultTargetTriple = Triple(sys::getDefaultTargetTriple());
+  triple_ = defaultTargetTriple;
   if (const opt::Arg *arg = args_.getLastArg(gollvm::options::OPT_target_EQ))
     triple_ = Triple(Triple::normalize(arg->getValue()));
-  else
-    triple_ = Triple(sys::getDefaultTargetTriple());
+  if (triple_ != defaultTargetTriple) {
+    errs() << progname_ << ": error: gollvm doesn't support cross compiling yet\n";
+    return nullptr;
+  }
 
   // Honor -dumpmachine
   if (args_.hasArg(gollvm::options::OPT_dumpmachine)) {