Skip to content

Commit 1079d5e

Browse files
Usse CMAKE_BUILD_TYPE=Debug for dev builds. (#135)
* Usse CMAKE_BUILD_TYPE=Debug for dev builds. * Use <<EOF ... EOF syntax in print_usage() * Also, added the -clean option.
1 parent d5c33a0 commit 1079d5e

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ project(GraphCompiler VERSION "0.1.0" LANGUAGES C CXX)
2020

2121
set(CMAKE_CXX_STANDARD 17)
2222
set(CMAKE_CXX_STANDARD_REQUIRED ON)
23+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")
2324

2425
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
2526

scripts/compile.sh

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ repo=intel/graph-compiler
66
# set -x
77

88
print_usage() {
9-
echo "Usage:"
10-
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"
9+
cat <<EOF
10+
Usage:
11+
$(basename "$0")
12+
[ -d | --dev ] Dev build, build LLVM in current env and place all to 'external' dir
13+
[ -l | --dyn ] Dynamical linking, requires rebuild of LLVM, activates 'dev' option
14+
[ -c | --clean ] Delete the build artifacts from the previous build
15+
[ -h | --help ] Print this message
16+
EOF
1417
}
1518

1619
DEV_BUILD=false
@@ -24,6 +27,9 @@ for arg in "$@"; do
2427
DEV_BUILD=true
2528
DYN_LINK=true
2629
;;
30+
-c | --clean)
31+
CLEANUP=true
32+
;;
2733
-h | --help)
2834
print_usage
2935
exit 0
@@ -60,22 +66,27 @@ load_llvm() {
6066
build_llvm() {
6167
if ! [ -d "llvm-project" ]; then
6268
git clone https://github.com/llvm/llvm-project.git
69+
cd llvm-project
70+
else
71+
cd llvm-project
72+
git fetch --all
6373
fi
6474

65-
cd llvm-project
6675
git checkout ${LLVM_HASH}
6776

6877
dylib=OFF
6978
if [ "$DYN_LINK" = 'true' ]; then
7079
dylib=ON
7180
fi
7281

82+
[ -z "$CLEANUP" ] || rm -rf build
7383
cmake -G Ninja llvm -B build \
74-
-DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=true \
75-
-DLLVM_ENABLE_PROJECTS="mlir" -DLLVM_TARGETS_TO_BUILD="X86" \
76-
-DLLVM_INSTALL_UTILS=true -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
77-
-DLLVM_INSTALL_GTEST=ON -DLLVM_BUILD_LLVM_DYLIB=$dylib -DLLVM_LINK_LLVM_DYLIB=$dylib
78-
cmake --build build
84+
-DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS_DEBUG="-g -O0" \
85+
-DLLVM_ENABLE_ASSERTIONS=true -DLLVM_ENABLE_PROJECTS="mlir"\
86+
-DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_INSTALL_UTILS=true \
87+
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DLLVM_INSTALL_GTEST=ON \
88+
-DLLVM_BUILD_LLVM_DYLIB=$dylib -DLLVM_LINK_LLVM_DYLIB=$dylib
89+
cmake --build build
7990

8091
MLIR_DIR="$PWD/build/lib/cmake/mlir"
8192
cd ..
@@ -113,15 +124,19 @@ if ! LIT_PATH=$(which lit) ; then
113124
fi
114125
fi
115126
if [ "$DEV_BUILD" = 'true' ]; then
127+
BUILD_TYPE=Debug
116128
FETCH_DIR=$PROJECT_DIR/externals
117129
LIT_PATH=$PROJECT_DIR/externals/llvm-project/build/bin/llvm-lit
130+
else
131+
BUILD_TYPE=RelWithDebInfo
118132
fi
119133
if [ "$DYN_LINK" = 'true' ]; then
120134
DYLIB=ON
121135
fi
122136

137+
[ -z "$CLEANUP" ] || rm -rf build
123138
cmake -S . -G Ninja -B build \
124-
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
139+
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
125140
-DMLIR_DIR=$MLIR_DIR \
126141
-DLLVM_EXTERNAL_LIT=$LIT_PATH \
127142
-DFETCHCONTENT_BASE_DIR=$FETCH_DIR \

0 commit comments

Comments
 (0)