Add host_cxxopt in parallel to host_copt. 


Closes #2543.

--
Change-Id: I0cd7566fc9ae91f3c1374eca61500a64b3cc8079
Reviewed-on: https://github.com/bazelbuild/bazel/pull/2543
PiperOrigin-RevId: 148449853
MOS_MIGRATED_REVID=148449853
diff --git a/site/versions/master/docs/bazel-user-manual.html b/site/versions/master/docs/bazel-user-manual.html
index 5fc5222..89417ea 100644
--- a/site/versions/master/docs/bazel-user-manual.html
+++ b/site/versions/master/docs/bazel-user-manual.html
@@ -1185,6 +1185,14 @@
   host configuration.
 </p>
 
+<h4 id='flag--host_cxxopt'><code class='flag'>--host_cxxopt <var>gcc-option</var></code></h4>
+<p>
+  This option takes an argument which is to be passed to gcc for source files
+  that are compiled in the host configuration. This is analogous to
+  the <a href='#flag--cxxopt'><code class='flag'>--cxxopt</code></a> option, but applies only to the
+  host configuration.
+</p>
+
 <h4 id='flag--conlyopt'><code class='flag'>--conlyopt <var>gcc-option</var></code></h4>
 <p>
   This option takes an argument which is to be passed to gcc when compiling C source files.
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java
index fa8787a..1dbec6d 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java
@@ -496,6 +496,15 @@
   public List<String> hostCoptList;
 
   @Option(
+    name = "host_cxxopt",
+    allowMultiple = true,
+    defaultValue = "",
+    category = "flags",
+    help = "Additional options to pass to gcc for host tools."
+  )
+  public List<String> hostCxxoptList;
+
+  @Option(
     name = "grte_top",
     defaultValue = "null", // The default value is chosen by the toolchain.
     category = "version",
@@ -625,6 +634,7 @@
     // -g0 is the default, but allowMultiple options cannot have default values so we just pass
     // -g0 first and let the user options override it.
     host.coptList = ImmutableList.<String>builder().add("-g0").addAll(hostCoptList).build();
+    host.cxxoptList = ImmutableList.<String>builder().add("-g0").addAll(hostCxxoptList).build();
 
     host.useStartEndLib = useStartEndLib;
     host.stripBinaries = StripMode.ALWAYS;