This is an automated email from the ASF dual-hosted git repository.

kxiao pushed a commit to branch revert-43035-upgrade_protoc
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 7f539a2e95a79f0bcb01c320c1a57a2e96a39f9e
Author: Kang <xiaok...@selectdb.com>
AuthorDate: Mon Nov 18 20:27:32 2024 +0800

    Revert "[fix](proto) upgrade protobuf to 21.11 (#43035)"
    
    This reverts commit febedbb870ed12c9ce60aba48b731eb7d47412fd.
---
 thirdparty/build-thirdparty.sh | 40 +++++++++++++++++++++++++++-------------
 thirdparty/vars.sh             |  9 ++++-----
 2 files changed, 31 insertions(+), 18 deletions(-)

diff --git a/thirdparty/build-thirdparty.sh b/thirdparty/build-thirdparty.sh
index ed75aaefe73..78415a2a4a3 100755
--- a/thirdparty/build-thirdparty.sh
+++ b/thirdparty/build-thirdparty.sh
@@ -416,6 +416,19 @@ 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}"
@@ -423,20 +436,21 @@ build_protobuf() {
         ldflags="-L${TP_LIB_DIR} -static-libstdc++ -static-libgcc 
-Wl,--undefined=pthread_create"
     fi
 
-    mkdir -p cmake/build
-    cd cmake/build
-
-    CXXFLAGS="-O2 -I${TP_INCLUDE_DIR}" \
+    CXXFLAGS="-fPIC -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}" ../..
+        ./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
+
+    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
 
     make -j "${PARALLEL}"
     make install
diff --git a/thirdparty/vars.sh b/thirdparty/vars.sh
index f8d44514abd..c132a7ec9d6 100644
--- a/thirdparty/vars.sh
+++ b/thirdparty/vars.sh
@@ -73,11 +73,10 @@ THRIFT_SOURCE=thrift-0.16.0
 THRIFT_MD5SUM="44cf1b54b4ec1890576c85804acfa637"
 
 # protobuf
-# 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"
+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"
 
 # gflags
 GFLAGS_DOWNLOAD="https://github.com/gflags/gflags/archive/v2.2.2.tar.gz";


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to