gollvm: support -fgo-importcfg command line option

Add support for accepting the '-fgo_importcfg' command line options
and passing on the results to the gofrontend (as implemented in
gofrontend CL 506095).

Change-Id: I935dee2d4b0bf4cbe0b35f306f7e2f301a2278cc
Reviewed-on: https://go-review.googlesource.com/c/gollvm/+/506215
Reviewed-by: Cherry Mui <cherryyz@google.com>
diff --git a/bridge/go-c.h b/bridge/go-c.h
index be80eec..29bf81d 100644
--- a/bridge/go-c.h
+++ b/bridge/go-c.h
@@ -29,6 +29,7 @@
   const char* relative_import_path;
   const char* c_header;
   const char* embedcfg;
+  const char* importcfg;
   Backend* backend;
   Linemap* linemap;
   bool check_divide_by_zero;
diff --git a/driver/CompileGo.cpp b/driver/CompileGo.cpp
index 3312a7a..26af4e7 100644
--- a/driver/CompileGo.cpp
+++ b/driver/CompileGo.cpp
@@ -588,6 +588,9 @@
   opt::Arg *ecfg =
       args_.getLastArg(gollvm::options::OPT_fgo_embedcfg_EQ);
   args.embedcfg = (ecfg == nullptr ? NULL : ecfg->getValue());
+  opt::Arg *icfg =
+      args_.getLastArg(gollvm::options::OPT_fgo_importcfg_EQ);
+  args.importcfg = (icfg == nullptr ? NULL : icfg->getValue());
   args.check_divide_by_zero =
       driver_.reconcileOptionPair(gollvm::options::OPT_fgo_check_divide_zero,
                                   gollvm::options::OPT_fno_go_check_divide_zero,
diff --git a/driver/GollvmOptions.td b/driver/GollvmOptions.td
index b2b627f..404a1ad 100644
--- a/driver/GollvmOptions.td
+++ b/driver/GollvmOptions.td
@@ -415,6 +415,14 @@
   Group<f_Group>,
   HelpText<"List of embedded files via go:embed.">;
 
+def fgo_importcfg_EQ : Joined<["-"], "fgo-importcfg=">,
+  Group<f_Group>,
+  HelpText<"Identifies a file that provides mappings for import package"
+           " paths found in the Go source files. The file can contain two"
+           " commands: 'importpath' to rename import paths for vendoring and"
+           " 'packagefile' to map from package path to files containing export"
+           " data. This option is intended for use by the 'go' command">;
+
 // Needed for compatibility with gccgo
 
 def xassembler_with_cpp : Flag<["-"], "xassembler-with-cpp">,