Skip to content

Commit 58ae5f8

Browse files
compiler: Upgrade to protobuf 33.1 (#12534)
1 parent 8d49dc1 commit 58ae5f8

File tree

6 files changed

+88
-59
lines changed

6 files changed

+88
-59
lines changed

buildscripts/kokoro/macos.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
#!/bin/bash
22
set -veux -o pipefail
3+
CMAKE_VERSION=3.31.10
34

45
if [[ -f /VERSION ]]; then
56
cat /VERSION
67
fi
78

89
readonly GRPC_JAVA_DIR="$(cd "$(dirname "$0")"/../.. && pwd)"
910

11+
DOWNLOAD_DIR=/tmp/source
12+
mkdir -p ${DOWNLOAD_DIR}
13+
curl -Ls https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-macos-universal.tar.gz | tar xz -C ${DOWNLOAD_DIR}
14+
1015
# We had problems with random tests timing out because it took seconds to do
1116
# trivial (ns) operations. The Kokoro Mac machines have 2 cores with 4 logical
1217
# threads, so Gradle should be using 4 workers by default.
@@ -15,7 +20,9 @@ export GRADLE_FLAGS="${GRADLE_FLAGS:-} --max-workers=2"
1520
. "$GRPC_JAVA_DIR"/buildscripts/kokoro/kokoro.sh
1621
trap spongify_logs EXIT
1722

18-
export -n JAVA_HOME
19-
export PATH="$(/usr/libexec/java_home -v"1.8.0")/bin:${PATH}"
23+
brew install --cask temurin@8
24+
export PATH="$(/usr/libexec/java_home -v"1.8.0")/bin:${DOWNLOAD_DIR}/cmake-${CMAKE_VERSION}-macos-universal/CMake.app/Contents/bin:${PATH}"
25+
export JAVA_HOME="$(/usr/libexec/java_home -v"1.8.0")"
26+
brew install maven
2027

2128
"$GRPC_JAVA_DIR"/buildscripts/kokoro/unix.sh

buildscripts/kokoro/windows32.bat

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ cd "%WORKSPACE%"
2525

2626
SET TARGET_ARCH=x86_32
2727
SET FAIL_ON_WARNINGS=true
28-
SET PROTOBUF_VER=26.1
28+
SET PROTOBUF_VER=33.1
2929
SET PKG_CONFIG_PATH=%ESCWORKSPACE%\\grpc-java-helper32\\protobuf-%PROTOBUF_VER%\\build\\protobuf-%PROTOBUF_VER%\\lib\\pkgconfig
3030
SET VC_PROTOBUF_LIBS=/LIBPATH:%ESCWORKSPACE%\\grpc-java-helper32\\protobuf-%PROTOBUF_VER%\\build\\protobuf-%PROTOBUF_VER%\\lib
3131
SET VC_PROTOBUF_INCLUDE=%ESCWORKSPACE%\\grpc-java-helper32\\protobuf-%PROTOBUF_VER%\\build\\protobuf-%PROTOBUF_VER%\\include
@@ -66,14 +66,16 @@ for /f "tokens=*" %%a in ('pkg-config --libs protobuf') do (
6666
set lib=!lib:~2!
6767
@rem remove spaces
6868
set lib=!lib: =!
69-
@rem Because protobuf is specified as libprotobuf and elsewhere
70-
if !lib! NEQ protobuf (
69+
set libprefix=!lib:~0,4!
70+
if !libprefix!==absl (
7171
set lib=!lib!.lib
72-
if "!libs_list!"=="" (
73-
set libs_list=!lib!
74-
) else (
75-
set libs_list=!libs_list!,!lib!
76-
)
72+
) else (
73+
set lib=lib!lib!.lib
74+
)
75+
if "!libs_list!"=="" (
76+
set libs_list=!lib!
77+
) else (
78+
set libs_list=!libs_list!,!lib!
7779
)
7880
)
7981
)

buildscripts/kokoro/windows64.bat

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ cd "%WORKSPACE%"
2424

2525
SET TARGET_ARCH=x86_64
2626
SET FAIL_ON_WARNINGS=true
27-
SET PROTOBUF_VER=26.1
27+
SET PROTOBUF_VER=33.1
2828
SET PKG_CONFIG_PATH=%ESCWORKSPACE%\\grpc-java-helper64\\protobuf-%PROTOBUF_VER%\\build\\protobuf-%PROTOBUF_VER%\\lib\\pkgconfig
2929
SET VC_PROTOBUF_LIBS=/LIBPATH:%ESCWORKSPACE%\\grpc-java-helper64\\protobuf-%PROTOBUF_VER%\\build\\protobuf-%PROTOBUF_VER%\\lib
3030
SET VC_PROTOBUF_INCLUDE=%ESCWORKSPACE%\\grpc-java-helper64\\protobuf-%PROTOBUF_VER%\\build\\protobuf-%PROTOBUF_VER%\\include
@@ -50,14 +50,16 @@ for /f "tokens=*" %%a in ('pkg-config --libs protobuf') do (
5050
set lib=!lib:~2!
5151
@rem remove spaces
5252
set lib=!lib: =!
53-
@rem Because protobuf is specified as libprotobuf and elsewhere
54-
if !lib! NEQ protobuf (
53+
set libprefix=!lib:~0,4!
54+
if !libprefix!==absl (
5555
set lib=!lib!.lib
56-
if "!libs_list!"=="" (
57-
set libs_list=!lib!
58-
) else (
59-
set libs_list=!libs_list!,!lib!
60-
)
56+
) else (
57+
set lib=lib!lib!.lib
58+
)
59+
if "!libs_list!"=="" (
60+
set libs_list=!lib!
61+
) else (
62+
set libs_list=!libs_list!,!lib!
6163
)
6264
)
6365
)

buildscripts/make_dependencies.bat

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
choco install -y pkgconfiglite
22
choco install -y openjdk --version=17.0
33
set PATH=%PATH%;"c:\Program Files\OpenJDK\jdk-17\bin"
4-
set PROTOBUF_VER=26.1
4+
set PROTOBUF_VER=33.1
55
set ABSL_VERSION=20250127.1
66
set CMAKE_NAME=cmake-3.26.3-windows-x86_64
77

@@ -30,7 +30,6 @@ del protobuf.zip
3030
powershell -command "$ProgressPreference = 'SilentlyContinue'; $ErrorActionPreference = 'stop'; & { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; iwr https://github.com/abseil/abseil-cpp/archive/refs/tags/%ABSL_VERSION%.zip -OutFile absl.zip }" || exit /b 1
3131
powershell -command "$ErrorActionPreference = 'stop'; & { Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::ExtractToDirectory('absl.zip', '.') }" || exit /b 1
3232
del absl.zip
33-
rmdir protobuf-%PROTOBUF_VER%\third_party\abseil-cpp
3433
move abseil-cpp-%ABSL_VERSION% protobuf-%PROTOBUF_VER%\third_party\abseil-cpp
3534
mkdir protobuf-%PROTOBUF_VER%\build
3635
pushd protobuf-%PROTOBUF_VER%\build
@@ -51,7 +50,7 @@ for /f "tokens=4 delims=\" %%a in ("%VCINSTALLDIR%") do (
5150
for /f "tokens=1 delims=." %%a in ("%VisualStudioVersion%") do (
5251
SET visual_studio_major_version=%%a
5352
)
54-
cmake -DABSL_MSVC_STATIC_RUNTIME=ON -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=%cd%\protobuf-%PROTOBUF_VER% -DCMAKE_PREFIX_PATH=%cd%\protobuf-%PROTOBUF_VER% -G "Visual Studio %visual_studio_major_version% %VC_YEAR%" %CMAKE_VSARCH% .. || exit /b 1
53+
cmake -DCMAKE_CXX_STANDARD=17 -DABSL_MSVC_STATIC_RUNTIME=ON -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=%cd%\protobuf-%PROTOBUF_VER% -DCMAKE_PREFIX_PATH=%cd%\protobuf-%PROTOBUF_VER% -G "Visual Studio %visual_studio_major_version% %VC_YEAR%" %CMAKE_VSARCH% .. || exit /b 1
5554
cmake --build . --config Release --target install || exit /b 1
5655
popd
5756
goto :eof

buildscripts/make_dependencies.sh

Lines changed: 55 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,54 +3,33 @@
33
# Build protoc
44
set -evux -o pipefail
55

6-
PROTOBUF_VERSION=26.1
6+
PROTOBUF_VERSION=33.1
77
ABSL_VERSION=20250127.1
8-
CMAKE_VERSION=3.26.3
98

109
# ARCH is x86_64 bit unless otherwise specified.
1110
ARCH="${ARCH:-x86_64}"
1211
DOWNLOAD_DIR=/tmp/source
1312
INSTALL_DIR="/tmp/protobuf-cache/$PROTOBUF_VERSION/$(uname -s)-$ARCH"
1413
BUILDSCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd)"
15-
mkdir -p $DOWNLOAD_DIR
16-
cd "$DOWNLOAD_DIR"
17-
18-
# Start with a sane default
19-
NUM_CPU=4
20-
if [[ $(uname) == 'Linux' ]]; then
21-
NUM_CPU=$(nproc)
22-
fi
23-
if [[ $(uname) == 'Darwin' ]]; then
24-
NUM_CPU=$(sysctl -n hw.ncpu)
25-
fi
2614

