Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
383f4dd
Set up static build of ODBC FlightSQL driver
amoeba Mar 24, 2026
51c6999
Set CMAKE_MSVC_RUNTIME_LIBRARY
amoeba Mar 24, 2026
d4cedb5
wip
amoeba Mar 25, 2026
10099e3
Revert "Set CMAKE_MSVC_RUNTIME_LIBRARY"
amoeba Mar 25, 2026
431946f
more testing
amoeba Mar 30, 2026
634c93e
Update odbc_test_suite.cc
amoeba Mar 31, 2026
62ded52
Check ARROW_FLIGHT_TEST_LINKAGE
amoeba Mar 31, 2026
02f83ab
force static link libs
amoeba Mar 31, 2026
0bf731d
Update CMakeLists.txt
amoeba Apr 4, 2026
de3bb1c
Update CMakeLists.txt
amoeba Apr 4, 2026
357efc1
Update cpp_extra.yml
amoeba Apr 4, 2026
3f51d51
formatting
amoeba Apr 7, 2026
0af2ae0
Simplify odbc_impl test linkage cmake directives
amoeba Apr 7, 2026
8bd5550
cleanup
amoeba Apr 7, 2026
afa4310
Update CMakeLists.txt
amoeba Apr 7, 2026
4ba66e3
format
amoeba Apr 10, 2026
c02f769
try to fix macos test crash
amoeba Apr 10, 2026
a0becd1
format
amoeba Apr 10, 2026
f51415a
add missing header
amoeba Apr 11, 2026
02869a6
testing
amoeba Apr 11, 2026
d9f91a7
format
amoeba Apr 11, 2026
3fea98a
Fix rebase mistake
amoeba Apr 22, 2026
4b4f980
add workaround
amoeba Apr 22, 2026
087874f
update comment
amoeba Apr 22, 2026
f73203c
fix rebase issue with linking
amoeba Apr 22, 2026
ccbfddd
restore comment
amoeba Apr 22, 2026
b188d5a
update comment
amoeba Apr 22, 2026
8a2248b
fix more targets
amoeba Apr 22, 2026
407c560
more fixes
amoeba Apr 23, 2026
345704c
update comments
amoeba Apr 23, 2026
39babea
update comments
amoeba Apr 23, 2026
84d59f6
comments
amoeba Apr 23, 2026
8d9141a
guard overrides better
amoeba Apr 23, 2026
f58e3f7
cmake-format
amoeba Apr 23, 2026
7968325
format
amoeba Jun 9, 2026
24b86b1
use static test linkage
amoeba Sep 24, 2026
ad2eea6
Update CMakeLists.txt
amoeba Sep 24, 2026
648c38e
format
amoeba Sep 24, 2026
ba44f7b
prefer ARROW_FLIGHT_TEST_LINKAGE
amoeba Sep 24, 2026
23606fe
cleanup from rebase
amoeba Sep 24, 2026
07dfafc
simplify ODBC test linkage
amoeba Sep 24, 2026
da794e5
GH-49538: Match GTest try-compile configuration
amoeba Sep 25, 2026
746f8c8
test better fix
amoeba Sep 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/cpp_extra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -689,8 +689,8 @@ jobs:
contents: read
packages: write
env:
ARROW_BUILD_SHARED: ON
ARROW_BUILD_STATIC: OFF
ARROW_BUILD_SHARED: OFF
ARROW_BUILD_STATIC: ON
ARROW_BUILD_TESTS: ON
ARROW_BUILD_TYPE: release
# Turn Arrow CSV off to disable `find_package(Arrow)` check on MSVC CI.
Expand All @@ -706,6 +706,10 @@ jobs:
# Build Arrow with GPR_DISABLE_ABSEIL_SYNC so grpcpp's Mutex ABI
# matches the gRPC rebuilt by the overlay triplet. Remove once fixed upstream.
ARROW_CXXFLAGS: -DGPR_DISABLE_ABSEIL_SYNC
ARROW_DEPENDENCY_USE_SHARED: OFF
ARROW_MIMALLOC: OFF
ARROW_TEST_LINKAGE: static
ARROW_USE_STATIC_CRT: OFF
CMAKE_GENERATOR: Ninja
CMAKE_INSTALL_PREFIX: /usr
VCPKG_BINARY_SOURCES: 'clear;nugettimeout,600;nuget,GitHub,readwrite'
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/package_odbc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,24 @@ jobs:
permissions:
packages: write
env: &odbc_msvc_env
ARROW_BUILD_SHARED: ON
ARROW_BUILD_STATIC: OFF
ARROW_BUILD_SHARED: OFF
ARROW_BUILD_STATIC: ON
ARROW_BUILD_TESTS: OFF
ARROW_BUILD_TYPE: release
# Turn Arrow CSV off to disable `find_package(Arrow)` check on MSVC CI.
# Turn Arrow CSV off to disable `find_package(Arrow)` check on MSVC CI.
# GH-49050 TODO: enable `find_package(Arrow)` check on MSVC CI.
ARROW_CSV: OFF
ARROW_DEPENDENCY_SOURCE: VCPKG
ARROW_DEPENDENCY_USE_SHARED: OFF
ARROW_FLIGHT_SQL_ODBC: ON
ARROW_FLIGHT_SQL_ODBC_INSTALLER: ON
ARROW_HOME: /usr
ARROW_MIMALLOC: OFF
ARROW_USE_STATIC_CRT: OFF
CMAKE_GENERATOR: Ninja
CMAKE_INSTALL_PREFIX: /usr
VCPKG_BINARY_SOURCES: 'clear;nugettimeout,600;nuget,GitHub,readwrite'
VCPKG_DEFAULT_TRIPLET: x64-windows
VCPKG_DEFAULT_TRIPLET: x64-windows-static-md
steps:
- name: Checkout Arrow
uses: actions/checkout@v7
Expand Down
4 changes: 2 additions & 2 deletions ci/vcpkg/amd64-windows-no-absl-sync-release.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

