@@ -8,9 +8,10 @@ repo=intel/graph-compiler
88print_usage () {
99 echo " Usage:"
1010 echo " $0 "
11- echo " [ -d | --dev ] Dev build, build LLVM in current env and place all to 'external' dir"
12- echo " [ -l | --dyn ] Dynamical linking, requires rebuild of LLVM, activates 'dev' option"
13- echo " [ -h | --help ] Print this message"
11+ echo " [ -d | --dev ] Dev build, build LLVM in current env and place all to 'external' dir"
12+ echo " [ -l | --dyn ] Dynamical linking, requires rebuild of LLVM, activates 'dev' option"
13+ echo " [ -c | --clean ] Delete the build artifacts from the previous build"
14+ echo " [ -h | --help ] Print this message"
1415}
1516
1617DEV_BUILD=false
@@ -24,6 +25,9 @@ for arg in "$@"; do
2425 DEV_BUILD=true
2526 DYN_LINK=true
2627 ;;
28+ -c | --clean)
29+ CLEANUP=true
30+ ;;
2731 -h | --help)
2832 print_usage
2933 exit 0
@@ -60,18 +64,22 @@ load_llvm() {
6064build_llvm () {
6165 if ! [ -d " llvm-project" ]; then
6266 git clone https://github.com/llvm/llvm-project.git
67+ cd llvm-project
68+ else
69+ cd llvm-project
70+ git fetch --all
6371 fi
6472
65- cd llvm-project
6673 git checkout ${LLVM_HASH}
6774
6875 dylib=OFF
6976 if [ " $DYN_LINK " = ' true' ]; then
7077 dylib=ON
7178 fi
7279
80+ [ -z " $CLEANUP " ] || rm -rf build
7381 cmake -G Ninja llvm -B build \
74- -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=true \
82+ -DCMAKE_BUILD_TYPE=Debug -DLLVM_ENABLE_ASSERTIONS=true \
7583 -DLLVM_ENABLE_PROJECTS=" mlir" -DLLVM_TARGETS_TO_BUILD=" X86" \
7684 -DLLVM_INSTALL_UTILS=true -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
7785 -DLLVM_INSTALL_GTEST=ON -DLLVM_BUILD_LLVM_DYLIB=$dylib -DLLVM_LINK_LLVM_DYLIB=$dylib
@@ -113,15 +121,19 @@ if ! LIT_PATH=$(which lit) ; then
113121 fi
114122fi
115123if [ " $DEV_BUILD " = ' true' ]; then
124+ BUILD_TYPE=Debug
116125 FETCH_DIR=$PROJECT_DIR /externals
117126 LIT_PATH=$PROJECT_DIR /externals/llvm-project/build/bin/llvm-lit
127+ else
128+ BUILD_TYPE=RelWithDebInfo
118129fi
119130if [ " $DYN_LINK " = ' true' ]; then
120131 DYLIB=ON
121132fi
122133
134+ [ -z " $CLEANUP " ] || rm -rf build
123135cmake -S . -G Ninja -B build \
124- -DCMAKE_BUILD_TYPE=RelWithDebInfo \
136+ -DCMAKE_BUILD_TYPE=$BUILD_TYPE \
125137 -DMLIR_DIR=$MLIR_DIR \
126138 -DLLVM_EXTERNAL_LIT=$LIT_PATH \
127139 -DFETCHCONTENT_BASE_DIR=$FETCH_DIR \
0 commit comments