Unverified Commit 35d8e436 authored by Sang Ik Lee's avatar Sang Ik Lee Committed by GitHub

[MLIR] Enable MLIR ninja build (#4200)

* Temp save.

* Enable MLIR ninja build.

* Fix issues.
parent 033be233
......@@ -270,10 +270,6 @@ if (NGRAPH_CPU_ENABLE)
message(STATUS "NGRAPH_TBB_ENABLE: ${NGRAPH_TBB_ENABLE}")
endif()
if("${CMAKE_GENERATOR}" STREQUAL "Ninja" AND NGRAPH_MLIR_ENABLE)
message(FATAL_ERROR "Ninja generator not supported.")
endif()
if (NGRAPH_CPU_ENABLE AND NGRAPH_MLIR_ENABLE)
#MLIR uses the latest version of LLVM which requires C++14.
set(NGRAPH_CXX_STANDARD 14)
......
......@@ -19,17 +19,20 @@ set(LLVM_INSTALL_ROOT ${EXTERNAL_PROJECTS_ROOT}/llvm)
configure_file(${CMAKE_SOURCE_DIR}/cmake/llvm_fetch.cmake.in ${LLVM_PROJECT_ROOT}/CMakeLists.txt @ONLY)
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" -DCMAKE_CXX_FLAGS:STRING=${CMAKE_ORIGINAL_CXX_FLAGS} .
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}"
-DCMAKE_GENERATOR_PLATFORM:STRING=${CMAKE_GENERATOR_PLATFORM}
-DCMAKE_GENERATOR_TOOLSET:STRING=${CMAKE_GENERATOR_TOOLSET}
-DCMAKE_CXX_FLAGS:STRING=${CMAKE_ORIGINAL_CXX_FLAGS} .
WORKING_DIRECTORY "${LLVM_PROJECT_ROOT}")
# clone and build llvm
include(ProcessorCount)
ProcessorCount(N)
if(("${CMAKE_GENERATOR}" STREQUAL "Unix Makefiles") AND (NOT N EQUAL 0))
execute_process(COMMAND "${CMAKE_COMMAND}" --build . --target ext_llvm -- -j${N}
execute_process(COMMAND "${CMAKE_COMMAND}" --build . -- -j${N}
WORKING_DIRECTORY "${LLVM_PROJECT_ROOT}")
else()
execute_process(COMMAND "${CMAKE_COMMAND}" --build . --target ext_llvm
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${LLVM_PROJECT_ROOT}")
endif()
......
......@@ -45,10 +45,13 @@ set(NGRAPH_LIT_TEST_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/test/mlir)
if (NOT NGRAPH_USE_PREBUILT_MLIR)
configure_file(${CMAKE_SOURCE_DIR}/cmake/mlir_fetch.cmake.in ${MLIR_PROJECT_ROOT}/CMakeLists.txt @ONLY)
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
-DCMAKE_GENERATOR_PLATFORM:STRING=${CMAKE_GENERATOR_PLATFORM}
-DCMAKE_GENERATOR_TOOLSET:STRING=${CMAKE_GENERATOR_TOOLSET}
-DCMAKE_CXX_FLAGS:STRING=${CMAKE_ORIGINAL_CXX_FLAGS} .
WORKING_DIRECTORY "${MLIR_PROJECT_ROOT}")
# Clone and build llvm + mlir.
execute_process(COMMAND "${CMAKE_COMMAND}" --build . --target ext_mlir_llvm
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${MLIR_PROJECT_ROOT}")
endif()
......
......@@ -65,13 +65,15 @@ if(NGRAPH_USE_PREBUILT_LLVM)
PREFIX llvm
URL ${LLVM_TARBALL_URL}
URL_HASH SHA1=${LLVM_SHA1_HASH}
CMAKE_GENERATOR "${CMAKE_GENERATOR}"
CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}"
CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
UPDATE_COMMAND ""
SOURCE_DIR @LLVM_INSTALL_ROOT@
DOWNLOAD_NO_PROGRESS TRUE
EXCLUDE_FROM_ALL TRUE
)
else()
......@@ -108,15 +110,14 @@ else()
PREFIX llvm
GIT_REPOSITORY https://github.com/llvm/llvm-project.git
GIT_TAG llvmorg-8.0.0
CMAKE_GENERATOR "@CMAKE_GENERATOR@"
CMAKE_GENERATOR_PLATFORM @CMAKE_GENERATOR_PLATFORM@
CMAKE_GENERATOR_TOOLSET @CMAKE_GENERATOR_TOOLSET@
CMAKE_GENERATOR "${CMAKE_GENERATOR}"
CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}"
CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}"
UPDATE_COMMAND ""
CONFIGURE_COMMAND ${CMAKE_COMMAND} ../ext_llvm/llvm -G "@CMAKE_GENERATOR@" ${LLVM_CMAKE_ARGS} -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
CONFIGURE_COMMAND ${CMAKE_COMMAND} ../ext_llvm/llvm -G "@CMAKE_GENERATOR@" -DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM} -DCMAKE_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET} ${LLVM_CMAKE_ARGS} -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
PATCH_COMMAND ${LLVM_PATCH_REVERT_COMMAND}
COMMAND git apply --ignore-space-change --ignore-whitespace @CMAKE_CURRENT_SOURCE_DIR@/cmake/llvm.patch
DOWNLOAD_NO_PROGRESS TRUE
EXCLUDE_FROM_ALL TRUE
)
else()
ExternalProject_Add(
......@@ -125,16 +126,15 @@ else()
GIT_REPOSITORY https://github.com/llvm/llvm-project.git
GIT_TAG llvmorg-8.0.0
GIT_SHALLOW 1
CMAKE_GENERATOR "@CMAKE_GENERATOR@"
CMAKE_GENERATOR_PLATFORM @CMAKE_GENERATOR_PLATFORM@
CMAKE_GENERATOR_TOOLSET @CMAKE_GENERATOR_TOOLSET@
CMAKE_GENERATOR "${CMAKE_GENERATOR}"
CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}"
CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}"
CMAKE_ARGS ${LLVM_CMAKE_ARGS} -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
UPDATE_COMMAND ""
PATCH_COMMAND ${LLVM_PATCH_REVERT_COMMAND}
COMMAND git apply --ignore-space-change --ignore-whitespace @CMAKE_CURRENT_SOURCE_DIR@/cmake/llvm.patch
SOURCE_SUBDIR llvm
DOWNLOAD_NO_PROGRESS TRUE
EXCLUDE_FROM_ALL TRUE
)
endif()
endif()
......@@ -20,6 +20,12 @@ include(ExternalProject)
project(mlir-fetch NONE)
set(MLIR_LLVM_CMAKE_ARGS @NGRAPH_FORWARD_CMAKE_ARGS@
-DLLVM_ENABLE_RTTI=ON
-DLLVM_ENABLE_PROJECTS:STRING=mlir
-DLLVM_BUILD_EXAMPLES=ON
-DLLVM_TARGETS_TO_BUILD=host)
include(ProcessorCount)
ProcessorCount(N)
if(N EQUAL 0)
......@@ -31,15 +37,14 @@ ExternalProject_Add(
PREFIX mlir_llvm
GIT_REPOSITORY @MLIR_LLVM_REPO_URL@
GIT_TAG @MLIR_LLVM_COMMIT_ID@
CMAKE_GENERATOR @CMAKE_GENERATOR@
CMAKE_GENERATOR_PLATFORM @CMAKE_GENERATOR_PLATFORM@
CMAKE_GENERATOR_TOOLSET @CMAKE_GENERATOR_TOOLSET@
CONFIGURE_COMMAND @CMAKE_COMMAND@ @MLIR_LLVM_SOURCE_DIR@ -DLLVM_ENABLE_PROJECTS=mlir -DLLVM_BUILD_EXAMPLES=ON -DLLVM_TARGETS_TO_BUILD=host -DLLVM_ENABLE_RTTI=ON -DCMAKE_BUILD_TYPE=@CMAKE_BUILD_TYPE@
CMAKE_GENERATOR "${CMAKE_GENERATOR}"
CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}"
CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}"
CONFIGURE_COMMAND @CMAKE_COMMAND@ @MLIR_LLVM_SOURCE_DIR@ -G "@CMAKE_GENERATOR@" -DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM} -DCMAKE_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET} ${MLIR_LLVM_CMAKE_ARGS} -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
BUILD_COMMAND @CMAKE_COMMAND@ --build . --target check-mlir -- -j${N}
INSTALL_COMMAND ""
SOURCE_DIR @MLIR_LLVM_ROOT@
BINARY_DIR @MLIR_LLVM_BUILD_DIR@
STAMP_DIR "@MLIR_PROJECT_ROOT@/mlir/stamp"
DOWNLOAD_NO_PROGRESS TRUE
EXCLUDE_FROM_ALL TRUE
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment