Skip to content

Commit

Permalink
Merge pull request #163 from h-vetinari/backports
Browse files Browse the repository at this point in the history
carry relevant upstream backports for 23.x
  • Loading branch information
h-vetinari authored Jun 6, 2023
2 parents ac8134a + 5e9b852 commit 39d3df4
Show file tree
Hide file tree
Showing 11 changed files with 336 additions and 66 deletions.
9 changes: 5 additions & 4 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ source:
- patches/0003-Enable-the-selection-of-system-provided-jsoncpp-1257.patch
- patches/0004-always-look-for-shared-abseil-builds.patch
- patches/0005-be-more-lenient-with-abseil-version.patch
- patches/0006-add-PROTOBUF_EXPORT-for-google-protobuf-io-SafeDoubl.patch
# backport https://github.com/protocolbuffers/protobuf/pull/12978
- patches/0007-use-namespaced-abseil-dll-imported-target-backport-12978.patch
# backports from https://github.com/protocolbuffers/protobuf/pull/12987 (3 commits)
- patches/0006-feat-workaround-for-DOMAIN-macro-12903.patch
- patches/0007-fix-missing-PROTOBUF_EXPORT-for-public-symbols.patch
- patches/0008-CMake-Fix-abseil_dll-target-name-when-using-find_pac.patch

build:
number: 3
number: 4

outputs:
- name: libprotobuf
Expand Down
4 changes: 2 additions & 2 deletions recipe/patches/0001-use-consistent-cmake-location.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 5f59e8cbbea1aab58dc41e81b844d2da05863f4b Mon Sep 17 00:00:00 2001
From fa6b8eb61c17a083d44b3e0fdb3b02bd7cc262f3 Mon Sep 17 00:00:00 2001
From: "H. Vetinari" <h.vetinari@gmx.com>
Date: Sat, 3 Sep 2022 19:48:04 +0200
Subject: [PATCH 1/6] use consistent cmake location
Subject: [PATCH 1/8] use consistent cmake location

---
cmake/install.cmake | 12 +++---------
Expand Down
6 changes: 3 additions & 3 deletions recipe/patches/0002-set-static-lib-extension-on-windows.patch
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
From 0e2901fac62f1fa3fc9534f4ab667fcebdff61f5 Mon Sep 17 00:00:00 2001
From 9dc4c31438927ce82a9aa5b2e38207c11d8d2433 Mon Sep 17 00:00:00 2001
From: "H. Vetinari" <h.vetinari@gmx.com>
Date: Sun, 4 Sep 2022 10:57:08 +0200
Subject: [PATCH 2/6] set static lib extension on windows
Subject: [PATCH 2/8] set static lib extension on windows

