Detect llvm-project commit change in utils/clone-mlir.sh and rebuild llvm-project (#132)

for zLinux Jenkins build bot

Co-authored-by: Tian Jin <tjingrant@gmail.com>
This commit is contained in:
gongsu832 2020-05-19 23:39:37 -04:00 committed by GitHub
parent 661fa601ee
commit 5d85843be4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 37 additions and 0 deletions

View File

@ -25,6 +25,43 @@ export CPATH=${INSTALL_PATH}/include:${CPATH}
export PATH=${JAVA_HOME}/bin:${PATH}
export CLASSPATH=.:${JAVA_HOME}/lib:${JAVA_HOME}/lib/tools.jar:${CLASSPATH}
# If LLVM_PROJECT_ROOT does not exist, or llvm-project commit hash changed,
# (re)build llvm-project
if ! [ -d ${LLVM_PROJECT_ROOT} ]; then
git clone https://github.com/llvm/llvm-project.git ${LLVM_PROJECT_ROOT}
fi
PREBUILT_LLVM_PROJECT_SHA1=$(git -C ${LLVM_PROJECT_ROOT} rev-parse HEAD)
EXPECTED_LLVM_PROJECT_SHA1=$(cat utils/clone-mlir.sh|grep -Po '(?<=git checkout )[0-9a-f]+')
echo "${LLVM_PROJECT_ROOT} sha1 prebuilt ${PREBUILT_LLVM_PROJECT_SHA1} expected ${EXPECTED_LLVM_PROJECT_SHA1}"
if [ "$1" = "shared" ]; then
LLVM_BUILD_SHARED_LIBS=ON
else
LLVM_BUILD_SHARED_LIBS=OFF
fi
if ! [ -d ${LLVM_PROJECT_ROOT}/build ] ||
[ "${PREBUILT_LLVM_PROJECT_SHA1}" != "${EXPECTED_LLVM_PROJECT_SHA1}" ]; then
echo "Rebuild llvm-project with sha1 ${EXPECTED_LLVM_PROJECT_SHA1}"
pushd ${LLVM_PROJECT_ROOT}
git fetch && git checkout ${EXPECTED_LLVM_PROJECT_SHA1}
rm -rf build && mkdir -p build && cd build
cmake -G Ninja ../llvm \
-DLLVM_ENABLE_PROJECTS=mlir \
-DLLVM_BUILD_EXAMPLES=ON \
-DLLVM_TARGETS_TO_BUILD="host" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_ENABLE_RTTI=ON \
-DBUILD_SHARED_LIBS=${LLVM_BUILD_SHARED_LIBS}
cmake --build . --target -- ${MAKEFLAGS}
popd
else
echo "Rebuild llvm-project not needed"
fi
# Build ONNX MLIR against specified llvm-project
export BUILD_PATH=build-against-$(basename ${LLVM_PROJECT_ROOT})
mkdir ${BUILD_PATH} && cd ${BUILD_PATH}