From f9df83f559cb36bd2a693f73b28a5205e9999498 Mon Sep 17 00:00:00 2001 From: LI Qing Date: Tue, 14 Apr 2020 09:30:39 +0000 Subject: [PATCH] Fix the demo's compiling failure in some cases Some demos based on CMake may search installed packages out of Occlum toolchain's directory, this could cause some building errors sometimes. By setting the $PKG_CONFIG_LIBDIR, we can make CMake searching for packages in Occlum toolchain's directory only. --- demos/grpc/download_and_install_grpc.sh | 4 +++- demos/openvino/download_and_build_openvino.sh | 5 ++++- demos/openvino/install_cmake.sh | 2 +- demos/xgboost/README.md | 2 +- .../{build_xgboost.sh => download_and_build_xgboost.sh} | 5 ++++- 5 files changed, 13 insertions(+), 5 deletions(-) rename demos/xgboost/{build_xgboost.sh => download_and_build_xgboost.sh} (86%) diff --git a/demos/grpc/download_and_install_grpc.sh b/demos/grpc/download_and_install_grpc.sh index 5f1c2e83..8f2a1dbc 100755 --- a/demos/grpc/download_and_install_grpc.sh +++ b/demos/grpc/download_and_install_grpc.sh @@ -1,7 +1,9 @@ #!/bin/sh -INSTALL_DIR=/usr/local/occlum/x86_64-linux-musl/ +INSTALL_DIR=/usr/local/occlum/x86_64-linux-musl GRPC_SRC_DIR=$PWD/grpc export PATH=$PATH:$INSTALL_DIR/bin +# Tell CMake to search for packages in Occlum toolchain's directory only +export PKG_CONFIG_LIBDIR=$INSTALL_DIR/lib git clone https://github.com/grpc/grpc.git cd grpc diff --git a/demos/openvino/download_and_build_openvino.sh b/demos/openvino/download_and_build_openvino.sh index 9843aed3..411809ef 100755 --- a/demos/openvino/download_and_build_openvino.sh +++ b/demos/openvino/download_and_build_openvino.sh @@ -36,7 +36,7 @@ build_opencv() { -DBUILD_opencv_python=OFF -DBUILD_PYTHON_SUPPORT=OFF \ -DBUILD_EXAMPLES=OFF -DWITH_FFMPEG=OFF \ -DWITH_QT=OFF -DWITH_CUDA=OFF - make -j + make -j4 sudo make install popd } @@ -105,6 +105,9 @@ while [ -n "$1" ]; do esac done +# Tell CMake to search for packages in Occlum toolchain's directory only +export PKG_CONFIG_LIBDIR=$PREFIX/lib + if [ "$THREADING" == "TBB" ] ; then echo "Build OpenVINO with TBB threading" build_opencv diff --git a/demos/openvino/install_cmake.sh b/demos/openvino/install_cmake.sh index 1f7bd112..cc99829c 100755 --- a/demos/openvino/install_cmake.sh +++ b/demos/openvino/install_cmake.sh @@ -4,5 +4,5 @@ cd ~ wget https://github.com/Kitware/CMake/releases/download/v3.15.5/cmake-3.15.5.tar.gz && tar xf cmake-3.15.5.tar.gz cd cmake-3.15.5 ./bootstrap -make -j +make -j4 sudo make install diff --git a/demos/xgboost/README.md b/demos/xgboost/README.md index 0823f1aa..8447a89d 100644 --- a/demos/xgboost/README.md +++ b/demos/xgboost/README.md @@ -2,7 +2,7 @@ Step 1: Download XGBoost and its dependencies, and then build XGBoost ``` -./build_xgboost.sh +./download_and_build_xgboost.sh ``` When completed, the resulting XGBoost can be found in `xgboost_src` directory. diff --git a/demos/xgboost/build_xgboost.sh b/demos/xgboost/download_and_build_xgboost.sh similarity index 86% rename from demos/xgboost/build_xgboost.sh rename to demos/xgboost/download_and_build_xgboost.sh index 5e246987..9abd11a5 100755 --- a/demos/xgboost/build_xgboost.sh +++ b/demos/xgboost/download_and_build_xgboost.sh @@ -1,6 +1,9 @@ #!/bin/bash set -e +# Tell CMake to search for packages in Occlum toolchain's directory only +export PKG_CONFIG_LIBDIR=/usr/local/occlum/x86_64-linux-musl/lib + # Install the dependencies apt-get update apt-get install -y python3.5 @@ -30,7 +33,7 @@ cd build cmake ../ \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_C_COMPILER=occlum-gcc -DCMAKE_CXX_COMPILER=occlum-g++ -make -j +make -j4 popd # Prepare data