Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Arrow using LLVM preset #1039

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 23 additions & 59 deletions arrow/cppbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@ if [[ $PLATFORM == windows* ]]; then
export PYTHON_BIN_PATH=$(which python.exe)
fi

LLVM_VERSION=11.1.0
OPENSSL_VERSION=1.1.1k
ZLIB_VERSION=1.2.11
PROTO_VERSION=3.13.0
ARROW_VERSION=3.0.0
download https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VERSION/llvm-$LLVM_VERSION.src.tar.xz llvm-$LLVM_VERSION.src.tar.xz
download https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VERSION/clang-$LLVM_VERSION.src.tar.xz clang-$LLVM_VERSION.src.tar.xz
download https://github.com/python/cpython-bin-deps/archive/openssl-bin.zip cpython-bin-deps-openssl-bin.zip
download https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz openssl-$OPENSSL_VERSION.tar.gz
download http://zlib.net/zlib-$ZLIB_VERSION.tar.gz zlib-$ZLIB_VERSION.tar.gz
Expand All @@ -28,40 +25,42 @@ download https://www.apache.org/dist/arrow/arrow-$ARROW_VERSION/apache-arrow-$AR
mkdir -p $PLATFORM
cd $PLATFORM
INSTALL_PATH=`pwd`

LLVM_PATH="$INSTALL_PATH/../../../llvm/cppbuild/$PLATFORM/"

if [[ -n "${BUILD_PATH:-}" ]]; then
PREVIFS="$IFS"
IFS="$BUILD_PATH_SEPARATOR"
for P in $BUILD_PATH; do
if [[ -f "$P/include/llvm-c/Core.h" ]]; then
LLVM_PATH="$P"
fi
done
IFS="$PREVIFS"
fi

LLVM_PATH="${LLVM_PATH//\\//}"

rm -Rf $LLVM_PATH/lib/cmake

echo "Decompressing archives... (ignore any symlink errors)"
tar --totals -xzf ../apache-arrow-$ARROW_VERSION.tar.gz
tar --totals -xzf ../protobuf-$PROTO_VERSION.tar.gz
tar --totals -xzf ../zlib-$ZLIB_VERSION.tar.gz
tar --totals -xzf ../openssl-$OPENSSL_VERSION.tar.gz
tar --totals -xf ../llvm-$LLVM_VERSION.src.tar.xz || tar --totals -xf ../llvm-$LLVM_VERSION.src.tar.xz
cd apache-arrow-$ARROW_VERSION
patch -Np1 < ../../../arrow.patch
sedinplace 's/ARROW_LLVM_VERSIONS "10"/ARROW_LLVM_VERSIONS "11" "10"/g' cpp/CMakeLists.txt
cd ../llvm-$LLVM_VERSION.src
sedinplace '/find_package(Git/d' cmake/modules/AddLLVM.cmake cmake/modules/VersionFromVCS.cmake
mkdir -p build tools
cd tools
tar --totals -xf ../../../clang-$LLVM_VERSION.src.tar.xz || tar --totals -xf ../../../clang-$LLVM_VERSION.src.tar.xz
rm -Rf clang
mv clang-$LLVM_VERSION.src clang
cd ../build
sedinplace 's/set(ARROW_LLVM_VERSIONS/set(ARROW_LLVM_VERSIONS "12"/g' cpp/CMakeLists.txt

mkdir -p build
cd build

COMPONENTS="-DARROW_COMPUTE=ON -DARROW_CSV=ON -DARROW_DATASET=ON -DARROW_FILESYSTEM=ON -DARROW_FLIGHT=ON -DARROW_GANDIVA=ON -DARROW_HDFS=ON -DARROW_JSON=ON -DARROW_ORC=ON -DARROW_PARQUET=ON -DARROW_PLASMA=ON -DARROW_DEPENDENCY_SOURCE=BUNDLED -DARROW_VERBOSE_THIRDPARTY_BUILD=ON -DARROW_USE_GLOG=ON -DARROW_WITH_BROTLI=ON -DARROW_WITH_BZ2=OFF -DARROW_WITH_LZ4=ON -DARROW_WITH_SNAPPY=ON -DARROW_WITH_ZLIB=ON -DARROW_WITH_ZSTD=OFF"

