Skip to content

Commit 910933e

Browse files
committed
Link ODBC library statically on unix
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.
1 parent 4c0fab3 commit 910933e

14 files changed

Lines changed: 784 additions & 55 deletions

File tree

.github/workflows/cpp_odbc.yml

Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
name: C++ ODBC
19+
20+
on:
21+
push:
22+
branches:
23+
- '**'
24+
- '!dependabot/**'
25+
tags:
26+
- '**'
27+
paths:
28+
- '.github/workflows/cpp_odbc.yml'
29+
- 'ci/scripts/cpp_*'
30+
- 'cpp/src/arrow/flight/sql/odbc/*'
31+
pull_request:
32+
paths:
33+
- '.github/workflows/cpp_odbc.yml'
34+
- 'ci/scripts/cpp_*'
35+
- 'cpp/src/arrow/flight/sql/odbc/*'
36+
schedule:
37+
- cron: '0 13 * * *'
38+
39+
concurrency:
40+
group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }}
41+
cancel-in-progress: true
42+
43+
permissions:
44+
contents: read
45+
46+
jobs:
47+
windows:
48+
runs-on: windows-2022
49+
timeout-minutes: 240
50+
env:
51+
ARROW_BUILD_SHARED: ON
52+
ARROW_BUILD_STATIC: ON
53+
ARROW_BUILD_TESTS: ON
54+
ARROW_BUILD_TYPE: release
55+
ARROW_DEPENDENCY_SOURCE: VCPKG
56+
ARROW_FLIGHT: ON
57+
ARROW_FLIGHT_SQL: ON
58+
ARROW_FLIGHT_SQL_ODBC: ON
59+
ARROW_FLIGHT_SQL_ODBC_INSTALLER: ON
60+
ARROW_SIMD_LEVEL: AVX2
61+
CMAKE_CXX_STANDARD: "17"
62+
CMAKE_GENERATOR: Ninja
63+
CMAKE_INSTALL_PREFIX: /usr
64+
VCPKG_BINARY_SOURCES: 'clear;nuget,GitHub,readwrite'
65+
VCPKG_DEFAULT_TRIPLET: x64-windows
66+
steps:
67+
- name: Disable Crash Dialogs
68+
run: |
69+
reg add `
70+
"HKCU\SOFTWARE\Microsoft\Windows\Windows Error Reporting" `
71+
/v DontShowUI `
72+
/t REG_DWORD `
73+
/d 1 `
74+
/f
75+
- name: Checkout Arrow
76+
uses: actions/checkout@v5
77+
with:
78+
fetch-depth: 0
79+
submodules: recursive
80+
- name: Download Timezone Database
81+
shell: bash
82+
run: ci/scripts/download_tz_database.sh
83+
- name: Install msys2 (for tzdata for ORC tests)
84+
uses: msys2/setup-msys2@v2
85+
id: setup-msys2
86+
- name: Install cmake
87+
shell: bash
88+
run: |
89+
ci/scripts/install_cmake.sh 4.1.2 /usr
90+
- name: Install ccache
91+
shell: bash
92+
run: |
93+
ci/scripts/install_ccache.sh 4.12.1 /usr
94+
- name: Setup ccache
95+
shell: bash
96+
run: |
97+
ci/scripts/ccache_setup.sh
98+
- name: ccache info
99+
id: ccache-info
100+
shell: bash
101+
run: |
102+
echo "cache-dir=$(ccache --get-config cache_dir)" >> $GITHUB_OUTPUT
103+
- name: Cache ccache
104+
uses: actions/cache@v4
105+
with:
106+
path: ${{ steps.ccache-info.outputs.cache-dir }}
107+
key: cpp-odbc-ccache-windows-x64-${{ hashFiles('cpp/**') }}
108+
restore-keys: cpp-odbc-ccache-windows-x64-
109+
- name: Checkout vcpkg
110+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
111+
with:
112+
fetch-depth: 0
113+
path: vcpkg
114+
repository: microsoft/vcpkg
115+
- name: Bootstrap vcpkg
116+
run: |
117+
vcpkg\bootstrap-vcpkg.bat
118+
$VCPKG_ROOT = $(Resolve-Path -LiteralPath "vcpkg").ToString()
119+
Write-Output ${VCPKG_ROOT} | `
120+
Out-File -FilePath ${Env:GITHUB_PATH} -Encoding utf8 -Append
121+
Write-Output "VCPKG_ROOT=${VCPKG_ROOT}" | `
122+
Out-File -FilePath ${Env:GITHUB_ENV} -Encoding utf8 -Append
123+
- name: Setup NuGet credentials for vcpkg caching
124+
shell: bash
125+
run: |
126+
$(vcpkg fetch nuget | tail -n 1) \
127+
sources add \
128+
-source "https://nuget.pkg.github.com/$GITHUB_REPOSITORY_OWNER/index.json" \
129+
-storepasswordincleartext \
130+
-name "GitHub" \
131+
-username "$GITHUB_REPOSITORY_OWNER" \
132+
-password "${{ secrets.GITHUB_TOKEN }}"
133+
$(vcpkg fetch nuget | tail -n 1) \
134+
setapikey "${{ secrets.GITHUB_TOKEN }}" \
135+
-source "https://nuget.pkg.github.com/$GITHUB_REPOSITORY_OWNER/index.json"
136+
- name: Build
137+
shell: cmd
138+
run: |
139+
set VCPKG_ROOT_KEEP=%VCPKG_ROOT%
140+
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
141+
set VCPKG_ROOT=%VCPKG_ROOT_KEEP%
142+
bash -c "ci/scripts/cpp_build.sh $(pwd) $(pwd)/build"
143+
- name: Register Flight SQL ODBC Driver
144+
shell: cmd
145+
run: |
146+
call "cpp\src\arrow\flight\sql\odbc\tests\install_odbc.cmd" ${{ github.workspace }}\build\cpp\%ARROW_BUILD_TYPE%\arrow_flight_sql_odbc.dll
147+
# GH-48270 TODO: Resolve segementation fault during Arrow library unload
148+
# GH-48269 TODO: Enable Flight & Flight SQL testing in MSVC CI
149+
# TODO: enable ODBC tests after GH-48270 and GH-48269 are resolved.
150+
# - name: Test
151+
# shell: cmd
152+
# run: |
153+
# set VCPKG_ROOT_KEEP=%VCPKG_ROOT%
154+
# call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
155+
# # For ORC
156+
# set TZDIR=${{ steps.setup-msys2.outputs.msys2-location }}\usr\share\zoneinfo
157+
158+
# # Convert VCPKG Windows path to MSYS path
159+
# for /f "usebackq delims=" %%I in (`bash -c "cygpath -u \"$VCPKG_ROOT_KEEP\""` ) do set VCPKG_ROOT=%%I
160+
161+
# bash -c "ci/scripts/cpp_test.sh $(pwd) $(pwd)/build"
162+
163+
- name: Install WiX Toolset
164+
shell: pwsh
165+
run: |
166+
Invoke-WebRequest -Uri https://github.com/wixtoolset/wix/releases/download/v6.0.0/wix-cli-x64.msi -OutFile wix-cli-x64.msi
167+
Start-Process -FilePath wix-cli-x64.msi -ArgumentList '/quiet', 'Include_freethreaded=1' -Wait
168+
echo "C:\Program Files\WiX Toolset v6.0\bin\" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
169+
- name: Build MSI ODBC installer
170+
shell: pwsh
171+
run: |
172+
# Verify WiX version
173+
wix --version
174+
cd "${{ github.workspace }}\build\cpp"
175+
cpack
176+
- name: Upload the artifacts to the job
177+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
178+
with:
179+
name: flight-sql-odbc-msi-installer
180+
path: ${{ github.workspace }}\build\cpp\Apache Arrow Flight SQL ODBC-1.0.0-win64.msi
181+
macos:
182+
name: ${{ matrix.architecture }} macOS ${{ matrix.macos-version }} C++
183+
runs-on: macos-${{ matrix.macos-version }}
184+
if: ${{ !contains(github.event.pull_request.title, 'WIP') }}
185+
timeout-minutes: 75
186+
strategy:
187+
fail-fast: false
188+
matrix:
189+
include:
190+
- architecture: AMD64
191+
macos-version: "15-intel"
192+
- architecture: ARM64
193+
macos-version: "14"
194+
env:
195+
ARROW_BUILD_TESTS: ON
196+
# -AL- for linking dependencies statically.
197+
# ARROW_DEPENDENCY_USE_SHARED: OFF
198+
ARROW_FLIGHT_SQL_ODBC: ON
199+
ARROW_HOME: /tmp/local
200+
steps:
201+
- name: Checkout Arrow
202+
uses: actions/checkout@v6.0.0
203+
with:
204+
fetch-depth: 0
205+
submodules: recursive
206+
- name: Install Dependencies
207+
run: |
208+
brew bundle --file=cpp/Brewfile
209+
export LIBIODBC_DIR="$(brew --cellar libiodbc)/$(brew list --versions libiodbc | awk '{print $2}')"
210+
echo ODBC_INCLUDE_DIR="$LIBIODBC_DIR/include" >> $GITHUB_ENV
211+
echo ODBC_LIB_DIR="$LIBIODBC_DIR/lib" >> $GITHUB_ENV
212+
# -AL- uncomment below if having icu4c missing issues, not tested.
213+
# export LIBICU4C_DIR="$(brew --cellar icu4c)/$(brew list --versions icu4c | awk '{print $2}')"
214+
# echo ICU4C_LIB_DIR="$LIBICU4C_DIR/lib" >> $GITHUB_ENV
215+
- name: Setup ccache
216+
run: |
217+
ci/scripts/ccache_setup.sh
218+
- name: ccache info
219+
id: ccache-info
220+
run: |
221+
echo "cache-dir=$(ccache --get-config cache_dir)" >> $GITHUB_OUTPUT
222+
- name: Cache ccache
223+
uses: actions/cache@v4
224+
with:
225+
path: ${{ steps.ccache-info.outputs.cache-dir }}
226+
key: cpp-ccache-macos-${{ matrix.macos-version }}-${{ hashFiles('cpp/**') }}
227+
restore-keys: cpp-ccache-macos-${{ matrix.macos-version }}-
228+
- name: Build
229+
run: |
230+
# Homebrew uses /usr/local as prefix. So packages
231+
# installed by Homebrew also use /usr/local/include. We
232+
# want to include headers for packages installed by
233+
# Homebrew as system headers to ignore warnings in them.
234+
# But "-isystem /usr/local/include" isn't used by CMake
235+
# because /usr/local/include is marked as the default
236+
# include path. So we disable -Werror to avoid build error
237+
# by warnings from packages installed by Homebrew.
238+
export BUILD_WARNING_LEVEL=PRODUCTION
239+
ci/scripts/cpp_build.sh $(pwd) $(pwd)/build
240+
- name: Register Flight SQL ODBC Driver
241+
run: |
242+
chmod +x cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc.sh
243+
sudo cpp/src/arrow/flight/sql/odbc/install/mac/install_odbc.sh $(pwd)/build/cpp/debug/libarrow_flight_sql_odbc.dylib
244+
- name: Test
245+
shell: bash
246+
run: |
247+
ci/scripts/cpp_test.sh $(pwd) $(pwd)/build

ci/scripts/cpp_build.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,8 @@ else
261261
-DCMAKE_BUILD_TYPE=${ARROW_BUILD_TYPE:-debug} \
262262
-DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE:-OFF} \
263263
-DCMAKE_C_FLAGS="${CFLAGS:-}" \
264+
#-AL- might need to add icudata here too. Uncomment below code if CI needs to find icu4c. untested.
265+
# -DCMAKE_CXX_FLAGS="${CXXFLAGS:-} -I${ODBC_INCLUDE_DIR:-} -L${ODBC_LIB_DIR:-} -L${ICU4C_LIB_DIR:-}" \
264266
-DCMAKE_CXX_FLAGS="${CXXFLAGS:-} -I${ODBC_INCLUDE_DIR:-} -L${ODBC_LIB_DIR:-}" \
265267
-DCMAKE_CXX_STANDARD="${CMAKE_CXX_STANDARD:-20}" \
266268
-DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR:-lib} \

cpp/cmake_modules/BuildUtils.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,10 @@ function(ADD_ARROW_LIB LIB_NAME)
220220
message(SEND_ERROR "Error: unrecognized arguments: ${ARG_UNPARSED_ARGUMENTS}")
221221
endif()
222222

223+
if("${LIB_NAME}" MATCHES "odbc")
224+
message(STATUS "-AL- LIB_NAME contains odbc (arrow flight sql odbc)")
225+
endif()
226+
223227
if(ARG_OUTPUTS)
224228
set(${ARG_OUTPUTS})
225229
endif()
@@ -319,6 +323,8 @@ function(ADD_ARROW_LIB LIB_NAME)
319323
endif()
320324

321325
if(BUILD_SHARED)
326+
message(STATUS "-AL- LIB_DEPS:${LIB_DEPS}, EXTRA_DEPS: ${EXTRA_DEPS}"
327+
)
322328
add_library(${LIB_NAME}_shared SHARED ${LIB_DEPS})
323329
if(EXTRA_DEPS)
324330
add_dependencies(${LIB_NAME}_shared ${EXTRA_DEPS})
@@ -364,6 +370,8 @@ function(ADD_ARROW_LIB LIB_NAME)
364370
VERSION "${ARROW_FULL_SO_VERSION}"
365371
SOVERSION "${ARROW_SO_VERSION}")
366372

373+
message(STATUS "-AL- ARG_SHARED_LINK_LIBS:${ARG_SHARED_LINK_LIBS}, ARG_SHARED_INSTALL_INTERFACE_LIBS: ${ARG_SHARED_INSTALL_INTERFACE_LIBS}, ARG_SHARED_PRIVATE_LINK_LIBS: ${ARG_SHARED_PRIVATE_LINK_LIBS}"
374+
)
367375
target_link_libraries(${LIB_NAME}_shared
368376
PUBLIC "$<BUILD_INTERFACE:${ARG_SHARED_LINK_LIBS}>"
369377
"$<INSTALL_INTERFACE:${ARG_SHARED_INSTALL_INTERFACE_LIBS}>"
@@ -719,6 +727,7 @@ function(ADD_TEST_CASE REL_TEST_NAME)
719727
# Customize link libraries
720728
target_link_libraries(${TEST_NAME} PRIVATE ${ARG_STATIC_LINK_LIBS})
721729
else()
730+
message(STATUS "-AL- ARROW_TEST_LINK_LIBS: ${ARROW_TEST_LINK_LIBS}")
722731
target_link_libraries(${TEST_NAME} PRIVATE ${ARROW_TEST_LINK_LIBS})
723732
endif()
724733

cpp/cmake_modules/ThirdpartyToolchain.cmake

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ set(ARROW_RE2_LINKAGE
4141
# ----------------------------------------------------------------------
4242
# Resolve the dependencies
4343

44+
# -AL- I believe this is the place where gRPC is linked. (or somewhere else related)
45+
4446
set(ARROW_THIRDPARTY_DEPENDENCIES
4547
absl
4648
AWSSDK
@@ -1107,6 +1109,12 @@ function(build_boost)
11071109
else()
11081110
list(APPEND BOOST_EXCLUDE_LIBRARIES uuid)
11091111
endif()
1112+
#-al- Add ODBC-specific dependencies
1113+
if(ARROW_FLIGHT_SQL_ODBC)
1114+
list(APPEND BOOST_INCLUDE_LIBRARIES beast xpressive)
1115+
else()
1116+
list(APPEND BOOST_EXCLUDE_LIBRARIES beast xpressive)
1117+
endif()
11101118
set(BOOST_SKIP_INSTALL_RULES ON)
11111119
if(NOT ARROW_ENABLE_THREADING)
11121120
set(BOOST_UUID_LINK_LIBATOMIC OFF)
@@ -3014,11 +3022,16 @@ function(build_cares)
30143022
set(CARES_BUILD_TOOLS OFF)
30153023
fetchcontent_makeavailable(cares)
30163024

3025+
# -AL- getting issue here. Resolved issue on macOS Intel with `c-ares`
30173026
if(APPLE)
30183027
# libresolv must be linked from c-ares version 1.16.1
30193028
find_library(LIBRESOLV_LIBRARY NAMES resolv libresolv REQUIRED)
3020-
set_target_properties(c-ares::cares PROPERTIES INTERFACE_LINK_LIBRARIES
3021-
"${LIBRESOLV_LIBRARY}")
3029+
# set_target_properties(c-ares::cares PROPERTIES INTERFACE_LINK_LIBRARIES
3030+
# "${LIBRESOLV_LIBRARY}")
3031+
# -AL- Changed to below code to get pass
3032+
# `set_target_properties can not be used on an ALIAS target.` error.
3033+
set_target_properties(c-ares PROPERTIES INTERFACE_LINK_LIBRARIES
3034+
"${LIBRESOLV_LIBRARY}")
30223035
endif()
30233036

30243037
set(ARROW_BUNDLED_STATIC_LIBS

0 commit comments

Comments
 (0)