Automated rollback of commit d3fc253a49a00c34408bbaf5378376cbcea1c5c9.

*** Reason for rollback ***

Breaks downstream projects on Mac: Bazel Examples, rules_apple, rules_cc, rules_go, TensorFlow.

See breakages:
https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/1743

Downstream with rollback:
https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/1744

*** Original change description ***

Add support for params files for darwin

Clang has supported params files for a while now. This updates the cc
toolchain for darwin to use them.

The logic for processing response files is mostly copied from
rules_swift where similar processing is done.

Closes #12265.

PiperOrigin-RevId: 340638807
diff --git a/tools/cpp/BUILD.tools b/tools/cpp/BUILD.tools
index db27b19..dc72e23 100644
--- a/tools/cpp/BUILD.tools
+++ b/tools/cpp/BUILD.tools
@@ -277,7 +277,7 @@
     linker_files = ":osx_wrapper",
     objcopy_files = ":empty",
     strip_files = ":empty",
-    supports_param_files = 1,
+    supports_param_files = 0,
     toolchain_config = ":local_darwin",
     toolchain_identifier = "local_darwin",
 )
diff --git a/tools/cpp/BUILD.tpl b/tools/cpp/BUILD.tpl
index d3514d1..37986a9 100644
--- a/tools/cpp/BUILD.tpl
+++ b/tools/cpp/BUILD.tpl
@@ -66,7 +66,7 @@
     linker_files = ":compiler_deps",
     objcopy_files = ":empty",
     strip_files = ":empty",
-    supports_param_files = 1,
+    supports_param_files = %{supports_param_files},
     module_map = %{modulemap},
 )
 
diff --git a/tools/cpp/osx_cc_wrapper.sh b/tools/cpp/osx_cc_wrapper.sh
index 8c9c111..bbb5d7e 100755
--- a/tools/cpp/osx_cc_wrapper.sh
+++ b/tools/cpp/osx_cc_wrapper.sh
@@ -34,32 +34,19 @@
 LIB_DIRS=
 RPATHS=
 OUTPUT=
-
-function parse_option() {
-    local -r opt="$1"
-    if [[ "${OUTPUT}" = "1" ]]; then
-        OUTPUT=$opt
-    elif [[ "$opt" =~ ^-l(.*)$ ]]; then
-        LIBS="${BASH_REMATCH[1]} $LIBS"
-    elif [[ "$opt" =~ ^-L(.*)$ ]]; then
-        LIB_DIRS="${BASH_REMATCH[1]} $LIB_DIRS"
-    elif [[ "$opt" =~ ^-Wl,-rpath,\@loader_path/(.*)$ ]]; then
-        RPATHS="${BASH_REMATCH[1]} ${RPATHS}"
-    elif [[ "$opt" = "-o" ]]; then
-        # output is coming
-        OUTPUT=1
-    fi
-}
-
 # let parse the option list
 for i in "$@"; do
-    if [[ "$i" = @* ]]; then
-        while IFS= read -r opt
-        do
-            parse_option "$opt"
-        done < "${i:1}" || exit 1
-    else
-        parse_option "$i"
+    if [[ "${OUTPUT}" = "1" ]]; then
+        OUTPUT=$i
+    elif [[ "$i" =~ ^-l(.*)$ ]]; then
+        LIBS="${BASH_REMATCH[1]} $LIBS"
+    elif [[ "$i" =~ ^-L(.*)$ ]]; then
+        LIB_DIRS="${BASH_REMATCH[1]} $LIB_DIRS"
+    elif [[ "$i" =~ ^-Wl,-rpath,\@loader_path/(.*)$ ]]; then
+        RPATHS="${BASH_REMATCH[1]} ${RPATHS}"
+    elif [[ "$i" = "-o" ]]; then
+        # output is coming
+        OUTPUT=1
     fi
 done
 
diff --git a/tools/cpp/osx_cc_wrapper.sh.tpl b/tools/cpp/osx_cc_wrapper.sh.tpl
index 28bd47ba..4c85cd9 100644
--- a/tools/cpp/osx_cc_wrapper.sh.tpl
+++ b/tools/cpp/osx_cc_wrapper.sh.tpl
@@ -33,32 +33,19 @@
 LIB_DIRS=
 RPATHS=
 OUTPUT=
-
-function parse_option() {
-    local -r opt="$1"
-    if [[ "${OUTPUT}" = "1" ]]; then
-        OUTPUT=$opt
-    elif [[ "$opt" =~ ^-l(.*)$ ]]; then
-        LIBS="${BASH_REMATCH[1]} $LIBS"
-    elif [[ "$opt" =~ ^-L(.*)$ ]]; then
-        LIB_DIRS="${BASH_REMATCH[1]} $LIB_DIRS"
-    elif [[ "$opt" =~ ^-Wl,-rpath,\@loader_path/(.*)$ ]]; then
-        RPATHS="${BASH_REMATCH[1]} ${RPATHS}"
-    elif [[ "$opt" = "-o" ]]; then
-        # output is coming
-        OUTPUT=1
-    fi
-}
-
 # let parse the option list
 for i in "$@"; do
-    if [[ "$i" = @* ]]; then
-        while IFS= read -r opt
-        do
-            parse_option "$opt"
-        done < "${i:1}" || exit 1
-    else
-        parse_option "$i"
+    if [[ "${OUTPUT}" = "1" ]]; then
+        OUTPUT=$i
+    elif [[ "$i" =~ ^-l(.*)$ ]]; then
+        LIBS="${BASH_REMATCH[1]} $LIBS"
+    elif [[ "$i" =~ ^-L(.*)$ ]]; then
+        LIB_DIRS="${BASH_REMATCH[1]} $LIB_DIRS"
+    elif [[ "$i" =~ ^-Wl,-rpath,\@loader_path/(.*)$ ]]; then
+        RPATHS="${BASH_REMATCH[1]} ${RPATHS}"
+    elif [[ "$i" = "-o" ]]; then
+        # output is coming
+        OUTPUT=1
     fi
 done
 
diff --git a/tools/cpp/unix_cc_configure.bzl b/tools/cpp/unix_cc_configure.bzl
index 5cb1a9b..5270e9e 100644
--- a/tools/cpp/unix_cc_configure.bzl
+++ b/tools/cpp/unix_cc_configure.bzl
@@ -447,6 +447,7 @@
             "%{cc_toolchain_identifier}": cc_toolchain_identifier,
             "%{name}": cpu_value,
             "%{modulemap}": ("\":module.modulemap\"" if is_clang else "None"),
+            "%{supports_param_files}": "0" if darwin else "1",
             "%{cc_compiler_deps}": get_starlark_list([":builtin_include_directory_paths"] + (
                 [":cc_wrapper"] if darwin else []
             )),