# GH-49465: rebuild gRPC with native sync instead of absl::Mutex to avoid the
# Windows exit hang. See the ODBC Windows job in cpp_extra.yml
# Dynamic CRT/linkage and release-only to match that job.
# Static library linkage, dynamic CRT (/MD), release-only to match that job.
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_BUILD_TYPE release)

set(VCPKG_C_FLAGS "/DGPR_DISABLE_ABSEIL_SYNC")
Expand Down
6 changes: 6 additions & 0 deletions cpp/cmake_modules/FindGTestAlt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ find_package(GTest ${find_package_args})
set(GTestAlt_FOUND ${GTest_FOUND})
if(GTestAlt_FOUND AND GTestAlt_NEED_CXX_STANDARD_CHECK)
set(KEEP_CMAKE_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE})
set(KEEP_CMAKE_TRY_COMPILE_CONFIGURATION ${CMAKE_TRY_COMPILE_CONFIGURATION})
set(CMAKE_TRY_COMPILE_TARGET_TYPE EXECUTABLE)
# Match the parent build when dependencies are available for only one configuration.
if(NOT CMAKE_TRY_COMPILE_CONFIGURATION)
set(CMAKE_TRY_COMPILE_CONFIGURATION ${CMAKE_BUILD_TYPE})
endif()
set(GTestAlt_CXX_STANDARD_TEST_SOURCE
"${CMAKE_CURRENT_BINARY_DIR}/gtest_cxx_standard_test.cc")
file(WRITE ${GTestAlt_CXX_STANDARD_TEST_SOURCE}
Expand All @@ -56,6 +61,7 @@ TEST(CXX_STANDARD, MatcherStringView) {
LINK_LIBRARIES GTest::gtest_main
OUTPUT_VARIABLE GTestAlt_CXX_STANDARD_OUTPUT)
set(CMAKE_TRY_COMPILE_TARGET_TYPE ${KEEP_CMAKE_TRY_COMPILE_TARGET_TYPE})
set(CMAKE_TRY_COMPILE_CONFIGURATION ${KEEP_CMAKE_TRY_COMPILE_CONFIGURATION})
if(NOT GTestAlt_CXX_STANDARD_AVAILABLE)
message(STATUS "GTest can't be used with C++${CMAKE_CXX_STANDARD}.")
message(STATUS "Use -DGTest_SOURCE=BUNDLED.")
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/arrow/flight/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ function(arrow_set_generated_proto_files_properties)
set(GENERATED_FILES ${ARGN})
set_source_files_properties(${GENERATED_FILES} PROPERTIES GENERATED TRUE)
if(MSVC)
# Suppress missing dll-interface warning
# Suppress warnings caused by Protobuf (dll-interface)
set_source_files_properties(${GENERATED_FILES}
PROPERTIES COMPILE_OPTIONS "/wd4251"
PROPERTIES COMPILE_OPTIONS "/wd4251;/wd4275"
SKIP_UNITY_BUILD_INCLUSION TRUE)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# Disable -Wmissing-declarations
Expand Down
5 changes: 5 additions & 0 deletions cpp/src/arrow/flight/sql/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ if(MSVC)
endif()
foreach(LIB_TARGET ${ARROW_FLIGHT_SQL_LIBRARIES})
target_compile_definitions(${LIB_TARGET} PRIVATE ARROW_FLIGHT_SQL_EXPORTING)
if(MSVC)
# Suppress warnings caused by Protobuf (dll-interface)
target_compile_options(${LIB_TARGET} PRIVATE "/wd4275")
endif()
endforeach()

if(ARROW_FLIGHT_TEST_LINKAGE STREQUAL "static" AND ARROW_BUILD_STATIC)
Expand Down Expand Up @@ -177,6 +181,7 @@ if(ARROW_BUILD_TESTS OR ARROW_BUILD_EXAMPLES)
ARROW_FLIGHT_SQL_STATIC)
endforeach()
endif()

