From d6d7d098697a34a849920339d36de2a4b9312e7c Mon Sep 17 00:00:00 2001 From: Rok Date: Mon, 28 Feb 2022 06:21:38 +0100 Subject: [PATCH 01/10] cmake changes and helper scripts --- cpp/build-support/list-absl-libraries.sh | 70 +++++++++++++++++++++ cpp/cmake_modules/BuildUtils.cmake | 10 ++- cpp/cmake_modules/ThirdpartyToolchain.cmake | 10 +-- cpp/src/arrow/ArrowConfig.cmake.in | 10 +-- cpp/src/arrow/CMakeLists.txt | 7 ++- cpp/src/arrow/flight/CMakeLists.txt | 4 +- 6 files changed, 90 insertions(+), 21 deletions(-) create mode 100755 cpp/build-support/list-absl-libraries.sh diff --git a/cpp/build-support/list-absl-libraries.sh b/cpp/build-support/list-absl-libraries.sh new file mode 100755 index 00000000000..9c311b44540 --- /dev/null +++ b/cpp/build-support/list-absl-libraries.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# This script extracts dependency information of all Abseil +# packages in the given build folder. +# +# Arguments: +# $1 - Path to a build folder + +function join { local IFS="$1"; shift; echo "$*"; } + +ABSL_PKGCONFIG_FOLDERS=$(find $1 -type f -name 'absl_*.pc' | sed -r 's|/[^/]+$||' | sort -u) +ABSL_LIBS=$(find $1 -type f -name 'libabsl_*.a' | sed -e 's/.*libabsl_//' -e 's/.a$//' | sort -u) +ABSL_INTERFACE_LIBS=$(find $1* -type f -name 'absl_*.pc' | sed -e 's/.*absl_//' -e 's/.pc$//' | sort -u) +ABSL_INTERFACE_LIBS=$(comm -13 <(echo ABSL_LIBS) <(echo $ABSL_INTERFACE_LIBS)) + +GRPC_PKGCONFIG_FOLDERS=$(find $1/grpc_* -type f -name '*.pc' | sed -r 's|/[^/]+$||' | sort -u) +GRPC_LIBS=$(find $1/grpc_* -type f -name '*.a' | sed -e 's/.*lib//' -e 's/.a$//' | sort -u) +GRPC_INTERFACE_LIBS=$(find $1/grpc_* -type f -name '*.pc' | sed -e 's/.*pkgconfig\///' -e 's/.pc$//' | sort -u) +GRPC_INTERFACE_LIBS=$(comm -13 <(echo $GRPC_LIBS) <(echo $GRPC_INTERFACE_LIBS)) + +printf "\n# Abseil produces the following libraries, each is fairly small, but there +# are (as you can see), many of them. We need to add the libraries first, +# and then describe how they depend on each other.\n\n" +echo "set(_ABSL_LIBS" $ABSL_LIBS")" + +printf "\n# Abseil creates a number of header-only targets, which are needed to resolve dependencies.\n\n" +echo "set(_ABSL_INTERFACE_LIBS" $(join " " ${ABSL_INTERFACE_LIBS[*]})")" +printf "\n" + +for FOLDER in $ABSL_PKGCONFIG_FOLDERS +do + grep Requires "$FOLDER"/*.pc | + sed -e 's;.*/absl_;set_property(TARGET absl::;' \ + -e 's/.pc:Requires:/\n PROPERTY INTERFACE_LINK_LIBRARIES /' \ + -e 's/ = 20210324,//g' \ + -e 's/ = 20210324//g' \ + -e 's/absl_/\n\ absl::/g' \ + -e 's/$/)/' | \ + grep -v 'INTERFACE_LINK_LIBRARIES[ ]*)' +done + +printf "\n\n" + +echo "set(_GRPC_LIBS" $GRPC_LIBS")" +echo "set(_GRPC_INTERFACE_LIBS" $(join " " ${GRPC_INTERFACE_LIBS[*]})")" + +for FOLDER in $GRPC_PKGCONFIG_FOLDERS +do + grep Requires "$FOLDER"/*.pc | + sed -e 's/ / gRPC::/g' \ + -e 's;.*pkgconfig\/;set_property(TARGET gRPC::;' \ + -e 's/.pc:Requires:/\n PROPERTY INTERFACE_LINK_LIBRARIES /' +done \ No newline at end of file diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake index 2bcaed43e5d..0ed2901f46a 100644 --- a/cpp/cmake_modules/BuildUtils.cmake +++ b/cpp/cmake_modules/BuildUtils.cmake @@ -240,7 +240,9 @@ function(ADD_ARROW_LIB LIB_NAME) DEPENDENCIES SHARED_INSTALL_INTERFACE_LIBS STATIC_INSTALL_INTERFACE_LIBS - OUTPUT_PATH) + OUTPUT_PATH + SHARED_INSTALL_EXTRA_TARGETS + STATIC_INSTALL_EXTRA_TARGETS) cmake_parse_arguments(ARG "${options}" "${one_value_args}" @@ -406,7 +408,8 @@ function(ADD_ARROW_LIB LIB_NAME) "${_lib_install_name}") endif() - install(TARGETS ${LIB_NAME}_shared ${INSTALL_IS_OPTIONAL} + install(TARGETS ${LIB_NAME}_shared ${ARG_SHARED_INSTALL_EXTRA_TARGETS} + ${INSTALL_IS_OPTIONAL} EXPORT ${LIB_NAME}_targets RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -470,7 +473,8 @@ function(ADD_ARROW_LIB LIB_NAME) endif() endif() - install(TARGETS ${LIB_NAME}_static ${INSTALL_IS_OPTIONAL} + install(TARGETS ${LIB_NAME}_static ${ARG_STATIC_INSTALL_EXTRA_TARGETS} + ${INSTALL_IS_OPTIONAL} EXPORT ${LIB_NAME}_targets RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 81524653db6..e590a603b49 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -2384,8 +2384,6 @@ macro(build_re2) # Set values so that FindRE2 finds this too set(RE2_LIB ${RE2_STATIC_LIB}) set(RE2_INCLUDE_DIR "${RE2_PREFIX}/include") - - list(APPEND ARROW_BUNDLED_STATIC_LIBS re2::re2) endmacro() if(ARROW_WITH_RE2) @@ -3585,12 +3583,9 @@ macro(build_grpc) set(GRPC_GPR_ABSL_LIBRARIES absl::base - absl::statusor - absl::status absl::cord - absl::strings - absl::synchronization - absl::time) + absl::statusor + absl::synchronization) add_library(gRPC::gpr STATIC IMPORTED) set_target_properties(gRPC::gpr PROPERTIES IMPORTED_LOCATION "${GRPC_STATIC_LIBRARY_GPR}" @@ -3614,7 +3609,6 @@ macro(build_grpc) gRPC::gpr gRPC::upb gRPC::address_sorting - re2::re2 c-ares::cares ZLIB::ZLIB OpenSSL::SSL diff --git a/cpp/src/arrow/ArrowConfig.cmake.in b/cpp/src/arrow/ArrowConfig.cmake.in index 6209baeec67..ac2b9a02759 100644 --- a/cpp/src/arrow/ArrowConfig.cmake.in +++ b/cpp/src/arrow/ArrowConfig.cmake.in @@ -38,6 +38,7 @@ set(ARROW_LIBRARY_PATH_SUFFIXES "@ARROW_LIBRARY_PATH_SUFFIXES@") set(ARROW_INCLUDE_PATH_SUFFIXES "@ARROW_INCLUDE_PATH_SUFFIXES@") set(ARROW_SYSTEM_DEPENDENCIES "@ARROW_SYSTEM_DEPENDENCIES@") set(ARROW_BUNDLED_STATIC_LIBS "@ARROW_BUNDLED_STATIC_LIBS@") +set(ARROW_STATIC_INSTALL_INTERFACE_LIBS "@ARROW_STATIC_INSTALL_INTERFACE_LIBS@") include("${CMAKE_CURRENT_LIST_DIR}/ArrowOptions.cmake") @@ -79,14 +80,9 @@ if(NOT (TARGET arrow_shared OR TARGET arrow_static)) PROPERTIES IMPORTED_LOCATION "${arrow_lib_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}arrow_bundled_dependencies${CMAKE_STATIC_LIBRARY_SUFFIX}" + INTERFACE_LINK_LIBRARIES + "${ARROW_STATIC_INSTALL_INTERFACE_LIBS}" ) - - get_property(arrow_static_interface_link_libraries - TARGET arrow_static - PROPERTY INTERFACE_LINK_LIBRARIES) - set_target_properties( - arrow_static PROPERTIES INTERFACE_LINK_LIBRARIES - "${arrow_static_interface_link_libraries};arrow_bundled_dependencies") endif() endif() endif() diff --git a/cpp/src/arrow/CMakeLists.txt b/cpp/src/arrow/CMakeLists.txt index a895881f9e3..6d689aa275b 100644 --- a/cpp/src/arrow/CMakeLists.txt +++ b/cpp/src/arrow/CMakeLists.txt @@ -535,6 +535,9 @@ endif() if(ARROW_BUILD_BUNDLED_DEPENDENCIES) string(APPEND ARROW_PC_LIBS_PRIVATE " -larrow_bundled_dependencies") + set(ARROW_STATIC_INSTALL_INTERFACE_LIBS_REAL "arrow_bundled_dependencies") +else() + set(ARROW_STATIC_INSTALL_INTERFACE_LIBS_REAL ${ARROW_STATIC_INSTALL_INTERFACE_LIBS}) endif() # Need -latomic on Raspbian. # See also: https://issues.apache.org/jira/browse/ARROW-12860 @@ -563,10 +566,10 @@ add_arrow_lib(arrow ${ARROW_SHARED_PRIVATE_LINK_LIBS} STATIC_LINK_LIBS ${ARROW_STATIC_LINK_LIBS} + ${ARROW_STATIC_INSTALL_INTERFACE_LIBS} SHARED_INSTALL_INTERFACE_LIBS ${ARROW_SHARED_INSTALL_INTERFACE_LIBS} - STATIC_INSTALL_INTERFACE_LIBS - ${ARROW_STATIC_INSTALL_INTERFACE_LIBS}) + STATIC_INSTALL_INTERFACE_LIBS) add_dependencies(arrow ${ARROW_LIBRARIES}) diff --git a/cpp/src/arrow/flight/CMakeLists.txt b/cpp/src/arrow/flight/CMakeLists.txt index cae36562be3..b154227db03 100644 --- a/cpp/src/arrow/flight/CMakeLists.txt +++ b/cpp/src/arrow/flight/CMakeLists.txt @@ -197,7 +197,9 @@ add_arrow_lib(arrow_flight ${ARROW_FLIGHT_LINK_LIBS} STATIC_LINK_LIBS arrow_static - ${ARROW_FLIGHT_LINK_LIBS}) + ${ARROW_FLIGHT_LINK_LIBS} + ${ARROW_STATIC_INSTALL_INTERFACE_LIBS_REAL} + arrow_static) foreach(LIB_TARGET ${ARROW_FLIGHT_LIBRARIES}) target_compile_definitions(${LIB_TARGET} PRIVATE ARROW_FLIGHT_EXPORTING) From b6e8a239057faf95f28247df1b89f68cebba68bc Mon Sep 17 00:00:00 2001 From: Rok Date: Wed, 2 Mar 2022 03:57:00 +0100 Subject: [PATCH 02/10] ArrowConfig.cmake.in --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 13 +++++-------- cpp/src/arrow/ArrowConfig.cmake.in | 10 +++++++--- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index e590a603b49..b7c701e2451 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -2384,6 +2384,8 @@ macro(build_re2) # Set values so that FindRE2 finds this too set(RE2_LIB ${RE2_STATIC_LIB}) set(RE2_INCLUDE_DIR "${RE2_PREFIX}/include") + + list(APPEND ARROW_BUNDLED_STATIC_LIBS re2::re2) endmacro() if(ARROW_WITH_RE2) @@ -3584,6 +3586,7 @@ macro(build_grpc) set(GRPC_GPR_ABSL_LIBRARIES absl::base absl::cord + absl::status absl::statusor absl::synchronization) add_library(gRPC::gpr STATIC IMPORTED) @@ -3609,6 +3612,7 @@ macro(build_grpc) gRPC::gpr gRPC::upb gRPC::address_sorting + re2::re2 c-ares::cares ZLIB::ZLIB OpenSSL::SSL @@ -3656,14 +3660,7 @@ macro(build_grpc) add_custom_target(grpc_copy_grpc++ ALL DEPENDS "${GRPC_STATIC_LIBRARY_GRPCPP_FOR_AR}") add_dependencies(gRPC::grpcpp_for_bundling grpc_copy_grpc++) - list(APPEND - ARROW_BUNDLED_STATIC_LIBS - ${GRPC_GPR_ABSL_LIBRARIES} - gRPC::address_sorting - gRPC::gpr - gRPC::grpc - gRPC::grpcpp_for_bundling - gRPC::upb) + list(APPEND ARROW_BUNDLED_STATIC_LIBS ${GRPC_GPR_ABSL_LIBRARIES}) endmacro() if(ARROW_WITH_GRPC) diff --git a/cpp/src/arrow/ArrowConfig.cmake.in b/cpp/src/arrow/ArrowConfig.cmake.in index ac2b9a02759..5f2cd72b94e 100644 --- a/cpp/src/arrow/ArrowConfig.cmake.in +++ b/cpp/src/arrow/ArrowConfig.cmake.in @@ -80,9 +80,13 @@ if(NOT (TARGET arrow_shared OR TARGET arrow_static)) PROPERTIES IMPORTED_LOCATION "${arrow_lib_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}arrow_bundled_dependencies${CMAKE_STATIC_LIBRARY_SUFFIX}" - INTERFACE_LINK_LIBRARIES - "${ARROW_STATIC_INSTALL_INTERFACE_LIBS}" - ) + ) + get_property(arrow_static_interface_link_libraries + TARGET arrow_static + PROPERTY INTERFACE_LINK_LIBRARIES) + set_target_properties( + arrow_static PROPERTIES INTERFACE_LINK_LIBRARIES + "${arrow_static_interface_link_libraries};arrow_bundled_dependencies") endif() endif() endif() From 26d27e6f0f43148789fbed063416679480340046 Mon Sep 17 00:00:00 2001 From: Rok Date: Thu, 3 Mar 2022 19:16:37 +0100 Subject: [PATCH 03/10] Removing -larrow_bundled_dependencies --- cpp/src/arrow/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/cpp/src/arrow/CMakeLists.txt b/cpp/src/arrow/CMakeLists.txt index 6d689aa275b..5d8eee94988 100644 --- a/cpp/src/arrow/CMakeLists.txt +++ b/cpp/src/arrow/CMakeLists.txt @@ -534,8 +534,6 @@ else() endif() if(ARROW_BUILD_BUNDLED_DEPENDENCIES) - string(APPEND ARROW_PC_LIBS_PRIVATE " -larrow_bundled_dependencies") - set(ARROW_STATIC_INSTALL_INTERFACE_LIBS_REAL "arrow_bundled_dependencies") else() set(ARROW_STATIC_INSTALL_INTERFACE_LIBS_REAL ${ARROW_STATIC_INSTALL_INTERFACE_LIBS}) endif() From 95c6df8f4306f5bf6060c9395b893642ef82f5fd Mon Sep 17 00:00:00 2001 From: Rok Date: Thu, 3 Mar 2022 22:11:02 +0100 Subject: [PATCH 04/10] Review feedback --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 18 ++++++++++++++---- cpp/src/arrow/ArrowConfig.cmake.in | 1 - cpp/src/arrow/CMakeLists.txt | 3 +-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index b7c701e2451..8ca76de5831 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -3585,10 +3585,12 @@ macro(build_grpc) set(GRPC_GPR_ABSL_LIBRARIES absl::base - absl::cord - absl::status absl::statusor - absl::synchronization) + absl::status + absl::cord + absl::strings + absl::synchronization + absl::time) add_library(gRPC::gpr STATIC IMPORTED) set_target_properties(gRPC::gpr PROPERTIES IMPORTED_LOCATION "${GRPC_STATIC_LIBRARY_GPR}" @@ -3660,7 +3662,15 @@ macro(build_grpc) add_custom_target(grpc_copy_grpc++ ALL DEPENDS "${GRPC_STATIC_LIBRARY_GRPCPP_FOR_AR}") add_dependencies(gRPC::grpcpp_for_bundling grpc_copy_grpc++) - list(APPEND ARROW_BUNDLED_STATIC_LIBS ${GRPC_GPR_ABSL_LIBRARIES}) + list(APPEND + ARROW_BUNDLED_STATIC_LIBS + gRPC::address_sorting + gRPC::gpr + gRPC::grpc + gRPC::grpcpp_for_bundling + gRPC::upb + ${GRPC_GPR_ABSL_LIBRARIES}) + endmacro() if(ARROW_WITH_GRPC) diff --git a/cpp/src/arrow/ArrowConfig.cmake.in b/cpp/src/arrow/ArrowConfig.cmake.in index 5f2cd72b94e..61febfc233f 100644 --- a/cpp/src/arrow/ArrowConfig.cmake.in +++ b/cpp/src/arrow/ArrowConfig.cmake.in @@ -48,7 +48,6 @@ include(CMakeFindDependencyMacro) # already existent target error. if(NOT (TARGET arrow_shared OR TARGET arrow_static)) include("${CMAKE_CURRENT_LIST_DIR}/ArrowTargets.cmake") - if(TARGET arrow_static) set(CMAKE_THREAD_PREFER_PTHREAD TRUE) set(THREADS_PREFER_PTHREAD_FLAG TRUE) diff --git a/cpp/src/arrow/CMakeLists.txt b/cpp/src/arrow/CMakeLists.txt index 5d8eee94988..a03f0bfff78 100644 --- a/cpp/src/arrow/CMakeLists.txt +++ b/cpp/src/arrow/CMakeLists.txt @@ -533,8 +533,7 @@ else() set(ARROW_BUILD_BUNDLED_DEPENDENCIES FALSE) endif() -if(ARROW_BUILD_BUNDLED_DEPENDENCIES) -else() +if(NOT ARROW_BUILD_BUNDLED_DEPENDENCIES) set(ARROW_STATIC_INSTALL_INTERFACE_LIBS_REAL ${ARROW_STATIC_INSTALL_INTERFACE_LIBS}) endif() # Need -latomic on Raspbian. From aa4f1ca5638dade025610a19ea558bb488210be9 Mon Sep 17 00:00:00 2001 From: Rok Date: Sun, 6 Mar 2022 06:32:33 +0100 Subject: [PATCH 05/10] Adding abseils --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 25 ++++++++++++++++----- cpp/src/arrow/ArrowConfig.cmake.in | 4 +++- cpp/src/arrow/CMakeLists.txt | 8 +++++-- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 8ca76de5831..23bbb3b016a 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -3584,13 +3584,28 @@ macro(build_grpc) INTERFACE_INCLUDE_DIRECTORIES "${GRPC_INCLUDE_DIR}") set(GRPC_GPR_ABSL_LIBRARIES + absl::bad_optional_access absl::base - absl::statusor - absl::status absl::cord + absl::debugging_internal + absl::demangle_internal + absl::graphcycles_internal + absl::int128 + absl::malloc_internal + absl::raw_logging_internal + absl::spinlock_wait + absl::stacktrace + absl::status + absl::statusor absl::strings + absl::strings_internal + absl::str_format_internal + absl::symbolize absl::synchronization - absl::time) + absl::throw_delegate + absl::time + absl::time_zone) + add_library(gRPC::gpr STATIC IMPORTED) set_target_properties(gRPC::gpr PROPERTIES IMPORTED_LOCATION "${GRPC_STATIC_LIBRARY_GPR}" @@ -3664,12 +3679,12 @@ macro(build_grpc) list(APPEND ARROW_BUNDLED_STATIC_LIBS + ${GRPC_GPR_ABSL_LIBRARIES} gRPC::address_sorting gRPC::gpr gRPC::grpc gRPC::grpcpp_for_bundling - gRPC::upb - ${GRPC_GPR_ABSL_LIBRARIES}) + gRPC::upb) endmacro() diff --git a/cpp/src/arrow/ArrowConfig.cmake.in b/cpp/src/arrow/ArrowConfig.cmake.in index 61febfc233f..e8d79c08982 100644 --- a/cpp/src/arrow/ArrowConfig.cmake.in +++ b/cpp/src/arrow/ArrowConfig.cmake.in @@ -38,7 +38,7 @@ set(ARROW_LIBRARY_PATH_SUFFIXES "@ARROW_LIBRARY_PATH_SUFFIXES@") set(ARROW_INCLUDE_PATH_SUFFIXES "@ARROW_INCLUDE_PATH_SUFFIXES@") set(ARROW_SYSTEM_DEPENDENCIES "@ARROW_SYSTEM_DEPENDENCIES@") set(ARROW_BUNDLED_STATIC_LIBS "@ARROW_BUNDLED_STATIC_LIBS@") -set(ARROW_STATIC_INSTALL_INTERFACE_LIBS "@ARROW_STATIC_INSTALL_INTERFACE_LIBS@") +set(ARROW_STATIC_INSTALL_INTERFACE_LIBS "@ARROW_STATIC_INSTALL_INTERFACE_LIBS_REAL@") include("${CMAKE_CURRENT_LIST_DIR}/ArrowOptions.cmake") @@ -79,6 +79,8 @@ if(NOT (TARGET arrow_shared OR TARGET arrow_static)) PROPERTIES IMPORTED_LOCATION "${arrow_lib_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}arrow_bundled_dependencies${CMAKE_STATIC_LIBRARY_SUFFIX}" + INTERFACE_LINK_LIBRARIES + ${ARROW_STATIC_INSTALL_INTERFACE_LIBS} ) get_property(arrow_static_interface_link_libraries TARGET arrow_static diff --git a/cpp/src/arrow/CMakeLists.txt b/cpp/src/arrow/CMakeLists.txt index a03f0bfff78..dd4ff08d16b 100644 --- a/cpp/src/arrow/CMakeLists.txt +++ b/cpp/src/arrow/CMakeLists.txt @@ -533,7 +533,11 @@ else() set(ARROW_BUILD_BUNDLED_DEPENDENCIES FALSE) endif() -if(NOT ARROW_BUILD_BUNDLED_DEPENDENCIES) +if(ARROW_BUILD_BUNDLED_DEPENDENCIES) + string(APPEND ARROW_PC_LIBS_PRIVATE " -larrow_bundled_dependencies") + set(ARROW_STATIC_INSTALL_INTERFACE_LIBS -libarrow_bundled_dependencies) + set(ARROW_STATIC_INSTALL_INTERFACE_LIBS_REAL ${ARROW_STATIC_INSTALL_INTERFACE_LIBS}) +else() set(ARROW_STATIC_INSTALL_INTERFACE_LIBS_REAL ${ARROW_STATIC_INSTALL_INTERFACE_LIBS}) endif() # Need -latomic on Raspbian. @@ -563,7 +567,7 @@ add_arrow_lib(arrow ${ARROW_SHARED_PRIVATE_LINK_LIBS} STATIC_LINK_LIBS ${ARROW_STATIC_LINK_LIBS} - ${ARROW_STATIC_INSTALL_INTERFACE_LIBS} + ${ARROW_STATIC_INSTALL_INTERFACE_LIBS_REAL} SHARED_INSTALL_INTERFACE_LIBS ${ARROW_SHARED_INSTALL_INTERFACE_LIBS} STATIC_INSTALL_INTERFACE_LIBS) From c073c60391ab3efa9d534a25d8522fdd888f9e8a Mon Sep 17 00:00:00 2001 From: Rok Date: Sun, 6 Mar 2022 06:46:25 +0100 Subject: [PATCH 06/10] Remove list-absl-libraries.sh --- cpp/build-support/list-absl-libraries.sh | 70 ------------------------ 1 file changed, 70 deletions(-) delete mode 100755 cpp/build-support/list-absl-libraries.sh diff --git a/cpp/build-support/list-absl-libraries.sh b/cpp/build-support/list-absl-libraries.sh deleted file mode 100755 index 9c311b44540..00000000000 --- a/cpp/build-support/list-absl-libraries.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env bash -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# This script extracts dependency information of all Abseil -# packages in the given build folder. -# -# Arguments: -# $1 - Path to a build folder - -function join { local IFS="$1"; shift; echo "$*"; } - -ABSL_PKGCONFIG_FOLDERS=$(find $1 -type f -name 'absl_*.pc' | sed -r 's|/[^/]+$||' | sort -u) -ABSL_LIBS=$(find $1 -type f -name 'libabsl_*.a' | sed -e 's/.*libabsl_//' -e 's/.a$//' | sort -u) -ABSL_INTERFACE_LIBS=$(find $1* -type f -name 'absl_*.pc' | sed -e 's/.*absl_//' -e 's/.pc$//' | sort -u) -ABSL_INTERFACE_LIBS=$(comm -13 <(echo ABSL_LIBS) <(echo $ABSL_INTERFACE_LIBS)) - -GRPC_PKGCONFIG_FOLDERS=$(find $1/grpc_* -type f -name '*.pc' | sed -r 's|/[^/]+$||' | sort -u) -GRPC_LIBS=$(find $1/grpc_* -type f -name '*.a' | sed -e 's/.*lib//' -e 's/.a$//' | sort -u) -GRPC_INTERFACE_LIBS=$(find $1/grpc_* -type f -name '*.pc' | sed -e 's/.*pkgconfig\///' -e 's/.pc$//' | sort -u) -GRPC_INTERFACE_LIBS=$(comm -13 <(echo $GRPC_LIBS) <(echo $GRPC_INTERFACE_LIBS)) - -printf "\n# Abseil produces the following libraries, each is fairly small, but there -# are (as you can see), many of them. We need to add the libraries first, -# and then describe how they depend on each other.\n\n" -echo "set(_ABSL_LIBS" $ABSL_LIBS")" - -printf "\n# Abseil creates a number of header-only targets, which are needed to resolve dependencies.\n\n" -echo "set(_ABSL_INTERFACE_LIBS" $(join " " ${ABSL_INTERFACE_LIBS[*]})")" -printf "\n" - -for FOLDER in $ABSL_PKGCONFIG_FOLDERS -do - grep Requires "$FOLDER"/*.pc | - sed -e 's;.*/absl_;set_property(TARGET absl::;' \ - -e 's/.pc:Requires:/\n PROPERTY INTERFACE_LINK_LIBRARIES /' \ - -e 's/ = 20210324,//g' \ - -e 's/ = 20210324//g' \ - -e 's/absl_/\n\ absl::/g' \ - -e 's/$/)/' | \ - grep -v 'INTERFACE_LINK_LIBRARIES[ ]*)' -done - -printf "\n\n" - -echo "set(_GRPC_LIBS" $GRPC_LIBS")" -echo "set(_GRPC_INTERFACE_LIBS" $(join " " ${GRPC_INTERFACE_LIBS[*]})")" - -for FOLDER in $GRPC_PKGCONFIG_FOLDERS -do - grep Requires "$FOLDER"/*.pc | - sed -e 's/ / gRPC::/g' \ - -e 's;.*pkgconfig\/;set_property(TARGET gRPC::;' \ - -e 's/.pc:Requires:/\n PROPERTY INTERFACE_LINK_LIBRARIES /' -done \ No newline at end of file From 25b4060fbb3e72811de5ed2635725be089c4fa0d Mon Sep 17 00:00:00 2001 From: Rok Date: Mon, 7 Mar 2022 04:09:35 +0100 Subject: [PATCH 07/10] minor change --- cpp/src/arrow/CMakeLists.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/cpp/src/arrow/CMakeLists.txt b/cpp/src/arrow/CMakeLists.txt index dd4ff08d16b..403a4e39a01 100644 --- a/cpp/src/arrow/CMakeLists.txt +++ b/cpp/src/arrow/CMakeLists.txt @@ -533,11 +533,7 @@ else() set(ARROW_BUILD_BUNDLED_DEPENDENCIES FALSE) endif() -if(ARROW_BUILD_BUNDLED_DEPENDENCIES) - string(APPEND ARROW_PC_LIBS_PRIVATE " -larrow_bundled_dependencies") - set(ARROW_STATIC_INSTALL_INTERFACE_LIBS -libarrow_bundled_dependencies) - set(ARROW_STATIC_INSTALL_INTERFACE_LIBS_REAL ${ARROW_STATIC_INSTALL_INTERFACE_LIBS}) -else() +if(NOT ARROW_BUILD_BUNDLED_DEPENDENCIES) set(ARROW_STATIC_INSTALL_INTERFACE_LIBS_REAL ${ARROW_STATIC_INSTALL_INTERFACE_LIBS}) endif() # Need -latomic on Raspbian. From 61ca815013356269dd18319f95adef458689db47 Mon Sep 17 00:00:00 2001 From: Rok Date: Mon, 7 Mar 2022 18:53:02 +0100 Subject: [PATCH 08/10] Review feedback and macOS fix for ARROW_BUILD_EXAMPLES=ON --- cpp/cmake_modules/BuildUtils.cmake | 11 +++-------- cpp/cmake_modules/ThirdpartyToolchain.cmake | 9 ++++++++- cpp/examples/arrow/CMakeLists.txt | 8 ++++++-- cpp/src/arrow/ArrowConfig.cmake.in | 1 + cpp/src/arrow/CMakeLists.txt | 2 +- cpp/src/arrow/flight/CMakeLists.txt | 4 +--- 6 files changed, 20 insertions(+), 15 deletions(-) diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake index 0ed2901f46a..8fbf94903df 100644 --- a/cpp/cmake_modules/BuildUtils.cmake +++ b/cpp/cmake_modules/BuildUtils.cmake @@ -239,10 +239,7 @@ function(ADD_ARROW_LIB LIB_NAME) PRIVATE_INCLUDES DEPENDENCIES SHARED_INSTALL_INTERFACE_LIBS - STATIC_INSTALL_INTERFACE_LIBS - OUTPUT_PATH - SHARED_INSTALL_EXTRA_TARGETS - STATIC_INSTALL_EXTRA_TARGETS) + STATIC_INSTALL_INTERFACE_LIBS) cmake_parse_arguments(ARG "${options}" "${one_value_args}" @@ -408,8 +405,7 @@ function(ADD_ARROW_LIB LIB_NAME) "${_lib_install_name}") endif() - install(TARGETS ${LIB_NAME}_shared ${ARG_SHARED_INSTALL_EXTRA_TARGETS} - ${INSTALL_IS_OPTIONAL} + install(TARGETS ${LIB_NAME}_shared ${INSTALL_IS_OPTIONAL} EXPORT ${LIB_NAME}_targets RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -473,8 +469,7 @@ function(ADD_ARROW_LIB LIB_NAME) endif() endif() - install(TARGETS ${LIB_NAME}_static ${ARG_STATIC_INSTALL_EXTRA_TARGETS} - ${INSTALL_IS_OPTIONAL} + install(TARGETS ${LIB_NAME}_static ${INSTALL_IS_OPTIONAL} EXPORT ${LIB_NAME}_targets RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 23bbb3b016a..570d57bb631 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -3412,6 +3412,14 @@ macro(build_absl_once) absl::raw_logging_internal absl::strings absl::time_zone) + if(APPLE) + # This is due to upstream absl::cctz issue + # https://github.com/abseil/abseil-cpp/issues/283 + find_library(CoreFoundation CoreFoundation) + set_property(TARGET absl::time + APPEND + PROPERTY INTERFACE_LINK_LIBRARIES ${CoreFoundation}) + endif() set_property(TARGET absl::type_traits PROPERTY INTERFACE_LINK_LIBRARIES absl::config) set_property(TARGET absl::utility PROPERTY INTERFACE_LINK_LIBRARIES absl::base_internal absl::config @@ -3685,7 +3693,6 @@ macro(build_grpc) gRPC::grpc gRPC::grpcpp_for_bundling gRPC::upb) - endmacro() if(ARROW_WITH_GRPC) diff --git a/cpp/examples/arrow/CMakeLists.txt b/cpp/examples/arrow/CMakeLists.txt index 62396b9ae9e..a38bd88333f 100644 --- a/cpp/examples/arrow/CMakeLists.txt +++ b/cpp/examples/arrow/CMakeLists.txt @@ -42,8 +42,12 @@ if(ARROW_FLIGHT) message(FATAL_ERROR "Statically built gRPC requires ARROW_BUILD_STATIC=ON") else() set(FLIGHT_EXAMPLES_LINK_LIBS arrow_flight_static) - set(GRPC_REFLECTION_LINK_LIBS -Wl,--whole-archive gRPC::grpc++_reflection - -Wl,--no-whole-archive) + if(APPLE) + set(GRPC_REFLECTION_LINK_LIBS -Wl,-force_load gRPC::grpc++_reflection) + else() + set(GRPC_REFLECTION_LINK_LIBS -Wl,--whole-archive gRPC::grpc++_reflection + -Wl,--no-whole-archive) + endif() endif() set(FLIGHT_EXAMPLE_GENERATED_PROTO_FILES diff --git a/cpp/src/arrow/ArrowConfig.cmake.in b/cpp/src/arrow/ArrowConfig.cmake.in index e8d79c08982..f675c5a3c09 100644 --- a/cpp/src/arrow/ArrowConfig.cmake.in +++ b/cpp/src/arrow/ArrowConfig.cmake.in @@ -48,6 +48,7 @@ include(CMakeFindDependencyMacro) # already existent target error. if(NOT (TARGET arrow_shared OR TARGET arrow_static)) include("${CMAKE_CURRENT_LIST_DIR}/ArrowTargets.cmake") + if(TARGET arrow_static) set(CMAKE_THREAD_PREFER_PTHREAD TRUE) set(THREADS_PREFER_PTHREAD_FLAG TRUE) diff --git a/cpp/src/arrow/CMakeLists.txt b/cpp/src/arrow/CMakeLists.txt index 403a4e39a01..b206ba894d1 100644 --- a/cpp/src/arrow/CMakeLists.txt +++ b/cpp/src/arrow/CMakeLists.txt @@ -533,7 +533,7 @@ else() set(ARROW_BUILD_BUNDLED_DEPENDENCIES FALSE) endif() -if(NOT ARROW_BUILD_BUNDLED_DEPENDENCIES) +if(ARROW_BUILD_BUNDLED_DEPENDENCIES) set(ARROW_STATIC_INSTALL_INTERFACE_LIBS_REAL ${ARROW_STATIC_INSTALL_INTERFACE_LIBS}) endif() # Need -latomic on Raspbian. diff --git a/cpp/src/arrow/flight/CMakeLists.txt b/cpp/src/arrow/flight/CMakeLists.txt index b154227db03..cae36562be3 100644 --- a/cpp/src/arrow/flight/CMakeLists.txt +++ b/cpp/src/arrow/flight/CMakeLists.txt @@ -197,9 +197,7 @@ add_arrow_lib(arrow_flight ${ARROW_FLIGHT_LINK_LIBS} STATIC_LINK_LIBS arrow_static - ${ARROW_FLIGHT_LINK_LIBS} - ${ARROW_STATIC_INSTALL_INTERFACE_LIBS_REAL} - arrow_static) + ${ARROW_FLIGHT_LINK_LIBS}) foreach(LIB_TARGET ${ARROW_FLIGHT_LIBRARIES}) target_compile_definitions(${LIB_TARGET} PRIVATE ARROW_FLIGHT_EXPORTING) From fa7fb3978fe05263a75e20b0320605b1448741bc Mon Sep 17 00:00:00 2001 From: Rok Date: Mon, 7 Mar 2022 23:47:26 +0100 Subject: [PATCH 09/10] Review feedback --- cpp/cmake_modules/BuildUtils.cmake | 3 ++- cpp/src/arrow/ArrowConfig.cmake.in | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake index 8fbf94903df..2bcaed43e5d 100644 --- a/cpp/cmake_modules/BuildUtils.cmake +++ b/cpp/cmake_modules/BuildUtils.cmake @@ -239,7 +239,8 @@ function(ADD_ARROW_LIB LIB_NAME) PRIVATE_INCLUDES DEPENDENCIES SHARED_INSTALL_INTERFACE_LIBS - STATIC_INSTALL_INTERFACE_LIBS) + STATIC_INSTALL_INTERFACE_LIBS + OUTPUT_PATH) cmake_parse_arguments(ARG "${options}" "${one_value_args}" diff --git a/cpp/src/arrow/ArrowConfig.cmake.in b/cpp/src/arrow/ArrowConfig.cmake.in index f675c5a3c09..1d25c81af81 100644 --- a/cpp/src/arrow/ArrowConfig.cmake.in +++ b/cpp/src/arrow/ArrowConfig.cmake.in @@ -81,7 +81,7 @@ if(NOT (TARGET arrow_shared OR TARGET arrow_static)) IMPORTED_LOCATION "${arrow_lib_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}arrow_bundled_dependencies${CMAKE_STATIC_LIBRARY_SUFFIX}" INTERFACE_LINK_LIBRARIES - ${ARROW_STATIC_INSTALL_INTERFACE_LIBS} + "${ARROW_STATIC_INSTALL_INTERFACE_LIBS}" ) get_property(arrow_static_interface_link_libraries TARGET arrow_static From b4c118b4bd64f724a0e5ee46c46bf5505e693428 Mon Sep 17 00:00:00 2001 From: Rok Date: Tue, 8 Mar 2022 15:06:11 +0100 Subject: [PATCH 10/10] Review feedback --- cpp/src/arrow/ArrowConfig.cmake.in | 2 +- cpp/src/arrow/CMakeLists.txt | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/cpp/src/arrow/ArrowConfig.cmake.in b/cpp/src/arrow/ArrowConfig.cmake.in index 1d25c81af81..44c8a66f67d 100644 --- a/cpp/src/arrow/ArrowConfig.cmake.in +++ b/cpp/src/arrow/ArrowConfig.cmake.in @@ -38,7 +38,7 @@ set(ARROW_LIBRARY_PATH_SUFFIXES "@ARROW_LIBRARY_PATH_SUFFIXES@") set(ARROW_INCLUDE_PATH_SUFFIXES "@ARROW_INCLUDE_PATH_SUFFIXES@") set(ARROW_SYSTEM_DEPENDENCIES "@ARROW_SYSTEM_DEPENDENCIES@") set(ARROW_BUNDLED_STATIC_LIBS "@ARROW_BUNDLED_STATIC_LIBS@") -set(ARROW_STATIC_INSTALL_INTERFACE_LIBS "@ARROW_STATIC_INSTALL_INTERFACE_LIBS_REAL@") +set(ARROW_STATIC_INSTALL_INTERFACE_LIBS "@ARROW_STATIC_INSTALL_INTERFACE_LIBS@") include("${CMAKE_CURRENT_LIST_DIR}/ArrowOptions.cmake") diff --git a/cpp/src/arrow/CMakeLists.txt b/cpp/src/arrow/CMakeLists.txt index b206ba894d1..3e56441479b 100644 --- a/cpp/src/arrow/CMakeLists.txt +++ b/cpp/src/arrow/CMakeLists.txt @@ -534,7 +534,7 @@ else() endif() if(ARROW_BUILD_BUNDLED_DEPENDENCIES) - set(ARROW_STATIC_INSTALL_INTERFACE_LIBS_REAL ${ARROW_STATIC_INSTALL_INTERFACE_LIBS}) + string(APPEND ARROW_PC_LIBS_PRIVATE " -larrow_bundled_dependencies") endif() # Need -latomic on Raspbian. # See also: https://issues.apache.org/jira/browse/ARROW-12860 @@ -563,10 +563,9 @@ add_arrow_lib(arrow ${ARROW_SHARED_PRIVATE_LINK_LIBS} STATIC_LINK_LIBS ${ARROW_STATIC_LINK_LIBS} - ${ARROW_STATIC_INSTALL_INTERFACE_LIBS_REAL} + ${ARROW_STATIC_INSTALL_INTERFACE_LIBS} SHARED_INSTALL_INTERFACE_LIBS - ${ARROW_SHARED_INSTALL_INTERFACE_LIBS} - STATIC_INSTALL_INTERFACE_LIBS) + ${ARROW_SHARED_INSTALL_INTERFACE_LIBS}) add_dependencies(arrow ${ARROW_LIBRARIES})