From b1c3b5ddfeb69dcb86e2c3afc37a0d82a27ee92e Mon Sep 17 00:00:00 2001 From: AJ Heller Date: Fri, 7 Jun 2024 12:48:12 -0700 Subject: [PATCH] [CI] Add clang-cl build to CI (#36840) This adds a clang-cl Windows build to the set of Github presubmit jobs. It builds the codebase with strict warnings enabled, including thread annotation checks, and the rest of diagnostics we've been missing on Windows. Here's [a successful run](https://btx.cloud.google.com/invocations/448792b6-3cff-4987-975a-af5e19526fc0/targets/grpc%2Fcore%2Fpull_request%2Fwindows%2Fgrpc_basictests_c/log) of the script (hijacking the C basic tests kokoro job, ignore that bit) Closes #36840 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36840 from drfloob:kokoro-grpc-win-clangcl f15c8c56262422e5caa94684140d4d34faaf1f0a PiperOrigin-RevId: 641330117 --- bazel/copts.bzl | 3 ++ .../windows/grpc_build_clang_cl.bat | 48 +++++++++++++++++++ .../pull_request/grpc_build_clang_cl.cfg | 25 ++++++++++ 3 files changed, 76 insertions(+) create mode 100644 tools/internal_ci/windows/grpc_build_clang_cl.bat create mode 100644 tools/internal_ci/windows/pull_request/grpc_build_clang_cl.cfg diff --git a/bazel/copts.bzl b/bazel/copts.bzl index 6149e5cfba5..3044ce85c5f 100644 --- a/bazel/copts.bzl +++ b/bazel/copts.bzl @@ -110,6 +110,7 @@ GRPC_LLVM_WINDOWS_WARNING_FLAGS = GRPC_LLVM_WARNING_FLAGS + [ # TODO(hork): clean up EE offenses "-Wno-missing-field-initializers", "-Wno-non-virtual-dtor", + "-Wno-thread-safety-reference-return", # TODO(ctiller): offense: dump_args. signed to unsigned "-Wno-sign-conversion", @@ -145,9 +146,11 @@ GRPC_LLVM_WINDOWS_WARNING_FLAGS = GRPC_LLVM_WARNING_FLAGS + [ "-Wno-suggest-override", "-Wno-documentation", "-Wno-documentation-unknown-command", + "-Wno-unsafe-buffer-usage", ### possibly bad warnings for this codebase "-Wno-covered-switch-default", + "-Wno-switch-default", "-Wno-switch-enum", "-Wno-c99-extensions", "-Wno-unused-private-field", # GRPC_UNUSED does not appear to work for private fields diff --git a/tools/internal_ci/windows/grpc_build_clang_cl.bat b/tools/internal_ci/windows/grpc_build_clang_cl.bat new file mode 100644 index 00000000000..a4c94ce8b7c --- /dev/null +++ b/tools/internal_ci/windows/grpc_build_clang_cl.bat @@ -0,0 +1,48 @@ +@rem Copyright 2024 gRPC authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem http://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. + +@rem Avoid slow finalization after the script has exited. +@rem See the script's prologue for info on the correct invocation pattern. +setlocal EnableDelayedExpansion +IF "%cd%"=="T:\src" ( + call %~dp0\..\..\..\tools\internal_ci\helper_scripts\move_src_tree_and_respawn_itself.bat %0 + echo respawn script has finished with exitcode !errorlevel! + exit /b !errorlevel! +) +endlocal + +@rem enter repo root +cd /d %~dp0\..\..\.. + +echo "!TIME!: Preparing for the Windows build" +call tools/internal_ci/helper_scripts/prepare_build_windows.bat || exit /b 1 + +@rem Install clang-cl +echo "!TIME!: Installing llvm" +choco install -y llvm --version=18.1.6 +set BAZEL_LLVM="C:\Program Files\LLVM" +clang-cl --version + +@rem Install bazel +@rem Side effect of the tools/bazel script is that it downloads the correct version of bazel binary. +echo "!TIME!: Installing bazel" +mkdir C:\bazel +bash -c "tools/bazel --version && cp tools/bazel-*.exe /c/bazel/bazel.exe" +set PATH=C:\bazel;%PATH% +bazel --version + +echo "!TIME!: Running the bazel build" +bazel build --config=clang-cl --config=windows_opt --build_tag_filters=-no_windows :all src/core:all + +echo "!TIME!: Job Finished" diff --git a/tools/internal_ci/windows/pull_request/grpc_build_clang_cl.cfg b/tools/internal_ci/windows/pull_request/grpc_build_clang_cl.cfg new file mode 100644 index 00000000000..b6ec15b9746 --- /dev/null +++ b/tools/internal_ci/windows/pull_request/grpc_build_clang_cl.cfg @@ -0,0 +1,25 @@ +# Copyright 2024 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Config file for the internal CI (in protobuf text format) + +# Location of the continuous shell script in repository. +build_file: "grpc/tools/internal_ci/windows/grpc_build_clang_cl.bat" +timeout_mins: 120 +action { + define_artifacts { + regex: "**/*sponge_log.*" + regex: "github/grpc/reports/**" + } +}