From a78cbf30f4dc4a73261e9912f556fba38bbf6511 Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Fri, 19 Feb 2021 22:10:47 +0100 Subject: [PATCH] First attempts for llvm 12.0.0rc1 --- .gitignore | 2 + ...ake-Support-building-MLIR-standalone.patch | 134 ++++++++++++++++++ ...-building-unittests-in-in-tree-build.patch | 28 ++++ mlir-cmake-standalone.patch | 56 -------- mlir.spec | 19 +-- sources | 4 +- 6 files changed, 177 insertions(+), 66 deletions(-) create mode 100644 0001-MLIR-CMake-Support-building-MLIR-standalone.patch create mode 100644 0001-MLIR-Fix-building-unittests-in-in-tree-build.patch delete mode 100644 mlir-cmake-standalone.patch diff --git a/.gitignore b/.gitignore index 86573ce..5d7845e 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,5 @@ /llvm-project-11.1.0rc1.src.tar.xz.sig /llvm-project-11.1.0rc2.src.tar.xz /llvm-project-11.1.0rc2.src.tar.xz.sig +/llvm-project-12.0.0rc1.src.tar.xz +/llvm-project-12.0.0rc1.src.tar.xz.sig diff --git a/0001-MLIR-CMake-Support-building-MLIR-standalone.patch b/0001-MLIR-CMake-Support-building-MLIR-standalone.patch new file mode 100644 index 0000000..dc5c4e3 --- /dev/null +++ b/0001-MLIR-CMake-Support-building-MLIR-standalone.patch @@ -0,0 +1,134 @@ +From 2aa1af9b1da0d832270d9b8afcba19a4aba2c366 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= +Date: Tue, 2 Feb 2021 13:09:45 -0600 +Subject: [PATCH] [MLIR] [CMake] Support building MLIR standalone + +Add the necessary bits to CMakeLists to make it possible to configure +MLIR against installed LLVM, and build it with minimal need for LLVM +source tree. The latter is only necessary to run unittests, and if it +is missing then unittests are skipped with a warning. + +This change includes the necessary changes to tests, in particular +adding some missing substitutions and defining missing variables +for lit.site.cfg.py substitution. + +Reviewed By: stephenneuendorffer + +Differential Revision: https://reviews.llvm.org/D85464 + +Co-authored-by: Isuru Fernando +--- + mlir/CMakeLists.txt | 33 ++++++++++++++++++++++++++++++++- + mlir/cmake/modules/AddMLIR.cmake | 1 + + mlir/test/CMakeLists.txt | 5 ++++- + mlir/test/lit.cfg.py | 4 ++++ + 4 files changed, 41 insertions(+), 2 deletions(-) + +diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt +index cbae5fd..baacbdd3 100644 +--- a/mlir/CMakeLists.txt ++++ b/mlir/CMakeLists.txt +@@ -1,10 +1,37 @@ + # MLIR project. ++ ++# Check if MLIR is built as a standalone project. ++if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) ++ project(mlir) ++ cmake_minimum_required(VERSION 3.13.4) ++ ++ find_package(LLVM CONFIG REQUIRED) ++ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${LLVM_CMAKE_DIR}) ++ include(HandleLLVMOptions) ++ include(AddLLVM) ++ include(TableGen) ++ ++ include_directories(${LLVM_INCLUDE_DIRS}) ++ ++ set(LLVM_MAIN_SRC_DIR ${CMAKE_SOURCE_DIR}/../llvm CACHE PATH ++ "Path to LLVM source tree") ++ set(UNITTEST_DIR ${LLVM_MAIN_SRC_DIR}/utils/unittest) ++ if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h) ++ add_subdirectory(${UNITTEST_DIR} utils/unittest) ++ endif() ++ ++ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ++ "${CMAKE_CURRENT_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}") ++ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") ++endif() ++ + set(MLIR_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR} ) + set(MLIR_MAIN_INCLUDE_DIR ${MLIR_MAIN_SRC_DIR}/include ) + + set(MLIR_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + set(MLIR_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) + set(MLIR_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include) ++set(MLIR_TOOLS_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") + +@@ -106,7 +133,11 @@ add_subdirectory(lib) + add_subdirectory(lib/CAPI) + if (MLIR_INCLUDE_TESTS) + add_definitions(-DMLIR_INCLUDE_TESTS) +- add_subdirectory(unittests) ++ if (TARGET gtest) ++ add_subdirectory(unittests) ++ else() ++ message(WARNING "gtest not found, unittests will not be available") ++ endif() + add_subdirectory(test) + endif() + if (MLIR_INCLUDE_INTEGRATION_TESTS) +diff --git a/mlir/cmake/modules/AddMLIR.cmake b/mlir/cmake/modules/AddMLIR.cmake +index 4cfd351..4a814ea 100644 +--- a/mlir/cmake/modules/AddMLIR.cmake ++++ b/mlir/cmake/modules/AddMLIR.cmake +@@ -2,6 +2,7 @@ function(mlir_tablegen ofn) + tablegen(MLIR ${ARGV}) + set(TABLEGEN_OUTPUT ${TABLEGEN_OUTPUT} ${CMAKE_CURRENT_BINARY_DIR}/${ofn} + PARENT_SCOPE) ++ include_directories(${CMAKE_CURRENT_BINARY_DIR}) + endfunction() + + # Declare a dialect in the include directory +diff --git a/mlir/test/CMakeLists.txt b/mlir/test/CMakeLists.txt +index 9ab9c09..999201e 100644 +--- a/mlir/test/CMakeLists.txt ++++ b/mlir/test/CMakeLists.txt +@@ -42,7 +42,6 @@ configure_lit_site_cfg( + + set(MLIR_TEST_DEPENDS + FileCheck count not +- MLIRUnitTests + mlir-capi-ir-test + mlir-capi-pass-test + mlir-cpu-runner +@@ -58,6 +57,10 @@ set(MLIR_TEST_DEPENDS + mlir_async_runtime + ) + ++if(TARGET gtest) ++ list(APPEND MLIR_TEST_DEPENDS MLIRUnitTests) ++endif() ++ + if(LLVM_BUILD_EXAMPLES) + list(APPEND MLIR_TEST_DEPENDS + toyc-ch1 +diff --git a/mlir/test/lit.cfg.py b/mlir/test/lit.cfg.py +index 482513b..bff47851 100644 +--- a/mlir/test/lit.cfg.py ++++ b/mlir/test/lit.cfg.py +@@ -61,6 +61,10 @@ tools = [ + 'mlir-capi-ir-test', + 'mlir-capi-pass-test', + 'mlir-edsc-builder-api-test', ++ 'mlir-cpu-runner', ++ 'mlir-linalg-ods-gen', ++ 'mlir-reduce', ++ 'mlir-sdbm-api-test', + ] + + # The following tools are optional +-- +1.8.3.1 + diff --git a/0001-MLIR-Fix-building-unittests-in-in-tree-build.patch b/0001-MLIR-Fix-building-unittests-in-in-tree-build.patch new file mode 100644 index 0000000..f9e1e4c --- /dev/null +++ b/0001-MLIR-Fix-building-unittests-in-in-tree-build.patch @@ -0,0 +1,28 @@ +From c95c0db2eb687edb91afa628655bb5025f7e863b Mon Sep 17 00:00:00 2001 +From: Isuru Fernando +Date: Thu, 4 Feb 2021 01:59:08 +0000 +Subject: [PATCH] [MLIR] Fix building unittests in in-tree build + +Reviewed By: mehdi_amini + +Differential Revision: https://reviews.llvm.org/D95978 +--- + mlir/CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt +index baacbdd3..5d21312 100644 +--- a/mlir/CMakeLists.txt ++++ b/mlir/CMakeLists.txt +@@ -133,7 +133,7 @@ add_subdirectory(lib) + add_subdirectory(lib/CAPI) + if (MLIR_INCLUDE_TESTS) + add_definitions(-DMLIR_INCLUDE_TESTS) +- if (TARGET gtest) ++ if (EXISTS ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include/gtest/gtest.h) + add_subdirectory(unittests) + else() + message(WARNING "gtest not found, unittests will not be available") +-- +1.8.3.1 + diff --git a/mlir-cmake-standalone.patch b/mlir-cmake-standalone.patch deleted file mode 100644 index bb2f265..0000000 --- a/mlir-cmake-standalone.patch +++ /dev/null @@ -1,56 +0,0 @@ -diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt -index 806eb42db..5fa0c16dc 100644 ---- a/mlir/CMakeLists.txt -+++ b/mlir/CMakeLists.txt -@@ -1,4 +1,50 @@ --# MLIR project. -+# Check if this is a in tree build. -+if (NOT DEFINED LLVM_MAIN_SRC_DIR) -+ project(Mlir) -+ cmake_minimum_required(VERSION 3.13.4) -+ -+ # Where is LLVM installed? -+ find_package(LLVM CONFIG REQUIRED) -+ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${LLVM_CMAKE_DIR}) -+ include(HandleLLVMOptions) -+ include(AddLLVM) -+ include(TableGen) -+ -+ # Add the llvm header path. -+ include_directories(${LLVM_INCLUDE_DIRS}) -+ # Local builddir generated header inclusion -+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I.") -+ -+ # Sources available, too? -+ if (LLVM_BUILD_MAIN_SRC_DIR) -+ set(LLVM_SOURCE_ROOT ${LLVM_BUILD_MAIN_SRC_DIR} CACHE PATH -+ "Path to LLVM source tree") -+ else() -+ execute_process(COMMAND "${LLVM_TOOLS_BINARY_DIR}/llvm-config" --src-root -+ OUTPUT_VARIABLE MAIN_SRC_DIR -+ OUTPUT_STRIP_TRAILING_WHITESPACE) -+ set(LLVM_SOURCE_ROOT ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree") -+ endif() -+ -+ # Make sure the isl c files are built as fPIC -+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") -+ -+ # Set directory for mlir test. -+ set(MLIR_TOOLS_DIR "${CMAKE_CURRENT_BINARY_DIR}/bin") -+ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") -+ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") -+ -+ if (LLVM_ENABLE_DOXYGEN) -+ message(STATUS "Doxygen enabled.") -+ find_package(Doxygen REQUIRED) -+ else() -+ message(STATUS "Doxygen disabled.") -+ endif() -+ -+else () -+ set(LLVM_SOURCE_ROOT "${LLVM_MAIN_SRC_DIR}") -+endif () -+ - set(MLIR_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR} ) - set(MLIR_MAIN_INCLUDE_DIR ${MLIR_MAIN_SRC_DIR}/include ) - diff --git a/mlir.spec b/mlir.spec index 11dffb7..6bd6dfa 100644 --- a/mlir.spec +++ b/mlir.spec @@ -1,7 +1,7 @@ -%global rc_ver 2 -%global baserelease 3 -%global maj_ver 11 -%global min_ver 1 +%global rc_ver 1 +%global baserelease 1 +%global maj_ver 12 +%global min_ver 0 %global patch_ver 0 %global mlir_srcdir llvm-project-%{version}%{?rc_ver:rc%{rc_ver}}.src @@ -16,8 +16,8 @@ Source0: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{versio Source1: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}%{?rc_ver:-rc%{rc_ver}}/%{mlir_srcdir}.tar.xz.sig Source2: tstellar-gpg-key.asc -# Support standalone build (MLIR is usually built as part of LLVM) -Patch0: mlir-cmake-standalone.patch +Patch0: 0001-MLIR-CMake-Support-building-MLIR-standalone.patch +Patch1: 0001-MLIR-Fix-building-unittests-in-in-tree-build.patch # Unexpected linking error: neither -j1, disabling lto, LD_LIBRARY_PATH, rpath work ExcludeArch: armv7hl @@ -65,7 +65,7 @@ find ../* -maxdepth 0 ! -name '%{name}' -exec rm -rf {} + -DCMAKE_SKIP_RPATH=ON \ -DLLVM_LINK_LLVM_DYLIB:BOOL=ON \ -DCMAKE_PREFIX_PATH=%{_libdir}/cmake/llvm/ \ - -DLLVM_BUILD_UTILS:BOOL=ON \ + -DLLVM_BUILD_UTILS:BOOL=ON \ -DMLIR_INCLUDE_DOCS:BOOL=ON \ -DMLIR_INCLUDE_TESTS:BOOL=OFF \ -DMLIR_INCLUDE_INTEGRATION_TESTS:BOOL=OFF \ @@ -75,7 +75,7 @@ find ../* -maxdepth 0 ! -name '%{name}' -exec rm -rf {} + -DLLVM_LIBDIR_SUFFIX= %endif # build process .exe tools normally use rpath or static linkage -export LD_LIBRARY_PATH=%{_builddir}/%{mlir_srcdir}/%{name}/%{_build}/bin +export LD_LIBRARY_PATH=%{_builddir}/%{mlir_srcdir}/%{name}/%{_build}/%{_lib} %cmake_build @@ -107,6 +107,9 @@ export LD_LIBRARY_PATH=%{_builddir}/%{mlir_srcdir}/%{name}/%{_build}/bin %{_libdir}/cmake/mlir %changelog +* Thu Feb 18 2021 sguelton@redhat.com - 12.0.0-0.1.rc1 +- llvm 12.0.0-rc1 release + * Tue Jan 26 2021 Fedora Release Engineering - 11.1.0-0.3.rc2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild diff --git a/sources b/sources index a2af1d3..1851938 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ -SHA512 (llvm-project-11.1.0rc2.src.tar.xz) = c40a416152e64b3589a24d072c7081f7de6515edf0f6c8d51cfe29ebd16b35ea7450244cb37e525a12671bef85bdc0caf001abdff0573f1babc06886f76d2a41 -SHA512 (llvm-project-11.1.0rc2.src.tar.xz.sig) = da28a8ec00edd100a017266c2ae398dcc0c1ce49d3ad631262a3b4445f968bb65d0fb0d86afac4c38c6651039939f1b4c3e41c6ac620adf26c02f0a8b88fef21 +SHA512 (llvm-project-12.0.0rc1.src.tar.xz) = 319e75a2e454665b85fd07c3f45f5e8c947e24278feec6d19aeaf3b5b4187550f12a26c3ceff5b697d6b38f1ba245dbe57e6fe222ca6b0b63d54aca352b8490c +SHA512 (llvm-project-12.0.0rc1.src.tar.xz.sig) = e7fdd5fc1fe140c5cc2aa1d0e9143a9ca6f869a1988ae73d1a7e20e3c97c6571a5939d271451341dcdd92db7a500ca9448685110faef90cfae39703bd8b63896