Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport windows fixes with INFINITY/NAN #19389

Merged
merged 7 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/test_cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/...
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test_objectivec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/test_upb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,15 @@ 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
with:
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
Expand Down Expand Up @@ -175,11 +176,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' }

Expand Down
34 changes: 30 additions & 4 deletions php/ext/google/protobuf/php-upb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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) {
Expand Down
34 changes: 30 additions & 4 deletions ruby/ext/google/protobuf_c/ruby-upb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion upb/message/copy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
32 changes: 29 additions & 3 deletions upb/message/internal/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,35 @@
// Must be last.
#include "upb/port/def.inc"

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) {
Expand Down
12 changes: 6 additions & 6 deletions upb/text/internal/encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)

/*
Expand Down Expand Up @@ -177,4 +177,4 @@ void UPB_PRIVATE(_upb_TextEncode_Scalar)(txtenc* e, upb_MessageValue val,
default:
UPB_UNREACHABLE();
}
}
}
Loading