2020-04-27 07:12:27 +08:00
|
|
|
#!/bin/bash
|
2020-09-17 12:57:46 +08:00
|
|
|
# Usage (for in-tree build/ directory):
|
|
|
|
# ./build_tools/install_mlir.sh
|
|
|
|
# Usage (for aribtrary build/ directory):
|
|
|
|
# BUILD_DIR=/build ./build_tools/install_mlir.sh
|
2020-04-27 07:12:27 +08:00
|
|
|
set -e
|
2020-04-30 08:05:45 +08:00
|
|
|
td="$(realpath $(dirname $0)/..)"
|
2020-09-17 12:57:46 +08:00
|
|
|
build_dir="$(realpath "${BUILD_DIR:-$td/build}")"
|
2020-04-30 08:05:45 +08:00
|
|
|
|
|
|
|
# Find LLVM source (assumes it is adjacent to this directory).
|
2020-08-02 05:54:20 +08:00
|
|
|
LLVM_SRC_DIR="$(realpath "${LLVM_SRC_DIR:-$td/external/llvm-project}")"
|
2020-04-27 07:12:27 +08:00
|
|
|
|
2020-04-30 08:05:45 +08:00
|
|
|
if ! [ -f "$LLVM_SRC_DIR/llvm/CMakeLists.txt" ]; then
|
2020-04-27 07:12:27 +08:00
|
|
|
echo "Expected LLVM_SRC_DIR variable to be set correctly (got '$LLVM_SRC_DIR')"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo "Using LLVM source dir: $LLVM_SRC_DIR"
|
2020-09-17 12:57:46 +08:00
|
|
|
echo "Build directory: $build_dir"
|
2020-04-27 07:12:27 +08:00
|
|
|
# Setup directories.
|
2020-09-17 12:57:46 +08:00
|
|
|
build_mlir="$build_dir/build-mlir"
|
|
|
|
install_mlir="$build_dir/install-mlir"
|
2020-04-27 07:12:27 +08:00
|
|
|
echo "Building MLIR in $build_mlir"
|
|
|
|
echo "Install MLIR to $install_mlir"
|
|
|
|
mkdir -p "$build_mlir"
|
|
|
|
mkdir -p "$install_mlir"
|
|
|
|
|
|
|
|
echo "Beginning build (commands will echo)"
|
|
|
|
set -x
|
|
|
|
|
2020-06-04 14:58:58 +08:00
|
|
|
# TODO: Make it possible to build without an RTTI compiled LLVM. There are
|
|
|
|
# a handful of vague linkage issues that need to be fixed upstream.
|
2020-04-27 07:12:27 +08:00
|
|
|
cmake -GNinja \
|
|
|
|
"-H$LLVM_SRC_DIR/llvm" \
|
|
|
|
"-B$build_mlir" \
|
|
|
|
-DLLVM_INSTALL_UTILS=ON \
|
|
|
|
-DLLVM_ENABLE_PROJECTS=mlir \
|
2020-07-03 02:24:05 +08:00
|
|
|
-DLLVM_TARGETS_TO_BUILD="X86;AArch64;ARM" \
|
2020-04-30 08:05:45 +08:00
|
|
|
-DLLVM_INCLUDE_TOOLS=ON \
|
|
|
|
-DLLVM_BUILD_TOOLS=OFF \
|
|
|
|
-DLLVM_INCLUDE_TESTS=OFF \
|
2020-04-27 07:12:27 +08:00
|
|
|
"-DCMAKE_INSTALL_PREFIX=$install_mlir" \
|
|
|
|
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
|
|
|
-DLLVM_ENABLE_ASSERTIONS=On \
|
2020-10-08 01:14:34 +08:00
|
|
|
-DLLVM_ENABLE_RTTI=On \
|
|
|
|
"-DMLIR_BINDINGS_PYTHON_ENABLED=ON"
|
2020-04-27 07:12:27 +08:00
|
|
|
|
|
|
|
cmake --build "$build_mlir" --target install
|