bazel_5: fix CLang 16 Werror-s on darwin

Fixing `bazel_5` after #234710

Error example
https://hydra.nixos.org/build/241240612/nixlog/1
```
external/com_google_absl/absl/meta/type_traits.h:560:8: error: builtin __has_trivial_assign is deprecated; use __is_trivially_assignable instead [-Werror,-Wdeprecated-builtins]
(__has_trivial_assign(ExtentsRemoved) || !kIsCopyOrMoveAssignable) &&
```

Similar to #269297, and remaining `bazel_4` is WIP for another PR

+87
+4
pkgs/development/tools/build-managers/bazel/bazel_5/default.nix
··· 166 166 inherit src; 167 167 inherit sourceRoot; 168 168 patches = [ 169 + ./upb-clang16.patch 170 + 169 171 # On Darwin, the last argument to gcc is coming up as an empty string. i.e: '' 170 172 # This is breaking the build of any C target. This patch removes the last 171 173 # argument if it's found to be an empty string. ··· 364 366 # libcxx includes aren't added by libcxx hook 365 367 # https://github.com/NixOS/nixpkgs/pull/41589 366 368 export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -isystem ${lib.getDev libcxx}/include/c++/v1" 369 + # for CLang 16 compatibility in external/{absl,upb} dependencies and in execlog 370 + export NIX_CFLAGS_COMPILE+=" -Wno-deprecated-builtins -Wno-gnu-offsetof-extensions -Wno-implicit-function-declaration" 367 371 368 372 # don't use system installed Xcode to run clang, use Nix clang instead 369 373 sed -i -E "s;/usr/bin/xcrun (--sdk macosx )?clang;${stdenv.cc}/bin/clang $NIX_CFLAGS_COMPILE $(bazelLinkFlags) -framework CoreFoundation;g" \
+83
pkgs/development/tools/build-managers/bazel/bazel_5/upb-clang16.patch
··· 1 + diff --git a/distdir_deps.bzl b/distdir_deps.bzl 2 + index 9068f50537..b3f45e8653 100644 3 + --- a/distdir_deps.bzl 4 + +++ b/distdir_deps.bzl 5 + @@ -110,6 +110,8 @@ DIST_DEPS = { 6 + "protocolbuffers": { 7 + "archive": "2de300726a1ba2de9a468468dc5ff9ed17a3215f.tar.gz", 8 + "sha256": "6a5f67874af66b239b709c572ac1a5a00fdb1b29beaf13c3e6f79b1ba10dc7c4", 9 + + "patches": ["//:upb-clang16.patch"], 10 + + "patch_args": ["-p1"], 11 + "urls": [ 12 + "https://mirror.bazel.build/github.com/protocolbuffers/upb/archive/2de300726a1ba2de9a468468dc5ff9ed17a3215f.tar.gz", 13 + "https://github.com/protocolbuffers/upb/archive/2de300726a1ba2de9a468468dc5ff9ed17a3215f.tar.gz", 14 + @@ -131,6 +133,7 @@ DIST_DEPS = { 15 + "patches": [ 16 + "//third_party/grpc:grpc_1.41.0.patch", 17 + "//third_party/grpc:grpc_1.41.0.win_arm64.patch", 18 + + "//:grpc-upb-clang16.patch", 19 + ], 20 + "used_in": [ 21 + "additional_distfiles", 22 + diff --git a/grpc-upb-clang16.patch b/grpc-upb-clang16.patch 23 + new file mode 100644 24 + index 0000000000..69194099db 25 + --- /dev/null 26 + +++ b/grpc-upb-clang16.patch 27 + @@ -0,0 +1,13 @@ 28 + +diff -r -u a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl 29 + +--- a/bazel/grpc_deps.bzl 30 + ++++ b/bazel/grpc_deps.bzl 31 + +@@ -340,6 +340,8 @@ 32 + + name = "upb", 33 + + sha256 = "6a5f67874af66b239b709c572ac1a5a00fdb1b29beaf13c3e6f79b1ba10dc7c4", 34 + + strip_prefix = "upb-2de300726a1ba2de9a468468dc5ff9ed17a3215f", 35 + ++ patches = ["//:upb-clang16.patch"], 36 + ++ patch_args = ["-p1"], 37 + + urls = [ 38 + + "https://storage.googleapis.com/grpc-bazel-mirror/github.com/protocolbuffers/upb/archive/2de300726a1ba2de9a468468dc5ff9ed17a3215f.tar.gz", 39 + + "https://github.com/protocolbuffers/upb/archive/2de300726a1ba2de9a468468dc5ff9ed17a3215f.tar.gz", 40 + + 41 + +diff -r -u a/third_party/upb/bazel/build_defs.bzl b/third_party/upb/bazel/build_defs.bzl 42 + +--- a/third_party/upb/bazel/build_defs.bzl 2021-09-25 04:33:41.000000000 +0200 43 + ++++ b/third_party/upb/bazel/build_defs.bzl 2023-11-22 22:27:39.421459688 +0100 44 + +@@ -34,6 +34,7 @@ 45 + + "-Wextra", 46 + + # "-Wshorten-64-to-32", # not in GCC (and my Kokoro images doesn't have Clang) 47 + + "-Werror", 48 + ++ "-Wno-gnu-offsetof-extensions", 49 + + "-Wno-long-long", 50 + + # copybara:strip_end 51 + + ], 52 + +@@ -48,6 +49,7 @@ 53 + + "-pedantic", 54 + + "-Werror=pedantic", 55 + + "-Wall", 56 + ++ "-Wno-gnu-offsetof-extensions", 57 + + "-Wstrict-prototypes", 58 + + # GCC (at least) emits spurious warnings for this that cannot be fixed 59 + + # without introducing redundant initialization (with runtime cost): 60 + diff --git a/upb-clang16.patch b/upb-clang16.patch 61 + new file mode 100644 62 + index 0000000000..f81855181f 63 + --- /dev/null 64 + +++ upb-clang16.patch 65 + @@ -0,0 +1,18 @@ 66 + +--- a/bazel/build_defs.bzl 67 + ++++ b/bazel/build_defs.bzl 68 + +@@ -34,6 +34,7 @@ 69 + + "-Wextra", 70 + + # "-Wshorten-64-to-32", # not in GCC (and my Kokoro images doesn't have Clang) 71 + + "-Werror", 72 + ++ "-Wno-gnu-offsetof-extensions", 73 + + "-Wno-long-long", 74 + + # copybara:strip_end 75 + + ], 76 + +@@ -48,6 +49,7 @@ 77 + + "-pedantic", 78 + + "-Werror=pedantic", 79 + + "-Wall", 80 + ++ "-Wno-gnu-offsetof-extensions", 81 + + "-Wstrict-prototypes", 82 + + # GCC (at least) emits spurious warnings for this that cannot be fixed 83 + + # without introducing redundant initialization (with runtime cost):