From b48f821048df6009f1f8fc99fba104d428554b2f Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Thu, 11 Jun 2020 13:00:14 -0700 Subject: [PATCH] Squashed 'third_party/upb/' changes from 363e39c171..92e63da733 92e63da733 Merge pull request #295 from haberman/mac-compile-fix e179dda212 Added initialization of all members to satisfy compiler warnings. f7fcc0df37 Fix divide by zero vs2019 compilation error #293 (#294) 7d38c201fa Enabled conformance tests to run under ASAN. This apears to work now. (#292) 0dc2394da5 Changes to support import into google3 (#291) git-subtree-dir: third_party/upb git-subtree-split: 92e63da73328d01b417cf26c2de7b0a27a0f83af --- BUILD | 20 +++++++++++++++----- bazel/build_defs.bzl | 3 ++- bazel/upb_proto_library.bzl | 2 +- bazel/workspace_deps.bzl | 2 +- kokoro/ubuntu/build.sh | 2 +- tests/conformance_upb_failures.txt | 2 +- upb/def.c | 2 +- upb/json_decode.c | 2 +- upb/json_decode.h | 1 - upb/port_def.inc | 5 +++++ upb/port_undef.inc | 1 + 11 files changed, 29 insertions(+), 13 deletions(-) diff --git a/BUILD b/BUILD index bcecd387af4..cfc734a9b4e 100644 --- a/BUILD +++ b/BUILD @@ -1,7 +1,3 @@ -load( - "@rules_proto//proto:defs.bzl", - "proto_library", -) load( "//bazel:build_defs.bzl", "generated_file_staleness_test", @@ -14,10 +10,17 @@ load( "upb_proto_library", "upb_proto_reflection_library", ) + +# copybara:strip_for_google3_begin +load( + "@rules_proto//proto:defs.bzl", + "proto_library", +) load( "//:upb/bindings/lua/lua_proto_library.bzl", "lua_proto_library", ) +# copybara:strip_end licenses(["notice"]) # BSD (Google-authored w/ possible external contributions) @@ -627,11 +630,15 @@ cc_binary( srcs = [ "tests/conformance_upb.c", ], + data = [ + "tests/conformance_upb_failures.txt", + ], copts = select({ ":windows": [], "//conditions:default": COPTS, }) + ["-Ibazel-out/k8-fastbuild/bin"], deps = [ + ":port", ":conformance_proto_upb", ":conformance_proto_upbdefs", ":json", @@ -646,7 +653,10 @@ cc_binary( make_shell_script( name = "gen_test_conformance_upb", out = "test_conformance_upb.sh", - contents = "external/com_google_protobuf/conformance_test_runner --enforce_recommended ./conformance_upb", + contents = "external/com_google_protobuf/conformance_test_runner " + + " --enforce_recommended " + + " --failure_list ./tests/conformance_upb_failures.txt" + + " ./conformance_upb", ) sh_test( diff --git a/bazel/build_defs.bzl b/bazel/build_defs.bzl index c51aded057d..121ae270c9d 100644 --- a/bazel/build_defs.bzl +++ b/bazel/build_defs.bzl @@ -50,7 +50,8 @@ def _remove_suffix(str, suffix): return str[:-len(suffix)] def make_shell_script(name, contents, out): - contents = (runfiles_init + contents).replace("$", "$$") + contents = runfiles_init + contents # copybara:strip_for_google3 + contents = contents.replace("$", "$$") native.genrule( name = "gen_" + name, outs = [out], diff --git a/bazel/upb_proto_library.bzl b/bazel/upb_proto_library.bzl index 3499ea94860..4dce00826dc 100644 --- a/bazel/upb_proto_library.bzl +++ b/bazel/upb_proto_library.bzl @@ -5,7 +5,7 @@ load("@bazel_skylib//lib:paths.bzl", "paths") load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain") -load("@rules_proto//proto:defs.bzl", "ProtoInfo") +load("@rules_proto//proto:defs.bzl", "ProtoInfo") # copybara:strip_for_google3 # Generic support code ######################################################### diff --git a/bazel/workspace_deps.bzl b/bazel/workspace_deps.bzl index 5e3e8a69005..967dfe36d92 100644 --- a/bazel/workspace_deps.bzl +++ b/bazel/workspace_deps.bzl @@ -16,7 +16,7 @@ def upb_deps(): git_repository, name = "com_google_protobuf", remote = "https://github.com/protocolbuffers/protobuf.git", - commit = "62832897c3cf14c93b91c412f7e64086cd272cb7", # Need to use Git until proto3 optional is released + commit = "5f5efe50c5bef20042645b51a697f58b0704ac89", # Need to use Git until proto3 optional is released ) maybe( diff --git a/kokoro/ubuntu/build.sh b/kokoro/ubuntu/build.sh index 3888d15f6ae..c0261a75886 100644 --- a/kokoro/ubuntu/build.sh +++ b/kokoro/ubuntu/build.sh @@ -24,7 +24,7 @@ bazel test --test_output=errors :all if [[ $(uname) = "Linux" ]]; then # Verify the ASAN build. Have to exclude test_conformance_upb as protobuf # currently leaks memory in the conformance test runner. - bazel test --copt=-fsanitize=address --linkopt=-fsanitize=address --test_output=errors -- :all -:test_conformance_upb + bazel test --copt=-fsanitize=address --linkopt=-fsanitize=address --test_output=errors :all # Verify the UBSan build. Have to exclude Lua as the version we are using # fails some UBSan tests. diff --git a/tests/conformance_upb_failures.txt b/tests/conformance_upb_failures.txt index 05aab585e77..d9290df9877 100644 --- a/tests/conformance_upb_failures.txt +++ b/tests/conformance_upb_failures.txt @@ -1 +1 @@ -Required.ProtobufInput.PrematureEofInSubmessageValue.MESSAGE +Recommended.Proto2.JsonInput.FieldNameExtension.Validator diff --git a/upb/def.c b/upb/def.c index 10f6b94bf1e..8f143354001 100644 --- a/upb/def.c +++ b/upb/def.c @@ -1802,7 +1802,7 @@ static bool build_filedef( const google_protobuf_FieldDescriptorProto *const *exts; const upb_strview* strs; size_t i, n; - decl_counts counts = {0}; + decl_counts counts = {0, 0, 0}; count_types_in_file(file_proto, &counts); diff --git a/upb/json_decode.c b/upb/json_decode.c index 301f16a1453..9c70173165e 100644 --- a/upb/json_decode.c +++ b/upb/json_decode.c @@ -733,7 +733,7 @@ static upb_msgval jsondec_double(jsondec *d, const upb_fielddef *f) { case JD_STRING: str = jsondec_string(d); if (jsondec_streql(str, "NaN")) { - val.double_val = 0.0 / 0.0; + val.double_val = UPB_NAN; } else if (jsondec_streql(str, "Infinity")) { val.double_val = UPB_INFINITY; } else if (jsondec_streql(str, "-Infinity")) { diff --git a/upb/json_decode.h b/upb/json_decode.h index 01ab9580f05..a0ba1ee596c 100644 --- a/upb/json_decode.h +++ b/upb/json_decode.h @@ -3,7 +3,6 @@ #define UPB_JSONDECODE_H_ #include "upb/def.h" -#include "upb/msg.h" #ifdef __cplusplus extern "C" { diff --git a/upb/port_def.inc b/upb/port_def.inc index 61675d37c05..9e9c506597f 100644 --- a/upb/port_def.inc +++ b/upb/port_def.inc @@ -172,3 +172,8 @@ int msvc_vsnprintf(char* s, size_t n, const char* format, va_list arg); #else #define UPB_INFINITY (1.0 / 0.0) #endif +#ifdef NAN +#define UPB_NAN NAN +#else +#define UPB_NAN (0.0 / 0.0) +#endif diff --git a/upb/port_undef.inc b/upb/port_undef.inc index c322d471608..c2b5f4a322b 100644 --- a/upb/port_undef.inc +++ b/upb/port_undef.inc @@ -21,6 +21,7 @@ #undef UPB_ASSERT_DEBUGVAR #undef UPB_UNREACHABLE #undef UPB_INFINITY +#undef UPB_NAN #undef UPB_MSVC_VSNPRINTF #undef _upb_snprintf #undef _upb_vsnprintf