Skip to content

Commit cd8e677

Browse files
authored
GH-47222: [CI][C++] Add a CI job that uses the same build options for JNI on macOS (#47305)
### Rationale for this change Static building for JNI build on macOS is failing in apache/arrow-java. We should avoid this in apache/arrow. See also: apache/arrow-java#799 ### What changes are included in this PR? * Add a CI job for JNI build on macOS * Fix build problems for bundled AWS SDK for C++ ### Are these changes tested? Yes. ### Are there any user-facing changes? Yes. * GitHub Issue: #47222 Authored-by: Sutou Kouhei <[email protected]> Signed-off-by: Sutou Kouhei <[email protected]>
1 parent 6660e84 commit cd8e677

File tree

4 files changed

+151
-11
lines changed

4 files changed

+151
-11
lines changed

.github/workflows/cpp_extra.yml

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ jobs:
8181
outputs:
8282
ci-extra: ${{ steps.check.outputs.ci-extra }}
8383
steps:
84+
- name: Checkout Arrow
85+
if: github.event_name == 'pull_request'
86+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
8487
- name: Check
8588
id: check
8689
env:
@@ -99,7 +102,15 @@ jobs:
99102
if [ "${n_ci_extra_labels}" -eq 1 ]; then
100103
ci_extra=true
101104
else
102-
ci_extra=false
105+
git fetch origin ${GITHUB_BASE_REF}
106+
if git diff --stat origin/${GITHUB_BASE_REF}.. | \
107+
grep \
108+
--fixed-strings ".github/workflows/cpp_extra.yml" \
109+
--quiet; then
110+
ci_extra=true
111+
else
112+
ci_extra=false
113+
fi
103114
fi
104115
;;
105116
esac
@@ -182,3 +193,88 @@ jobs:
182193
ARCHERY_DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}
183194
continue-on-error: true
184195
run: archery docker push ${{ matrix.image }}
196+
197+
jni-macos:
198+
needs: check-labels
199+
name: JNI macOS
200+
runs-on: macos-14
201+
if: needs.check-labels.outputs.ci-extra == 'true'
202+
timeout-minutes: 45
203+
env:
204+
MACOSX_DEPLOYMENT_TARGET: "14.0"
205+
steps:
206+
- name: Checkout Arrow
207+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
208+
with:
209+
fetch-depth: 0
210+
submodules: recursive
211+
- name: Install dependencies
212+
run: |
213+
brew bundle --file=cpp/Brewfile
214+
# We want to link aws-sdk-cpp statically but Homebrew's
215+
# aws-sdk-cpp provides only shared library. If we have
216+
# Homebrew's aws-sdk-cpp, our build mix Homebrew's
217+
# aws-sdk-cpp and bundled aws-sdk-cpp. We uninstall Homebrew's
218+
# aws-sdk-cpp to ensure using only bundled aws-sdk-cpp.
219+
brew uninstall aws-sdk-cpp
220+
# We want to use bundled RE2 for static linking. If
221+
# Homebrew's RE2 is installed, its header file may be used.
222+
# We uninstall Homebrew's RE2 to ensure using bundled RE2.
223+
brew uninstall grpc || : # gRPC depends on RE2
224+
brew uninstall [email protected] || : # gRPC 1.54 may be installed too
225+
brew uninstall re2
226+
# We want to use bundled Protobuf for static linking. If
227+
# Homebrew's Protobuf is installed, its library file may be
228+
# used on test We uninstall Homebrew's Protobuf to ensure using
229+
# bundled Protobuf.
230+
brew uninstall protobuf
231+
- name: Prepare ccache
232+
run: |
233+
echo "CCACHE_DIR=${PWD}/ccache" >> ${GITHUB_ENV}
234+
- name: Cache ccache
235+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
236+
with:
237+
path: ccache
238+
key: jni-macos-${{ hashFiles('cpp/**') }}
239+
restore-keys: jni-macos-
240+
- name: CMake
241+
run: |
242+
cmake \
243+
-S cpp \
244+
-B cpp.build \
245+
--preset=ninja-release-jni-macos \
246+
-DARROW_BUILD_TESTS=ON \
247+
-DCMAKE_INSTALL_PREFIX=$PWD/cpp.install
248+
- name: Build
249+
run: |
250+
cmake --build cpp.build
251+
- name: Install
252+
run: |
253+
cmake --install cpp.build
254+
- name: Test
255+
env:
256+
ARROW_TEST_DATA: ${{ github.workspace }}/testing/data
257+
PARQUET_TEST_DATA: ${{ github.workspace }}/cpp/submodules/parquet-testing/data
258+
run: |
259+
# MinIO is required
260+
exclude_tests="arrow-s3fs-test"
261+
# unstable
262+
exclude_tests="${exclude_tests}|arrow-acero-asof-join-node-test"
263+
exclude_tests="${exclude_tests}|arrow-acero-hash-join-node-test"
264+
ctest \
265+
--exclude-regex "${exclude_tests}" \
266+
--label-regex unittest \
267+
--output-on-failure \
268+
--parallel "$(sysctl -n hw.ncpu)" \
269+
--test-dir "cpp.build" \
270+
--timeout 300
271+
- name: Build example
272+
run: |
273+
cmake \
274+
-S cpp/examples/minimal_build/ \
275+
-B cpp/examples/minimal_build.build \
276+
-GNinja \
277+
-DCMAKE_INSTALL_PREFIX=$PWD/cpp.install
278+
cmake --build cpp/examples/minimal_build.build
279+
cd cpp/examples/minimal_build
280+
../minimal_build.build/arrow-example

