Skip to content

Commit

Permalink
apacheGH-34523: [C++] Avoid mixing bundled Abseil and system Abseil (a…
Browse files Browse the repository at this point in the history
…pache#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: apache#34523

Lead-authored-by: Sutou Kouhei <kou@clear-code.com>
Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
Co-authored-by: David Li <li.davidm96@gmail.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
  • Loading branch information
3 people authored and rtpsw committed May 16, 2023
1 parent 1036ba3 commit 5891293
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
25 changes: 17 additions & 8 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 8 additions & 2 deletions cpp/src/arrow/flight/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 5891293

Please sign in to comment.