Skip to content

Conversation

@alinaliBQ
Copy link
Collaborator

@alinaliBQ alinaliBQ commented Feb 11, 2026

Rationale for this change

#49219
Support static ODBC build on macOS. Linux support will be in a different PR.

What changes are included in this PR?

  • Add unix-specific CMake build commands in CMakeLists.txt to link ODBC DYLIB statically to dependencies.
  • Header file changes due to switch to static build.
  • Test file changes due to static macOS linking that caused different behavior in iodbc

Are these changes tested?

Build is tested in CI.

Are there any user-facing changes?

N/A

* Link ODBC library statically on unix

Change unit tests to re-use code. Testing on windows is needed.

Now seeing error
```
Library not loaded: /usr/local/opt/grpc/lib/libgrpc++.1.76.dylib
```
on Excel.

Attempt to unlink arrow_flight.proto

Now I see ODBC.dylib has 100MB, and error from Excel is
```
Library not loaded: /usr/local/opt/libiodbc/lib/libiodbc.2.dylib
```
instead of looking for flightsql.

`iodbctest` command outside of Excel works.

in-progress link arrow statically for `flightsql-odbc`

* both ODBC driver and `arrow_odbc_spi_impl` need to link Arrow statically for tests to work.
* getting error
`File already exists in database: Flight.proto`
since the ODBC layer is linking dynamically while I successfully got `arrow_odbc_spi_impl` to link to Arrow statically

Draft for resolving `File already exists in database: FlightSql.proto` error

Note: make ODBC available on Excel first, test with `iodbctest`, worry about ODBC test executable later.

Add unix build (same as Windows build)

* Attempted to link static libraries with `arrow_odbc_spi_impl`, failed as it caused linking errors and rendered the ODBC driver unusable.

Undo changes to resolve broken driver

Resolves dependency errors

Attempt to switch to static build

Still getting error
```
[iODBC][Driver Manager]dlopen(/Library/ODBC/arrow-odbc/libarrow_flight_sql_odbc.2300.0.0.dylib, 0x0006): Library not loaded: @rpath/libarrow_flight_sql.2300.dylib
```

In-progress attempt to build ODBC statically on unix systems

In-progress changes to enable static odbc_impl library

pushing the changes just for saving my code. Currently odbc test still has double registration issue, work on this next. I think it should be solvable by either adding library flags or just using odbc spi shared. Because `odbc_spi_impl_test` works. And the ODBC tests worked just fine before I switched to static odbc spi impl.

Fix for gtest missing issue

Attempting to fix for issue:
IMPORTANT NOTICE - DO NOT IGNORE:
This test program did NOT call testing::InitGoogleTest() before calling RUN_ALL_TESTS().
This is INVALID. Soon Google Test will start to enforce the valid usage.
Please fix it ASAP, or IT WILL START TO FAIL.

Issue fixed with adding `${ARROW_TEST_LINK_LIBS}`. It is needed alongside `arrow_flight_testing_shared`.

IN-PROGRESS build static test on macOS

* Trying to have 2 builds. One `arrow_odbc_spi_impl_static` for static build and one `arrow_odbc_spi_impl_shared` for a shared lib that links Arrow dynamically
---
only committing the approach that worked.
Trying to work from `flight_sql_odbc_test` to debug the real issue.

Link 3rd party dependencies statically

Fix 3rd party headers cannot find issue for:
- boost xpressive and beast headers
- rapidjson headers

Resolve unneeded link for ODBC

----
Moving `set(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".a")` up didn't seem to have any effect

----
Fix for static gRPC connection issue:
export GRPC_DEFAULT_SSL_ROOTS_FILE_PATH=/etc/ssl/cert.pem

Fix cares `cannot modify alias target` issue

Make arrow_odbc_spi_impl static lib

In progress for getting gprc linked statically

Add debug msgs in add_arrow_lib BuildUtils.cmake

Remove commented out code in odbc lib

Fix build issue from odbc impl tests

Added draft code for Link Arrow libs statically on Unix for unit tests

Add commented out code`ARROW_DEPENDENCY_USE_SHARED` in ODBC cpp yml

Uncomment when it is verified to work.

In-progress Fix ODBC test build and make it run.

Build executable from scratch

Revert "Build executable from scratch"

This reverts commit a51dc39.

Dummy test

dummy test without using ODBC passed without double registration issue

Make ODBC test run

Issue to resolve:
[libprotobuf FATAL /path/to/arrow/cpp/debug-build/_deps/protobuf-src/src/google/protobuf/extension_set.cc:100] Multiple extension registrations for type "google.protobuf.MessageOptions", field number 1000.
unknown file: Failure
C++ exception with description "Multiple extension registrations for type "google.protobuf.MessageOptions", field number 1000." thrown in SetUp().

Fix: only link test executable directly with ODBC shared dylib. Do not link test executable with odbc spi impl dylib. And change ODBC to link odbc spi impl dylib publicly instead of privately

in-progress changes to accomodate macos CI

Test ODBC CI - to be reverted

Can revert later

Only install ODBC dependencies in mac

As dependencies are static and built from source

Uninstall absl as attempt to resolve build on Intel

Add C++ standard 20

Remove absl header from intel

Use static linking in dependency install step

Use bundled boost for static linking

In-progress Fix Windows build

Fix macOS (after Windows build)

Remove unneeded ODBC link

Resolves the issue of ODBC on macOS being dynamically linked to ODBC

Fix ODBC double proto issue on macOS

Need to check if Windows CI passes

Clean up PR

- Remove dummy tests
- Remove unneeded changes

Revert "Test ODBC CI - to be reverted"

This reverts commit 711b3e0.

Remove unneeded code

Attempt to revert c-ares change

