Skip to content

Commit adeeeca

Browse files
authored
fine tune compile_bundle.sh (#1578)
1 parent 48b4eea commit adeeeca

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed

scripts/compile_bundle.sh

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
22
set -x
3+
set -e
34

45
VER_LLVM="llvmorg-13.0.0"
56
VER_PYTORCH=""
@@ -8,18 +9,10 @@ VER_TORCHAUDIO=""
89
VER_IPEX="v2.0.0+cpu"
910

1011
# Check existance of required Linux commands
11-
which python > /dev/null 2>&1
12-
if [[ $? -ne 0 ]]; then
13-
echo "Error: linux command \"python\" not found."
14-
exit 4
15-
fi
16-
which git > /dev/null 2>&1
17-
if [[ $? -ne 0 ]]; then
18-
echo "Error: linux command \"git\" not found."
19-
exit 5
20-
fi
21-
env | grep CONDA_PREFIX > /dev/null 2>&1
22-
CONDA=$?
12+
for CMD in gcc g++ python git; do
13+
command -v ${CMD} || (echo "Error: Command \"${CMD}\" not found." ; exit 4)
14+
done
15+
echo "You are using GCC: $(gcc --version | grep gcc)"
2316

2417
# Save current directory path
2518
BASEFOLDER=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
@@ -34,11 +27,15 @@ fi
3427

3528
# Checkout required branch/commit and update submodules
3629
cd llvm-project
37-
git checkout ${VER_LLVM}
30+
if [ ! -z ${VER_LLVM} ]; then
31+
git checkout ${VER_LLVM}
32+
fi
3833
git submodule sync
3934
git submodule update --init --recursive
4035
cd ../intel-extension-for-pytorch
41-
git checkout ${VER_IPEX}
36+
if [ ! -z ${VER_IPEX} ]; then
37+
git checkout ${VER_IPEX}
38+
fi
4239
git submodule sync
4340
git submodule update --init --recursive
4441

@@ -50,7 +47,9 @@ ABI=$(python -c "import torch; print(int(torch._C._GLIBCXX_USE_CXX11_ABI))")
5047
# Compile individual component
5148
# LLVM
5249
cd ../llvm-project
53-
git config --global --add safe.directory `pwd`
50+
if [ ${UID} -eq 0 ]; then
51+
git config --global --add safe.directory `pwd`
52+
fi
5453
if [ -d build ]; then
5554
rm -rf build
5655
fi
@@ -60,18 +59,22 @@ cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-D_GLIBC
6059
cmake --build . -j $(nproc)
6160
LLVM_ROOT=`pwd`/../release
6261
if [ -d ${LLVM_ROOT} ]; then
63-
rm -rf ${LLVM_ROOT}
62+
rm -rf ${LLVM_ROOT}
6463
fi
6564
cmake -DCMAKE_INSTALL_PREFIX=${LLVM_ROOT}/../release/ -P cmake_install.cmake
6665
#xargs rm -rf < install_manifest.txt
6766
ln -s ${LLVM_ROOT}/bin/llvm-config ${LLVM_ROOT}/bin/llvm-config-13
6867
export PATH=${LLVM_ROOT}/bin:$PATH
6968
export LD_LIBRARY_PATH=${LLVM_ROOT}/lib:$LD_LIBRARY_PATH
7069
cd ..
71-
git config --global --unset safe.directory
70+
if [ ${UID} -eq 0 ]; then
71+
git config --global --unset safe.directory
72+
fi
7273
# Intel® Extension for PyTorch*
7374
cd ../intel-extension-for-pytorch
74-
git config --global --add safe.directory `pwd`
75+
if [ ${UID} -eq 0 ]; then
76+
git config --global --add safe.directory `pwd`
77+
fi
7578
python -m pip install -r requirements.txt
7679
export USE_LLVM=${LLVM_ROOT}
7780
export LLVM_DIR=${USE_LLVM}/lib/cmake/llvm
@@ -82,7 +85,9 @@ unset DNNL_GRAPH_BUILD_COMPILER_BACKEND
8285
unset LLVM_DIR
8386
unset USE_LLVM
8487
python -m pip install --force-reinstall dist/*.whl
85-
git config --global --unset safe.directory
88+
if [ ${UID} -eq 0 ]; then
89+
git config --global --unset safe.directory
90+
fi
8691

8792
# Sanity Test
8893
cd ..

0 commit comments

Comments
 (0)