···11+From 8b531c41f956b27e4be32b430db2e7a44e0cdd3e Mon Sep 17 00:00:00 200122+From: Luke Granger-Brown <git@lukegb.com>33+Date: Thu, 7 Jan 2021 11:09:18 +000044+Subject: [PATCH] Add upb patch to make it compile under GCC1055+66+---77+ bazel/repositories.bzl | 5 +++-88+ bazel/upb2.patch | 55 ++++++++++++++++++++++++++++++++++++++++++99+ 2 files changed, 59 insertions(+), 1 deletion(-)1010+ create mode 100644 bazel/upb2.patch1111+1212+diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl1313+index 64d61ea49..c6cadc9df 1006441414+--- a/bazel/repositories.bzl1515++++ b/bazel/repositories.bzl1616+@@ -811,7 +811,10 @@ def _com_github_grpc_grpc():1717+ def _upb():1818+ _repository_impl(1919+ name = "upb",2020+- patches = ["@envoy//bazel:upb.patch"],2121++ patches = [2222++ "@envoy//bazel:upb.patch",2323++ "@envoy//bazel:upb2.patch",2424++ ],2525+ patch_args = ["-p1"],2626+ )2727+2828+diff --git a/bazel/upb2.patch b/bazel/upb2.patch2929+new file mode 1006443030+index 000000000..6e436c61b3131+--- /dev/null3232++++ b/bazel/upb2.patch3333+@@ -0,0 +1,55 @@3434++From 9bd23dab4240b015321a53c45b3c9e4847fbf020 Mon Sep 17 00:00:00 20013535++From: Joshua Haberman <jhaberman@gmail.com>3636++Date: Tue, 7 Apr 2020 15:22:11 -07003737++Subject: [PATCH] Changed upb status to suit GCC10's warning about strncpy().3838++ (#268)3939++4040++Added tests for all cases. Also removed ellipses from truncated4141++messages, they were more trouble than they are worth.4242++---4343++ tests/test_generated_code.c | 33 +++++++++++++++++++++++++++++++++4444++ upb/upb.c | 17 +++--------------4545++ 2 files changed, 36 insertions(+), 14 deletions(-)4646++4747++diff --git a/upb/upb.c b/upb/upb.c4848++index cb2cdfd9d..258192d79 1006444949++--- a/upb/upb.c5050+++++ b/upb/upb.c5151++@@ -11,17 +11,6 @@5252++ 5353++ #include "upb/port_def.inc"5454++ 5555++-/* Guarantee null-termination and provide ellipsis truncation.5656++- * It may be tempting to "optimize" this by initializing these final5757++- * four bytes up-front and then being careful never to overwrite them,5858++- * this is safer and simpler. */5959++-static void nullz(upb_status *status) {6060++- const char *ellipsis = "...";6161++- size_t len = strlen(ellipsis);6262++- UPB_ASSERT(sizeof(status->msg) > len);6363++- memcpy(status->msg + sizeof(status->msg) - len, ellipsis, len);6464++-}6565++-6666++ /* upb_status *****************************************************************/6767++ 6868++ void upb_status_clear(upb_status *status) {6969++@@ -37,8 +26,8 @@ const char *upb_status_errmsg(const upb_status *status) { return status->msg; }7070++ void upb_status_seterrmsg(upb_status *status, const char *msg) {7171++ if (!status) return;7272++ status->ok = false;7373++- strncpy(status->msg, msg, sizeof(status->msg));7474++- nullz(status);7575+++ strncpy(status->msg, msg, UPB_STATUS_MAX_MESSAGE - 1);7676+++ status->msg[UPB_STATUS_MAX_MESSAGE - 1] = '\0';7777++ }7878++ 7979++ void upb_status_seterrf(upb_status *status, const char *fmt, ...) {8080++@@ -52,7 +41,7 @@ void upb_status_vseterrf(upb_status *status, const char *fmt, va_list args) {8181++ if (!status) return;8282++ status->ok = false;8383++ _upb_vsnprintf(status->msg, sizeof(status->msg), fmt, args);8484++- nullz(status);8585+++ status->msg[UPB_STATUS_MAX_MESSAGE - 1] = '\0';8686++ }8787++ 8888++ /* upb_alloc ******************************************************************/8989+-- 9090+2.29.29191+
+119
pkgs/servers/http/envoy/default.nix
···11+{ buildBazelPackage22+, fetchFromGitHub33+, stdenv44+, cmake55+, go66+, ninja77+, python388+}:99+1010+let1111+ srcVer = {1212+ # We need the commit hash, since Bazel stamps the build with it.1313+ # However, the version string is more useful for end-users.1414+ # These are contained in a attrset of their own to make it obvious that1515+ # people should update both.1616+ version = "1.16.2";1717+ commit = "e98e41a8e168af7acae8079fc0cd68155f699aa3";1818+ };1919+in2020+buildBazelPackage rec {2121+ pname = "envoy";2222+ version = srcVer.version;2323+ src = fetchFromGitHub {2424+ owner = "envoyproxy";2525+ repo = "envoy";2626+ rev = srcVer.commit;2727+ hash = "sha256-aWVMRKFCZzf9/96NRPCP4jiW38DJhXyi0gEqW7uIpnQ=";2828+2929+ extraPostFetch = ''3030+ chmod -R +w $out3131+ rm $out/.bazelversion3232+ echo ${srcVer.commit} > $out/SOURCE_VERSION3333+ sed -i 's/GO_VERSION = ".*"/GO_VERSION = "host"/g' $out/bazel/dependency_imports.bzl3434+ '';3535+ };3636+3737+ patches = [3838+ # Quiche needs to be updated to compile under newer GCC.3939+ # This is a manual backport of http://github.com/envoyproxy/envoy/pull/13949.4040+ ./0001-quiche-update-QUICHE-tar-13949.patch4141+4242+ # upb needs to be updated to compile under newer GCC.4343+ # This is a manual backport of https://github.com/protocolbuffers/upb/commit/9bd23dab4240b015321a53c45b3c9e4847fbf020.4444+ ./0002-Add-upb-patch-to-make-it-compile-under-GCC10.patch4545+ ];4646+ postPatch = ''4747+ sed -i 's,#!/usr/bin/env python3,#!${python3}/bin/python,' bazel/foreign_cc/luajit.patch4848+ '';4949+5050+ nativeBuildInputs = [5151+ cmake5252+ python35353+ go5454+ ninja5555+ ];5656+5757+ fetchAttrs = {5858+ sha256 = "sha256-mct7anzErY9eSujZyGORfRJqzAO9XuFAv04DS8VRZKM=";5959+ dontUseCmakeConfigure = true;6060+ preInstall = ''6161+ # Strip out the path to the build location (by deleting the comment line).6262+ find $bazelOut/external -name requirements.bzl | while read requirements; do6363+ sed -i '/# Generated from /d' "$requirements"6464+ done6565+6666+ # Remove references to paths in the Nix store.6767+ sed -i \6868+ -e 's,${python3},__NIXPYTHON__,' \6969+ -e 's,${stdenv.shellPackage},__NIXSHELL__,' \7070+ $bazelOut/external/com_github_luajit_luajit/build.py \7171+ $bazelOut/external/local_config_sh/BUILD7272+ rm -r $bazelOut/external/go_sdk7373+7474+ # Replace some wheels which are only used for tests with empty files;7575+ # they're nondeterministically built and packed.7676+ >$bazelOut/external/config_validation_pip3/PyYAML-5.3.1-cp38-cp38-linux_x86_64.whl7777+ >$bazelOut/external/protodoc_pip3/PyYAML-5.3.1-cp38-cp38-linux_x86_64.whl7878+ >$bazelOut/external/thrift_pip3/thrift-0.13.0-cp38-cp38-linux_x86_64.whl7979+ '';8080+ };8181+ buildAttrs = {8282+ dontUseCmakeConfigure = true;8383+ dontUseNinjaInstall = true;8484+ preConfigure = ''8585+ sed -i 's,#!/usr/bin/env bash,#!${stdenv.shell},' $bazelOut/external/rules_foreign_cc/tools/build_defs/framework.bzl8686+8787+ # Add paths to Nix store back.8888+ sed -i \8989+ -e 's,__NIXPYTHON__,${python3},' \9090+ -e 's,__NIXSHELL__,${stdenv.shellPackage},' \9191+ $bazelOut/external/com_github_luajit_luajit/build.py \9292+ $bazelOut/external/local_config_sh/BUILD9393+ '';9494+ installPhase = ''9595+ install -Dm0755 bazel-bin/source/exe/envoy-static $out/bin/envoy9696+ '';9797+ };9898+9999+ fetchConfigured = true;100100+ removeRulesCC = false;101101+ removeLocalConfigCc = true;102102+ removeLocal = false;103103+ bazelTarget = "//source/exe:envoy-static";104104+ bazelBuildFlags = [105105+ "-c opt"106106+ "--spawn_strategy=standalone"107107+ "--noexperimental_strict_action_env"108108+ "--cxxopt=-Wno-maybe-uninitialized"109109+ "--cxxopt=-Wno-uninitialized"110110+ ];111111+112112+ meta = with stdenv.lib; {113113+ homepage = "https://envoyproxy.io";114114+ description = "Cloud-native edge and service proxy";115115+ license = licenses.asl20;116116+ maintainers = with maintainers; [ lukegb ];117117+ platforms = [ "x86_64-linux" ]; # Other platforms will generate different fetch hashes.118118+ };119119+}