Skip to content

Usse CMAKE_BUILD_TYPE=Debug for dev builds. #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ project(GraphCompiler VERSION "0.1.0" LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

Expand Down
39 changes: 27 additions & 12 deletions scripts/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ repo=intel/graph-compiler
# set -x

print_usage() {
echo "Usage:"
echo "$0 "
echo " [ -d | --dev ] Dev build, build LLVM in current env and place all to 'external' dir"
echo " [ -l | --dyn ] Dynamical linking, requires rebuild of LLVM, activates 'dev' option"
echo " [ -h | --help ] Print this message"
cat <<EOF
Usage:
$(basename "$0")
[ -d | --dev ] Dev build, build LLVM in current env and place all to 'external' dir
[ -l | --dyn ] Dynamical linking, requires rebuild of LLVM, activates 'dev' option
[ -c | --clean ] Delete the build artifacts from the previous build
[ -h | --help ] Print this message
EOF
}

DEV_BUILD=false
Expand All @@ -24,6 +27,9 @@ for arg in "$@"; do
DEV_BUILD=true
DYN_LINK=true
;;
-c | --clean)
CLEANUP=true
;;
-h | --help)
print_usage
exit 0
Expand Down Expand Up @@ -60,22 +66,27 @@ load_llvm() {
build_llvm() {
if ! [ -d "llvm-project" ]; then
git clone https://github.com/llvm/llvm-project.git
cd llvm-project
else
cd llvm-project
git fetch --all
fi

cd llvm-project
git checkout ${LLVM_HASH}

dylib=OFF
if [ "$DYN_LINK" = 'true' ]; then
dylib=ON
fi

[ -z "$CLEANUP" ] || rm -rf build
cmake -G Ninja llvm -B build \
-DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=true \
-DLLVM_ENABLE_PROJECTS="mlir" -DLLVM_TARGETS_TO_BUILD="X86" \
-DLLVM_INSTALL_UTILS=true -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DLLVM_INSTALL_GTEST=ON -DLLVM_BUILD_LLVM_DYLIB=$dylib -DLLVM_LINK_LLVM_DYLIB=$dylib
cmake --build build
-DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS_DEBUG="-g -O0" \
-DLLVM_ENABLE_ASSERTIONS=true -DLLVM_ENABLE_PROJECTS="mlir"\
-DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_INSTALL_UTILS=true \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DLLVM_INSTALL_GTEST=ON \
-DLLVM_BUILD_LLVM_DYLIB=$dylib -DLLVM_LINK_LLVM_DYLIB=$dylib
cmake --build build

MLIR_DIR="$PWD/build/lib/cmake/mlir"
cd ..
Expand Down Expand Up @@ -113,15 +124,19 @@ if ! LIT_PATH=$(which lit) ; then
fi
fi
if [ "$DEV_BUILD" = 'true' ]; then
BUILD_TYPE=Debug
FETCH_DIR=$PROJECT_DIR/externals
LIT_PATH=$PROJECT_DIR/externals/llvm-project/build/bin/llvm-lit
else
BUILD_TYPE=RelWithDebInfo
fi
if [ "$DYN_LINK" = 'true' ]; then
DYLIB=ON
fi

[ -z "$CLEANUP" ] || rm -rf build
cmake -S . -G Ninja -B build \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DMLIR_DIR=$MLIR_DIR \
-DLLVM_EXTERNAL_LIT=$LIT_PATH \
-DFETCHCONTENT_BASE_DIR=$FETCH_DIR \
Expand Down