-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
[mlir][cmake] Do not export MLIR_MAIN_SRC_DIR and MLIR_INCLUDE_DIR #125842
Conversation
MLIR_MAIN_SRC_DIR points to the source directory, which is not installed. As such, the installed MLIRConfig.cmake also should not reference it. The comment indicates that this is needed for mlir_tablegen(), but I don't see any related uses. The motivation for this is the use in flang, where we end up inheriting a meaningless MLIR_MAIN_SRC_DIR from a previous MLIR build, whose source directory obviously doesn't exist anymore, and that cannot be overridden with the correct path, because it's not a cached variable. Instead do what all the other projects do (for LLVM_MAIN_SRC_DIR) and initialize MLIR_MAIN_SRC_DIR to CMAKE_CURRENT_SOURCE_DIR/../mlir.
@llvm/pr-subscribers-flang-fir-hlfir @llvm/pr-subscribers-mlir Author: Nikita Popov (nikic) ChangesMLIR_MAIN_SRC_DIR points to the source directory, which is not installed. As such, the installed MLIRConfig.cmake also should not reference it. The comment indicates that this is needed for mlir_tablegen(), but I don't see any related uses. The motivation for this is the use in flang, where we end up inheriting a meaningless MLIR_MAIN_SRC_DIR from a previous MLIR build, whose source directory doesn't exist anymore, and that cannot be overridden with the correct path, because it's not a cached variable. Instead do what all the other projects do for LLVM_MAIN_SRC_DIR and initialize MLIR_MAIN_SRC_DIR to CMAKE_CURRENT_SOURCE_DIR/../mlir. Full diff: https://github.com/llvm/llvm-project/pull/125842.diff 2 Files Affected:
diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index 2e27bc2279ac47..90881adf0c92db 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -79,6 +79,8 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 4)
message(FATAL_ERROR "flang isn't supported on 32 bit CPUs")
endif()
+set(MLIR_MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../mlir" CACHE PATH "Path to MLIR source tree")
+
if (FLANG_STANDALONE_BUILD)
set(FLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_INCLUDE_CURRENT_DIR ON)
@@ -240,7 +242,6 @@ else()
set(FLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
endif()
- set(MLIR_MAIN_SRC_DIR ${LLVM_MAIN_SRC_DIR}/../mlir ) # --src-root
set(MLIR_INCLUDE_DIR ${MLIR_MAIN_SRC_DIR}/include ) # --includedir
set(MLIR_TABLEGEN_OUTPUT_DIR ${CMAKE_BINARY_DIR}/tools/mlir/include)
include_directories(SYSTEM ${MLIR_INCLUDE_DIR})
diff --git a/mlir/cmake/modules/MLIRConfig.cmake.in b/mlir/cmake/modules/MLIRConfig.cmake.in
index 7076d94a32f2bc..c09af1e4eeee9f 100644
--- a/mlir/cmake/modules/MLIRConfig.cmake.in
+++ b/mlir/cmake/modules/MLIRConfig.cmake.in
@@ -18,7 +18,6 @@ set(MLIR_ENABLE_EXECUTION_ENGINE "@MLIR_ENABLE_EXECUTION_ENGINE@")
# For mlir_tablegen()
set(MLIR_INCLUDE_DIR "@MLIR_INCLUDE_DIR@")
-set(MLIR_MAIN_SRC_DIR "@MLIR_MAIN_SRC_DIR@")
set_property(GLOBAL PROPERTY MLIR_ALL_LIBS "@MLIR_ALL_LIBS@")
set_property(GLOBAL PROPERTY MLIR_DIALECT_LIBS "@MLIR_DIALECT_LIBS@")
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite understand why the line you removed in mlir/cmake/modules/MLIRConfig.cmake.in
was there, but if it break something we can always revert an document better the setup.
What about the line before you left: set(MLIR_INCLUDE_DIR "@MLIR_INCLUDE_DIR@")
?
Good point. It also points to the include directory in the source tree, so it should be dropped as well. |
I've updated this to drop MLIR_INCLUDE_DIR now. Note that there already is MLIR_INCLUDE_DIRS, which is set up correctly depending on whether it's the installed or the build-tree config. I've dropped the MLIR_INCLUDE_DIR use for FIROps.td because I don't think it's actually necessary. We already add the MLIR_INCLUDE_DIRS to the include directories at a higher level, so we don't need to do so again here. (Otherwise I could switch this to use EXTRA_INCLUDES with MLIR_INCLUDE_DIRS.) |
@joker-eph Would you mind taking another look at this (now that it also removes MLIR_INCLUDE_DIR)? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I had approve before and thought it was enough, but happy to re-approve explicitly of course. Thanks.
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/201/builds/2906 Here is the relevant piece of the build log for the reference
|
…lvm#125842) MLIR_MAIN_SRC_DIR and MLIR_INCLUDE_DIR point to the source directory, which is not installed. As such, the installed MLIRConfig.cmake also should not reference it. The comment indicates that these are needed for mlir_tablegen(), but I don't see any related uses. The motivation for this is the use in flang, where we end up inheriting a meaningless MLIR_MAIN_SRC_DIR from a previous MLIR build, whose source directory doesn't exist anymore, and that cannot be overridden with the correct path, because it's not a cached variable. Instead do what all the other projects do for LLVM_MAIN_SRC_DIR and initialize MLIR_MAIN_SRC_DIR to CMAKE_CURRENT_SOURCE_DIR/../mlir. For MLIR_INCLUDE_DIR there already is an exported MLIR_INCLUDE_DIRS, which can be used instead.
…lvm#125842) MLIR_MAIN_SRC_DIR and MLIR_INCLUDE_DIR point to the source directory, which is not installed. As such, the installed MLIRConfig.cmake also should not reference it. The comment indicates that these are needed for mlir_tablegen(), but I don't see any related uses. The motivation for this is the use in flang, where we end up inheriting a meaningless MLIR_MAIN_SRC_DIR from a previous MLIR build, whose source directory doesn't exist anymore, and that cannot be overridden with the correct path, because it's not a cached variable. Instead do what all the other projects do for LLVM_MAIN_SRC_DIR and initialize MLIR_MAIN_SRC_DIR to CMAKE_CURRENT_SOURCE_DIR/../mlir. For MLIR_INCLUDE_DIR there already is an exported MLIR_INCLUDE_DIRS, which can be used instead.
This change is no longer necessary after llvm#125842. Thanks to @nikic for letting me know.
/cherry-pick 82bd148 |
/pull-request #127589 |
MLIR_MAIN_SRC_DIR and MLIR_INCLUDE_DIR point to the source directory, which is not installed. As such, the installed MLIRConfig.cmake also should not reference it.
The comment indicates that these are needed for mlir_tablegen(), but I don't see any related uses.
The motivation for this is the use in flang, where we end up inheriting a meaningless MLIR_MAIN_SRC_DIR from a previous MLIR build, whose source directory doesn't exist anymore, and that cannot be overridden with the correct path, because it's not a cached variable.
Instead do what all the other projects do for LLVM_MAIN_SRC_DIR and initialize MLIR_MAIN_SRC_DIR to CMAKE_CURRENT_SOURCE_DIR/../mlir.
For MLIR_INCLUDE_DIR there already is an exported MLIR_INCLUDE_DIRS, which can be used instead.