-
Notifications
You must be signed in to change notification settings - Fork 447
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[VL] Support building arrow CPP and finding installed arrow libs from…
… system (#6229)
- Loading branch information
Showing
7 changed files
with
239 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#!/bin/bash | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
CURRENT_DIR=$(cd "$(dirname "$BASH_SOURCE")"; pwd) | ||
source ${CURRENT_DIR}/build_helper_functions.sh | ||
VELOX_ARROW_BUILD_VERSION=15.0.0 | ||
ARROW_PREFIX=$CURRENT_DIR/arrow_ep | ||
# Always uses BUNDLED in case of that thrift is not installed. | ||
THRIFT_SOURCE="BUNDLED" | ||
BUILD_TYPE=Release | ||
|
||
function prepare_arrow_build() { | ||
sudo rm -rf arrow_ep/ | ||
wget_and_untar https://archive.apache.org/dist/arrow/arrow-${VELOX_ARROW_BUILD_VERSION}/apache-arrow-${VELOX_ARROW_BUILD_VERSION}.tar.gz arrow_ep | ||
cd arrow_ep/ | ||
patch -p1 < $CURRENT_DIR/../ep/build-velox/src/modify_arrow.patch | ||
patch -p1 < $CURRENT_DIR/../ep/build-velox/src/modify_arrow_dataset_scan_option.patch | ||
} | ||
|
||
function install_arrow_deps { | ||
wget_and_untar https://github.com/openssl/openssl/archive/refs/tags/OpenSSL_1_1_1s.tar.gz openssl | ||
pushd openssl | ||
./config no-shared && make depend && make && sudo make install | ||
popd | ||
} | ||
|
||
function build_arrow_cpp() { | ||
if [ -n "$1" ]; then | ||
BUILD_TYPE=$1 | ||
fi | ||
pushd $ARROW_PREFIX/cpp | ||
|
||
cmake_install \ | ||
-DARROW_PARQUET=ON \ | ||
-DARROW_FILESYSTEM=ON \ | ||
-DARROW_PROTOBUF_USE_SHARED=OFF \ | ||
-DARROW_WITH_THRIFT=ON \ | ||
-DARROW_WITH_LZ4=ON \ | ||
-DARROW_WITH_SNAPPY=ON \ | ||
-DARROW_WITH_ZLIB=ON \ | ||
-DARROW_WITH_ZSTD=ON \ | ||
-DARROW_JEMALLOC=OFF \ | ||
-DARROW_SIMD_LEVEL=NONE \ | ||
-DARROW_RUNTIME_SIMD_LEVEL=NONE \ | ||
-DARROW_WITH_UTF8PROC=OFF \ | ||
-DARROW_TESTING=ON \ | ||
-DCMAKE_INSTALL_PREFIX=/usr/local \ | ||
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ | ||
-DARROW_BUILD_STATIC=ON \ | ||
-DThrift_SOURCE=${THRIFT_SOURCE} | ||
popd | ||
} | ||
|
||
function build_arrow_java() { | ||
ARROW_INSTALL_DIR="${ARROW_PREFIX}/install" | ||
|
||
pushd $ARROW_PREFIX/java | ||
# Because arrow-bom module need the -DprocessAllModules | ||
mvn versions:set -DnewVersion=15.0.0-gluten -DprocessAllModules | ||
|
||
mvn clean install -pl bom,maven/module-info-compiler-maven-plugin,vector -am \ | ||
-DskipTests -Drat.skip -Dmaven.gitcommitid.skip -Dcheckstyle.skip -Dassembly.skipAssembly | ||
|
||
# Arrow C Data Interface CPP libraries | ||
mvn generate-resources -P generate-libs-cdata-all-os -Darrow.c.jni.dist.dir=$ARROW_INSTALL_DIR \ | ||
-Dmaven.test.skip -Drat.skip -Dmaven.gitcommitid.skip -Dcheckstyle.skip -N | ||
|
||
# Arrow JNI Date Interface CPP libraries | ||
export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}} | ||
mvn generate-resources -Pgenerate-libs-jni-macos-linux -N -Darrow.dataset.jni.dist.dir=$ARROW_INSTALL_DIR \ | ||
-DARROW_GANDIVA=OFF -DARROW_JAVA_JNI_ENABLE_GANDIVA=OFF -DARROW_ORC=OFF -DARROW_JAVA_JNI_ENABLE_ORC=OFF \ | ||
-Dmaven.test.skip -Drat.skip -Dmaven.gitcommitid.skip -Dcheckstyle.skip -N | ||
|
||
# Arrow Java libraries | ||
mvn install -Parrow-jni -P arrow-c-data -pl c,dataset -am \ | ||
-Darrow.c.jni.dist.dir=$ARROW_INSTALL_DIR/lib -Darrow.dataset.jni.dist.dir=$ARROW_INSTALL_DIR/lib -Darrow.cpp.build.dir=$ARROW_INSTALL_DIR/lib \ | ||
-Dmaven.test.skip -Drat.skip -Dmaven.gitcommitid.skip -Dcheckstyle.skip -Dassembly.skipAssembly | ||
popd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
#!/bin/bash | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
function get_cxx_flags { | ||
local CPU_ARCH=$1 | ||
|
||
local OS | ||
OS=$(uname) | ||
local MACHINE | ||
MACHINE=$(uname -m) | ||
ADDITIONAL_FLAGS="" | ||
|
||
if [[ -z "$CPU_ARCH" ]] || [[ $CPU_ARCH == "unknown" ]]; then | ||
if [ "$OS" = "Darwin" ]; then | ||
|
||
if [ "$MACHINE" = "x86_64" ]; then | ||
local CPU_CAPABILITIES | ||
CPU_CAPABILITIES=$(sysctl -a | grep machdep.cpu.features | awk '{print tolower($0)}') | ||
|
||
if [[ $CPU_CAPABILITIES =~ "avx" ]]; then | ||
CPU_ARCH="avx" | ||
else | ||
CPU_ARCH="sse" | ||
fi | ||
|
||
elif [[ $(sysctl -a | grep machdep.cpu.brand_string) =~ "Apple" ]]; then | ||
# Apple silicon. | ||
CPU_ARCH="arm64" | ||
fi | ||
|
||
# On MacOs prevent the flood of translation visibility settings warnings. | ||
ADDITIONAL_FLAGS="-fvisibility=hidden -fvisibility-inlines-hidden" | ||
else [ "$OS" = "Linux" ]; | ||
|
||
local CPU_CAPABILITIES | ||
CPU_CAPABILITIES=$(cat /proc/cpuinfo | grep flags | head -n 1| awk '{print tolower($0)}') | ||
|
||
if [[ "$CPU_CAPABILITIES" =~ "avx" ]]; then | ||
CPU_ARCH="avx" | ||
elif [[ "$CPU_CAPABILITIES" =~ "sse" ]]; then | ||
CPU_ARCH="sse" | ||
elif [ "$MACHINE" = "aarch64" ]; then | ||
CPU_ARCH="aarch64" | ||
fi | ||
fi | ||
fi | ||
|
||
case $CPU_ARCH in | ||
|
||
"arm64") | ||
echo -n "-mcpu=apple-m1+crc -std=c++17 -fvisibility=hidden $ADDITIONAL_FLAGS" | ||
;; | ||
|
||
"avx") | ||
echo -n "-mavx2 -mfma -mavx -mf16c -mlzcnt -std=c++17 -mbmi2 $ADDITIONAL_FLAGS" | ||
;; | ||
|
||
"sse") | ||
echo -n "-msse4.2 -std=c++17 $ADDITIONAL_FLAGS" | ||
;; | ||
|
||
"aarch64") | ||
echo -n "-mcpu=neoverse-n1 -std=c++17 $ADDITIONAL_FLAGS" | ||
;; | ||
*) | ||
echo -n "Architecture not supported!" | ||
esac | ||
|
||
} | ||
|
||
function wget_and_untar { | ||
local URL=$1 | ||
local DIR=$2 | ||
mkdir -p "${DIR}" | ||
pushd "${DIR}" | ||
curl -L "${URL}" > $2.tar.gz | ||
tar -xz --strip-components=1 -f $2.tar.gz | ||
popd | ||
} | ||
|
||
function cmake_install { | ||
local NAME=$(basename "$(pwd)") | ||
local BINARY_DIR=_build | ||
SUDO="${SUDO:-""}" | ||
if [ -d "${BINARY_DIR}" ] && prompt "Do you want to rebuild ${NAME}?"; then | ||
${SUDO} rm -rf "${BINARY_DIR}" | ||
fi | ||
mkdir -p "${BINARY_DIR}" | ||
CPU_TARGET="${CPU_TARGET:-unknown}" | ||
COMPILER_FLAGS=$(get_cxx_flags $CPU_TARGET) | ||
|
||
# CMAKE_POSITION_INDEPENDENT_CODE is required so that Velox can be built into dynamic libraries \ | ||
cmake -Wno-dev -B"${BINARY_DIR}" \ | ||
-GNinja \ | ||
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \ | ||
-DCMAKE_CXX_STANDARD=17 \ | ||
"${INSTALL_PREFIX+-DCMAKE_PREFIX_PATH=}${INSTALL_PREFIX-}" \ | ||
"${INSTALL_PREFIX+-DCMAKE_INSTALL_PREFIX=}${INSTALL_PREFIX-}" \ | ||
-DCMAKE_CXX_FLAGS="$COMPILER_FLAGS" \ | ||
-DBUILD_TESTING=OFF \ | ||
"$@" | ||
|
||
cmake --build "${BINARY_DIR}" | ||
${SUDO} cmake --install "${BINARY_DIR}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.