endif()

if(ARROW_FLIGHT_SQL_ODBC)
Expand Down
44 changes: 25 additions & 19 deletions cpp/src/arrow/flight/sql/odbc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,28 +59,41 @@ if(WIN32)
list(APPEND ARROW_FLIGHT_SQL_ODBC_SRCS odbc.def install/versioninfo.rc)
endif()

# On Windows, dynmaic build for ODBC is supported.
# On unix systems, static build for ODBC is supported, all libraries are linked statically on unix.
set(ARROW_FLIGHT_SQL_ODBC_DEPENDENCIES "")
# Initialize install interface libs (only set in Windows static build)
set(ARROW_FLIGHT_SQL_ODBC_SHARED_INSTALL_INTERFACE_LIBS "")
set(ARROW_FLIGHT_SQL_ODBC_STATIC_INSTALL_INTERFACE_LIBS "")
set(ARROW_FLIGHT_SQL_ODBC_SHARED_PRIVATE_LINK_LIBS "")

if(WIN32)
set(ARROW_FLIGHT_SQL_ODBC_DEPENDENCIES arrow_flight_sql)
set(ARROW_FLIGHT_SQL_ODBC_SHARED_LINK_LIBS arrow_flight_sql_shared arrow_odbc_spi_impl)
set(ARROW_FLIGHT_SQL_ODBC_STATIC_LINK_LIBS arrow_flight_sql_static)
list(APPEND ARROW_FLIGHT_SQL_ODBC_SHARED_INSTALL_INTERFACE_LIBS
ArrowFlight::arrow_flight_sql_shared)
list(APPEND ARROW_FLIGHT_SQL_ODBC_STATIC_INSTALL_INTERFACE_LIBS
ArrowFlight::arrow_flight_sql_static)
if(ARROW_BUILD_STATIC)
# Static Arrow deps on Windows — self-contained ODBC DLL
set(ARROW_FLIGHT_SQL_ODBC_SHARED_LINK_LIBS arrow_flight_sql_static
arrow_odbc_spi_impl)
set(ARROW_FLIGHT_SQL_ODBC_STATIC_LINK_LIBS arrow_flight_sql_static)
list(APPEND ARROW_FLIGHT_SQL_ODBC_SHARED_INSTALL_INTERFACE_LIBS
ArrowFlight::arrow_flight_sql_static)
list(APPEND ARROW_FLIGHT_SQL_ODBC_STATIC_INSTALL_INTERFACE_LIBS
ArrowFlight::arrow_flight_sql_static)
else()
set(ARROW_FLIGHT_SQL_ODBC_SHARED_LINK_LIBS arrow_flight_sql_shared
arrow_odbc_spi_impl)
set(ARROW_FLIGHT_SQL_ODBC_STATIC_LINK_LIBS arrow_flight_sql_static)
list(APPEND ARROW_FLIGHT_SQL_ODBC_SHARED_INSTALL_INTERFACE_LIBS
ArrowFlight::arrow_flight_sql_shared)
list(APPEND ARROW_FLIGHT_SQL_ODBC_STATIC_INSTALL_INTERFACE_LIBS
ArrowFlight::arrow_flight_sql_static)
endif()
list(APPEND ARROW_FLIGHT_SQL_ODBC_SHARED_PRIVATE_LINK_LIBS ODBC::ODBC ${ODBCINST})
else()
# Unix
# Unix/macOS: driver dynamically links arrow_flight_sql so the driver and test
# binary share the same grpc/arrow_flight runtime.
set(ARROW_FLIGHT_SQL_ODBC_SHARED_LINK_LIBS arrow_odbc_spi_impl)
set(ARROW_FLIGHT_SQL_ODBC_STATIC_LINK_LIBS ODBC::ODBC ${ODBCINST})
endif()

