From 449b6e860f52f2e166790295e599826348edd5c2 Mon Sep 17 00:00:00 2001 From: Mike Kruskal Date: Wed, 19 Oct 2022 16:19:03 -0700 Subject: [PATCH] Fixing merge issues --- .bazelrc | 34 ++++++++++++++++ CMakeLists.txt | 4 ++ cmake/protobuf-config.cmake.in | 1 + cmake/utf8_range.cmake | 8 ++-- kokoro/windows/prepare_build_win64.bat | 2 +- protobuf_deps.bzl | 4 +- python/google/protobuf/pyext/message.cc | 1 - python/setup.py | 2 + .../compiler/csharp/csharp_map_field.cc | 2 +- .../generated_message_tctable_lite.cc | 40 +++++++++++-------- third_party/utf8_range | 2 +- 11 files changed, 75 insertions(+), 25 deletions(-) diff --git a/.bazelrc b/.bazelrc index 554440cfe3..de30d6b48c 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1 +1,35 @@ build --cxxopt=-std=c++14 --host_cxxopt=-std=c++14 + +build:dbg --compilation_mode=dbg + +build:opt --compilation_mode=opt + +build:san-common --config=dbg --strip=never --copt=-O0 --copt=-fno-omit-frame-pointer + +build:asan --config=san-common --copt=-fsanitize=address --linkopt=-fsanitize=address +build:asan --copt=-DADDRESS_SANITIZER=1 +# ASAN hits ODR violations with shared linkage due to rules_proto. +build:asan --dynamic_mode=off + +build:msan --config=san-common --copt=-fsanitize=memory --linkopt=-fsanitize=memory +build:msan --copt=-fsanitize-memory-track-origins +build:msan --copt=-fsanitize-memory-use-after-dtor +build:msan --action_env=MSAN_OPTIONS=poison_in_dtor=1 +build:msan --copt=-DMEMORY_SANITIZER=1 + +# Use our instrumented LLVM libc++ in Kokoro. +build:kokoro-msan --config=msan +build:kokoro-msan --linkopt=-L/opt/libcxx_msan/lib +build:kokoro-msan --linkopt=-Wl,-rpath,/opt/libcxx_msan/lib +build:kokoro-msan --cxxopt=-stdlib=libc++ --linkopt=-stdlib=libc++ + + +build:tsan --config=san-common --copt=-fsanitize=thread --linkopt=-fsanitize=thread +build:tsan --copt=-DTHREAD_SANITIZER=1 + +build:ubsan --config=san-common --copt=-fsanitize=undefined --linkopt=-fsanitize=undefined +build:ubsan --action_env=UBSAN_OPTIONS=halt_on_error=1:print_stacktrace=1 +build:ubsan --copt=-DUNDEFINED_SANITIZER=1 +# Workaround for the fact that Bazel links with $CC, not $CXX +# https://github.com/bazelbuild/bazel/issues/11122#issuecomment-613746748 +build:ubsan --copt=-fno-sanitize=function --copt=-fno-sanitize=vptr diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c91c7b447..d490527747 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,10 @@ endif() if(POLICY CMP0063) cmake_policy(SET CMP0063 NEW) endif() +# option() honor variables +if (POLICY CMP0077) + cmake_policy(SET CMP0077 NEW) +endif (POLICY CMP0077) # Project project(protobuf C CXX) diff --git a/cmake/protobuf-config.cmake.in b/cmake/protobuf-config.cmake.in index 1a8d243a74..44805c79a7 100644 --- a/cmake/protobuf-config.cmake.in +++ b/cmake/protobuf-config.cmake.in @@ -4,6 +4,7 @@ include("${CMAKE_CURRENT_LIST_DIR}/protobuf-options.cmake") # Depend packages @_protobuf_FIND_ZLIB@ @_protobuf_FIND_ABSL@ +@_protobuf_FIND_UTF8_RANGE@ # Imported targets include("${CMAKE_CURRENT_LIST_DIR}/protobuf-targets.cmake") diff --git a/cmake/utf8_range.cmake b/cmake/utf8_range.cmake index 90f5ff1ea5..4dcfa4bcca 100644 --- a/cmake/utf8_range.cmake +++ b/cmake/utf8_range.cmake @@ -1,4 +1,4 @@ -set(utf8_range_ENABLE_TESTS OFF) +set(utf8_range_ENABLE_TESTS OFF CACHE BOOL "Disable utf8_range tests") if (NOT EXISTS "${protobuf_SOURCE_DIR}/third_party/utf8_range/CMakeLists.txt") message(FATAL_ERROR @@ -8,5 +8,7 @@ if (NOT EXISTS "${protobuf_SOURCE_DIR}/third_party/utf8_range/CMakeLists.txt") " git submodule update --init --recursive\n") endif() -set(utf8_range_ENABLE_INSTALL ${protobuf_INSTALL}) -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/utf8_range third_party/utf8_range) \ No newline at end of file +set(utf8_range_ENABLE_INSTALL ${protobuf_INSTALL} CACHE BOOL "Set install") +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/utf8_range third_party/utf8_range) + +set(_protobuf_FIND_UTF8_RANGE "if(NOT TARGET utf8_range)\n find_package(utf8_range CONFIG)\nendif()") diff --git a/kokoro/windows/prepare_build_win64.bat b/kokoro/windows/prepare_build_win64.bat index d8eb2a2b30..37d27ac7a7 100644 --- a/kokoro/windows/prepare_build_win64.bat +++ b/kokoro/windows/prepare_build_win64.bat @@ -13,4 +13,4 @@ call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary @rem Convert Windows line breaks to Unix line breaks @rem This allows text-matching tests to pass -find . -type f -print0 | xargs -0 d2u +@find . -type f -print0 | xargs -0 d2u diff --git a/protobuf_deps.bzl b/protobuf_deps.bzl index 47d6b251d4..82e7bf279d 100644 --- a/protobuf_deps.bzl +++ b/protobuf_deps.bzl @@ -67,8 +67,8 @@ def protobuf_deps(): _github_archive( name = "utf8_range", repo = "https://github.com/protocolbuffers/utf8_range", - commit = "a67b76f9f40107f2c78a5aa860bb6ce37ed83d85", - sha256 = "de5f99318f3b5073dd99f3d4ca31e00e90a86cc400fb375e2147ae1fd41711ed", + commit = "de0b4a8ff9b5d4c98108bdfe723291a33c52c54f", + sha256 = "5da960e5e5d92394c809629a03af3c7709d2d3d0ca731dacb3a9fb4bf28f7702", ) if not native.existing_rule("rules_cc"): diff --git a/python/google/protobuf/pyext/message.cc b/python/google/protobuf/pyext/message.cc index 532fc3cb4e..f4dd00dabf 100644 --- a/python/google/protobuf/pyext/message.cc +++ b/python/google/protobuf/pyext/message.cc @@ -70,7 +70,6 @@ #include "google/protobuf/pyext/unknown_field_set.h" #include "google/protobuf/pyext/unknown_fields.h" #include "google/protobuf/util/message_differencer.h" -#include "strings/util.h" #include "absl/strings/string_view.h" #include "google/protobuf/io/coded_stream.h" #include "google/protobuf/io/strtod.h" diff --git a/python/setup.py b/python/setup.py index 7a553594a7..9a95ff8f88 100755 --- a/python/setup.py +++ b/python/setup.py @@ -297,6 +297,8 @@ if __name__ == '__main__': extra_objects = ['../bazel-bin/src/google/protobuf/libprotobuf.a'] else: extra_objects = ['../libprotobuf.a'] + extra_objects += list( + glob.iglob('../third_party/utf8_range/*.a')) # Repeat all of these enough times to eliminate order-dependence. extra_objects += list( glob.iglob('../third_party/abseil-cpp/absl/**/*.a')) diff --git a/src/google/protobuf/compiler/csharp/csharp_map_field.cc b/src/google/protobuf/compiler/csharp/csharp_map_field.cc index efe87f2a6a..50d8b1d828 100644 --- a/src/google/protobuf/compiler/csharp/csharp_map_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_map_field.cc @@ -88,7 +88,7 @@ void MapFieldGenerator::GenerateMembers(io::Printer* printer) { void MapFieldGenerator::GenerateMergingCode(io::Printer* printer) { printer->Print( variables_, - "$name$_.Add(other.$name$_);\n"); + "$name$_.MergeFrom(other.$name$_);\n"); } void MapFieldGenerator::GenerateParsingCode(io::Printer* printer) { diff --git a/src/google/protobuf/generated_message_tctable_lite.cc b/src/google/protobuf/generated_message_tctable_lite.cc index a2a6c5720c..ea8f4fb005 100644 --- a/src/google/protobuf/generated_message_tctable_lite.cc +++ b/src/google/protobuf/generated_message_tctable_lite.cc @@ -297,23 +297,31 @@ const char* TcParser::MiniParse(PROTOBUF_TC_PARAM_DECL) { &Error, // kSplitMask | FieldKind::kFkMap }; // Just to be sure we got the order right, above. - static_assert(0 == FieldKind::kFkNone); - static_assert(1 == FieldKind::kFkVarint); - static_assert(2 == FieldKind::kFkPackedVarint); - static_assert(3 == FieldKind::kFkFixed); - static_assert(4 == FieldKind::kFkPackedFixed); - static_assert(5 == FieldKind::kFkString); - static_assert(6 == FieldKind::kFkMessage); - static_assert(7 == FieldKind::kFkMap); + static_assert(0 == FieldKind::kFkNone, "Invalid table order"); + static_assert(1 == FieldKind::kFkVarint, "Invalid table order"); + static_assert(2 == FieldKind::kFkPackedVarint, "Invalid table order"); + static_assert(3 == FieldKind::kFkFixed, "Invalid table order"); + static_assert(4 == FieldKind::kFkPackedFixed, "Invalid table order"); + static_assert(5 == FieldKind::kFkString, "Invalid table order"); + static_assert(6 == FieldKind::kFkMessage, "Invalid table order"); + static_assert(7 == FieldKind::kFkMap, "Invalid table order"); - static_assert(8 == (+field_layout::kSplitMask | FieldKind::kFkNone)); - static_assert(9 == (+field_layout::kSplitMask | FieldKind::kFkVarint)); - static_assert(10 == (+field_layout::kSplitMask | FieldKind::kFkPackedVarint)); - static_assert(11 == (+field_layout::kSplitMask | FieldKind::kFkFixed)); - static_assert(12 == (+field_layout::kSplitMask | FieldKind::kFkPackedFixed)); - static_assert(13 == (+field_layout::kSplitMask | FieldKind::kFkString)); - static_assert(14 == (+field_layout::kSplitMask | FieldKind::kFkMessage)); - static_assert(15 == (+field_layout::kSplitMask | FieldKind::kFkMap)); + static_assert(8 == (+field_layout::kSplitMask | FieldKind::kFkNone), + "Invalid table order"); + static_assert(9 == (+field_layout::kSplitMask | FieldKind::kFkVarint), + "Invalid table order"); + static_assert(10 == (+field_layout::kSplitMask | FieldKind::kFkPackedVarint), + "Invalid table order"); + static_assert(11 == (+field_layout::kSplitMask | FieldKind::kFkFixed), + "Invalid table order"); + static_assert(12 == (+field_layout::kSplitMask | FieldKind::kFkPackedFixed), + "Invalid table order"); + static_assert(13 == (+field_layout::kSplitMask | FieldKind::kFkString), + "Invalid table order"); + static_assert(14 == (+field_layout::kSplitMask | FieldKind::kFkMessage), + "Invalid table order"); + static_assert(15 == (+field_layout::kSplitMask | FieldKind::kFkMap), + "Invalid table order"); TailCallParseFunc parse_fn = kMiniParseTable[field_type]; PROTOBUF_MUSTTAIL return parse_fn(PROTOBUF_TC_PARAM_PASS); diff --git a/third_party/utf8_range b/third_party/utf8_range index a67b76f9f4..de0b4a8ff9 160000 --- a/third_party/utf8_range +++ b/third_party/utf8_range @@ -1 +1 @@ -Subproject commit a67b76f9f40107f2c78a5aa860bb6ce37ed83d85 +Subproject commit de0b4a8ff9b5d4c98108bdfe723291a33c52c54f