case $PLATFORM in
linux-armhf)
mkdir -p ../tblgen
cd ../tblgen
"$CMAKE" -DLLVM_CCACHE_BUILD=ON -DCMAKE_BUILD_TYPE=Release -DLLVM_HOST_TRIPLE=arm-unknown-linux-gnueabihf -DLLVM_DEFAULT_TARGET_TRIPLE=arm-unknown-linux-gnueabihf -DLLVM_TARGET_ARCH=ARM -DLLVM_TARGETS_TO_BUILD=ARM -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_INCLUDE_TESTS=OFF -DPYTHON_EXECUTABLE="$PYTHON_BIN_PATH" ..
make -j $MAKEJ llvm-tblgen clang-tblgen
TBLGEN=`pwd`
mkdir -p ../build
cd ../build
export CC="arm-linux-gnueabihf-gcc"
export CXX="arm-linux-gnueabihf-g++ -std=c++11"
"$CMAKE" -DCMAKE_EXE_LINKER_FLAGS="-ldl" -DCMAKE_SHARED_LINKER_FLAGS="-ldl" -DLLVM_CCACHE_BUILD=ON -DCMAKE_CROSSCOMPILING=True -DCMAKE_INSTALL_PREFIX="$INSTALL_PATH" -DLLVM_TABLEGEN="$TBLGEN/bin/llvm-tblgen" -DCLANG_TABLEGEN="$TBLGEN/bin/clang-tblgen" -DCMAKE_C_FLAGS="-march=armv6 -mfpu=vfp -mfloat-abi=hard" -DCMAKE_CXX_FLAGS="-march=armv6 -mfpu=vfp -mfloat-abi=hard" -DCMAKE_BUILD_TYPE=Release -DLLVM_HOST_TRIPLE=arm-unknown-linux-gnueabihf -DLLVM_DEFAULT_TARGET_TRIPLE=arm-unknown-linux-gnueabihf -DLLVM_TARGET_ARCH=ARM -DLLVM_TARGETS_TO_BUILD=ARM -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_INCLUDE_TESTS=OFF -DPYTHON_EXECUTABLE="$PYTHON_BIN_PATH" ..
make -j $MAKEJ
make install
cd ../../openssl-$OPENSSL_VERSION
./Configure linux-generic32 -march=armv6 -mfpu=vfp -mfloat-abi=hard -fPIC no-shared --prefix=$INSTALL_PATH --cross-compile-prefix=arm-linux-gnueabihf-
make -s -j $MAKEJ
Expand All @@ -72,18 +71,8 @@ case $PLATFORM in
make install/strip
;;
linux-arm64)
mkdir -p ../tblgen
cd ../tblgen
"$CMAKE" -DLLVM_CCACHE_BUILD=ON -DCMAKE_BUILD_TYPE=Release -DLLVM_HOST_TRIPLE=aarch64-unknown-linux-gnu -DLLVM_DEFAULT_TARGET_TRIPLE=aarch64-unknown-linux-gnu -DLLVM_TARGET_ARCH=AArch64 -DLLVM_TARGETS_TO_BUILD=AArch64 -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_INCLUDE_TESTS=OFF -DPYTHON_EXECUTABLE="$PYTHON_BIN_PATH" ..
make -j $MAKEJ llvm-tblgen clang-tblgen
TBLGEN=`pwd`
mkdir -p ../build
cd ../build
export CC="aarch64-linux-gnu-gcc"
export CXX="aarch64-linux-gnu-g++ -std=c++11"
"$CMAKE" -DLLVM_CCACHE_BUILD=ON -DCMAKE_CROSSCOMPILING=True -DCMAKE_INSTALL_PREFIX="$INSTALL_PATH" -DLLVM_TABLEGEN="$TBLGEN/bin/llvm-tblgen" -DCLANG_TABLEGEN="$TBLGEN/bin/clang-tblgen" -DCMAKE_BUILD_TYPE=Release -DLLVM_HOST_TRIPLE=aarch64-unknown-linux-gnu -DLLVM_DEFAULT_TARGET_TRIPLE=aarch64-unknown-linux-gnu -DLLVM_TARGET_ARCH=AArch64 -DLLVM_TARGETS_TO_BUILD=AArch64 -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_INCLUDE_TESTS=OFF -DPYTHON_EXECUTABLE="$PYTHON_BIN_PATH" ..
make -j $MAKEJ
make install
cd ../../openssl-$OPENSSL_VERSION
./Configure linux-aarch64 -march=armv8-a+crypto -mcpu=cortex-a57+crypto -fPIC no-shared --prefix=$INSTALL_PATH --cross-compile-prefix=aarch64-linux-gnu-
make -s -j $MAKEJ
Expand All @@ -94,18 +83,8 @@ case $PLATFORM in
make install/strip
;;
linux-ppc64le)
mkdir -p ../tblgen
cd ../tblgen
"$CMAKE" -DLLVM_CCACHE_BUILD=ON -DCMAKE_BUILD_TYPE=Release -DLLVM_HOST_TRIPLE=powerpc64le-unknown-linux-gnu -DLLVM_DEFAULT_TARGET_TRIPLE=powerpc64le-unknown-linux-gnu -DLLVM_TARGET_ARCH=PowerPC -DLLVM_TARGETS_TO_BUILD=PowerPC -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_INCLUDE_TESTS=OFF -DPYTHON_EXECUTABLE="$PYTHON_BIN_PATH" ..
make -j $MAKEJ llvm-tblgen clang-tblgen
TBLGEN=`pwd`
mkdir -p ../build
cd ../build
export CC="powerpc64le-linux-gnu-gcc"
export CXX="powerpc64le-linux-gnu-g++ -std=c++11"
"$CMAKE" -DLLVM_CCACHE_BUILD=ON -DCMAKE_CROSSCOMPILING=True -DCMAKE_INSTALL_PREFIX="$INSTALL_PATH" -DLLVM_TABLEGEN="$TBLGEN/bin/llvm-tblgen" -DCLANG_TABLEGEN="$TBLGEN/bin/clang-tblgen" -DCMAKE_BUILD_TYPE=Release -DLLVM_HOST_TRIPLE=powerpc64le-unknown-linux-gnu -DLLVM_DEFAULT_TARGET_TRIPLE=powerpc64le-unknown-linux-gnu -DLLVM_TARGET_ARCH=PowerPC -DLLVM_TARGETS_TO_BUILD=PowerPC -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_INCLUDE_TESTS=OFF -DPYTHON_EXECUTABLE="$PYTHON_BIN_PATH" ..
make -j $MAKEJ
make install
cd ../../openssl-$OPENSSL_VERSION
./Configure linux-ppc64le -fPIC no-shared --prefix=$INSTALL_PATH --cross-compile-prefix=powerpc64le-linux-gnu-
make -s -j $MAKEJ
Expand All @@ -118,9 +97,6 @@ case $PLATFORM in
linux-x86)
export CC="gcc -m32"
export CXX="g++ -std=c++11 -m32"
"$CMAKE" -DLLVM_CCACHE_BUILD=ON -DCMAKE_INSTALL_PREFIX="$INSTALL_PATH" -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=host -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_INCLUDE_TESTS=OFF -DPYTHON_EXECUTABLE="$PYTHON_BIN_PATH" ..
make -j $MAKEJ
make install
cd ../../openssl-$OPENSSL_VERSION
./Configure linux-elf -m32 -fPIC no-shared --prefix=$INSTALL_PATH
make -s -j $MAKEJ
Expand All @@ -133,24 +109,18 @@ case $PLATFORM in
linux-x86_64)
export CC="gcc -m64"
export CXX="g++ -std=c++11 -m64"
"$CMAKE" -DLLVM_CCACHE_BUILD=ON -DCMAKE_INSTALL_PREFIX="$INSTALL_PATH" -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=host -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_INCLUDE_TESTS=OFF -DPYTHON_EXECUTABLE="$PYTHON_BIN_PATH" ..
make -j $MAKEJ
make install
cd ../../openssl-$OPENSSL_VERSION
./Configure linux-x86_64 -fPIC no-shared --prefix=$INSTALL_PATH
make -s -j $MAKEJ
make install_sw
cd ../apache-arrow-$ARROW_VERSION/cpp
"$CMAKE" -DCMAKE_C_FLAGS="-m64" -DCMAKE_CXX_FLAGS="-std=c++11 -m64" -DLLVM_ROOT="$INSTALL_PATH" -DOPENSSL_ROOT_DIR="$INSTALL_PATH" $COMPONENTS -DARROW_RPATH_ORIGIN=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$INSTALL_PATH" -DCMAKE_INSTALL_LIBDIR="lib" -DARROW_BUILD_UTILITIES=OFF -DPython3_EXECUTABLE="$PYTHON_BIN_PATH" .
"$CMAKE" -DCMAKE_C_FLAGS="-m64" -DCMAKE_CXX_FLAGS="-std=c++11 -m64" -DLLVM_DIR="$LLVM_PATH" -DLLVM_TOOLS_BINARY_DIR="$LLVM_PATH" -DOPENSSL_ROOT_DIR="$INSTALL_PATH" $COMPONENTS -DARROW_RPATH_ORIGIN=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$INSTALL_PATH" -DCMAKE_INSTALL_LIBDIR="lib" -DARROW_BUILD_UTILITIES=OFF -DPython3_EXECUTABLE="$PYTHON_BIN_PATH" .
make -j $MAKEJ
make install/strip
;;
macosx-*)
export CC="clang"
export CXX="clang++"
"$CMAKE" -DLLVM_CCACHE_BUILD=ON -DCMAKE_INSTALL_PREFIX="$INSTALL_PATH" -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=host -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_INCLUDE_TESTS=OFF -DPYTHON_EXECUTABLE="$PYTHON_BIN_PATH" ..
make -j $MAKEJ
make install
cd ../../openssl-$OPENSSL_VERSION
./Configure darwin64-x86_64-cc -fPIC no-shared --prefix=$INSTALL_PATH
make -s -j $MAKEJ
Expand All @@ -164,9 +134,6 @@ case $PLATFORM in
windows-x86)
export CC="cl.exe"
export CXX="cl.exe"
"$CMAKE" -G "Ninja" -DCMAKE_EXE_LINKER_FLAGS="/FORCE:MULTIPLE" -DCMAKE_SHARED_LINKER_FLAGS="/FORCE:MULTIPLE" -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON -DLLVM_USE_CRT_RELEASE=MD -DCMAKE_INSTALL_PREFIX="$INSTALL_PATH" -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=host -DLLVM_ENABLE_DIA_SDK=OFF -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_INCLUDE_TESTS=OFF -DPYTHON_EXECUTABLE="$PYTHON_BIN_PATH" ..
ninja -j $MAKEJ
ninja install
cd ../..
unzip -o ../cpython-bin-deps-openssl-bin.zip
cd cpython-bin-deps-openssl-bin/
Expand All @@ -192,9 +159,6 @@ case $PLATFORM in
windows-x86_64)
export CC="cl.exe"
export CXX="cl.exe"
"$CMAKE" -G "Ninja" -DCMAKE_EXE_LINKER_FLAGS="/FORCE:MULTIPLE" -DCMAKE_SHARED_LINKER_FLAGS="/FORCE:MULTIPLE" -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON -DLLVM_USE_CRT_RELEASE=MD -DCMAKE_INSTALL_PREFIX="$INSTALL_PATH" -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=host -DLLVM_ENABLE_DIA_SDK=OFF -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_INCLUDE_TESTS=OFF -DPYTHON_EXECUTABLE="$PYTHON_BIN_PATH" ..
ninja -j $MAKEJ
ninja install
cd ../..
unzip -o ../cpython-bin-deps-openssl-bin.zip
cd cpython-bin-deps-openssl-bin/
Expand Down
53 changes: 53 additions & 0 deletions arrow/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,18 @@
<version>3.0.0-${project.parent.version}</version>
<name>JavaCPP Presets for Arrow</name>

