From ffff01783c00b46ab45b309ed5fa3e6dc41f0539 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Mon, 15 Jul 2024 11:16:10 -0700 Subject: [PATCH 1/7] Fixed `NAN`/`INFINITY` definitions to work on Windows 11 SDK. Fixes: https://github.com/protocolbuffers/protobuf/issues/17308, https://github.com/protocolbuffers/protobuf/issues/17238 Confirmation that this addresses the issue: https://github.com/grpc/grpc/issues/37210#issuecomment-2226809722 PiperOrigin-RevId: 652541857 --- upb/message/internal/message.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/upb/message/internal/message.c b/upb/message/internal/message.c index 57ab2d7371cdb..5f321c7bb220f 100644 --- a/upb/message/internal/message.c +++ b/upb/message/internal/message.c @@ -17,9 +17,9 @@ // Must be last. #include "upb/port/def.inc" -const float kUpb_FltInfinity = INFINITY; -const double kUpb_Infinity = INFINITY; -const double kUpb_NaN = NAN; +const float kUpb_FltInfinity = (float)(1.0 / 0.0); +const double kUpb_Infinity = 1.0 / 0.0; +const double kUpb_NaN = 0.0 / 0.0; bool UPB_PRIVATE(_upb_Message_Realloc)(struct upb_Message* msg, size_t need, upb_Arena* a) { From 1d43d3694b0637d00f706da3fad9769542e3becf Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Mon, 7 Oct 2024 06:08:06 -0700 Subject: [PATCH 2/7] Fix compilation in Clang C23 mode. In C23, `false` is now of type `bool`, not `int`. This turned a couple places where `false` was returned instead of `NULL` into errors. The workaround in upb for Windows's broken NAN macro causes an error in Clang under C23, `cannot compile this static initializer yet`, I believe because `0.0 / 0.0` is not valid in constant-evaluation. This seems like it's probably a legitimate result of C23 standardizing constexpr, although it _could_ be a clang bug. In any case, refine the workaround a bit, to avoid this problem. I've also reverted the kUpb_FltInfinity/kUpb_Infinity back to their former definitions, as INFINITY wasn't broken by the windows header, only NAN. PiperOrigin-RevId: 683152452 --- php/ext/google/protobuf/wkt.inc | 121 -------------------------------- upb/message/copy.c | 2 +- upb/message/internal/message.c | 26 ++++++- upb/text/internal/encode.c | 12 ++-- 4 files changed, 30 insertions(+), 131 deletions(-) diff --git a/php/ext/google/protobuf/wkt.inc b/php/ext/google/protobuf/wkt.inc index 799a48fd46567..c13244e77080a 100644 --- a/php/ext/google/protobuf/wkt.inc +++ b/php/ext/google/protobuf/wkt.inc @@ -2584,127 +2584,6 @@ static void google_protobuf_Syntax_ModuleInit() { strlen("SYNTAX_PROTO3"), 1); } -/* google/protobuf/timestamp.proto */ - -zend_class_entry* GPBMetadata_Google_Protobuf_Timestamp_ce; - -const char google_protobuf_timestamp_proto_descriptor [239] = { -'\n', '\037', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'i', 'm', 'e', 's', 't', 'a', -'m', 'p', '.', 'p', 'r', 'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', -'\"', '+', '\n', '\t', 'T', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p', '\022', '\017', '\n', '\007', 's', 'e', 'c', 'o', 'n', 'd', 's', '\030', -'\001', ' ', '\001', '(', '\003', '\022', '\r', '\n', '\005', 'n', 'a', 'n', 'o', 's', '\030', '\002', ' ', '\001', '(', '\005', 'B', '\205', '\001', '\n', '\023', -'c', 'o', 'm', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', 'B', '\016', 'T', 'i', 'm', 'e', -'s', 't', 'a', 'm', 'p', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', '2', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'g', 'o', 'l', 'a', -'n', 'g', '.', 'o', 'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', 'p', 'e', 's', '/', 'k', 'n', 'o', -'w', 'n', '/', 't', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p', 'p', 'b', '\370', '\001', '\001', '\242', '\002', '\003', 'G', 'P', 'B', '\252', '\002', -'\036', 'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', 'w', -'n', 'T', 'y', 'p', 'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', '3', -}; - -static void google_protobuf_timestamp_proto_AddDescriptor() { - if (DescriptorPool_HasFile("google/protobuf/timestamp.proto")) return; - DescriptorPool_AddDescriptor("google/protobuf/timestamp.proto", google_protobuf_timestamp_proto_descriptor, - sizeof(google_protobuf_timestamp_proto_descriptor)); -} - -static PHP_METHOD(GPBMetadata_Google_Protobuf_Timestamp, initOnce) { - google_protobuf_timestamp_proto_AddDescriptor(); -} - -static zend_function_entry GPBMetadata_Google_Protobuf_Timestamp_methods[] = { - PHP_ME(GPBMetadata_Google_Protobuf_Timestamp, initOnce, arginfo_void, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) - ZEND_FE_END -}; - -static void GPBMetadata_Google_Protobuf_Timestamp_ModuleInit() { - zend_class_entry tmp_ce; - - INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\Timestamp", - GPBMetadata_Google_Protobuf_Timestamp_methods); - - GPBMetadata_Google_Protobuf_Timestamp_ce = zend_register_internal_class(&tmp_ce); -} - -/* google_protobuf_Timestamp */ - -zend_class_entry* google_protobuf_Timestamp_ce; - -static PHP_METHOD(google_protobuf_Timestamp, __construct) { - google_protobuf_timestamp_proto_AddDescriptor(); - zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); -} - -static PHP_METHOD(google_protobuf_Timestamp, getSeconds) { - Message* intern = (Message*)Z_OBJ_P(getThis()); - const upb_FieldDef *f = upb_MessageDef_FindFieldByName( - intern->desc->msgdef, "seconds"); - zval ret; - Message_get(intern, f, &ret); - RETURN_COPY_VALUE(&ret); -} - -static PHP_METHOD(google_protobuf_Timestamp, setSeconds) { - Message* intern = (Message*)Z_OBJ_P(getThis()); - const upb_FieldDef *f = upb_MessageDef_FindFieldByName( - intern->desc->msgdef, "seconds"); - zval *val; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) - == FAILURE) { - return; - } - Message_set(intern, f, val); - RETURN_COPY(getThis()); -} - -static PHP_METHOD(google_protobuf_Timestamp, getNanos) { - Message* intern = (Message*)Z_OBJ_P(getThis()); - const upb_FieldDef *f = upb_MessageDef_FindFieldByName( - intern->desc->msgdef, "nanos"); - zval ret; - Message_get(intern, f, &ret); - RETURN_COPY_VALUE(&ret); -} - -static PHP_METHOD(google_protobuf_Timestamp, setNanos) { - Message* intern = (Message*)Z_OBJ_P(getThis()); - const upb_FieldDef *f = upb_MessageDef_FindFieldByName( - intern->desc->msgdef, "nanos"); - zval *val; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) - == FAILURE) { - return; - } - Message_set(intern, f, val); - RETURN_COPY(getThis()); -} - -ZEND_BEGIN_ARG_INFO_EX(arginfo_timestamp_fromdatetime, 0, 0, 1) - ZEND_ARG_INFO(0, datetime) -ZEND_END_ARG_INFO() - -static zend_function_entry google_protobuf_Timestamp_phpmethods[] = { - PHP_ME(google_protobuf_Timestamp, __construct, arginfo_construct, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Timestamp, getSeconds, arginfo_void, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Timestamp, setSeconds, arginfo_setter, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Timestamp, getNanos, arginfo_void, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Timestamp, setNanos, arginfo_setter, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Timestamp, fromDateTime, arginfo_timestamp_fromdatetime, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Timestamp, toDateTime, arginfo_void, ZEND_ACC_PUBLIC) - ZEND_FE_END -}; - -static void google_protobuf_Timestamp_ModuleInit() { - zend_class_entry tmp_ce; - - INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Timestamp", - google_protobuf_Timestamp_phpmethods); - - google_protobuf_Timestamp_ce = zend_register_internal_class(&tmp_ce); - google_protobuf_Timestamp_ce->ce_flags |= ZEND_ACC_FINAL; - google_protobuf_Timestamp_ce->create_object = Message_create; - zend_do_inheritance(google_protobuf_Timestamp_ce, message_ce); -} - /* google/protobuf/wrappers.proto */ zend_class_entry* GPBMetadata_Google_Protobuf_Wrappers_ce; diff --git a/upb/message/copy.c b/upb/message/copy.c index 67e1b5b5030d0..94f41056355e5 100644 --- a/upb/message/copy.c +++ b/upb/message/copy.c @@ -150,7 +150,7 @@ upb_Array* upb_Array_DeepClone(const upb_Array* array, upb_CType value_type, for (size_t i = 0; i < size; ++i) { upb_MessageValue val = upb_Array_Get(array, i); if (!upb_Clone_MessageValue(&val, value_type, sub, arena)) { - return false; + return NULL; } upb_Array_Set(cloned_array, i, val); } diff --git a/upb/message/internal/message.c b/upb/message/internal/message.c index 5f321c7bb220f..ba4ceaa4bc621 100644 --- a/upb/message/internal/message.c +++ b/upb/message/internal/message.c @@ -17,9 +17,29 @@ // Must be last. #include "upb/port/def.inc" -const float kUpb_FltInfinity = (float)(1.0 / 0.0); -const double kUpb_Infinity = 1.0 / 0.0; -const double kUpb_NaN = 0.0 / 0.0; +const float kUpb_FltInfinity = INFINITY; +const double kUpb_Infinity = INFINITY; + +// The latest win32 SDKs have an invalid definition of NAN. +// https://developercommunity.visualstudio.com/t/NAN-is-no-longer-compile-time-constant-i/10688907 +// +// Unfortunately, the `0.0 / 0.0` workaround doesn't work in Clang under C23, so +// try __builtin_nan first, if that exists. +#ifdef _WIN32 +#ifdef __has_builtin +#if __has_builtin(__builtin_nan) +#define UPB_NAN __builtin_nan("0") +#endif +#endif +#ifndef UPB_NAN +#define UPB_NAN 0.0 / 0.0 +#endif +#else +// For !_WIN32, assume math.h works. +#define UPB_NAN NAN +#endif + +const double kUpb_NaN = UPB_NAN; bool UPB_PRIVATE(_upb_Message_Realloc)(struct upb_Message* msg, size_t need, upb_Arena* a) { diff --git a/upb/text/internal/encode.c b/upb/text/internal/encode.c index fc9cc6fd27373..403da037e4f3a 100644 --- a/upb/text/internal/encode.c +++ b/upb/text/internal/encode.c @@ -22,11 +22,11 @@ // Must be last. #include "upb/port/def.inc" -#define CHK(x) \ - do { \ - if (!(x)) { \ - return false; \ - } \ +#define CHK(x) \ + do { \ + if (!(x)) { \ + return NULL; \ + } \ } while (0) /* @@ -177,4 +177,4 @@ void UPB_PRIVATE(_upb_TextEncode_Scalar)(txtenc* e, upb_MessageValue val, default: UPB_UNREACHABLE(); } -} \ No newline at end of file +} From 1f10a8c88f642fcb7db0e5715302a5cfc5393437 Mon Sep 17 00:00:00 2001 From: Mike Kruskal Date: Fri, 22 Nov 2024 21:55:01 -0800 Subject: [PATCH 3/7] Fix const INFINITY issue on MSVC. We previously hit this for NAN, but it appears the latest version of MSVC used in windows github runners has the same issue for INFINITY. The same strategy can be applied here. This will be backported to fix broken release branches. PiperOrigin-RevId: 699390594 --- upb/message/internal/message.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/upb/message/internal/message.c b/upb/message/internal/message.c index ba4ceaa4bc621..45b1067db1c95 100644 --- a/upb/message/internal/message.c +++ b/upb/message/internal/message.c @@ -17,9 +17,6 @@ // Must be last. #include "upb/port/def.inc" -const float kUpb_FltInfinity = INFINITY; -const double kUpb_Infinity = INFINITY; - // The latest win32 SDKs have an invalid definition of NAN. // https://developercommunity.visualstudio.com/t/NAN-is-no-longer-compile-time-constant-i/10688907 // @@ -30,15 +27,24 @@ const double kUpb_Infinity = INFINITY; #if __has_builtin(__builtin_nan) #define UPB_NAN __builtin_nan("0") #endif +#if __has_builtin(__builtin_inf) +#define UPB_INFINITY __builtin_inf() +#endif #endif #ifndef UPB_NAN #define UPB_NAN 0.0 / 0.0 #endif +#ifndef UPB_INFINITY +#define UPB_INFINITY 1.0 / 0.0 +#endif #else // For !_WIN32, assume math.h works. #define UPB_NAN NAN +#define UPB_INFINITY INFINITY #endif +const float kUpb_FltInfinity = UPB_INFINITY; +const double kUpb_Infinity = UPB_INFINITY; const double kUpb_NaN = UPB_NAN; bool UPB_PRIVATE(_upb_Message_Realloc)(struct upb_Message* msg, size_t need, From 26354c568ed37167453e13673eb40108c5fb1da8 Mon Sep 17 00:00:00 2001 From: Mike Kruskal Date: Mon, 25 Nov 2024 11:32:09 -0800 Subject: [PATCH 4/7] Regenerate stale files --- php/ext/google/protobuf/php-upb.c | 34 +++++++++++++++++++++++---- ruby/ext/google/protobuf_c/ruby-upb.c | 34 +++++++++++++++++++++++---- 2 files changed, 60 insertions(+), 8 deletions(-) diff --git a/php/ext/google/protobuf/php-upb.c b/php/ext/google/protobuf/php-upb.c index 964f53ce57092..a3cf23a569eed 100644 --- a/php/ext/google/protobuf/php-upb.c +++ b/php/ext/google/protobuf/php-upb.c @@ -6161,7 +6161,7 @@ upb_Array* upb_Array_DeepClone(const upb_Array* array, upb_CType value_type, for (size_t i = 0; i < size; ++i) { upb_MessageValue val = upb_Array_Get(array, i); if (!upb_Clone_MessageValue(&val, value_type, sub, arena)) { - return false; + return NULL; } upb_Array_Set(cloned_array, i, val); } @@ -12204,9 +12204,35 @@ upb_Extension* UPB_PRIVATE(_upb_Message_GetOrCreateExtension)( // Must be last. -const float kUpb_FltInfinity = INFINITY; -const double kUpb_Infinity = INFINITY; -const double kUpb_NaN = NAN; +// The latest win32 SDKs have an invalid definition of NAN. +// https://developercommunity.visualstudio.com/t/NAN-is-no-longer-compile-time-constant-i/10688907 +// +// Unfortunately, the `0.0 / 0.0` workaround doesn't work in Clang under C23, so +// try __builtin_nan first, if that exists. +#ifdef _WIN32 +#ifdef __has_builtin +#if __has_builtin(__builtin_nan) +#define UPB_NAN __builtin_nan("0") +#endif +#if __has_builtin(__builtin_inf) +#define UPB_INFINITY __builtin_inf() +#endif +#endif +#ifndef UPB_NAN +#define UPB_NAN 0.0 / 0.0 +#endif +#ifndef UPB_INFINITY +#define UPB_INFINITY 1.0 / 0.0 +#endif +#else +// For !_WIN32, assume math.h works. +#define UPB_NAN NAN +#define UPB_INFINITY INFINITY +#endif + +const float kUpb_FltInfinity = UPB_INFINITY; +const double kUpb_Infinity = UPB_INFINITY; +const double kUpb_NaN = UPB_NAN; bool UPB_PRIVATE(_upb_Message_Realloc)(struct upb_Message* msg, size_t need, upb_Arena* a) { diff --git a/ruby/ext/google/protobuf_c/ruby-upb.c b/ruby/ext/google/protobuf_c/ruby-upb.c index 98715cb8d2b8d..4787dcf984477 100644 --- a/ruby/ext/google/protobuf_c/ruby-upb.c +++ b/ruby/ext/google/protobuf_c/ruby-upb.c @@ -5649,7 +5649,7 @@ upb_Array* upb_Array_DeepClone(const upb_Array* array, upb_CType value_type, for (size_t i = 0; i < size; ++i) { upb_MessageValue val = upb_Array_Get(array, i); if (!upb_Clone_MessageValue(&val, value_type, sub, arena)) { - return false; + return NULL; } upb_Array_Set(cloned_array, i, val); } @@ -11692,9 +11692,35 @@ upb_Extension* UPB_PRIVATE(_upb_Message_GetOrCreateExtension)( // Must be last. -const float kUpb_FltInfinity = INFINITY; -const double kUpb_Infinity = INFINITY; -const double kUpb_NaN = NAN; +// The latest win32 SDKs have an invalid definition of NAN. +// https://developercommunity.visualstudio.com/t/NAN-is-no-longer-compile-time-constant-i/10688907 +// +// Unfortunately, the `0.0 / 0.0` workaround doesn't work in Clang under C23, so +// try __builtin_nan first, if that exists. +#ifdef _WIN32 +#ifdef __has_builtin +#if __has_builtin(__builtin_nan) +#define UPB_NAN __builtin_nan("0") +#endif +#if __has_builtin(__builtin_inf) +#define UPB_INFINITY __builtin_inf() +#endif +#endif +#ifndef UPB_NAN +#define UPB_NAN 0.0 / 0.0 +#endif +#ifndef UPB_INFINITY +#define UPB_INFINITY 1.0 / 0.0 +#endif +#else +// For !_WIN32, assume math.h works. +#define UPB_NAN NAN +#define UPB_INFINITY INFINITY +#endif + +const float kUpb_FltInfinity = UPB_INFINITY; +const double kUpb_Infinity = UPB_INFINITY; +const double kUpb_NaN = UPB_NAN; bool UPB_PRIVATE(_upb_Message_Realloc)(struct upb_Message* msg, size_t need, upb_Arena* a) { From 6d10f0a4bb50ce8668b692d8f6de6dc969700e3e Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Thu, 10 Oct 2024 12:57:01 -0700 Subject: [PATCH 5/7] Update GitHub Actions to use macOS-13 ahead of macOS-12 deprecation. See https://github.com/actions/runner-images/issues/10721. PiperOrigin-RevId: 684546079 --- .github/BUILD.bazel | 2 +- .github/workflows/test_cpp.yml | 14 +++++++------- .github/workflows/test_objectivec.yml | 8 ++++---- .github/workflows/test_php.yml | 2 +- .github/workflows/test_python.yml | 2 +- .github/workflows/test_ruby.yml | 2 +- .github/workflows/test_upb.yml | 6 +++--- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/BUILD.bazel b/.github/BUILD.bazel index 45297fc11671a..7ce6f2c2b8052 100644 --- a/.github/BUILD.bazel +++ b/.github/BUILD.bazel @@ -1,5 +1,5 @@ # This information is extracted from the MacOS runner specs located at: -# https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md +# https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md # # When updating, also ensure the "xcode_destination" entries in # `.github/workflows/test_objectivec.yml` are supported for the given versions diff --git a/.github/workflows/test_cpp.yml b/.github/workflows/test_cpp.yml index 35ecae8633b6b..742848fdc568d 100644 --- a/.github/workflows/test_cpp.yml +++ b/.github/workflows/test_cpp.yml @@ -321,17 +321,17 @@ jobs: matrix: include: - name: MacOS Bazel - os: macos-12 - cache_key: macos-12 + os: macos-13 + cache_key: macos-13 bazel: test //src/... //third_party/utf8_range/... - name: MacOS Bazel 7 - os: macos-12 - cache_key: macos-12-bazel7 + os: macos-13 + cache_key: macos-13-bazel7 bazel: test //src/... //third_party/utf8_range/... bazel_version: '7.1.2' - name: MacOS Apple Silicon (build only) Bazel - os: macos-12 - cache_key: macos-12-arm + os: macos-13 + cache_key: macos-13-arm # Current github runners are all Intel based, so just build/compile # for Apple Silicon to detect issues there. bazel: build --cpu=darwin_arm64 //src/... //third_party/utf8_range/... @@ -366,7 +366,7 @@ jobs: include: # TODO: investigate and fix # - name: MacOS CMake - # os: macos-12 + # os: macos-13 # flags: -DCMAKE_CXX_STANDARD=14 # cache-prefix: macos-cmake - name: Windows CMake diff --git a/.github/workflows/test_objectivec.yml b/.github/workflows/test_objectivec.yml index ab3a5af4b37ce..e4d7a205d2dec 100644 --- a/.github/workflows/test_objectivec.yml +++ b/.github/workflows/test_objectivec.yml @@ -25,11 +25,11 @@ jobs: destination: "platform=macOS" xc_project: "ProtocolBuffers_OSX.xcodeproj" - platform: "iOS" - destination: "platform=iOS Simulator,name=iPhone 13,OS=latest" + destination: "platform=iOS Simulator,name=iPhone 14,OS=latest" xc_project: "ProtocolBuffers_iOS.xcodeproj" name: Xcode ${{ matrix.platform}} ${{ matrix.xc_config }} - runs-on: macos-12 + runs-on: macos-13 env: DEVELOPER_DIR: /Applications/Xcode_14.1.app/Contents/Developer steps: @@ -71,7 +71,7 @@ jobs: PLATFORM: ["ios", "macos", "tvos", "watchos", "visionos"] CONFIGURATION: ["Debug", "Release"] include: - - OS: macos-12 + - OS: macos-13 XCODE: "14.1" - OS: macos-14 PLATFORM: "visionos" @@ -123,7 +123,7 @@ jobs: - platform: "macOS" bazel_targets: //objectivec/... name: Bazel ${{ matrix.platform }} ${{ matrix.config.name }} - runs-on: macos-12 + runs-on: macos-13 steps: - name: Checkout pending changes uses: protocolbuffers/protobuf-ci/checkout@v3 diff --git a/.github/workflows/test_php.yml b/.github/workflows/test_php.yml index 86d24954b2c81..d3e77b4b42fb3 100644 --- a/.github/workflows/test_php.yml +++ b/.github/workflows/test_php.yml @@ -158,7 +158,7 @@ jobs: version: ['8.2', '8.3'] name: MacOS PHP ${{ matrix.version }} - runs-on: macos-12 + runs-on: macos-13 steps: - name: Checkout pending changes uses: protocolbuffers/protobuf-ci/checkout@v3 diff --git a/.github/workflows/test_python.yml b/.github/workflows/test_python.yml index b48da36aabf2b..db7074493f56b 100644 --- a/.github/workflows/test_python.yml +++ b/.github/workflows/test_python.yml @@ -65,7 +65,7 @@ jobs: flags: --define=use_fast_cpp_protos=true name: MacOS ${{ matrix.type }} ${{ matrix.version }} - runs-on: macos-12 + runs-on: macos-13 steps: - name: Checkout pending changes uses: protocolbuffers/protobuf-ci/checkout@v3 diff --git a/.github/workflows/test_ruby.yml b/.github/workflows/test_ruby.yml index 8d754189ce916..22bee1e970cd6 100644 --- a/.github/workflows/test_ruby.yml +++ b/.github/workflows/test_ruby.yml @@ -128,7 +128,7 @@ jobs: - { version: "3.3", ffi: FFI } name: MacOS Ruby ${{ matrix.version }}${{ matrix.ffi == 'FFI' && ' FFI' || '' }} - runs-on: macos-12 + runs-on: macos-13 steps: - name: Checkout pending changes uses: protocolbuffers/protobuf-ci/checkout@v3 diff --git a/.github/workflows/test_upb.yml b/.github/workflows/test_upb.yml index 7490e75f754d2..8fb42104ca837 100644 --- a/.github/workflows/test_upb.yml +++ b/.github/workflows/test_upb.yml @@ -95,7 +95,7 @@ jobs: - { name: "macOS", bazel-command: "test" } - { name: "macOS ARM (build only)", bazel-command: "build", flags: "--cpu=darwin_arm64" } name: ${{ matrix.config.name }} - runs-on: macos-12 + runs-on: macos-13 steps: - name: Checkout pending changes uses: protocolbuffers/protobuf-ci/checkout@v3 @@ -175,11 +175,11 @@ jobs: # supported Python versions and assume this gives us sufficient test # coverage. - { os: ubuntu-latest, python-version: "3.8", architecture: x64, type: 'binary' } - - { os: macos-12, python-version: "3.8", architecture: x64, type: 'binary' } + - { os: macos-13, python-version: "3.8", architecture: x64, type: 'binary' } - { os: ubuntu-latest, python-version: "3.12", architecture: x64, type: 'binary' } - { os: macos-13, python-version: "3.12", architecture: x64, type: 'binary' } - { os: ubuntu-latest, python-version: "3.8", architecture: x64, type: 'source' } - - { os: macos-12, python-version: "3.8", architecture: x64, type: 'source' } + - { os: macos-13, python-version: "3.8", architecture: x64, type: 'source' } - { os: ubuntu-latest, python-version: "3.12", architecture: x64, type: 'source' } - { os: macos-13, python-version: "3.12", architecture: x64, type: 'source' } From d89d224780ab9128b4b2bc45924870cfcf68d048 Mon Sep 17 00:00:00 2001 From: Mike Kruskal Date: Fri, 25 Oct 2024 16:56:51 -0700 Subject: [PATCH 6/7] Pin to python 3.12 in upb/macos tests. Python 3.13 seems to have some issues with our dependencies and both numpy and setuptools fails to install. PiperOrigin-RevId: 689955916 --- .github/workflows/test_upb.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test_upb.yml b/.github/workflows/test_upb.yml index 8fb42104ca837..bef06d2da3452 100644 --- a/.github/workflows/test_upb.yml +++ b/.github/workflows/test_upb.yml @@ -103,6 +103,7 @@ jobs: ref: ${{ inputs.safe-checkout }} - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 with: + python-version: 3.12 cache: pip cache-dependency-path: 'python/requirements.txt' - name: Run tests From b3c127269f3e19c611555ed3d8b9219943b21569 Mon Sep 17 00:00:00 2001 From: Mike Kruskal Date: Mon, 25 Nov 2024 12:54:19 -0800 Subject: [PATCH 7/7] Fix bad cherry-pick --- php/ext/google/protobuf/wkt.inc | 121 ++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/php/ext/google/protobuf/wkt.inc b/php/ext/google/protobuf/wkt.inc index c13244e77080a..799a48fd46567 100644 --- a/php/ext/google/protobuf/wkt.inc +++ b/php/ext/google/protobuf/wkt.inc @@ -2584,6 +2584,127 @@ static void google_protobuf_Syntax_ModuleInit() { strlen("SYNTAX_PROTO3"), 1); } +/* google/protobuf/timestamp.proto */ + +zend_class_entry* GPBMetadata_Google_Protobuf_Timestamp_ce; + +const char google_protobuf_timestamp_proto_descriptor [239] = { +'\n', '\037', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'i', 'm', 'e', 's', 't', 'a', +'m', 'p', '.', 'p', 'r', 'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', +'\"', '+', '\n', '\t', 'T', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p', '\022', '\017', '\n', '\007', 's', 'e', 'c', 'o', 'n', 'd', 's', '\030', +'\001', ' ', '\001', '(', '\003', '\022', '\r', '\n', '\005', 'n', 'a', 'n', 'o', 's', '\030', '\002', ' ', '\001', '(', '\005', 'B', '\205', '\001', '\n', '\023', +'c', 'o', 'm', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', 'B', '\016', 'T', 'i', 'm', 'e', +'s', 't', 'a', 'm', 'p', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', '2', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'g', 'o', 'l', 'a', +'n', 'g', '.', 'o', 'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', 'p', 'e', 's', '/', 'k', 'n', 'o', +'w', 'n', '/', 't', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p', 'p', 'b', '\370', '\001', '\001', '\242', '\002', '\003', 'G', 'P', 'B', '\252', '\002', +'\036', 'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', 'w', +'n', 'T', 'y', 'p', 'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', '3', +}; + +static void google_protobuf_timestamp_proto_AddDescriptor() { + if (DescriptorPool_HasFile("google/protobuf/timestamp.proto")) return; + DescriptorPool_AddDescriptor("google/protobuf/timestamp.proto", google_protobuf_timestamp_proto_descriptor, + sizeof(google_protobuf_timestamp_proto_descriptor)); +} + +static PHP_METHOD(GPBMetadata_Google_Protobuf_Timestamp, initOnce) { + google_protobuf_timestamp_proto_AddDescriptor(); +} + +static zend_function_entry GPBMetadata_Google_Protobuf_Timestamp_methods[] = { + PHP_ME(GPBMetadata_Google_Protobuf_Timestamp, initOnce, arginfo_void, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + ZEND_FE_END +}; + +static void GPBMetadata_Google_Protobuf_Timestamp_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\Timestamp", + GPBMetadata_Google_Protobuf_Timestamp_methods); + + GPBMetadata_Google_Protobuf_Timestamp_ce = zend_register_internal_class(&tmp_ce); +} + +/* google_protobuf_Timestamp */ + +zend_class_entry* google_protobuf_Timestamp_ce; + +static PHP_METHOD(google_protobuf_Timestamp, __construct) { + google_protobuf_timestamp_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static PHP_METHOD(google_protobuf_Timestamp, getSeconds) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_FieldDef *f = upb_MessageDef_FindFieldByName( + intern->desc->msgdef, "seconds"); + zval ret; + Message_get(intern, f, &ret); + RETURN_COPY_VALUE(&ret); +} + +static PHP_METHOD(google_protobuf_Timestamp, setSeconds) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_FieldDef *f = upb_MessageDef_FindFieldByName( + intern->desc->msgdef, "seconds"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_COPY(getThis()); +} + +static PHP_METHOD(google_protobuf_Timestamp, getNanos) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_FieldDef *f = upb_MessageDef_FindFieldByName( + intern->desc->msgdef, "nanos"); + zval ret; + Message_get(intern, f, &ret); + RETURN_COPY_VALUE(&ret); +} + +static PHP_METHOD(google_protobuf_Timestamp, setNanos) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_FieldDef *f = upb_MessageDef_FindFieldByName( + intern->desc->msgdef, "nanos"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_COPY(getThis()); +} + +ZEND_BEGIN_ARG_INFO_EX(arginfo_timestamp_fromdatetime, 0, 0, 1) + ZEND_ARG_INFO(0, datetime) +ZEND_END_ARG_INFO() + +static zend_function_entry google_protobuf_Timestamp_phpmethods[] = { + PHP_ME(google_protobuf_Timestamp, __construct, arginfo_construct, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Timestamp, getSeconds, arginfo_void, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Timestamp, setSeconds, arginfo_setter, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Timestamp, getNanos, arginfo_void, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Timestamp, setNanos, arginfo_setter, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Timestamp, fromDateTime, arginfo_timestamp_fromdatetime, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Timestamp, toDateTime, arginfo_void, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_Timestamp_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Timestamp", + google_protobuf_Timestamp_phpmethods); + + google_protobuf_Timestamp_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_Timestamp_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_Timestamp_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_Timestamp_ce, message_ce); +} + /* google/protobuf/wrappers.proto */ zend_class_entry* GPBMetadata_Google_Protobuf_Wrappers_ce;