llvmPackages_{18,19}.mlir: fix build with gcc15

- add patch from 2 upstream commits that were not backported to llvm_18
and llvm_19:

https://github.com/llvm/llvm-project/commit/41eb186fbb024898bacc2577fa3b88db0510ba1f
Fixes build failure with gcc15:
```
In file included from /build/mlir-src-18.1.8/mlir/lib/Dialect/Affine/IR/ValueBoundsOpInterfaceImpl.cpp:9:
/build/mlir-src-18.1.8/mlir/include/mlir/Dialect/Affine/IR/ValueBoundsOpInterfaceImpl.h:31:11:
error: 'int64_t' was not declared in this scope
   31 | FailureOr<int64_t> fullyComposeAndComputeConstantDelta(Value value1,
      |           ^~~~~~~
/build/mlir-src-18.1.8/mlir/include/mlir/Dialect/Affine/IR/ValueBoundsOpInterfaceImpl.h:13:1:
note: 'int64_t' is defined in header '<cstdint>'; this is probably
fixable by adding '#include <cstdint>'
   12 | #include "mlir/Support/LogicalResult.h"
  +++ |+#include <cstdint>
   13 |
```

https://github.com/llvm/llvm-project/commit/101109fc5460d5bb9bb597c6ec77f998093a6687
Fixes failure with gcc15:
```
In file included from /build/mlir-src-19.1.7/mlir/lib/Target/SPIRV/Deserialization/Deserialization.cpp:9:
/build/mlir-src-19.1.7/mlir/include/mlir/Target/SPIRV/Deserialization.h:29:51:
error: 'uint32_t' was not declared in this scope
   29 | OwningOpRef<spirv::ModuleOp> deserialize(ArrayRef<uint32_t> binary,
      |                                                   ^~~~~~~~
/build/mlir-src-19.1.7/mlir/include/mlir/Target/SPIRV/Deserialization.h:18:1:
note: 'uint32_t' is defined in header '<cstdint>'; this is probably
fixable by adding '#include <cstdint>'
   17 | #include "mlir/Support/LLVM.h"
  +++ |+#include <cstdint>
   18 |
```

First patch can be applied with `fetchpatch`, but only on llvm_19, because
of changed include line right above.
So use 2 versions of combined patches with 2 commits.
This commit is contained in:
ghpzin
2025-12-04 07:21:16 +03:00
parent 3d2200b18c
commit 9ecbf0230d
4 changed files with 76 additions and 0 deletions
@@ -0,0 +1,28 @@
Rebase of 2 upstream commits:
https://github.com/llvm/llvm-project/commit/41eb186fbb024898bacc2577fa3b88db0510ba1f
https://github.com/llvm/llvm-project/commit/101109fc5460d5bb9bb597c6ec77f998093a6687
diff --git a/include/mlir/Dialect/Affine/IR/ValueBoundsOpInterfaceImpl.h b/include/mlir/Dialect/Affine/IR/ValueBoundsOpInterfaceImpl.h
index 451c466fa0c95..642e99d963ef6 100644
--- a/include/mlir/Dialect/Affine/IR/ValueBoundsOpInterfaceImpl.h
+++ b/include/mlir/Dialect/Affine/IR/ValueBoundsOpInterfaceImpl.h
@@ -10,6 +10,7 @@
#define MLIR_DIALECT_AFFINE_IR_VALUEBOUNDSOPINTERFACEIMPL_H
#include "mlir/Support/LogicalResult.h"
+#include <cstdint>
namespace mlir {
class DialectRegistry;
diff --git a/include/mlir/Target/SPIRV/Deserialization.h b/include/mlir/Target/SPIRV/Deserialization.h
index e39258beeaac8..a346a7fd1e5f7 100644
--- a/include/mlir/Target/SPIRV/Deserialization.h
+++ b/include/mlir/Target/SPIRV/Deserialization.h
@@ -15,6 +15,7 @@
#include "mlir/IR/OwningOpRef.h"
#include "mlir/Support/LLVM.h"
+#include <cstdint>
namespace mlir {
class MLIRContext;
@@ -0,0 +1,29 @@
Rebase of 2 upstream commits:
https://github.com/llvm/llvm-project/commit/41eb186fbb024898bacc2577fa3b88db0510ba1f
https://github.com/llvm/llvm-project/commit/101109fc5460d5bb9bb597c6ec77f998093a6687
diff --git a/include/mlir/Dialect/Affine/IR/ValueBoundsOpInterfaceImpl.h b/include/mlir/Dialect/Affine/IR/ValueBoundsOpInterfaceImpl.h
index 451c466fa0c95..642e99d963ef6 100644
--- a/include/mlir/Dialect/Affine/IR/ValueBoundsOpInterfaceImpl.h
+++ b/include/mlir/Dialect/Affine/IR/ValueBoundsOpInterfaceImpl.h
@@ -10,6 +10,7 @@
#define MLIR_DIALECT_AFFINE_IR_VALUEBOUNDSOPINTERFACEIMPL_H
#include "mlir/Support/LLVM.h"
+#include <cstdint>
namespace mlir {
class DialectRegistry;
diff --git a/include/mlir/Target/SPIRV/Deserialization.h b/include/mlir/Target/SPIRV/Deserialization.h
index e39258beeaac8..a346a7fd1e5f7 100644
--- a/include/mlir/Target/SPIRV/Deserialization.h
+++ b/include/mlir/Target/SPIRV/Deserialization.h
@@ -15,6 +15,7 @@
#include "mlir/IR/OwningOpRef.h"
#include "mlir/Support/LLVM.h"
+#include <cstdint>
namespace mlir {
class MLIRContext;
@@ -12,6 +12,7 @@
libllvm,
version,
devExtraCmakeFlags ? [ ],
getVersionFile,
}:
stdenv.mkDerivation (finalAttrs: {
@@ -38,6 +39,12 @@ stdenv.mkDerivation (finalAttrs: {
patches = [
./gnu-install-dirs.patch
]
++ lib.optional (lib.versionOlder release_version "20") [
# Fix build with gcc15
# https://github.com/llvm/llvm-project/commit/41eb186fbb024898bacc2577fa3b88db0510ba1f
# https://github.com/llvm/llvm-project/commit/101109fc5460d5bb9bb597c6ec77f998093a6687
(getVersionFile "mlir/mlir-add-include-cstdint.patch")
];
nativeBuildInputs = [
@@ -116,4 +116,16 @@
path = ../21;
}
];
"mlir/mlir-add-include-cstdint.patch" = [
{
after = "18";
before = "19";
path = ../18;
}
{
after = "19";
before = "20";
path = ../19;
}
];
}