[clang] 3997076 - [CMake] Require python 3.6 if enabling LLVM test targets
Christopher Tetreault via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 15 09:50:56 PDT 2021
Author: Christopher Tetreault
Date: 2021-03-15T09:50:39-07:00
New Revision: 39970764af39415ad62136ff75b0f89577c18037
URL: https://github.com/llvm/llvm-project/commit/39970764af39415ad62136ff75b0f89577c18037
DIFF: https://github.com/llvm/llvm-project/commit/39970764af39415ad62136ff75b0f89577c18037.diff
LOG: [CMake] Require python 3.6 if enabling LLVM test targets
The lit test suite uses python 3.6 features. Rather than a strange
python syntax error upon running the lit tests, we will require the
correct version in CMake.
Reviewed By: serge-sans-paille, yln
Differential Revision: https://reviews.llvm.org/D95635
Added:
Modified:
clang/CMakeLists.txt
lld/CMakeLists.txt
llvm/CMakeLists.txt
llvm/cmake/modules/HandleLLVMOptions.cmake
mlir/CMakeLists.txt
Removed:
################################################################################
diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 4695dc8a46fff..9ecf4b9d2de86 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -131,7 +131,8 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
if(LLVM_INCLUDE_TESTS)
- find_package(Python3 REQUIRED COMPONENTS Interpreter)
+ find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED
+ COMPONENTS Interpreter)
# Check prebuilt llvm/utils.
if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}
diff --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt
index d4e561b50d8f8..cbca979aaeb11 100644
--- a/lld/CMakeLists.txt
+++ b/lld/CMakeLists.txt
@@ -57,7 +57,8 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
include(CheckAtomic)
if(LLVM_INCLUDE_TESTS)
- find_package(Python3 REQUIRED COMPONENTS Interpreter)
+ find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED
+ COMPONENTS Interpreter)
# Check prebuilt llvm/utils.
if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index f5298de9f7ca6..22c1a130f4a56 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -693,7 +693,8 @@ set(ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER TRUE CACHE BOOL
include(HandleLLVMOptions)
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED
+ COMPONENTS Interpreter)
######
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 32fb4e10e31e9..2e088bd6e9168 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -1176,3 +1176,11 @@ if(LLVM_USE_RELATIVE_PATHS_IN_FILES)
append_if(SUPPORTS_FFILE_PREFIX_MAP "-ffile-prefix-map=${source_root}/=${LLVM_SOURCE_PREFIX}" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
add_flag_if_supported("-no-canonical-prefixes" NO_CANONICAL_PREFIXES)
endif()
+
+if(LLVM_INCLUDE_TESTS)
+ # Lit test suite requires at least python 3.6
+ set(LLVM_MINIMUM_PYTHON_VERSION 3.6)
+else()
+ # FIXME: it is unknown if this is the actual minimum bound
+ set(LLVM_MINIMUM_PYTHON_VERSION 3.0)
+endif()
diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index 7385e6b172226..79ef5510ad2d3 100644
--- a/mlir/CMakeLists.txt
+++ b/mlir/CMakeLists.txt
@@ -106,7 +106,8 @@ set(MLIR_PYTHON_BINDINGS_VERSION_LOCKED 1 CACHE BOOL
if(MLIR_BINDINGS_PYTHON_ENABLED)
include(MLIRDetectPythonEnv)
- find_package(Python3 COMPONENTS Interpreter Development NumPy REQUIRED)
+ find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION}
+ COMPONENTS Interpreter Development NumPy REQUIRED)
message(STATUS "Found python include dirs: ${Python3_INCLUDE_DIRS}")
message(STATUS "Found python libraries: ${Python3_LIBRARIES}")
message(STATUS "Found numpy v${Python3_NumPy_VERSION}: ${Python3_NumPy_INCLUDE_DIRS}")
More information about the cfe-commits
mailing list