Unverified Commit c3c2fe48 authored by Uri Baghin's avatar Uri Baghin Committed by GitHub
Browse files

Merge pull request #269481 from boltzmannrain/bazel_5_clang16

bazel_5: fix CLang 16 Werror-s on darwin
parents c5a7460f 781538c5
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -166,6 +166,8 @@ stdenv.mkDerivation rec {
  inherit src;
  inherit sourceRoot;
  patches = [
    ./upb-clang16.patch

    # On Darwin, the last argument to gcc is coming up as an empty string. i.e: ''
    # This is breaking the build of any C target. This patch removes the last
    # argument if it's found to be an empty string.
+83 −0
Original line number Diff line number Diff line
diff --git a/distdir_deps.bzl b/distdir_deps.bzl
index 9068f50537..b3f45e8653 100644
--- a/distdir_deps.bzl
+++ b/distdir_deps.bzl
@@ -110,6 +110,8 @@ DIST_DEPS = {
     "protocolbuffers": {
         "archive": "2de300726a1ba2de9a468468dc5ff9ed17a3215f.tar.gz",
         "sha256": "6a5f67874af66b239b709c572ac1a5a00fdb1b29beaf13c3e6f79b1ba10dc7c4",
+        "patches": ["//:upb-clang16.patch"],
+        "patch_args": ["-p1"],
         "urls": [
             "https://mirror.bazel.build/github.com/protocolbuffers/upb/archive/2de300726a1ba2de9a468468dc5ff9ed17a3215f.tar.gz",
             "https://github.com/protocolbuffers/upb/archive/2de300726a1ba2de9a468468dc5ff9ed17a3215f.tar.gz",
@@ -131,6 +133,7 @@ DIST_DEPS = {
         "patches": [
             "//third_party/grpc:grpc_1.41.0.patch",
             "//third_party/grpc:grpc_1.41.0.win_arm64.patch",
+            "//:grpc-upb-clang16.patch",
         ],
         "used_in": [
             "additional_distfiles",
diff --git a/grpc-upb-clang16.patch b/grpc-upb-clang16.patch
new file mode 100644
index 0000000000..69194099db
--- /dev/null
+++ b/grpc-upb-clang16.patch
@@ -0,0 +1,13 @@
+diff -r -u a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl
+--- a/bazel/grpc_deps.bzl
++++ b/bazel/grpc_deps.bzl
+@@ -340,6 +340,8 @@
+             name = "upb",
+             sha256 = "6a5f67874af66b239b709c572ac1a5a00fdb1b29beaf13c3e6f79b1ba10dc7c4",
+             strip_prefix = "upb-2de300726a1ba2de9a468468dc5ff9ed17a3215f",
++            patches = ["//:upb-clang16.patch"],
++            patch_args = ["-p1"],
+             urls = [
+                 "https://storage.googleapis.com/grpc-bazel-mirror/github.com/protocolbuffers/upb/archive/2de300726a1ba2de9a468468dc5ff9ed17a3215f.tar.gz",
+                 "https://github.com/protocolbuffers/upb/archive/2de300726a1ba2de9a468468dc5ff9ed17a3215f.tar.gz",
+
+diff -r -u a/third_party/upb/bazel/build_defs.bzl b/third_party/upb/bazel/build_defs.bzl
+--- a/third_party/upb/bazel/build_defs.bzl	2021-09-25 04:33:41.000000000 +0200
++++ b/third_party/upb/bazel/build_defs.bzl	2023-11-22 22:27:39.421459688 +0100
+@@ -34,6 +34,7 @@
+         "-Wextra",
+         # "-Wshorten-64-to-32",  # not in GCC (and my Kokoro images doesn't have Clang)
+         "-Werror",
++        "-Wno-gnu-offsetof-extensions",
+         "-Wno-long-long",
+         # copybara:strip_end
+     ],
+@@ -48,6 +49,7 @@
+         "-pedantic",
+         "-Werror=pedantic",
+         "-Wall",
++        "-Wno-gnu-offsetof-extensions",
+         "-Wstrict-prototypes",
+         # GCC (at least) emits spurious warnings for this that cannot be fixed
+         # without introducing redundant initialization (with runtime cost):
diff --git a/upb-clang16.patch b/upb-clang16.patch
new file mode 100644
index 0000000000..f81855181f
--- /dev/null
+++ upb-clang16.patch
@@ -0,0 +1,18 @@
+--- a/bazel/build_defs.bzl
++++ b/bazel/build_defs.bzl
+@@ -34,6 +34,7 @@
+         "-Wextra",
+         # "-Wshorten-64-to-32",  # not in GCC (and my Kokoro images doesn't have Clang)
+         "-Werror",
++        "-Wno-gnu-offsetof-extensions",
+         "-Wno-long-long",
+         # copybara:strip_end
+     ],
+@@ -48,6 +49,7 @@
+         "-pedantic",
+         "-Werror=pedantic",
+         "-Wall",
++        "-Wno-gnu-offsetof-extensions",
+         "-Wstrict-prototypes",
+         # GCC (at least) emits spurious warnings for this that cannot be fixed
+         # without introducing redundant initialization (with runtime cost):