[flang-commits] [flang] 112499f - [mlir] Fix calling the native mlir-tblgen tool when cross compiling flang

Martin Storsjö via flang-commits flang-commits at lists.llvm.org
Tue Aug 2 01:00:31 PDT 2022


Author: Martin Storsjö
Date: 2022-08-02T10:58:24+03:00
New Revision: 112499f35f4169f798d7f6436cf60e822b9c1da0

URL: https://github.com/llvm/llvm-project/commit/112499f35f4169f798d7f6436cf60e822b9c1da0
DIFF: https://github.com/llvm/llvm-project/commit/112499f35f4169f798d7f6436cf60e822b9c1da0.diff

LOG: [mlir] Fix calling the native mlir-tblgen tool when cross compiling flang

When the mlir-tblgen tool is set up, the `MLIR_TABLEGEN_EXE` variable
is set, which either points to the mlir-tblgen tool built in the current
cmake build, or points to one built in a nested cmake build (if cross
conpiling, or if building with e.g. `LLVM_OPTIMIZED_TABLEGEN`.

The `MLIR_TABLEGEN_EXE` variable is only set within the scope of the
mlir/CMakeLists.txt file, so it's unavailable in sibling level projects
such as flang.

Set the `MLIR_TABLEGEN_EXE` and the `MLIR_TABLEGEN_TARGET` variables
as global, so that flang can use them properly without guessing.

Differential Revision: https://reviews.llvm.org/D130350

Added: 
    

Modified: 
    flang/CMakeLists.txt
    mlir/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index 7e0aec2bf090..0b55bb34da09 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -199,7 +199,6 @@ else()
   set(MLIR_MAIN_SRC_DIR ${LLVM_MAIN_SRC_DIR}/../mlir/include ) # --src-root
   set(MLIR_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/../mlir/include ) # --includedir
   set(MLIR_TABLEGEN_OUTPUT_DIR ${CMAKE_BINARY_DIR}/tools/mlir/include)
-  set(MLIR_TABLEGEN_EXE $<TARGET_FILE:mlir-tblgen>)
   include_directories(SYSTEM ${MLIR_INCLUDE_DIR})
   include_directories(SYSTEM ${MLIR_TABLEGEN_OUTPUT_DIR})
 endif()

diff  --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index 3ea0be3e6b05..808a98546249 100644
--- a/mlir/CMakeLists.txt
+++ b/mlir/CMakeLists.txt
@@ -155,6 +155,9 @@ add_subdirectory(tools/mlir-tblgen)
 add_subdirectory(tools/mlir-linalg-ods-gen)
 add_subdirectory(tools/mlir-pdll)
 
+set(MLIR_TABLEGEN_EXE "${MLIR_TABLEGEN_EXE}" CACHE INTERNAL "")
+set(MLIR_TABLEGEN_TARGET "${MLIR_TABLEGEN_TARGET}" CACHE INTERNAL "")
+
 add_subdirectory(include/mlir)
 add_subdirectory(lib)
 # C API needs all dialects for registration, but should be built before tests.


        


More information about the flang-commits mailing list