diff --git a/pkgs/development/tools/build-managers/bazel/bazel_4/default.nix b/pkgs/development/tools/build-managers/bazel/bazel_4/default.nix index 652e7e32bc509..f123eff4787e3 100644 --- a/pkgs/development/tools/build-managers/bazel/bazel_4/default.nix +++ b/pkgs/development/tools/build-managers/bazel/bazel_4/default.nix @@ -204,6 +204,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. @@ -399,6 +401,8 @@ stdenv.mkDerivation rec { # libcxx includes aren't added by libcxx hook # https://github.com/NixOS/nixpkgs/pull/41589 export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -isystem ${lib.getDev libcxx}/include/c++/v1" + # for CLang 16 compatibility in third_party/{zlib}, external/{upb} dependencies + export NIX_CFLAGS_COMPILE+=" -Wno-implicit-function-declaration -Wno-gnu-offsetof-extensions" # don't use system installed Xcode to run clang, use Nix clang instead sed -i -E "s;/usr/bin/xcrun (--sdk macosx )?clang;${stdenv.cc}/bin/clang $NIX_CFLAGS_COMPILE $(bazelLinkFlags) -framework CoreFoundation;g" \ diff --git a/pkgs/development/tools/build-managers/bazel/bazel_4/upb-clang16.patch b/pkgs/development/tools/build-managers/bazel/bazel_4/upb-clang16.patch new file mode 100644 index 0000000000000..34bb71747b171 --- /dev/null +++ b/pkgs/development/tools/build-managers/bazel/bazel_4/upb-clang16.patch @@ -0,0 +1,57 @@ +diff --git a/WORKSPACE b/WORKSPACE +index 2d995f095e..55fddef663 100644 +--- a/WORKSPACE ++++ b/WORKSPACE +@@ -1232,7 +1232,7 @@ register_toolchains("//src/main/res:empty_rc_toolchain") + http_archive( + name = "com_github_grpc_grpc", + patch_args = ["-p1"], +- patches = ["//third_party/grpc:grpc_1.33.1.patch"], ++ patches = ["//third_party/grpc:grpc_1.33.1.patch", "//:grpc-upb-clang16.patch"], + sha256 = "58eaee5c0f1bd0b92ebe1fa0606ec8f14798500620e7444726afcaf65041cb63", + strip_prefix = "grpc-1.33.1", + urls = [ +diff --git a/grpc-upb-clang16.patch b/grpc-upb-clang16.patch +new file mode 100644 +index 0000000000..ae6a7ad0e0 +--- /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 ++@@ -285,6 +285,8 @@ ++ name = "upb", ++ sha256 = "7992217989f3156f8109931c1fc6db3434b7414957cb82371552377beaeb9d6c", ++ strip_prefix = "upb-382d5afc60e05470c23e8de19b19fc5ad231e732", +++ patches = ["//:upb-clang16.patch"], +++ patch_args = ["-p1"], ++ urls = [ ++ "https://storage.googleapis.com/grpc-bazel-mirror/github.com/protocolbuffers/upb/archive/382d5afc60e05470c23e8de19b19fc5ad231e732.tar.gz", ++ "https://github.com/protocolbuffers/upb/archive/382d5afc60e05470c23e8de19b19fc5ad231e732.tar.gz", ++ +diff --git a/upb-clang16.patch b/upb-clang16.patch +new file mode 100644 +index 0000000000..b799737fac +--- /dev/null ++++ b/upb-clang16.patch +@@ -0,0 +1,18 @@ ++--- a/BUILD +++++ b/BUILD ++@@ -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 ++ ] ++@@ -42,6 +43,7 @@ ++ # copybara:strip_for_google3_begin ++ "-pedantic", ++ "-Werror=pedantic", +++ "-Wno-gnu-offsetof-extensions", ++ "-Wstrict-prototypes", ++ # copybara:strip_end ++ ] + diff --git a/pkgs/development/tools/build-managers/bazel/bazel_5/default.nix b/pkgs/development/tools/build-managers/bazel/bazel_5/default.nix index 8382f9d4be352..29288a1c78f81 100644 --- a/pkgs/development/tools/build-managers/bazel/bazel_5/default.nix +++ b/pkgs/development/tools/build-managers/bazel/bazel_5/default.nix @@ -364,6 +364,8 @@ stdenv.mkDerivation rec { # libcxx includes aren't added by libcxx hook # https://github.com/NixOS/nixpkgs/pull/41589 export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -isystem ${lib.getDev libcxx}/include/c++/v1" + # for CLang 16 compatibility in external/{absl,upb} dependencies and in execlog + export NIX_CFLAGS_COMPILE+=" -Wno-deprecated-builtins -Wno-gnu-offsetof-extensions -Wno-implicit-function-declaration" # don't use system installed Xcode to run clang, use Nix clang instead sed -i -E "s;/usr/bin/xcrun (--sdk macosx )?clang;${stdenv.cc}/bin/clang $NIX_CFLAGS_COMPILE $(bazelLinkFlags) -framework CoreFoundation;g" \