Fix `set_target_properties can not be used on an ALIAS target.` error.

Example of failed run in forked repo:
https://github.com/Bit-Quill/arrow/actions/runs/21459770235/job/61809740997?pr=153#step:7:540

Fix descriptor pointer tests on static macOS

Fix mimalloc issue

Fixes issue:
```
mimalloc: assertion failed: at "arrow/cpp/debug-build/mimalloc_ep-prefix/src/mimalloc_ep/include/mimalloc/internal.h":658, _mi_ptr_page
  assertion: "p==NULL || mi_is_in_heap_region(p)"
zsh: abort      debug/arrow-flight-sql-odbc-test
```

Enable ODBC tests for static build

Add iodbc link to macOS build on ODBC layer

Add iodbc link to macOS build on ODBC Test

Add iodbc link to macOS build on ODBC layer did not resolve issue of unixodbc being picked in CI

* Fix segfault at SQLError

* work on Justin's comments
@alinaliBQ alinaliBQ force-pushed the gh-49219-static-odbc-macos-unix branch from 54c9575 to 15d9da8 Compare February 11, 2026 20:10
@alinaliBQ alinaliBQ marked this pull request as ready for review February 11, 2026 20:13
Comment on lines 3030 to 3044
find_library(LIBRESOLV_LIBRARY NAMES resolv libresolv REQUIRED)
set_target_properties(c-ares::cares PROPERTIES INTERFACE_LINK_LIBRARIES
"${LIBRESOLV_LIBRARY}")
set_target_properties(c-ares PROPERTIES INTERFACE_LINK_LIBRARIES
"${LIBRESOLV_LIBRARY}")
endif()
Copy link
Collaborator Author

@alinaliBQ alinaliBQ Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change fixes error:

CMake Error at cmake_modules/ThirdpartyToolchain.cmake:3032 (set_target_properties):
  set_target_properties can not be used on an ALIAS target.

Without this change, we have failed run with c-ares::cares being used. Log: https://github.com/Bit-Quill/arrow/actions/runs/21459770235/job/61809740997?pr=153#step:7:540

@github-actions github-actions bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Feb 11, 2026
@alinaliBQ
Copy link
Collaborator Author

Hi @lidavidm and @kou. This PR is ready for review. I’ll be OOO starting Feb 13 and will be back on Feb 23. I will address the review comments once I’m back.

ARROW_FLIGHT_SQL_ODBC: ON
ARROW_HOME: /tmp/local
ARROW_DEPENDENCY_USE_SHARED: OFF
ARROW_DEPENDENCY_SOURCE: BUNDLED
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you keep this list in alphabetical order?

CMAKE_INSTALL_PREFIX: /usr
VCPKG_BINARY_SOURCES: 'clear;nugettimeout,600;nuget,GitHub,readwrite'
VCPKG_DEFAULT_TRIPLET: x64-windows
CMAKE_CXX_STANDARD: "20"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this? We use C++20 by default.

Comment on lines +3042 to +3043
set_target_properties(c-ares PROPERTIES INTERFACE_LINK_LIBRARIES
"${LIBRESOLV_LIBRARY}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you try this?

Suggested change
set_target_properties(c-ares PROPERTIES INTERFACE_LINK_LIBRARIES
"${LIBRESOLV_LIBRARY}")
target_link_libraries(c-ares INTERFACE ${LIBRESOLV_LIBRARY})

${SQLite3_LIBRARIES}
${ARROW_FLIGHT_SQL_ODBC_TEST_LINK_LIBS})
elseif(APPLE)
# macOS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that this is redundant after the elseif(APPLE):

Suggested change
# macOS

Comment on lines +22 to +26
if(APPLE)
# CMAKE_FIND_LIBRARY_SUFFIXES.
set(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".a")
endif()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we revert this?

Comment on lines +71 to +118
if(WIN32)
add_arrow_lib(arrow_flight_sql_odbc
CMAKE_PACKAGE_NAME
ArrowFlightSqlOdbc
PKG_CONFIG_NAME
arrow-flight-sql-odbc
OUTPUTS
ARROW_FLIGHT_SQL_ODBC_LIBRARIES
SOURCES
${ARROW_FLIGHT_SQL_ODBC_SRCS}
DEFINITIONS
UNICODE
SHARED_LINK_FLAGS
${ARROW_VERSION_SCRIPT_FLAGS} # Defined in cpp/arrow/CMakeLists.txt
SHARED_LINK_LIBS
arrow_flight_sql_shared
arrow_odbc_spi_impl
SHARED_INSTALL_INTERFACE_LIBS
ArrowFlight::arrow_flight_sql_shared
STATIC_LINK_LIBS
arrow_flight_sql_static
STATIC_INSTALL_INTERFACE_LIBS
ArrowFlight::arrow_flight_sql_static
SHARED_PRIVATE_LINK_LIBS
ODBC::ODBC
${ODBCINST})
else()
# Unix
add_arrow_lib(arrow_flight_sql_odbc
CMAKE_PACKAGE_NAME
ArrowFlightSqlOdbc
PKG_CONFIG_NAME
arrow-flight-sql-odbc
OUTPUTS
ARROW_FLIGHT_SQL_ODBC_LIBRARIES
SOURCES
${ARROW_FLIGHT_SQL_ODBC_SRCS}
DEFINITIONS
UNICODE
SHARED_LINK_FLAGS
${ARROW_VERSION_SCRIPT_FLAGS} # Defined in cpp/arrow/CMakeLists.txt
STATIC_LINK_LIBS
iodbc
ODBC::ODBC
${ODBCINST}
SHARED_LINK_LIBS
arrow_odbc_spi_impl)
endif()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this if()/else()? Can we use only one add_arrow_lib()?

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting committer review Awaiting committer review labels Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants