mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-10-02 13:00:23 +00:00
llvmPackages.mlir: version tablegen patch
The patch failed to apply on 18 and 19. We have to version it. LLVM 18 has no MLIR_SRC_SHARDER_TABLEGEN_EXE. LLVM 19 and 20 fail to apply the 21+ patch due to mechanical hunk failures, but otherwise use an identical patch to 21+.
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
diff --git a/cmake/modules/MLIRConfig.cmake.in b/cmake/modules/MLIRConfig.cmake.in
|
||||
--- a/cmake/modules/MLIRConfig.cmake.in
|
||||
+++ b/cmake/modules/MLIRConfig.cmake.in
|
||||
@@ -9,8 +9,13 @@ find_package(LLVM ${LLVM_VERSION} EXACT REQUIRED CONFIG
|
||||
set(MLIR_EXPORTED_TARGETS "@MLIR_EXPORTS@")
|
||||
set(MLIR_CMAKE_DIR "@MLIR_CONFIG_CMAKE_DIR@")
|
||||
set(MLIR_INCLUDE_DIRS "@MLIR_CONFIG_INCLUDE_DIRS@")
|
||||
-set(MLIR_TABLEGEN_EXE "@MLIR_CONFIG_TABLEGEN_EXE@")
|
||||
-set(MLIR_PDLL_TABLEGEN_EXE "@MLIR_CONFIG_PDLL_TABLEGEN_EXE@")
|
||||
+# Allow users to override tablegen executables (e.g. for sandboxed builds).
|
||||
+if(NOT MLIR_TABLEGEN_EXE)
|
||||
+ set(MLIR_TABLEGEN_EXE "@MLIR_CONFIG_TABLEGEN_EXE@")
|
||||
+endif()
|
||||
+if(NOT MLIR_PDLL_TABLEGEN_EXE)
|
||||
+ set(MLIR_PDLL_TABLEGEN_EXE "@MLIR_CONFIG_PDLL_TABLEGEN_EXE@")
|
||||
+endif()
|
||||
set(MLIR_INSTALL_AGGREGATE_OBJECTS "@MLIR_INSTALL_AGGREGATE_OBJECTS@")
|
||||
set(MLIR_ENABLE_BINDINGS_PYTHON "@MLIR_ENABLE_BINDINGS_PYTHON@")
|
||||
set(MLIR_ENABLE_EXECUTION_ENGINE "@MLIR_ENABLE_EXECUTION_ENGINE@")
|
||||
@@ -34,6 +39,29 @@ if(NOT TARGET MLIRSupport)
|
||||
@MLIR_CONFIG_INCLUDE_EXPORTS@
|
||||
endif()
|
||||
|
||||
+# Ensure MLIR_TABLEGEN_EXE is a full path and has a corresponding imported
|
||||
+# target. In install trees, MLIR_TABLEGEN_EXE may be a bare name
|
||||
+# ("mlir-tblgen") rather than an absolute path. Resolve it so that
|
||||
+# TableGen.cmake can use it as both a COMMAND and a DEPENDS entry.
|
||||
+if(MLIR_TABLEGEN_EXE AND NOT IS_ABSOLUTE "${MLIR_TABLEGEN_EXE}"
|
||||
+ AND NOT TARGET "${MLIR_TABLEGEN_EXE}")
|
||||
+ find_program(_mlir_tblgen_exe "${MLIR_TABLEGEN_EXE}"
|
||||
+ HINTS "${LLVM_TOOLS_BINARY_DIR}")
|
||||
+ if(_mlir_tblgen_exe)
|
||||
+ set(MLIR_TABLEGEN_EXE "${_mlir_tblgen_exe}")
|
||||
+ endif()
|
||||
+ unset(_mlir_tblgen_exe)
|
||||
+endif()
|
||||
+
|
||||
+if(NOT TARGET mlir-tblgen AND MLIR_TABLEGEN_EXE)
|
||||
+ add_executable(mlir-tblgen IMPORTED GLOBAL)
|
||||
+ set_target_properties(mlir-tblgen PROPERTIES
|
||||
+ IMPORTED_LOCATION "${MLIR_TABLEGEN_EXE}")
|
||||
+endif()
|
||||
+if(NOT DEFINED MLIR_TABLEGEN_TARGET)
|
||||
+ set(MLIR_TABLEGEN_TARGET mlir-tblgen)
|
||||
+endif()
|
||||
+
|
||||
# By creating these targets here, subprojects that depend on MLIR's
|
||||
# tablegen-generated headers can always depend on these targets whether building
|
||||
# in-tree with MLIR or not.
|
||||
@@ -0,0 +1,53 @@
|
||||
diff --git a/cmake/modules/MLIRConfig.cmake.in b/cmake/modules/MLIRConfig.cmake.in
|
||||
--- a/cmake/modules/MLIRConfig.cmake.in
|
||||
+++ b/cmake/modules/MLIRConfig.cmake.in
|
||||
@@ -9,9 +9,16 @@ find_package(LLVM ${LLVM_VERSION} EXACT REQUIRED CONFIG
|
||||
set(MLIR_EXPORTED_TARGETS "@MLIR_EXPORTS@")
|
||||
set(MLIR_CMAKE_DIR "@MLIR_CONFIG_CMAKE_DIR@")
|
||||
set(MLIR_INCLUDE_DIRS "@MLIR_CONFIG_INCLUDE_DIRS@")
|
||||
-set(MLIR_TABLEGEN_EXE "@MLIR_CONFIG_TABLEGEN_EXE@")
|
||||
-set(MLIR_PDLL_TABLEGEN_EXE "@MLIR_CONFIG_PDLL_TABLEGEN_EXE@")
|
||||
-set(MLIR_SRC_SHARDER_TABLEGEN_EXE "@MLIR_CONFIG_SRC_SHARDER_TABLEGEN_EXE@")
|
||||
+# Allow users to override tablegen executables (e.g. for sandboxed builds).
|
||||
+if(NOT MLIR_TABLEGEN_EXE)
|
||||
+ set(MLIR_TABLEGEN_EXE "@MLIR_CONFIG_TABLEGEN_EXE@")
|
||||
+endif()
|
||||
+if(NOT MLIR_PDLL_TABLEGEN_EXE)
|
||||
+ set(MLIR_PDLL_TABLEGEN_EXE "@MLIR_CONFIG_PDLL_TABLEGEN_EXE@")
|
||||
+endif()
|
||||
+if(NOT MLIR_SRC_SHARDER_TABLEGEN_EXE)
|
||||
+ set(MLIR_SRC_SHARDER_TABLEGEN_EXE "@MLIR_CONFIG_SRC_SHARDER_TABLEGEN_EXE@")
|
||||
+endif()
|
||||
set(MLIR_INSTALL_AGGREGATE_OBJECTS "@MLIR_INSTALL_AGGREGATE_OBJECTS@")
|
||||
set(MLIR_ENABLE_BINDINGS_PYTHON "@MLIR_ENABLE_BINDINGS_PYTHON@")
|
||||
set(MLIR_ENABLE_EXECUTION_ENGINE "@MLIR_ENABLE_EXECUTION_ENGINE@")
|
||||
@@ -35,6 +42,29 @@ if(NOT TARGET MLIRSupport)
|
||||
@MLIR_CONFIG_INCLUDE_EXPORTS@
|
||||
endif()
|
||||
|
||||
+# Ensure MLIR_TABLEGEN_EXE is a full path and has a corresponding imported
|
||||
+# target. In install trees, MLIR_TABLEGEN_EXE may be a bare name
|
||||
+# ("mlir-tblgen") rather than an absolute path. Resolve it so that
|
||||
+# TableGen.cmake can use it as both a COMMAND and a DEPENDS entry.
|
||||
+if(MLIR_TABLEGEN_EXE AND NOT IS_ABSOLUTE "${MLIR_TABLEGEN_EXE}"
|
||||
+ AND NOT TARGET "${MLIR_TABLEGEN_EXE}")
|
||||
+ find_program(_mlir_tblgen_exe "${MLIR_TABLEGEN_EXE}"
|
||||
+ HINTS "${LLVM_TOOLS_BINARY_DIR}")
|
||||
+ if(_mlir_tblgen_exe)
|
||||
+ set(MLIR_TABLEGEN_EXE "${_mlir_tblgen_exe}")
|
||||
+ endif()
|
||||
+ unset(_mlir_tblgen_exe)
|
||||
+endif()
|
||||
+
|
||||
+if(NOT TARGET mlir-tblgen AND MLIR_TABLEGEN_EXE)
|
||||
+ add_executable(mlir-tblgen IMPORTED GLOBAL)
|
||||
+ set_target_properties(mlir-tblgen PROPERTIES
|
||||
+ IMPORTED_LOCATION "${MLIR_TABLEGEN_EXE}")
|
||||
+endif()
|
||||
+if(NOT DEFINED MLIR_TABLEGEN_TARGET)
|
||||
+ set(MLIR_TABLEGEN_TARGET mlir-tblgen)
|
||||
+endif()
|
||||
+
|
||||
# By creating these targets here, subprojects that depend on MLIR's
|
||||
# tablegen-generated headers can always depend on these targets whether building
|
||||
# in-tree with MLIR or not.
|
||||
@@ -1,5 +1,4 @@
|
||||
diff --git a/cmake/modules/MLIRConfig.cmake.in b/cmake/modules/MLIRConfig.cmake.in
|
||||
index 71f3e028b1e8..b30b6cdc0de1 100644
|
||||
--- a/cmake/modules/MLIRConfig.cmake.in
|
||||
+++ b/cmake/modules/MLIRConfig.cmake.in
|
||||
@@ -9,9 +9,16 @@ find_package(LLVM ${LLVM_VERSION} EXACT REQUIRED CONFIG
|
||||
@@ -53,7 +53,7 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
# workaround in flang's CMakeLists.txt.
|
||||
|
||||
# Upstream issue: https://github.com/llvm/llvm-project/issues/150986
|
||||
./mlir-tablegen-imported-target.patch
|
||||
(getVersionFile "mlir/mlir-tablegen-imported-target.patch")
|
||||
]
|
||||
++ lib.optionals (lib.versionOlder release_version "20") [
|
||||
# Fix build with gcc15
|
||||
|
||||
@@ -129,6 +129,21 @@
|
||||
path = ../19;
|
||||
}
|
||||
];
|
||||
"mlir/mlir-tablegen-imported-target.patch" = [
|
||||
{
|
||||
before = "19";
|
||||
path = ../18;
|
||||
}
|
||||
{
|
||||
after = "19";
|
||||
before = "21";
|
||||
path = ../19;
|
||||
}
|
||||
{
|
||||
after = "21";
|
||||
path = ../21;
|
||||
}
|
||||
];
|
||||
"flang/warn-on-fbuiltin-and-fno-builtin.patch" = [
|
||||
{
|
||||
after = "20";
|
||||
|
||||
Reference in New Issue
Block a user