---
CMakeLists.txt | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ec1641ba9..97a39e4ba 100644
index 1fb018b61..61e9ac383 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -371,6 +371,12 @@ else ()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From ec985b8640e701f2e21f395b453729d5b85466d3 Mon Sep 17 00:00:00 2001
From edc4100e2af9ba8fd279974ee9652b21420c5387 Mon Sep 17 00:00:00 2001
From: Mike Rochefort <mroche@omenos.dev>
Date: Mon, 1 May 2023 09:34:17 -0700
Subject: [PATCH 3/6] Enable the selection of system provided jsoncpp (#12577)
Subject: [PATCH 3/8] Enable the selection of system provided jsoncpp (#12577)

Allows the use of an external `jsoncpp` library to be used. Replicates the model used by `abseil-cpp` as a "package" or "module" to the `protobuf_JSONCPP_PROVIDER` option.

Expand All @@ -17,7 +17,7 @@ PiperOrigin-RevId: 528492610
2 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 97a39e4ba..7d2dc8bab 100644
index 61e9ac383..3db1d0e6a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -332,6 +332,9 @@ endif (protobuf_UNICODE)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 855774183cbd1355ca1eefaebb8699c5eb89b18d Mon Sep 17 00:00:00 2001
From 4d90fa0fc44fd851eef0511b2b9c10ca3befb47f Mon Sep 17 00:00:00 2001
From: "H. Vetinari" <h.vetinari@gmx.com>
Date: Sat, 13 May 2023 22:43:45 +1100
Subject: [PATCH 4/6] always look for shared abseil builds
Subject: [PATCH 4/8] always look for shared abseil builds

---
cmake/abseil-cpp.cmake | 2 +-
Expand Down
6 changes: 3 additions & 3 deletions recipe/patches/0005-be-more-lenient-with-abseil-version.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 3ed82472434815a3e5befcefd5e13e3bd0e07759 Mon Sep 17 00:00:00 2001
From c649c3e227cb88ff5cc276d3876e2f8dfdb16c22 Mon Sep 17 00:00:00 2001
From: "H. Vetinari" <h.vetinari@gmx.com>
Date: Thu, 18 May 2023 09:02:21 +1100
Subject: [PATCH 5/6] be more lenient with abseil version
Subject: [PATCH 5/8] be more lenient with abseil version

we carry the patch for the only pertinent difference
between .2 & .3 anyway
Expand All @@ -10,7 +10,7 @@ between .2 & .3 anyway
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc
index 1c6a24945..2ee003e15 100644
index 18d7ccfe8..90f58f6ec 100644
--- a/src/google/protobuf/port_def.inc
+++ b/src/google/protobuf/port_def.inc
@@ -216,7 +216,7 @@ static_assert(PROTOBUF_CPLUSPLUS_MIN(201402L), "Protobuf only supports C++14 and
Expand Down

This file was deleted.

241 changes: 241 additions & 0 deletions recipe/patches/0006-feat-workaround-for-DOMAIN-macro-12903.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
From 701113e0472269a966ae69f25e428140e34dc8fc Mon Sep 17 00:00:00 2001
From: Carlos O'Ryan <coryan@google.com>
Date: Fri, 26 May 2023 10:10:47 -0700
Subject: [PATCH 6/8] feat: workaround for `DOMAIN` macro (#12903)

This is a macro on some (older) versions of GCC, and macOS, and Windows. Sigh. I moved the `#undef` block to a common section. I also took the opportunity to add a regression test for all these macros that need to be `#undef`'d.

Part of the work for googleapis/google-cloud-cpp#8125

Closes #12903

PiperOrigin-RevId: 535649278
---
src/file_lists.cmake | 1 +
src/google/protobuf/BUILD.bazel | 2 +
src/google/protobuf/port_def.inc | 22 +++--
src/google/protobuf/port_undef.inc | 12 ++-
.../protobuf/unittest_proto3_bad_macros.proto | 98 +++++++++++++++++++
5 files changed, 123 insertions(+), 12 deletions(-)
create mode 100644 src/google/protobuf/unittest_proto3_bad_macros.proto

diff --git a/src/file_lists.cmake b/src/file_lists.cmake
index da030df3d..8b48f6b9c 100644
--- a/src/file_lists.cmake
+++ b/src/file_lists.cmake
@@ -666,6 +666,7 @@ set(protobuf_test_protos_files
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_proto3.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_proto3_arena.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_proto3_arena_lite.proto
+ ${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_proto3_bad_macros.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_proto3_lite.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_proto3_optional.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_retention.proto
diff --git a/src/google/protobuf/BUILD.bazel b/src/google/protobuf/BUILD.bazel
index 77ed2309f..91827d9cf 100644
--- a/src/google/protobuf/BUILD.bazel
+++ b/src/google/protobuf/BUILD.bazel
@@ -645,6 +645,7 @@ filegroup(
"unittest_proto3.proto",
"unittest_proto3_arena.proto",
"unittest_proto3_arena_lite.proto",
+ "unittest_proto3_bad_macros.proto",
"unittest_proto3_lite.proto",
"unittest_proto3_optional.proto",
"unittest_retention.proto",
@@ -702,6 +703,7 @@ proto_library(
"unittest_proto3.proto",
"unittest_proto3_arena.proto",
"unittest_proto3_arena_lite.proto",
+ "unittest_proto3_bad_macros.proto",
"unittest_proto3_lite.proto",
"unittest_proto3_optional.proto",
"unittest_retention.proto",
diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc
index 90f58f6ec..24278aba7 100644
--- a/src/google/protobuf/port_def.inc
+++ b/src/google/protobuf/port_def.inc
@@ -888,11 +888,18 @@ static_assert(PROTOBUF_ABSL_MIN(20230125, 2),
#undef PACKAGE
#endif

-// autoheader defines this in some circumstances
-#ifdef PACKAGE
-#define PROTOBUF_DID_UNDEF_PACKAGE
-#pragma push_macro("PACKAGE")
-#undef PACKAGE
+// a few common headers define this
+#ifdef PACKED
+#define PROTOBUF_DID_UNDEF_PACKED
+#pragma push_macro("PACKED")
+#undef PACKED
+#endif
+
+// This is a macro on Windows, macOS, and some variants of GCC.
+#ifdef DOMAIN
+#define PROTOBUF_DID_UNDEF_DOMAIN
+#pragma push_macro("DOMAIN")
+#undef DOMAIN
#endif

// linux is a legacy MACRO defined in most popular C++ standards.
@@ -909,8 +916,6 @@ static_assert(PROTOBUF_ABSL_MIN(20230125, 2),
#undef CREATE_NEW
#pragma push_macro("DELETE")
#undef DELETE
-#pragma push_macro("DOMAIN")
-#undef DOMAIN
#pragma push_macro("DOUBLE_CLICK")
#undef DOUBLE_CLICK
#pragma push_macro("ERROR")
@@ -968,9 +973,6 @@ static_assert(PROTOBUF_ABSL_MIN(20230125, 2),
#endif // _WIN32

#ifdef __APPLE__
-// Inconvenient macro names from usr/include/math.h in some macOS SDKs.
-#pragma push_macro("DOMAIN")
-#undef DOMAIN
// Inconvenient macro names from /usr/include/mach/boolean.h in some macOS SDKs.
#pragma push_macro("TRUE")
#undef TRUE
diff --git a/src/google/protobuf/port_undef.inc b/src/google/protobuf/port_undef.inc
index e9eae069c..cee6f8b90 100644
--- a/src/google/protobuf/port_undef.inc
+++ b/src/google/protobuf/port_undef.inc
@@ -128,6 +128,16 @@
#undef PROTOBUF_DID_UNDEF_PACKAGE
#endif

+#ifdef PROTOBUF_DID_UNDEF_PACKED
+#pragma pop_macro("PACKED")
+#undef PROTOBUF_DID_UNDEF_PACKED
+#endif
+
+#ifdef PROTOBUF_DID_UNDEF_DOMAIN
+#pragma pop_macro("DOMAIN")
+#undef PROTOBUF_DID_UNDEF_DOMAIN
+#endif
+
#ifdef PROTOBUF_DID_UNDEF_LINUX
#pragma pop_macro("linux")
#endif
@@ -135,7 +145,6 @@
#ifdef _WIN32
#pragma pop_macro("CREATE_NEW")
#pragma pop_macro("DELETE")
-#pragma pop_macro("DOMAIN")
#pragma pop_macro("DOUBLE_CLICK")
#pragma pop_macro("ERROR")
#pragma pop_macro("ERROR_BUSY")
@@ -166,7 +175,6 @@
#endif

#ifdef __APPLE__
-#pragma pop_macro("DOMAIN")
#pragma pop_macro("TRUE")
#pragma pop_macro("FALSE")
#pragma pop_macro("UID_MAX")
diff --git a/src/google/protobuf/unittest_proto3_bad_macros.proto b/src/google/protobuf/unittest_proto3_bad_macros.proto
new file mode 100644
index 000000000..7d245b5d4
--- /dev/null
+++ b/src/google/protobuf/unittest_proto3_bad_macros.proto
@@ -0,0 +1,98 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2023 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto3";
+
+package protobuf_unittest;
+
+option csharp_namespace = "ProtobufUnittest";
+option java_multiple_files = true;
+option java_package = "com.google.protobuf.testing.proto";
+
+// `google/protobuf/port_def.inc` #undef's a number of inconvenient macros
+// defined in system headers under varying circumstances. The code generated
+// from this file will not compile if those `#undef` calls are accidentally
+// removed.
+
+// This generates `GID_MAX`, which is a macro in some circumstances.
+enum GID {
+ GID_UNUSED = 0;
+}
+
+// This generates `UID_MAX`, which is a mcro in some circumstances.
+enum UID {
+ UID_UNUSED = 0;
+}
+
+// Just a container for bad macro names. Some of these do not follow the normal
+// naming conventions, this is intentional, we just want to trigger a build
+// failure if the macro is left defined.
+enum BadNames {
+ // autoheader defines this in some circumstances.
+ PACKAGE = 0;
+ // The comment says "a few common headers define this".
+ PACKED = 1;
+ // Defined in many Linux system headers.
+ linux = 2;
+ // This is often a macro in `<math.h>`.
+ DOMAIN = 3;
+ // These are defined in both Windows and macOS headers.
+ TRUE = 4;
+ FALSE = 5;
+ // Sometimes defined in Windows system headers.
+ CREATE_NEW = 6;
+ DELETE = 7;
+ DOUBLE_CLICK = 8;
+ ERROR = 9;
+ ERROR_BUSY = 10;
+ ERROR_INSTALL_FAILED = 11;
+ ERROR_NOT_FOUND = 12;
+ GetClassName = 13;
+ GetCurrentTime = 14;
+ GetMessage = 15;
+ GetObject = 16;
+ IGNORE = 17;
+ IN = 18;
+ INPUT_KEYBOARD = 19;
+ NO_ERROR = 20;
+ OUT = 21;
+ OPTIONAL = 22;
+ NEAR = 23;
+ NO_DATA = 24;
+ REASON_UNKNOWN = 25;
+ SERVICE_DISABLED = 26;
+ SEVERITY_ERROR = 27;
+ STATUS_PENDING = 28;
+ STRICT = 29;
+ // Sometimed defined in macOS system headers.
+ TYPE_BOOL = 30;
+ // Defined in macOS, Windows, and Linux headers.
+ DEBUG = 31;
+}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
From db0beb910fcf2c5092e95e87c7f84deffb395602 Mon Sep 17 00:00:00 2001
From: Protobuf Team Bot <protobuf-github-bot@google.com>
Date: Thu, 1 Jun 2023 09:14:48 -0700
Subject: [PATCH 7/8] fix: missing `PROTOBUF_EXPORT` for public symbols

PiperOrigin-RevId: 537042088
---
src/google/protobuf/io/strtod.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/google/protobuf/io/strtod.h b/src/google/protobuf/io/strtod.h
index 851c8e621..b368e4d87 100644
--- a/src/google/protobuf/io/strtod.h
+++ b/src/google/protobuf/io/strtod.h
@@ -60,12 +60,12 @@ PROTOBUF_EXPORT std::string SimpleFtoa(float value);

// A locale-independent version of the standard strtod(), which always
// uses a dot as the decimal separator.
-double NoLocaleStrtod(const char* str, char** endptr);
+PROTOBUF_EXPORT double NoLocaleStrtod(const char* str, char** endptr);

// Casts a double value to a float value. If the value is outside of the
// representable range of float, it will be converted to positive or negative
// infinity.
-float SafeDoubleToFloat(double value);
+PROTOBUF_EXPORT float SafeDoubleToFloat(double value);

} // namespace io
} // namespace protobuf
Loading

0 comments on commit 39d3df4

Please sign in to comment.