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

kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new 34414b537a GH-49764: [C++][Python] Avoid building bundled Abseil 
outside resolve_dependency (#49936)
34414b537a is described below

commit 34414b537a82013041b49cf84c7a2267cefd2cc4
Author: Raúl Cumplido <[email protected]>
AuthorDate: Thu May 7 11:11:02 2026 +0200

    GH-49764: [C++][Python] Avoid building bundled Abseil outside 
resolve_dependency (#49936)
    
    ### Rationale for this change
    
    With the bump versions for gRPC/Protobuf/Abseil and others a bug was 
introduced where we build Abseil outside of resolve dependency. This caused to 
interpret Abseil as System dependency for Arrow Flight when it was bundled and 
failing to find it when trying to build PyArrow.
    
    ### What changes are included in this PR?
    
    Reorder resolve_dependency abseil to be done before resolving protobuf in 
order to not require manually building abseil.
    
    ### Are these changes tested?
    
    Yes via CI, via archery and validated the local build that previously 
failed now succeeds
    
    ### Are there any user-facing changes?
    No
    
    * GitHub Issue: #49764
    
    Authored-by: Raúl Cumplido <[email protected]>
    Signed-off-by: Sutou Kouhei <[email protected]>
---
 cpp/cmake_modules/ThirdpartyToolchain.cmake | 63 +++++++++++++++--------------
 1 file changed, 32 insertions(+), 31 deletions(-)

diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake 
b/cpp/cmake_modules/ThirdpartyToolchain.cmake
index 28d9b350b3..2f5bbf55a4 100644
--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake
+++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake
@@ -1934,13 +1934,6 @@ function(build_protobuf)
   list(APPEND CMAKE_MESSAGE_INDENT "Protobuf: ")
   message(STATUS "Building Protocol Buffers from source using FetchContent")
 
-  # Protobuf requires Abseil. Build Abseil first with OVERRIDE_FIND_PACKAGE
-  # so that protobuf doesn't build its own copy and we can reuse it on 
google-cloud-cpp
-  # if it's also being built.
-  if(NOT TARGET absl::strings)
-    build_absl()
-  endif()
-
   set(PROTOBUF_VENDORED
       TRUE
       PARENT_SCOPE)
@@ -2100,6 +2093,38 @@ function(build_protobuf)
   list(POP_BACK CMAKE_MESSAGE_INDENT)
 endfunction()
 
+# Abseil must be resolved before Protobuf because Protobuf 22+ requires
+# Abseil during its own configure. See GH-49764.
+if(ARROW_WITH_GOOGLE_CLOUD_CPP
+   OR ARROW_WITH_GRPC
+   OR ARROW_WITH_PROTOBUF)
+  # Abseil 20230125 released CRC32C which is necessary for GCS builds
+  set(ARROW_ABSL_REQUIRED_VERSION 20230125)
+  # Google Cloud C++ SDK, gRPC and any dependency that pulls Protobuf
+  # requires Abseil.
+  if(ARROW_WITH_GOOGLE_CLOUD_CPP
+     OR ARROW_ORC
+     OR ARROW_SUBSTRAIT
+     OR ARROW_WITH_OPENTELEMETRY)
+    set(ARROW_ABSL_CMAKE_PACKAGE_NAME Arrow)
+    set(ARROW_ABSL_PC_PACKAGE_NAME arrow)
+  else()
+    set(ARROW_ABSL_CMAKE_PACKAGE_NAME ArrowFlight)
+    set(ARROW_ABSL_PC_PACKAGE_NAME arrow-flight)
+  endif()
+  resolve_dependency(absl
+                     ARROW_CMAKE_PACKAGE_NAME
+                     ${ARROW_ABSL_CMAKE_PACKAGE_NAME}
+                     ARROW_PC_PACKAGE_NAME
+                     ${ARROW_ABSL_PC_PACKAGE_NAME}
+                     HAVE_ALT
+                     TRUE
+                     FORCE_ANY_NEWER_VERSION
+                     TRUE
+                     REQUIRED_VERSION
+                     ${ARROW_ABSL_REQUIRED_VERSION})
+endif()
+
 if(ARROW_WITH_PROTOBUF)
   if(ARROW_FLIGHT_SQL)
     # Flight SQL uses proto3 optionals, which require 3.12 or later.
@@ -3253,30 +3278,6 @@ function(build_grpc)
   list(POP_BACK CMAKE_MESSAGE_INDENT)
 endfunction()
 
-if(ARROW_WITH_GOOGLE_CLOUD_CPP OR ARROW_WITH_GRPC)
-  # Abseil 20230125 released CRC32C which is necessary for GCS builds
-  set(ARROW_ABSL_REQUIRED_VERSION 20230125)
-  # Google Cloud C++ SDK and gRPC require Google Abseil
-  if(ARROW_WITH_GOOGLE_CLOUD_CPP)
-    set(ARROW_ABSL_CMAKE_PACKAGE_NAME Arrow)
-    set(ARROW_ABSL_PC_PACKAGE_NAME arrow)
-  else()
-    set(ARROW_ABSL_CMAKE_PACKAGE_NAME ArrowFlight)
-    set(ARROW_ABSL_PC_PACKAGE_NAME arrow-flight)
-  endif()
-  resolve_dependency(absl
-                     ARROW_CMAKE_PACKAGE_NAME
-                     ${ARROW_ABSL_CMAKE_PACKAGE_NAME}
-                     ARROW_PC_PACKAGE_NAME
-                     ${ARROW_ABSL_PC_PACKAGE_NAME}
-                     HAVE_ALT
-                     TRUE
-                     FORCE_ANY_NEWER_VERSION
-                     TRUE
-                     REQUIRED_VERSION
-                     ${ARROW_ABSL_REQUIRED_VERSION})
-endif()
-
 if(ARROW_WITH_GRPC)
   if(NOT ARROW_ENABLE_THREADING)
     message(FATAL_ERROR "Can't use gRPC with ARROW_ENABLE_THREADING=OFF")

Reply via email to