27-
# Make protoc
28-
# Can't check for presence of directory as cache auto-creates it.
29-
if [ -f ${INSTALL_DIR}/bin/protoc ]; then
30-
echo "Not building protobuf. Already built"
31-
# TODO(ejona): swap to `brew install --devel protobuf` once it is up-to-date
32-
else
33-
if [[ ! -d "protobuf-${PROTOBUF_VERSION}" ]]; then
34-
curl -Ls "https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/protobuf-${PROTOBUF_VERSION}.tar.gz" | tar xz
35-
curl -Ls "https://github.com/abseil/abseil-cpp/archive/refs/tags/${ABSL_VERSION}.tar.gz" | tar xz
36-
rmdir "protobuf-$PROTOBUF_VERSION/third_party/abseil-cpp"
37-
mv "abseil-cpp-$ABSL_VERSION" "protobuf-$PROTOBUF_VERSION/third_party/abseil-cpp"
15+
function build_and_install() {
16+
if [[ "$1" == "abseil" ]]; then
17+
TESTS_OFF_ARG=ABSL_BUILD_TEST_HELPERS
18+
else
19+
TESTS_OFF_ARG=protobuf_BUILD_TESTS
3820
fi
39-
# the same source dir is used for 32 and 64 bit builds, so we need to clean stale data first
40-
rm -rf "$DOWNLOAD_DIR/protobuf-${PROTOBUF_VERSION}/build"
41-
mkdir "$DOWNLOAD_DIR/protobuf-${PROTOBUF_VERSION}/build"
42-
pushd "$DOWNLOAD_DIR/protobuf-${PROTOBUF_VERSION}/build"
43-
# install here so we don't need sudo
4421
if [[ "$(uname -s)" == "Darwin" ]]; then
4522
cmake .. \
46-
-DCMAKE_CXX_STANDARD=14 -Dprotobuf_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF \
47-
-DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" -DABSL_INTERNAL_AT_LEAST_CXX17=0 \
23+
-DCMAKE_CXX_STANDARD=17 -D${TESTS_OFF_ARG}=OFF -DBUILD_SHARED_LIBS=OFF \
24+
-DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" \
25+
-DCMAKE_PREFIX_PATH="$INSTALL_DIR" \
4826
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
4927
-B. || exit 1
5028
elif [[ "$ARCH" == x86* ]]; then
5129
CFLAGS=-m${ARCH#*_} CXXFLAGS=-m${ARCH#*_} cmake .. \
52-
-DCMAKE_CXX_STANDARD=14 -Dprotobuf_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF \
53-
-DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" -DABSL_INTERNAL_AT_LEAST_CXX17=0 \
30+
-DCMAKE_CXX_STANDARD=17 -D${TESTS_OFF_ARG}=OFF -DBUILD_SHARED_LIBS=OFF \
31+
-DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" \
32+
-DCMAKE_PREFIX_PATH="$INSTALL_DIR" \
5433
-B. || exit 1
5534
else
5635
if [[ "$ARCH" == aarch_64 ]]; then
@@ -66,17 +45,56 @@ else
6645
exit 1
6746
fi
6847
cmake .. \
69-
-DCMAKE_CXX_STANDARD=14 -Dprotobuf_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF \
70-
-DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" -DABSL_INTERNAL_AT_LEAST_CXX17=0 \
48+
-DCMAKE_CXX_STANDARD=17 -D${TESTS_OFF_ARG}=OFF -DBUILD_SHARED_LIBS=OFF \
49+
-DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" \
50+
-DCMAKE_PREFIX_PATH="$INSTALL_DIR" \
7151
-Dcrosscompile_ARCH="$GCC_ARCH" \
7252
-DCMAKE_TOOLCHAIN_FILE=$BUILDSCRIPTS_DIR/toolchain.cmake \
7353
-B. || exit 1
7454
fi
7555
export CMAKE_BUILD_PARALLEL_LEVEL="$NUM_CPU"
7656
cmake --build . || exit 1
57+
# install here so we don't need sudo
7758
cmake --install . || exit 1
78-
[ -d "$INSTALL_DIR/lib64" ] && mv "$INSTALL_DIR/lib64" "$INSTALL_DIR/lib"
59+
}
60+
61+
mkdir -p $DOWNLOAD_DIR
62+
cd "$DOWNLOAD_DIR"
63+
64+
# Start with a sane default
65+
NUM_CPU=4
66+
if [[ $(uname) == 'Linux' ]]; then
67+
NUM_CPU=$(nproc)
68+
fi
69+
if [[ $(uname) == 'Darwin' ]]; then
70+
NUM_CPU=$(sysctl -n hw.ncpu)
71+
fi
72+
export CMAKE_BUILD_PARALLEL_LEVEL="$NUM_CPU"
73+
74+
# Make protoc
75+
# Can't check for presence of directory as cache auto-creates it.
76+
if [ -f ${INSTALL_DIR}/bin/protoc ]; then
77+
echo "Not building protobuf. Already built"
78+
# TODO(ejona): swap to `brew install --devel protobuf` once it is up-to-date
79+
else
80+
if [[ ! -d "protobuf-${PROTOBUF_VERSION}" ]]; then
81+
curl -Ls "https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/protobuf-${PROTOBUF_VERSION}.tar.gz" | tar xz
82+
curl -Ls "https://github.com/abseil/abseil-cpp/archive/refs/tags/${ABSL_VERSION}.tar.gz" | tar xz
83+
fi
84+
# the same source dir is used for 32 and 64 bit builds, so we need to clean stale data first
85+
rm -rf "$DOWNLOAD_DIR/abseil-cpp-${ABSL_VERSION}/build"
86+
mkdir "$DOWNLOAD_DIR/abseil-cpp-${ABSL_VERSION}/build"
87+
pushd "$DOWNLOAD_DIR/abseil-cpp-${ABSL_VERSION}/build"
88+
build_and_install "abseil"
89+
popd
90+
91+
rm -rf "$DOWNLOAD_DIR/protobuf-${PROTOBUF_VERSION}/build"
92+
mkdir "$DOWNLOAD_DIR/protobuf-${PROTOBUF_VERSION}/build"
93+
pushd "$DOWNLOAD_DIR/protobuf-${PROTOBUF_VERSION}/build"
94+
build_and_install "protobuf"
7995
popd
96+
97+
[ -d "$INSTALL_DIR/lib64" ] && mv "$INSTALL_DIR/lib64" "$INSTALL_DIR/lib"
8098
fi
8199

82100
# If /tmp/protobuf exists then we just assume it's a symlink created by us.
@@ -94,3 +112,4 @@ export CXXFLAGS="$(PKG_CONFIG_PATH=/tmp/protobuf/lib/pkgconfig pkg-config --cfla
94112
export LIBRARY_PATH=/tmp/protobuf/lib
95113
export LD_LIBRARY_PATH=/tmp/protobuf/lib
96114
EOF
115+

compiler/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ model {
102102
all {
103103
if (toolChain in Gcc || toolChain in Clang) {
104104
cppCompiler.define("GRPC_VERSION", version)
105-
cppCompiler.args "--std=c++14"
105+
cppCompiler.args "--std=c++17"
106106
addEnvArgs("CXXFLAGS", cppCompiler.args)
107107
addEnvArgs("CPPFLAGS", cppCompiler.args)
108108
if (project.hasProperty('buildUniversal') &&
@@ -132,7 +132,7 @@ model {
132132
} else if (toolChain in VisualCpp) {
133133
usingVisualCpp = true
134134
cppCompiler.define("GRPC_VERSION", version)
135-
cppCompiler.args "/EHsc", "/MT"
135+
cppCompiler.args "/EHsc", "/MT", "/std:c++17"
136136
if (rootProject.hasProperty('vcProtobufInclude')) {
137137
cppCompiler.args "/I${rootProject.vcProtobufInclude}"
138138
}

0 commit comments

Comments
 (0)