cpp/CMakePresets.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,34 @@
582582
],
583583
"displayName": "Benchmarking build with everything enabled",
584584
"cacheVariables": {}
585+
},
586+
{
587+
"name": "ninja-release-jni-macos",
588+
"inherits": [
589+
"base-release"
590+
],
591+
"displayName": "Build for JNI on macOS",
592+
"cacheVariables": {
593+
"ARROW_ACERO": "ON",
594+
"ARROW_BUILD_SHARED": "OFF",
595+
"ARROW_BUILD_STATIC": "ON",
596+
"ARROW_CSV": "ON",
597+
"ARROW_DATASET": "ON",
598+
"ARROW_DEPENDENCY_USE_SHARED": "OFF",
599+
"ARROW_GANDIVA": "ON",
600+
"ARROW_GANDIVA_STATIC_LIBSTDCPP": "ON",
601+
"ARROW_JSON": "ON",
602+
"ARROW_ORC": "ON",
603+
"ARROW_PARQUET": "ON",
604+
"ARROW_S3": "ON",
605+
"ARROW_SUBSTRAIT": "ON",
606+
"AWSSDK_SOURCE": "BUNDLED",
607+
"GTest_SOURCE": "BUNDLED",
608+
"PARQUET_BUILD_EXAMPLES": "OFF",
609+
"PARQUET_BUILD_EXECUTABLES": "OFF",
610+
"PARQUET_REQUIRE_ENCRYPTION": "OFF",
611+
"re2_SOURCE": "BUNDLED"
612+
}
585613
}
586614
]
587615
}

cpp/cmake_modules/ThirdpartyToolchain.cmake

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5055,6 +5055,8 @@ endif()
50555055
# AWS SDK for C++
50565056

50575057
function(build_awssdk)
5058+
list(APPEND CMAKE_MESSAGE_INDENT "AWS SDK for C++: ")
5059+
50585060
message(STATUS "Building AWS SDK for C++ from source")
50595061

50605062
# aws-c-common must be the first product because others depend on
@@ -5159,9 +5161,9 @@ function(build_awssdk)
51595161

51605162
# For aws-sdk-cpp
51615163
#
5162-
# We need to use CACHE variables because aws-sdk-cpp < 12.0.0 uses
5164+
# We need to use CACHE variables because aws-sdk-cpp < 1.12.0 uses
51635165
# CMP0077 OLD policy. We can use normal variables when we use
5164-
# aws-sdk-cpp >= 12.0.0.
5166+
# aws-sdk-cpp >= 1.12.0.
51655167
set(AWS_SDK_WARNINGS_ARE_ERRORS
51665168
OFF
51675169
CACHE BOOL "" FORCE)
@@ -5186,12 +5188,15 @@ function(build_awssdk)
51865188
OFF
51875189
CACHE BOOL "" FORCE)
51885190
if(NOT WIN32)
5189-
set(ZLIB_INCLUDE_DIR
5190-
"$<TARGET_PROPERTY:ZLIB::ZLIB,INTERFACE_INCLUDE_DIRECTORIES>"
5191-
CACHE STRING "" FORCE)
5192-
set(ZLIB_LIBRARY
5193-
"$<TARGET_FILE:ZLIB::ZLIB>"
5194-
CACHE STRING "" FORCE)
5191+
if(ZLIB_VENDORED)
5192+
# Use vendored zlib.
5193+
set(ZLIB_INCLUDE_DIR
5194+
"$<TARGET_PROPERTY:ZLIB::ZLIB,INTERFACE_INCLUDE_DIRECTORIES>"
5195+
CACHE STRING "" FORCE)
5196+
set(ZLIB_LIBRARY
5197+
"$<TARGET_FILE:ZLIB::ZLIB>"
5198+
CACHE STRING "" FORCE)
5199+
endif()
51955200
endif()
51965201
if(MINGW AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9")
51975202
# This is for RTools 40. We can remove this after we dropped
@@ -5258,9 +5263,15 @@ function(build_awssdk)
52585263
set(AWSSDK_LINK_LIBRARIES
52595264
${AWSSDK_LINK_LIBRARIES}
52605265
PARENT_SCOPE)
5266+
5267+
list(POP_BACK CMAKE_MESSAGE_INDENT)
52615268
endfunction()
52625269

52635270
if(ARROW_S3)
5271+
if(NOT WIN32)
5272+
# This is for adding system curl dependency.
5273+
find_curl()
5274+
endif()
52645275
# Keep this in sync with s3fs.cc
52655276
resolve_dependency(AWSSDK
52665277
HAVE_ALT

cpp/examples/minimal_build/CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,15 @@ cmake_minimum_required(VERSION 3.25)
1919

2020
project(ArrowMinimalExample)
2121

22-
option(ARROW_LINK_SHARED "Link to the Arrow shared library" ON)
23-
2422
find_package(Arrow REQUIRED)
2523

24+
include(CMakeDependentOption)
25+
cmake_dependent_option(ARROW_LINK_SHARED
26+
"Link to the Arrow shared library if possible"
27+
ON
28+
ARROW_BUILD_SHARED
29+
OFF)
30+
2631
if(NOT DEFINED CMAKE_CXX_STANDARD)
2732
set(CMAKE_CXX_STANDARD 17)
2833
endif()

0 commit comments

Comments
 (0)