# # Bazel RBE on Windows GCP workers currently will not invoke cmd.exe batch files correctly # # Symptom is program not found 'bazel-out', because of the way that the CreateProcess command # is constructed by bazel with actions.run with forward slashes, e.g. the command # cmd.exe /c "bazel-out/host/bin/external/go_sdk/builder.exe.bat" # where cmd.exe on GCP is treating 'bazel-out' as the target, and /host as a command line switch. # This problem was not observed on Azure CI pipelines or locally by the developers. The eventual # fix is not specific to rules_go; this patch simply addresses immediate breakage and can be removed # once the underlying issue within Bazel/RBE is fixed. # See: # - https://github.com/bazelbuild/rules_go/pull/2542 # - https://github.com/envoyproxy/envoy/issues/11657 # diff --git a/go/private/rules/binary.bzl b/go/private/rules/binary.bzl index b88dfd96..e68b5ece 100644 --- a/go/private/rules/binary.bzl +++ b/go/private/rules/binary.bzl @@ -128,8 +128,9 @@ def _go_tool_binary_impl(ctx): content = cmd, ) ctx.actions.run( - executable = bat, - inputs = sdk.libs + sdk.headers + sdk.tools + ctx.files.srcs + [sdk.go], + executable = "cmd.exe", + arguments = ["/S", "/C", bat.path.replace("/", "\\")], + inputs = sdk.libs + sdk.headers + sdk.tools + ctx.files.srcs + [sdk.go, bat], outputs = [cout], env = {"GOROOT": sdk.root_file.dirname}, # NOTE(#2005): avoid realpath in sandbox mnemonic = "GoToolchainBinaryCompile",