add_arrow_lib(arrow_flight_sql_odbc
BUILD_SHARED
ON
CMAKE_PACKAGE_NAME
ArrowFlightSqlOdbc
PKG_CONFIG_NAME
Expand All @@ -91,8 +104,6 @@ add_arrow_lib(arrow_flight_sql_odbc
${ARROW_FLIGHT_SQL_ODBC_SRCS}
DEFINITIONS
UNICODE
DEPENDENCIES
${ARROW_FLIGHT_SQL_ODBC_DEPENDENCIES}
SHARED_LINK_FLAGS
${ARROW_VERSION_SCRIPT_FLAGS} # Defined in cpp/arrow/CMakeLists.txt
SHARED_LINK_LIBS
Expand Down Expand Up @@ -149,15 +160,10 @@ if(ARROW_FLIGHT_SQL_ODBC_INSTALLER)
set(CPACK_PACKAGE_CONTACT "dev@arrow.apache.org")

if(WIN32)
# Install ODBC and its Arrow dependencies
install(PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}
DESTINATION bin
COMPONENT ArrowFlightSQLODBC)
install(TARGETS arrow_shared
arrow_compute_shared
arrow_flight_shared
arrow_flight_sql_shared
arrow_flight_sql_odbc_shared
install(TARGETS arrow_flight_sql_odbc_shared
RUNTIME_DEPENDENCIES
PRE_EXCLUDE_REGEXES
"api-ms-.*"
Expand Down
42 changes: 30 additions & 12 deletions cpp/src/arrow/flight/sql/odbc/odbc_impl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,21 @@ endif()
if(WIN32)
find_package(ODBC REQUIRED)
target_include_directories(arrow_odbc_spi_impl PUBLIC ${ODBC_INCLUDE_DIR})
target_link_libraries(arrow_odbc_spi_impl
PUBLIC arrow_flight_sql_shared
arrow_compute_shared
Boost::locale
arrow::simdjson
${ODBCINST})
if(ARROW_BUILD_STATIC)
target_link_libraries(arrow_odbc_spi_impl
PUBLIC arrow_flight_sql_static
arrow_compute_static
Boost::locale
arrow::simdjson
${ODBCINST})
else()
target_link_libraries(arrow_odbc_spi_impl
PUBLIC arrow_flight_sql_shared
arrow_compute_shared
Boost::locale
arrow::simdjson
${ODBCINST})
endif()
else()
# Unix
target_include_directories(arrow_odbc_spi_impl SYSTEM BEFORE PUBLIC ${ODBC_INCLUDE_DIR})
Expand Down Expand Up @@ -166,11 +175,19 @@ target_link_libraries(arrow_odbc_spi_impl_cli arrow_odbc_spi_impl)

# On Windows, dynamic linking ODBC is supported.
# On unix systems, static linking ODBC is supported, thus the library linking is static.
if(WIN32)
set(ODBC_SPI_IMPL_TEST_LINK_LIBS arrow_flight_testing_shared)
# Use STATIC_LINK_LIBS when Flight tests require static linkage to avoid mixing static/shared Arrow
if(WIN32 AND ARROW_FLIGHT_TEST_LINKAGE STREQUAL "static")
set(ODBC_SPI_IMPL_TEST_STATIC_LIBS arrow_odbc_spi_impl arrow_flight_testing_static
${ARROW_TEST_STATIC_LINK_LIBS})
set(ODBC_SPI_IMPL_TEST_EXTRA_LIBS "")
elseif(WIN32)
set(ODBC_SPI_IMPL_TEST_STATIC_LIBS "")
set(ODBC_SPI_IMPL_TEST_EXTRA_LIBS arrow_odbc_spi_impl arrow_flight_testing_shared)
else()
# unix
set(ODBC_SPI_IMPL_TEST_LINK_LIBS arrow_flight_testing_static)
# Unix - always static
set(ODBC_SPI_IMPL_TEST_STATIC_LIBS arrow_odbc_spi_impl arrow_flight_testing_static
${ARROW_TEST_STATIC_LINK_LIBS})
set(ODBC_SPI_IMPL_TEST_EXTRA_LIBS "")
endif()

add_arrow_test(odbc_spi_impl_test
Expand All @@ -190,5 +207,6 @@ add_arrow_test(odbc_spi_impl_test
record_batch_transformer_test.cc
util_test.cc
EXTRA_LINK_LIBS
arrow_odbc_spi_impl
${ODBC_SPI_IMPL_TEST_LINK_LIBS})
${ODBC_SPI_IMPL_TEST_EXTRA_LIBS}
STATIC_LINK_LIBS
${ODBC_SPI_IMPL_TEST_STATIC_LIBS})
61 changes: 28 additions & 33 deletions cpp/src/arrow/flight/sql/odbc/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,38 +42,35 @@ set(ARROW_FLIGHT_SQL_ODBC_TEST_SRCS
# GH-46889: move protobuf_test_util to a more common location
../../../../engine/substrait/protobuf_test_util.cc)

# GH-49651 Link ODBC tests statically on Linux and dynamically on macOS/Windows
if(WIN32 OR APPLE)
set(ARROW_FLIGHT_SQL_ODBC_TEST_LINK_LIBS arrow_flight_sql_odbc_shared
${ARROW_TEST_SHARED_LINK_LIBS})
else()
# GH-49651 Link ODBC tests statically on Linux to fix segfault
set(ARROW_FLIGHT_SQL_ODBC_TEST_LINK_LIBS arrow_flight_sql_odbc_static
${ARROW_TEST_STATIC_LINK_LIBS})
endif()

# On macOS, link `ODBCINST` first to ensure iodbc take precedence over unixodbc
# On macOS, link `ODBCINST` first to ensure iodbc takes precedence over unixodbc.
set(ARROW_FLIGHT_SQL_ODBC_TEST_LIBS ${ODBCINST} ${ODBC_LIBRARIES} ${SQLite3_LIBRARIES})

# On Windows, dynamic linking ODBC is supported, tests link libraries dynamically.
# On unix systems, static linking ODBC is supported, thus tests link libraries statically.
set(ARROW_FLIGHT_SQL_ODBC_TEST_EXTRA_LINK_LIBS "")
set(ARROW_FLIGHT_SQL_ODBC_TEST_STATIC_LINK_LIBS "")
if(WIN32)
# arrow_odbc_spi_impl is required on Windows due to dynamic linking
list(APPEND ARROW_FLIGHT_SQL_ODBC_TEST_EXTRA_LINK_LIBS arrow_odbc_spi_impl
${ARROW_FLIGHT_SQL_ODBC_TEST_LIBS})
# STATIC_LINK_LIBS replaces add_arrow_test's default Arrow test libraries, while
# EXTRA_LINK_LIBS supplements them.
if(WIN32 AND ARROW_FLIGHT_TEST_LINKAGE STREQUAL "shared")
set(ARROW_FLIGHT_SQL_ODBC_TEST_LINK_MODE EXTRA_LINK_LIBS)
set(ARROW_FLIGHT_SQL_ODBC_TEST_LINK_LIBS arrow_odbc_spi_impl
${ARROW_FLIGHT_SQL_ODBC_TEST_LIBS})
elseif(WIN32)
set(ARROW_FLIGHT_SQL_ODBC_TEST_LINK_MODE STATIC_LINK_LIBS)
set(ARROW_FLIGHT_SQL_ODBC_TEST_LINK_LIBS
arrow_odbc_spi_impl ${ARROW_FLIGHT_SQL_ODBC_TEST_LIBS} arrow_flight_sql_odbc_static
${ARROW_TEST_STATIC_LINK_LIBS})
elseif(APPLE)
# GH-49651: Link the ODBC driver dynamically on macOS.
set(ARROW_FLIGHT_SQL_ODBC_TEST_LINK_MODE STATIC_LINK_LIBS)
set(ARROW_FLIGHT_SQL_ODBC_TEST_LINK_LIBS
${ARROW_FLIGHT_SQL_ODBC_TEST_LIBS} arrow_flight_sql_odbc_shared
${ARROW_TEST_SHARED_LINK_LIBS})
else()
# Unix
list(APPEND ARROW_FLIGHT_SQL_ODBC_TEST_STATIC_LINK_LIBS
${ARROW_FLIGHT_SQL_ODBC_TEST_LIBS} ${ARROW_FLIGHT_SQL_ODBC_TEST_LINK_LIBS})

if(NOT APPLE)
# Links static dependencies on Linux to support ARROW_TEST_LINKAGE=static
list(APPEND ARROW_FLIGHT_SQL_ODBC_TEST_STATIC_LINK_LIBS arrow_odbc_spi_impl
${ARROW_PROTOBUF_LIBPROTOBUF})
endif()

# GH-49651: Link the ODBC driver statically on Linux to avoid a segfault.
set(ARROW_FLIGHT_SQL_ODBC_TEST_LINK_MODE STATIC_LINK_LIBS)
set(ARROW_FLIGHT_SQL_ODBC_TEST_LINK_LIBS
${ARROW_FLIGHT_SQL_ODBC_TEST_LIBS}
arrow_flight_sql_odbc_static
${ARROW_TEST_STATIC_LINK_LIBS}
arrow_odbc_spi_impl
${ARROW_PROTOBUF_LIBPROTOBUF})
endif()

add_arrow_test(flight_sql_odbc_test
Expand All @@ -82,10 +79,8 @@ add_arrow_test(flight_sql_odbc_test
${ARROW_FLIGHT_SQL_MOCK_SERVER_SRCS}
DEFINITIONS
UNICODE
EXTRA_LINK_LIBS
${ARROW_FLIGHT_SQL_ODBC_TEST_EXTRA_LINK_LIBS}
STATIC_LINK_LIBS
${ARROW_FLIGHT_SQL_ODBC_TEST_STATIC_LINK_LIBS})
${ARROW_FLIGHT_SQL_ODBC_TEST_LINK_MODE}
${ARROW_FLIGHT_SQL_ODBC_TEST_LINK_LIBS})

find_package(ODBC REQUIRED)
target_link_libraries(arrow-flight-sql-odbc-test PRIVATE ODBC::ODBC)
Expand Down
38 changes: 32 additions & 6 deletions cpp/src/arrow/flight/transport/grpc/customize_grpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,42 @@
#include <limits>
#include <memory>

#if __has_include(<absl/synchronization/mutex.h>)

// HACK: Workaround absl::Mutex ABI incompatibility by making sure the
// non-debug version of Abseil is included
// (https://github.com/conda-forge/abseil-cpp-feedstock/issues/104,
// https://github.com/abseil/abseil-cpp/issues/1624)

#if __has_include(<absl/synchronization/mutex.h>)

# ifndef NDEBUG
# define ARROW_NO_NDEBUG
# define NDEBUG
//
// Abseil picks where Mutex::Dtor lives based on NDEBUG:
//
// mutex.h: #if defined(NDEBUG) && !ABSL_HAVE_THREAD_SANITIZER &&
// !ABSL_BUILD_DLL -> inline, emitted into this TU
// mutex.cc: #if !defined(NDEBUG) || ABSL_HAVE_THREAD_SANITIZER ||
// ABSL_BUILD_DLL -> strong, out-of-line
//
// Defining NDEBUG here makes this TU emit its own inline Mutex::Dtor. Whether
// that helps or hurts depends on how the Abseil we link against was built:
//
// - Abseil built *with* NDEBUG (the conda case above): it inlined Dtor away
// and never exported it, so a debug TU that expects the out-of-line symbol
// gets an undefined reference. Emitting our own copy fixes that.
//
// - Abseil built *without* NDEBUG (a Debug vcpkg/system build): it has the
// strong out-of-line Dtor. Emitting our own copy is then a duplicate
// definition, which a *static* Abseil turns into LNK2005 (GH-49585). With a
// shared Abseil it is harmless, since the definitions live in separate
// images.
//
// So restrict the hack to the cases where it cannot produce a duplicate:
// anything that is not MSVC-linking-static-Abseil. On MSVC, Abseil's CMake puts
// ABSL_CONSUME_DLL in the INTERFACE compile definitions of its targets, so its
// presence tells us we are consuming the DLL rather than the static library.
# if !defined(_MSC_VER) || defined(ABSL_CONSUME_DLL)
# ifndef NDEBUG
# define ARROW_NO_NDEBUG
# define NDEBUG
# endif
# endif

# include <absl/synchronization/mutex.h>
Expand Down
Loading