Skip to content

Commit

Permalink
[fix](proto) upgrade protobuf to 21.11
Browse files Browse the repository at this point in the history
  • Loading branch information
morningman committed Oct 31, 2024
1 parent 8eb7e3b commit 896eb63
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 31 deletions.
40 changes: 13 additions & 27 deletions thirdparty/build-thirdparty.sh
Original file line number Diff line number Diff line change
Expand Up @@ -416,41 +416,27 @@ build_thrift() {
build_protobuf() {
check_if_source_exist "${PROTOBUF_SOURCE}"
cd "${TP_SOURCE_DIR}/${PROTOBUF_SOURCE}"
rm -fr gmock

# NOTE(amos): -Wl,--undefined=pthread_create force searching for pthread symbols.
# See https://stackoverflow.com/a/65348893/1329147 for detailed explanation.
mkdir gmock
cd gmock
tar xf "${TP_SOURCE_DIR}/${GTEST_NAME}"

mv "${GTEST_SOURCE}" gtest

cd "${TP_SOURCE_DIR}/${PROTOBUF_SOURCE}"

./autogen.sh

if [[ "${KERNEL}" == 'Darwin' ]]; then
ldflags="-L${TP_LIB_DIR}"
else
ldflags="-L${TP_LIB_DIR} -static-libstdc++ -static-libgcc -Wl,--undefined=pthread_create"
fi

CXXFLAGS="-fPIC -O2 -I${TP_INCLUDE_DIR}" \
LDFLAGS="${ldflags}" \
./configure --prefix="${TP_INSTALL_DIR}" --disable-shared --enable-static --with-zlib="${TP_INSTALL_DIR}/include"

# ATTN: If protoc is not built fully statically the linktime libc may newer than runtime.
# This will casue protoc cannot run
# If you really need to dynamically link protoc, please set the environment variable DYN_LINK_PROTOC=1
mkdir -p cmake/build
cd cmake/build

if [[ "${DYN_LINK_PROTOC:-0}" == "1" || "${KERNEL}" == 'Darwin' ]]; then
echo "link protoc dynamiclly"
else
cd src
sed -i 's/^AM_LDFLAGS\(.*\)$/AM_LDFLAGS\1 -all-static/' Makefile
cd -
fi
CXXFLAGS="-O2 -I${TP_INCLUDE_DIR}" \
LDFLAGS="${ldflags}" \
"${CMAKE_CMD}" -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH="${TP_INSTALL_DIR}" \
-Dprotobuf_USE_EXTERNAL_GTEST=ON \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-Dprotobuf_BUILD_SHARED_LIBS=OFF \
-Dprotobuf_BUILD_TESTS=OFF \
-Dprotobuf_WITH_ZLIB_DEFAULT=ON \
-Dprotobuf_ABSL_PROVIDER=package \
-DCMAKE_INSTALL_PREFIX="${TP_INSTALL_DIR}" ../..

make -j "${PARALLEL}"
make install
Expand Down
9 changes: 5 additions & 4 deletions thirdparty/vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@ THRIFT_SOURCE=thrift-0.16.0
THRIFT_MD5SUM="44cf1b54b4ec1890576c85804acfa637"

# protobuf
PROTOBUF_DOWNLOAD="https://github.com/google/protobuf/archive/v3.15.0.tar.gz"
PROTOBUF_NAME=protobuf-3.15.0.tar.gz
PROTOBUF_SOURCE=protobuf-3.15.0
PROTOBUF_MD5SUM="3fb6c41f7b3c621424543f43d54baa42"
# brpc is not yet compatible with protobuf >= 22
PROTOBUF_DOWNLOAD="https://github.com/protocolbuffers/protobuf/releases/download/v21.11/protobuf-all-21.11.tar.gz"
PROTOBUF_NAME="protobuf-all-21.11.tar.gz"
PROTOBUF_SOURCE=protobuf-21.11
PROTOBUF_MD5SUM="b3b104f0374802e1add5d5d7a5a845ac"

# gflags
GFLAGS_DOWNLOAD="https://github.com/gflags/gflags/archive/v2.2.2.tar.gz"
Expand Down

0 comments on commit 896eb63

Please sign in to comment.