Skip to content

Commit 0d0c847

Browse files
committed
build: require at least major version 23 for llvm
1 parent 25d1116 commit 0d0c847

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

‎src/CMakeLists.txt‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,10 @@ target_link_libraries(python-cpp
302302
)
303303

304304
# LLVM backend
305-
find_package(LLVM CONFIG 23)
305+
# No version is requested here for the same reason as in executable/mlir: LLVM's
306+
# config-version file wants an exact major.minor match. The MLIR subdirectory has
307+
# already validated the major version by this point.
308+
find_package(LLVM CONFIG)
306309
if(ENABLE_LLVM_BACKEND AND NOT LLVM_FOUND)
307310
message(FATAL_ERROR "Could not find LLVM in the local environment")
308311
elseif(ENABLE_LLVM_BACKEND AND LLVM_FOUND)

‎src/executable/mlir/CMakeLists.txt‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
find_package(LLVM 23 REQUIRED CONFIG)
2-
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
1+
# LLVMConfigVersion.cmake only accepts an exact major.minor match, so asking for
2+
# "23" means "23.0" and rejects the 23.1.x releases. Search without a version,
3+
# newest install first, and enforce the major version ourselves.
4+
set(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL)
5+
set(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC)
6+
find_package(LLVM REQUIRED CONFIG)
7+
if(LLVM_VERSION_MAJOR LESS 23)
8+
message(FATAL_ERROR
9+
"LLVM 23 or newer is required, found ${LLVM_PACKAGE_VERSION} in ${LLVM_DIR}. "
10+
"Point CMake at a newer install with -DLLVM_DIR=<prefix>/lib/cmake/llvm")
11+
endif()
12+
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR} (${LLVM_PACKAGE_VERSION})")
313

414
find_package(MLIR CONFIG REQUIRED
515
HINTS ${LLVM_DIR}/../lib/cmake/mlir)

0 commit comments

Comments
 (0)