Description: Fix FTBFS when the auto-configured C++ toolchain flag contains a quote
 Bazel's cc_configure generates @local_config_cc//BUILD via get_starlark_list.
 When any compiler flag value contains a double quote (or backslash), the flag
 was written unescaped into the generated Starlark file, producing adjacent
 string literals, which makes Starlark fail with "Implicit string concatenation
 is forbidden" and aborts the analysis. GCC 15's default specs inject flags such
 as -fzero-init-padding-bits=all which, combined with the injected CXXFLAGS,
 trigger this. Escape backslashes and double quotes in each value so the
 generated BUILD is always valid.
Author: tangxiaofeng <tangxiaofeng@kylinos.cn>
Origin: other
Forwarded: not-needed
Last-Update: 2026-08-28

--- bazel-bootstrap-4.2.3+ds.orig/tools/cpp/lib_cc_configure.bzl
+++ bazel-bootstrap-4.2.3+ds/tools/cpp/lib_cc_configure.bzl
@@ -222,7 +222,8 @@ def get_starlark_list(values):
     """Convert a list of string into a string that can be passed to a rule attribute."""
     if not values:
         return ""
-    return "\"" + "\",\n    \"".join(values) + "\""
+    escaped_values = [v.replace("\\", "\\\\").replace("\"", "\\\"") for v in values]
+    return "\"" + "\",\n    \"".join(escaped_values) + "\""
 
 def auto_configure_warning_maybe(repository_ctx, msg):
     """Output warning message when CC_CONFIGURE_DEBUG is enabled."""

