Polygeist Current Status:
- Tracked LLVM Commit:
26eb4285b56edd8c897642078d91f16ff0fd3472 - LLVM Version: 18.0.0 (NOT 22.0.0)
- Gap: ~4 major LLVM versions behind (18 → 19 → 20 → 21 → 22)
Conclusion: You are 100% correct - Polygeist does NOT support LLVM 22 out of the box and requires patches.
LLVM/MLIR undergoes breaking API changes between major versions:
-
MLIR Dialect Changes
- New operations added
- Deprecated operations removed
- IR structure modifications
-
C++ API Changes
- Function signature changes
- Class hierarchy modifications
- Namespace reorganizations
-
CMake Build Changes
- Build system updates
- Dependency handling changes
- Plugin registration changes
Based on LLVM upgrade patterns, these areas will need patches:
- File:
lib/polygeist/Ops.cpp,include/polygeist/Ops.td - Issue: MLIR operation builder signatures changed
- Fix: Update to new
OpBuilderAPI
- File:
lib/polygeist/Passes/*.cpp - Issue: Pass registration API changed in LLVM 20+
- Fix: Update from old
PassRegistration<>to newregisterPass()
- File:
tools/cgeist/cgeist.cpp,lib/polygeist/ClangFrontend.cpp - Issue: Clang AST API changes
- Fix: Update AST traversal and type handling
- File:
lib/polygeist/Conversions/*.cpp - Issue: LLVM IR builder API changes
- Fix: Update IR construction calls
- File:
CMakeLists.txt,AddClang.cmake - Issue: LLVM CMake module changes
- Fix: Update
find_package(MLIR)andadd_mlir_library()
Check for existing LLVM 22 support work:
# Check Polygeist issues for LLVM 22 support
https://github.com/llvm/Polygeist/issues?q=is%3Aissue+llvm
# Check recent commits for version bumps
https://github.com/llvm/Polygeist/commits/mainIf found: Use community patches If not found: We need to create patches
Step-by-step approach:
// OLD (LLVM 18):
void buildOp(OpBuilder &builder, OperationState &state, ...) {
builder.createOperation(state);
}
// NEW (LLVM 22):
void buildOp(OpBuilder &builder, OperationState &state, ...) {
builder.create<OpType>(builder.getUnknownLoc(), ...);
}// OLD (LLVM 18):
void registerMyPass() {
PassRegistration<MyPass>("my-pass", "Description");
}
// NEW (LLVM 22):
void registerMyPass() {
mlir::registerPass([]() -> std::unique_ptr<Pass> {
return std::make_unique<MyPass>();
});
}// OLD (LLVM 18):
QualType getType(const Expr *E) {
return E->getType();
}
// NEW (LLVM 22):
QualType getType(const Expr *E) {
return E->getType().getCanonicalType();
}If patches are too complex, we can:
- Keep Polygeist on LLVM 18
- Use LLVM 22 for everything else (ClangIR, MLIR passes)
- Create conversion layer between LLVM 18 MLIR → LLVM 22 MLIR
- ✅ Confirm Polygeist uses LLVM 18
- ⏭️ Check Polygeist GitHub for LLVM 22 PRs/issues
- ⏭️ Test build Polygeist with LLVM 22 (collect errors)
- Build Polygeist against LLVM 22 → collect ALL errors
- Categorize errors by:
- MLIR API changes
- Clang API changes
- CMake changes
- Create patch list
Create individual patches for each category:
patches/
├── 001-mlir-operation-builders.patch
├── 002-pass-registration.patch
├── 003-clang-ast-api.patch
├── 004-llvm-ir-conversion.patch
└── 005-cmake-build-system.patch
# Download Polygeist
RUN git clone https://github.com/llvm/Polygeist.git /opt/polygeist-source
# Apply LLVM 22 compatibility patches
WORKDIR /opt/polygeist-source
COPY patches/polygeist-llvm22/*.patch ./patches/
RUN for patch in patches/*.patch; do \
patch -p1 < "$patch" || echo "Patch $patch failed"; \
done
# Build with LLVM 22
RUN mkdir build && cd build && \
cmake .. \
-DLLVM_DIR=/usr/lib/llvm-22/lib/cmake/llvm \
-DMLIR_DIR=/usr/lib/llvm-22/lib/cmake/mlir \
-DCMAKE_BUILD_TYPE=Release && \
ninja-
Check Polygeist Issues for LLVM 22 work
https://github.com/llvm/Polygeist/issues https://github.com/llvm/Polygeist/pulls
-
Attempt build with LLVM 22 (collect errors)
cd /tmp/polygeist-research mkdir build && cd build cmake .. \ -DLLVM_DIR=/usr/lib/llvm-22/lib/cmake/llvm \ -DMLIR_DIR=/usr/lib/llvm-22/lib/cmake/mlir ninja 2>&1 | tee build-errors.log
-
Analyze build errors → create patch requirements list
- Create patch files for each error category
- Test patches individually
- Integrate into Dockerfile
Use LLVM 18 for Polygeist, LLVM 22 for everything else:
# LLVM 22 - Main tools
ENV PATH="/usr/lib/llvm-22/bin:${PATH}"
ENV LLVM_DIR="/usr/lib/llvm-22/lib/cmake/llvm"
ENV MLIR_DIR="/usr/lib/llvm-22/lib/cmake/mlir"
# LLVM 18 - Polygeist only
RUN apt-get install llvm-18 llvm-18-dev
RUN git clone https://github.com/llvm/Polygeist.git && \
cd Polygeist && \
mkdir build && cd build && \
cmake .. \
-DLLVM_DIR=/usr/lib/llvm-18/lib/cmake/llvm \
-DMLIR_DIR=/usr/lib/llvm-18/lib/cmake/mlirThen create conversion layer:
C/C++ → Polygeist (LLVM 18) → MLIR (18) → Convert to MLIR (22) → Obfuscation passes (22)
| Component | Priority | Complexity | Estimated Effort |
|---|---|---|---|
| MLIR Op Builders | HIGH | Medium | 4-6 hours |
| Pass Registration | HIGH | Low | 1-2 hours |
| Clang AST API | CRITICAL | High | 8-12 hours |
| LLVM IR Conversion | MEDIUM | Medium | 3-4 hours |
| CMake Build | MEDIUM | Low | 1-2 hours |
| TOTAL | - | - | 17-26 hours |
QUESTION FOR YOU:
- Attempt full LLVM 22 patches (17-26 hours of work, might fail)
- Use dual LLVM versions (18 for Polygeist, 22 for everything else)
- Skip Polygeist (focus on ClangIR only, which is LLVM 22 compatible)
My Recommendation: Option 2 or 3
- Option 2: Keep working pipeline, add Polygeist as LLVM 18 addon
- Option 3: Focus on ClangIR (which works with LLVM 22 out of box)
ClangIR is officially part of LLVM now and has native LLVM 22 support, making it the safer choice.
What should we do?
A) Try patching Polygeist for LLVM 22 (high risk, high effort) B) Use Polygeist with LLVM 18 (safe, proven) C) Focus on ClangIR only (safe, modern, LLVM 22 native)
Let me know your preference and I'll proceed accordingly!
Version: 1.0.0 Date: 2025-12-01 Status: Awaiting decision