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 a77aab07b0 GH-34523: [C++] Avoid mixing bundled Abseil and system
Abseil (#35387)
a77aab07b0 is described below
commit a77aab07b02b7d0dd6bd9c9a11c4af067d26b674
Author: Sutou Kouhei <[email protected]>
AuthorDate: Wed May 3 15:46:38 2023 +0900
GH-34523: [C++] Avoid mixing bundled Abseil and system Abseil (#35387)
### Rationale for this change
If we use a CMake target that provides the same include path for system
Abseil in advance of a CMake target for bundled Abseil, header files for system
Abseil are used.
It causes a link error when system Abseil and bundled Abseil are
incompatible.
### What changes are included in this PR?
Use a CMake target for bundled Abseil as early as possible.
### Are these changes tested?
Yes.
### Are there any user-facing changes?
Yes.
* Closes: #34523
Lead-authored-by: Sutou Kouhei <[email protected]>
Co-authored-by: Sutou Kouhei <[email protected]>
Co-authored-by: David Li <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
---
cpp/CMakeLists.txt | 25 +++++++++++++++++--------
cpp/src/arrow/flight/CMakeLists.txt | 10 ++++++++--
2 files changed, 25 insertions(+), 10 deletions(-)
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index b0adf749d4..c81427058c 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -659,6 +659,23 @@ set(ARROW_SHARED_INSTALL_INTERFACE_LIBS)
set(ARROW_STATIC_LINK_LIBS arrow::flatbuffers arrow::hadoop)
set(ARROW_STATIC_INSTALL_INTERFACE_LIBS)
+# We must use google-cloud-cpp::storage first. If
+# google-cloud-cpp::storage depends on bundled Abseil, bundled Abseil
+# and system Abseil may be mixed.
+#
+# For example, if Boost::headers is used before
+# google-cloud-cpp::storage AND Boost::headers has
+# -I/opt/homebrew/include AND /opt/homebrew/include/absl/ exists,
+# /opt/homebrew/include/absl/**/*.h are used instead of .h provided by
+# bundled Abseil.
+if(ARROW_GCS)
+ list(APPEND ARROW_SHARED_LINK_LIBS google-cloud-cpp::storage)
+ list(APPEND ARROW_STATIC_LINK_LIBS google-cloud-cpp::storage)
+ if(google_cloud_cpp_storage_SOURCE STREQUAL "SYSTEM")
+ list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS google-cloud-cpp::storage)
+ endif()
+endif()
+
if(ARROW_USE_BOOST)
list(APPEND ARROW_SHARED_LINK_LIBS Boost::headers)
list(APPEND ARROW_STATIC_LINK_LIBS Boost::headers)
@@ -725,14 +742,6 @@ if(ARROW_ORC)
endif()
endif()
-if(ARROW_GCS)
- list(APPEND ARROW_SHARED_LINK_LIBS google-cloud-cpp::storage)
- list(APPEND ARROW_STATIC_LINK_LIBS google-cloud-cpp::storage)
- if(google_cloud_cpp_storage_SOURCE STREQUAL "SYSTEM")
- list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS google-cloud-cpp::storage)
- endif()
-endif()
-
if(ARROW_USE_GLOG)
list(APPEND ARROW_SHARED_LINK_LIBS glog::glog)
list(APPEND ARROW_STATIC_LINK_LIBS glog::glog)
diff --git a/cpp/src/arrow/flight/CMakeLists.txt
b/cpp/src/arrow/flight/CMakeLists.txt
index 42dafdf496..2a88e5f8ec 100644
--- a/cpp/src/arrow/flight/CMakeLists.txt
+++ b/cpp/src/arrow/flight/CMakeLists.txt
@@ -238,13 +238,19 @@ add_arrow_lib(arrow_flight
SHARED_LINK_FLAGS
${ARROW_VERSION_SCRIPT_FLAGS} # Defined in
cpp/arrow/CMakeLists.txt
SHARED_LINK_LIBS
- arrow_shared
+ # We must use gRPC::grpc++ first. If gRPC::grpc++
+ # depends on bundled Abseil, bundled Abseil and system
+ # Abseil may be mixed.
+ #
+ # See also a comment for "if(ARROW_GCS)" in
+ # cpp/CMakeLists.txt.
${ARROW_FLIGHT_LINK_LIBS}
+ arrow_shared
SHARED_INSTALL_INTERFACE_LIBS
Arrow::arrow_shared
STATIC_LINK_LIBS
- arrow_static
${ARROW_FLIGHT_LINK_LIBS}
+ arrow_static
STATIC_INSTALL_INTERFACE_LIBS
Arrow::arrow_static)