Skip to content

Apache DataFusion SQL Query Engine

ARROW-7615: [CI][Gandiva] Ensure gandiva_jni library has only a whitelisted set of shared dependencies

Projjal Chanda60c1bb7beaef
diff --git a/dev/tasks/gandiva-jars/build-java.sh b/dev/tasks/gandiva-jars/build-java.sh
index c21f7599af..bba7adfd8e 100755
--- a/dev/tasks/gandiva-jars/build-java.sh
+++ b/dev/tasks/gandiva-jars/build-java.sh
@@ -23,7 +23,35 @@ CPP_BUILD_DIR=$TRAVIS_BUILD_DIR/dist/
pushd java
if [ $TRAVIS_OS_NAME == "linux" ]; then
- ldd $CPP_BUILD_DIR/libgandiva_jni.so
+ SO_DEP=ldd
+ GANDIVA_LIB="$CPP_BUILD_DIR"libgandiva_jni.so
+ WHITELIST=(linux-vdso libz librt libdl libpthread libstdc++ libm libgcc_s libc ld-linux-x86-64)
+ else
+ SO_DEP="otool -L"
+ GANDIVA_LIB="$CPP_BUILD_DIR"libgandiva_jni.dylib
+ WHITELIST=(libgandiva_jni libz libncurses libSystem libc++)
+ fi
+
+ # print the shared library dependencies
+ eval "$SO_DEP" "$GANDIVA_LIB"
+
+ if [[ $CHECK_SHARED_DEPENDENCIES ]] ; then
+ # exit if any shared library not in whitelisted set is found
+ echo "Checking shared dependencies"
+ while read -r line
+ do
+ found=false
+ for item in "${WHITELIST[@]}"
+ do
+ if [[ "$line" == *"$item"* ]] ; then
+ found=true
+ fi
+ done
+ if [[ "$found" == false ]] ; then
+ echo "Unexpected shared dependency found"
+ exit 1
+ fi
+ done < <(eval "$SO_DEP" "$GANDIVA_LIB" | awk '{print $1}')
fi
# build the entire project
diff --git a/dev/tasks/gandiva-jars/travis.osx.yml b/dev/tasks/gandiva-jars/travis.osx.yml
index 8a43e3a242..191a8e2326 100644
--- a/dev/tasks/gandiva-jars/travis.osx.yml
+++ b/dev/tasks/gandiva-jars/travis.osx.yml
@@ -53,6 +53,9 @@ script:
- dev/tasks/gandiva-jars/build-cpp-osx.sh || travis_terminate 1
- dev/tasks/gandiva-jars/build-java.sh || travis_terminate 1
# deploy using crossbow
+ # pip install pygit2 fails if MACOS_DEPLOYMENT_TARGET is set to an earlier version. Since the
+ # gandiva libraries are already built we can reset MACOS_DEPLOYMENT_TARGET to current osx version
+ - if [[ $MACOSX_DEPLOYMENT_TARGET ]] ; then export MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion | cut -d '.' -f 1,2) ; fi
- brew install libgit2
- pip3 install click github3.py jinja2 jira pygit2 ruamel.yaml setuptools_scm toolz
- >