Fix crosstools to expand fdo_instrument conditionally

After this change, the flag_group will be only expanded when bazel exposes the
variable. This fixes some users of the C++ toolchain api that don't pass
fdo_instrument path.

RELNOTES: None.
PiperOrigin-RevId: 213628141
diff --git a/src/test/java/com/google/devtools/build/lib/packages/util/MOCK_OSX_CROSSTOOL b/src/test/java/com/google/devtools/build/lib/packages/util/MOCK_OSX_CROSSTOOL
index b8a5d82..00ed7cc 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/util/MOCK_OSX_CROSSTOOL
+++ b/src/test/java/com/google/devtools/build/lib/packages/util/MOCK_OSX_CROSSTOOL
@@ -1000,6 +1000,7 @@
       flag_group {
         flag: "-fprofile-generate=%{fdo_instrument_path}"
         flag: "-fno-data-sections"
+        expand_if_all_available: "fdo_instrument_path"
       }
     }
     provides: "profile"
@@ -2772,6 +2773,7 @@
       flag_group {
         flag: "-fprofile-generate=%{fdo_instrument_path}"
         flag: "-fno-data-sections"
+        expand_if_all_available: "fdo_instrument_path"
       }
     }
     provides: "profile"
@@ -4539,6 +4541,7 @@
       flag_group {
         flag: "-fprofile-generate=%{fdo_instrument_path}"
         flag: "-fno-data-sections"
+        expand_if_all_available: "fdo_instrument_path"
       }
     }
     provides: "profile"
@@ -6306,6 +6309,7 @@
       flag_group {
         flag: "-fprofile-generate=%{fdo_instrument_path}"
         flag: "-fno-data-sections"
+        expand_if_all_available: "fdo_instrument_path"
       }
     }
     provides: "profile"
@@ -8077,6 +8081,7 @@
       flag_group {
         flag: "-fprofile-generate=%{fdo_instrument_path}"
         flag: "-fno-data-sections"
+        expand_if_all_available: "fdo_instrument_path"
       }
     }
     provides: "profile"
@@ -9856,6 +9861,7 @@
       flag_group {
         flag: "-fprofile-generate=%{fdo_instrument_path}"
         flag: "-fno-data-sections"
+        expand_if_all_available: "fdo_instrument_path"
       }
     }
     provides: "profile"
@@ -11634,6 +11640,7 @@
       flag_group {
         flag: "-fprofile-generate=%{fdo_instrument_path}"
         flag: "-fno-data-sections"
+        expand_if_all_available: "fdo_instrument_path"
       }
     }
     provides: "profile"
@@ -13441,6 +13448,7 @@
       flag_group {
         flag: "-fprofile-generate=%{fdo_instrument_path}"
         flag: "-fno-data-sections"
+        expand_if_all_available: "fdo_instrument_path"
       }
     }
     provides: "profile"
@@ -15218,6 +15226,7 @@
       flag_group {
         flag: "-fprofile-generate=%{fdo_instrument_path}"
         flag: "-fno-data-sections"
+        expand_if_all_available: "fdo_instrument_path"
       }
     }
     provides: "profile"
@@ -17017,6 +17026,7 @@
       flag_group {
         flag: "-fprofile-generate=%{fdo_instrument_path}"
         flag: "-fno-data-sections"
+        expand_if_all_available: "fdo_instrument_path"
       }
     }
     provides: "profile"
@@ -18815,6 +18825,7 @@
       flag_group {
         flag: "-fprofile-generate=%{fdo_instrument_path}"
         flag: "-fno-data-sections"
+        expand_if_all_available: "fdo_instrument_path"
       }
     }
     provides: "profile"
@@ -20642,6 +20653,7 @@
       flag_group {
         flag: "-fprofile-generate=%{fdo_instrument_path}"
         flag: "-fno-data-sections"
+        expand_if_all_available: "fdo_instrument_path"
       }
     }
     provides: "profile"
diff --git a/tools/osx/crosstool/CROSSTOOL.tpl b/tools/osx/crosstool/CROSSTOOL.tpl
index 22f0390..5761edc 100644
--- a/tools/osx/crosstool/CROSSTOOL.tpl
+++ b/tools/osx/crosstool/CROSSTOOL.tpl
@@ -792,6 +792,7 @@
       flag_group {
         flag: "-fprofile-generate=%{fdo_instrument_path}"
         flag: "-fno-data-sections"
+        expand_if_all_available: "fdo_instrument_path"
       }
     }
     provides: "profile"
@@ -2450,6 +2451,7 @@
       flag_group {
         flag: "-fprofile-generate=%{fdo_instrument_path}"
         flag: "-fno-data-sections"
+        expand_if_all_available: "fdo_instrument_path"
       }
     }
     provides: "profile"
@@ -4115,6 +4117,7 @@
       flag_group {
         flag: "-fprofile-generate=%{fdo_instrument_path}"
         flag: "-fno-data-sections"
+        expand_if_all_available: "fdo_instrument_path"
       }
     }
     provides: "profile"
@@ -5783,6 +5786,7 @@
       flag_group {
         flag: "-fprofile-generate=%{fdo_instrument_path}"
         flag: "-fno-data-sections"
+        expand_if_all_available: "fdo_instrument_path"
       }
     }
     provides: "profile"
@@ -7478,6 +7482,7 @@
       flag_group {
         flag: "-fprofile-generate=%{fdo_instrument_path}"
         flag: "-fno-data-sections"
+        expand_if_all_available: "fdo_instrument_path"
       }
     }
     provides: "profile"
@@ -9143,6 +9148,7 @@
       flag_group {
         flag: "-fprofile-generate=%{fdo_instrument_path}"
         flag: "-fno-data-sections"
+        expand_if_all_available: "fdo_instrument_path"
       }
     }
     provides: "profile"
@@ -10796,6 +10802,7 @@
       flag_group {
         flag: "-fprofile-generate=%{fdo_instrument_path}"
         flag: "-fno-data-sections"
+        expand_if_all_available: "fdo_instrument_path"
       }
     }
     provides: "profile"
@@ -12452,6 +12459,7 @@
       flag_group {
         flag: "-fprofile-generate=%{fdo_instrument_path}"
         flag: "-fno-data-sections"
+        expand_if_all_available: "fdo_instrument_path"
       }
     }
     provides: "profile"
@@ -14135,6 +14143,7 @@
       flag_group {
         flag: "-fprofile-generate=%{fdo_instrument_path}"
         flag: "-fno-data-sections"
+        expand_if_all_available: "fdo_instrument_path"
       }
     }
     provides: "profile"
@@ -15789,6 +15798,7 @@
       flag_group {
         flag: "-fprofile-generate=%{fdo_instrument_path}"
         flag: "-fno-data-sections"
+        expand_if_all_available: "fdo_instrument_path"
       }
     }
     provides: "profile"