<properties>
<javacpp.nativeRequires>
requires org.bytedeco.llvm.${javacpp.platform.module};
</javacpp.nativeRequires>
</properties>

<dependencies>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>llvm</artifactId>
<version>12.0.0-${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacpp</artifactId>
Expand All @@ -32,6 +43,48 @@
<plugin>
<groupId>org.bytedeco</groupId>
<artifactId>javacpp</artifactId>
<dependencies>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>llvm-platform</artifactId>
<version>12.0.0-${project.parent.version}</version>
</dependency>
</dependencies>
<configuration>
<classPaths>
<classPath>${basedir}/../llvm/target/classes/</classPath>
<classPath>${project.build.outputDirectory}</classPath>
</classPaths>
<includePaths>
<includePath>${basedir}/../llvm/src/main/resources/org/bytedeco/llvm/include/</includePath>
<includePath>${basedir}/../llvm/target/classes/org/bytedeco/llvm/include/</includePath>
<includePath>${basedir}/../llvm/cppbuild/${javacpp.platform}/include/</includePath>
<includePath>${basedir}/cppbuild/${javacpp.platform}${javacpp.platform.extension}/include/</includePath>
</includePaths>
<linkPaths>
<linkPath>${basedir}/../llvm/cppbuild/${javacpp.platform}/lib/</linkPath>
<linkPath>${basedir}/cppbuild/${javacpp.platform}${javacpp.platform.extension}/lib/</linkPath>
</linkPaths>
<preloadPaths>
<preloadPath>${basedir}/../llvm/cppbuild/${javacpp.platform}/bin/</preloadPath>
<preloadPath>${basedir}/cppbuild/${javacpp.platform}${javacpp.platform.extension}/bin/</preloadPath>
</preloadPaths>
<buildResources>
<buildResource>/${javacpp.platform.library.path}/</buildResource>
<buildResource>/org/bytedeco/llvm/${javacpp.platform}/</buildResource>
</buildResources>
<includeResources>
<includeResource>/${javacpp.platform.library.path}/include/</includeResource>
<includeResource>/org/bytedeco/llvm/include/</includeResource>
<includeResource>/org/bytedeco/llvm/${javacpp.platform}/include/</includeResource>
</includeResources>
<linkResources>
<linkResource>/${javacpp.platform.library.path}/</linkResource>
<linkResource>/${javacpp.platform.library.path}/lib/</linkResource>
<linkResource>/org/bytedeco/llvm/${javacpp.platform}/</linkResource>
<linkResource>/org/bytedeco/llvm/${javacpp.platform}/lib/</linkResource>
</linkResources>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion llvm/cppbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ case $PLATFORM in
linux-x86_64)
export CC="gcc -m64"
export CXX="g++ -m64"
$CMAKE -S ../llvm -B $LLVM_BUILD -DLLVM_CCACHE_BUILD=ON -DCMAKE_EXE_LINKER_FLAGS='-Wl,-rpath,$ORIGIN/' -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_LINK_LLVM_DYLIB=ON -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=all -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_INCLUDE_TESTS=OFF -DLLVM_ENABLE_PROJECTS="$PROJECTS"
$CMAKE -S ../llvm -B $LLVM_BUILD -DLLVM_CCACHE_BUILD=ON -DCMAKE_EXE_LINKER_FLAGS='-Wl,-rpath,$ORIGIN/' -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_LINK_LLVM_DYLIB=ON -DLLVM_BUILD_STATIC=OFF -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=all -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_INCLUDE_TESTS=OFF -DLLVM_ENABLE_PROJECTS="$PROJECTS"
make -C $LLVM_BUILD -j $MAKEJ
make -C $LLVM_BUILD install > /dev/null
cp $INSTALL_PATH/lib/LLVMPolly.so $INSTALL_PATH/lib/libLLVMPolly.so
Expand Down