Skip to content

Commit 1f4910b

Browse files
kouraulcd
authored andcommitted
GH-47632: [CI][C++] Add a CI job for JNI on Linux (#47746)
### Rationale for this change This is for preventing to break Apache Arrow Java JNI use case on Linux. ### What changes are included in this PR? * Add a CI job that uses build options for JNI use case * Install more packages in manylinux image that is also used by JNI build ### Are these changes tested? Yes. ### Are there any user-facing changes? No. * GitHub Issue: #47632 Authored-by: Sutou Kouhei <kou@clear-code.com> Signed-off-by: Sutou Kouhei <kou@clear-code.com>
1 parent f1ff2e1 commit 1f4910b

File tree

11 files changed

+305
-9
lines changed

11 files changed

+305
-9
lines changed

.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ DOCKER_BUILDKIT=1
3737
ARCH=amd64
3838
ARCH_ALIAS=x86_64
3939
ARCH_SHORT=amd64
40+
# For aarch64
41+
# ARCH=arm64v8
42+
# ARCH_ALIAS=aarch64
43+
# ARCH_SHORT=arm64
4044

4145
# Default repository to pull and push images from
4246
REPO=apache/arrow-dev

.github/workflows/cpp.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,6 @@ jobs:
321321
BOOST_SOURCE: BUNDLED
322322
CMAKE_CXX_STANDARD: "17"
323323
CMAKE_GENERATOR: Ninja
324-
CMAKE_INSTALL_LIBDIR: bin
325324
CMAKE_INSTALL_PREFIX: /usr
326325
CMAKE_UNITY_BUILD: ON
327326
steps:
@@ -369,11 +368,12 @@ jobs:
369368
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
370369
bash -c "ci/scripts/cpp_build.sh $(pwd) $(pwd)/build"
371370
- name: Test
372-
shell: bash
371+
shell: cmd
373372
run: |
373+
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
374374
# For ORC
375-
export TZDIR=/c/msys64/usr/share/zoneinfo
376-
ci/scripts/cpp_test.sh $(pwd) $(pwd)/build
375+
set TZDIR=C:\msys64\usr\share\zoneinfo
376+
bash -c "ci/scripts/cpp_test.sh $(pwd) $(pwd)/build"
377377
378378
windows-mingw:
379379
name: AMD64 Windows MinGW ${{ matrix.msystem_upper }} C++

.github/workflows/cpp_extra.yml

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,67 @@ jobs:
164164
continue-on-error: true
165165
run: archery docker push ${{ matrix.image }}
166166

167+
jni-linux:
168+
needs: check-labels
169+
name: JNI ${{ matrix.platform.runs-on }} ${{ matrix.platform.arch }}
170+
runs-on: ${{ matrix.platform.runs-on }}
171+
if: >-
172+
needs.check-labels.outputs.force == 'true' ||
173+
contains(fromJSON(needs.check-labels.outputs.ci-extra-labels || '[]'), 'CI: Extra') ||
174+
contains(fromJSON(needs.check-labels.outputs.ci-extra-labels || '[]'), 'CI: Extra: C++')
175+
timeout-minutes: 240
176+
permissions:
177+
# This is for using GitHub Packages for vcpkg cache
178+
packages: write
179+
strategy:
180+
fail-fast: false
181+
matrix:
182+
platform:
183+
- arch: "amd64"
184+
runs-on: ubuntu-latest
185+
- arch: "arm64v8"
186+
runs-on: ubuntu-24.04-arm
187+
env:
188+
ARCH: ${{ matrix.platform.arch }}
189+
REPO: ghcr.io/${{ github.repository }}-dev
190+
steps:
191+
- name: Checkout Arrow
192+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
193+
with:
194+
fetch-depth: 0
195+
submodules: recursive
196+
- name: Cache Docker Volumes
197+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
198+
with:
199+
path: .docker
200+
key: jni-${{ matrix.platform.runs-on }}-${{ hashFiles('cpp/**') }}
201+
restore-keys: jni-${{ matrix.platform.runs-on }}-
202+
- name: Setup Python
203+
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
204+
with:
205+
python-version: 3
206+
- name: Setup Archery
207+
run: python3 -m pip install -e dev/archery[docker]
208+
- name: Execute Docker Build
209+
env:
210+
ARCHERY_DOCKER_USER: ${{ github.actor }}
211+
ARCHERY_DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
212+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
213+
VCPKG_BINARY_SOURCES: "clear;nuget,GitHub,readwrite"
214+
run: |
215+
source ci/scripts/util_enable_core_dumps.sh
216+
archery docker run cpp-jni
217+
- name: Docker Push
218+
if: >-
219+
success() &&
220+
github.event_name == 'push' &&
221+
github.ref_name == 'main'
222+
env:
223+
ARCHERY_DOCKER_USER: ${{ github.actor }}
224+
ARCHERY_DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
225+
continue-on-error: true
226+
run: archery docker push cpp-jni
227+
167228
jni-macos:
168229
needs: check-labels
169230
name: JNI macOS
@@ -177,7 +238,7 @@ jobs:
177238
MACOSX_DEPLOYMENT_TARGET: "14.0"
178239
steps:
179240
- name: Checkout Arrow
180-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
241+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
181242
with:
182243
fetch-depth: 0
183244
submodules: recursive

ci/docker/cpp-jni.dockerfile

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
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+
ARG base
19+
FROM ${base}
20+
21+
ARG arch
22+
ARG arch_short
23+
24+
SHELL ["/bin/bash", "-i", "-c"]
25+
ENTRYPOINT ["/bin/bash", "-i", "-c"]
26+
27+
# Install basic dependencies
28+
RUN dnf install -y \
29+
autoconf \
30+
curl \
31+
flex \
32+
gdb \
33+
git \
34+
perl-IPC-Cmd \
35+
wget \
36+
zip
37+
38+
# A system Python is required for Ninja and vcpkg in this Dockerfile.
39+
# On manylinux_2_28 base images, no system Python is installed.
40+
# We therefore override the PATH with Python 3.10 in /opt/python
41+
# so that we have a consistent Python version across base images.
42+
ENV CPYTHON_VERSION=cp310
43+
ENV PATH=/opt/python/${CPYTHON_VERSION}-${CPYTHON_VERSION}/bin:${PATH}
44+
45+
# Install CMake
46+
ARG cmake=3.29.2
47+
COPY ci/scripts/install_cmake.sh arrow/ci/scripts/
48+
RUN /arrow/ci/scripts/install_cmake.sh ${cmake} /usr/local
49+
50+
# Install Ninja
51+
ARG ninja=1.10.2
52+
COPY ci/scripts/install_ninja.sh arrow/ci/scripts/
53+
RUN /arrow/ci/scripts/install_ninja.sh ${ninja} /usr/local
54+
55+
# Install ccache
56+
ARG ccache=4.1
57+
COPY ci/scripts/install_ccache.sh arrow/ci/scripts/
58+
RUN /arrow/ci/scripts/install_ccache.sh ${ccache} /usr/local
59+
60+
# Install vcpkg
61+
ARG vcpkg
62+
COPY ci/vcpkg/*.patch \
63+
ci/vcpkg/*linux*.cmake \
64+
ci/vcpkg/vcpkg.json \
65+
arrow/ci/vcpkg/
66+
COPY ci/scripts/install_vcpkg.sh \
67+
arrow/ci/scripts/
68+
ENV VCPKG_ROOT=/opt/vcpkg
69+
ARG build_type=release
70+
ENV CMAKE_BUILD_TYPE=${build_type} \
71+
PATH="${PATH}:${VCPKG_ROOT}" \
72+
VCPKG_DEFAULT_TRIPLET=${arch_short}-linux-static-${build_type} \
73+
VCPKG_FEATURE_FLAGS="manifests" \
74+
VCPKG_FORCE_SYSTEM_BINARIES=1 \
75+
VCPKG_OVERLAY_TRIPLETS=/arrow/ci/vcpkg
76+
# For --mount=type=secret: The GITHUB_TOKEN is the only real secret but we use
77+
# --mount=type=secret for GITHUB_REPOSITORY_OWNER and
78+
# VCPKG_BINARY_SOURCES too because we don't want to store them
79+
# into the built image in order to easily reuse the built image cache.
80+
#
81+
# For vcpkg install: cannot use the S3 feature here because while
82+
# aws-sdk-cpp=1.9.160 contains ssl related fixes as well as we can
83+
# patch the vcpkg portfile to support arm machines it hits ARROW-15141
84+
# where we would need to fall back to 1.8.186 but we cannot patch
85+
# those portfiles since vcpkg-tool handles the checkout of previous
86+
# versions => use bundled S3 build
87+
RUN --mount=type=secret,id=github_repository_owner \
88+
--mount=type=secret,id=github_token \
89+
--mount=type=secret,id=vcpkg_binary_sources \
90+
export GITHUB_REPOSITORY_OWNER=$(cat /run/secrets/github_repository_owner); \
91+
export GITHUB_TOKEN=$(cat /run/secrets/github_token); \
92+
export VCPKG_BINARY_SOURCES=$(cat /run/secrets/vcpkg_binary_sources); \
93+
arrow/ci/scripts/install_vcpkg.sh ${VCPKG_ROOT} ${vcpkg} && \
94+
vcpkg install \
95+
--clean-after-build \
96+
--x-install-root=${VCPKG_ROOT}/installed \
97+
--x-manifest-root=/arrow/ci/vcpkg \
98+
--x-feature=azure \
99+
--x-feature=dev \
100+
--x-feature=flight \
101+
--x-feature=gandiva \
102+
--x-feature=gcs \
103+
--x-feature=json \
104+
--x-feature=orc \
105+
--x-feature=parquet \
106+
--x-feature=s3 && \
107+
rm -rf ~/.config/NuGet/
108+
109+
ENV ARROW_BUILD_TESTS=ON \
110+
ARROW_CMAKE_ARGS="-DARROW_BUILD_TESTS=ON" \
111+
CMAKE_PRESET=ninja-${CMAKE_BUILD_TYPE}-jni-linux

ci/scripts/cpp_build.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,11 @@ elif [ "${ARROW_EMSCRIPTEN:-OFF}" = "ON" ]; then
174174
-DCMAKE_UNITY_BUILD=${CMAKE_UNITY_BUILD:-OFF} \
175175
${ARROW_CMAKE_ARGS} \
176176
${source_dir}
177+
elif [ -n "${CMAKE_PRESET}" ]; then
178+
cmake \
179+
--preset="${CMAKE_PRESET}" \
180+
${ARROW_CMAKE_ARGS} \
181+
${source_dir}
177182
else
178183
cmake \
179184
-Dabsl_SOURCE=${absl_SOURCE:-} \
@@ -308,10 +313,14 @@ fi
308313
popd
309314

310315
if [ -x "$(command -v ldconfig)" ]; then
311-
if [ -x "$(command -v sudo)" ]; then
312-
SUDO=sudo
313-
else
316+
if [ "$(id --user)" -eq 0 ]; then
314317
SUDO=
318+
else
319+
if [ -x "$(command -v sudo)" ]; then
320+
SUDO=sudo
321+
else
322+
SUDO=
323+
fi
315324
fi
316325
${SUDO} ldconfig ${ARROW_HOME}/${CMAKE_INSTALL_LIBDIR:-lib}
317326
fi

ci/scripts/cpp_test.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ ctest_options=()
4747
if ! type azurite >/dev/null 2>&1; then
4848
exclude_tests+=("arrow-azurefs-test")
4949
fi
50+
if ! type storage-testbench >/dev/null 2>&1; then
51+
exclude_tests+=("arrow-gcsfs-test")
52+
fi
53+
if ! type minio >/dev/null 2>&1; then
54+
exclude_tests+=("arrow-s3fs-test")
55+
fi
5056
case "$(uname)" in
5157
Linux)
5258
n_jobs=$(nproc)
@@ -114,6 +120,41 @@ else
114120
"$@"
115121
fi
116122

123+
# This is for testing find_package(Arrow).
124+
#
125+
# Note that this is not a perfect solution. We should improve this
126+
# later.
127+
#
128+
# * This is ad-hoc
129+
# * This doesn't test other CMake packages such as ArrowDataset
130+
if [ "${ARROW_USE_MESON:-OFF}" = "OFF" ] && \
131+
[ "${ARROW_EMSCRIPTEN:-OFF}" = "OFF" ] && \
132+
[ "${ARROW_USE_ASAN:-OFF}" = "OFF" ]; then
133+
CMAKE_PREFIX_PATH="${CMAKE_INSTALL_PREFIX:-${ARROW_HOME}}"
134+
case "$(uname)" in
135+
MINGW*)
136+
# <prefix>/lib/cmake/ isn't searched on Windows.
137+
#
138+
# See also:
139+
# https://cmake.org/cmake/help/latest/command/find_package.html#config-mode-search-procedure
140+
CMAKE_PREFIX_PATH+="/lib/cmake/"
141+
;;
142+
esac
143+
if [ -n "${VCPKG_ROOT}" ] && [ -n "${VCPKG_DEFAULT_TRIPLET}" ]; then
144+
CMAKE_PREFIX_PATH+=";${VCPKG_ROOT}/installed/${VCPKG_DEFAULT_TRIPLET}"
145+
fi
146+
cmake \
147+
-S "${source_dir}/examples/minimal_build" \
148+
-B "${build_dir}/examples/minimal_build" \
149+
-DCMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}"
150+
cmake --build "${build_dir}/examples/minimal_build"
151+
pushd "${source_dir}/examples/minimal_build"
152+
# PATH= is for Windows.
153+
PATH="${CMAKE_INSTALL_PREFIX:-${ARROW_HOME}}/bin:${PATH}" \
154+
"${build_dir}/examples/minimal_build/arrow-example"
155+
popd
156+
fi
157+
117158
if [ "${ARROW_BUILD_EXAMPLES}" == "ON" ]; then
118159
examples=$(find "${binary_output_dir}" -executable -name "*example")
119160
if [ "${examples}" == "" ]; then

ci/vcpkg/vcpkg.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"re2",
2020
"snappy",
2121
"utf8proc",
22+
"xsimd",
2223
"zlib",
2324
"zstd",
2425
{

cpp/CMakePresets.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,37 @@
583583
"displayName": "Benchmarking build with everything enabled",
584584
"cacheVariables": {}
585585
},
586+
{
587+
"name": "ninja-release-jni-linux",
588+
"inherits": [
589+
"base-release"
590+
],
591+
"displayName": "Build for JNI on Linux",
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_SOURCE": "VCPKG",
599+
"ARROW_DEPENDENCY_USE_SHARED": "OFF",
600+
"ARROW_GANDIVA": "ON",
601+
"ARROW_GANDIVA_STATIC_LIBSTDCPP": "ON",
602+
"ARROW_GCS": "ON",
603+
"ARROW_JSON": "ON",
604+
"ARROW_ORC": "ON",
605+
"ARROW_PARQUET": "ON",
606+
"ARROW_RPATH_ORIGIN": "ON",
607+
"ARROW_S3": "ON",
608+
"ARROW_SUBSTRAIT": "ON",
609+
"PARQUET_BUILD_EXAMPLES": "OFF",
610+
"PARQUET_BUILD_EXECUTABLES": "OFF",
611+
"PARQUET_REQUIRE_ENCRYPTION": "OFF",
612+
"VCPKG_MANIFEST_MODE": "OFF",
613+
"VCPKG_ROOT": "$env{VCPKG_ROOT}",
614+
"VCPKG_TARGET_TRIPLET": "$env{VCPKG_TARGET_TRIPLET}"
615+
}
616+
},
586617
{
587618
"name": "ninja-release-jni-macos",
588619
"inherits": [

cpp/src/arrow/testing/process.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class Process::Impl {
176176
for (const auto& kv : process::environment::current()) {
177177
env[kv.key()] = process::environment::value(kv.value());
178178
}
179-
env["PATH"] = process::environment::value(current_exe.parent_path());
179+
env["PATH"] = process::environment::value(current_exe.parent_path().string());
180180
executable_ = process::environment::find_executable(name, env);
181181
# else
182182
executable_ = process::search_path(name, {current_exe.parent_path()});

cpp/src/gandiva/tests/projector_test.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,10 @@ TEST_F(TestProjector, TestAllIntTypes) {
389389
}
390390

391391
TEST_F(TestProjector, TestExtendedMath) {
392+
#ifdef __aarch64__
393+
GTEST_SKIP() << "Failed on aarch64 with 'JIT session error: Symbols not found: [ "
394+
"__multf3, __subtf3, __trunctfdf2, __extenddftf2, __divtf3 ]'";
395+
#endif
392396
// schema for input fields
393397
auto field0 = arrow::field("f0", arrow::float64());
394398
auto field1 = arrow::field("f1", arrow::float64());

0 commit comments

Comments
 (0)