Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cmake] FindPython architecture check broken on clangarm64 #20569

Open
jeremyd2019 opened this issue Apr 6, 2024 · 5 comments
Open

[cmake] FindPython architecture check broken on clangarm64 #20569

jeremyd2019 opened this issue Apr 6, 2024 · 5 comments

Comments

@jeremyd2019
Copy link
Member

jeremyd2019 commented Apr 6, 2024

From build of mingw-w64-freecad (https://github.com/msys2-arm/msys2-autobuild/actions/runs/8575422878/job/23504484155#step:11:6142):

  CMake Error at C:/msys64/clangarm64/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
    Could NOT find Python (missing: Python_EXECUTABLE Interpreter) (found
    suitable version "3.11.8", minimum required is "3")
  
        Reason given by package: 
            Interpreter: Wrong architecture for the interpreter "C:/msys64/clangarm64/bin/python.exe"

This appears to be down to this check in share/cmake/FindPython/Support.cmake:

      execute_process (COMMAND ${launcher} "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c
        "import sys, sysconfig; sys.stdout.write(sysconfig.get_platform())"
        RESULT_VARIABLE result
        OUTPUT_VARIABLE platform
        ERROR_QUIET
        OUTPUT_STRIP_TRAILING_WHITESPACE)
      string(TOUPPER "${platform}" platform)
      if (result OR ((target_arm AND NOT platform MATCHES "ARM") OR
                     (NOT target_arm AND platform MATCHES "ARM")))
        # interpreter not usable or has wrong architecture

In this case, sysconfig.get_platform() returns mingw_aarch64, it does not contain arm.

@jeremyd2019
Copy link
Member Author

Not:

Administrator@WIN-K0UDL7621KH CLANGARM64 ~
# cat > CMakeLists.txt
cmake_minimum_required(VERSION 3.16)
project(test CXX)
find_package(Python 3.11 REQUIRED COMPONENTS Interpreter Development)

Administrator@WIN-K0UDL7621KH CLANGARM64 ~
# cmake -GNinja
CMake Warning:
  No source or binary directory provided.  Both will be assumed to be the
  same as the current working directory, but note that this warning will
  become a fatal error in future CMake releases.


-- The CXX compiler identification is Clang 18.1.3
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/msys64/clangarm64/bin/c++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at C:/msys64/clangarm64/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find Python (missing: Python_EXECUTABLE Interpreter) (found
  suitable version "3.11.8", minimum required is "3.11")

      Reason given by package:
          Interpreter: Wrong architecture for the interpreter "C:/msys64/clangarm64/bin/python.exe"

Call Stack (most recent call first):
  C:/msys64/clangarm64/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  C:/msys64/clangarm64/share/cmake/Modules/FindPython/Support.cmake:3867 (find_package_handle_standard_args)
  C:/msys64/clangarm64/share/cmake/Modules/FindPython.cmake:574 (include)
  CMakeLists.txt:3 (find_package)


-- Configuring incomplete, errors occurred!

@jeremyd2019
Copy link
Member Author

jeremyd2019 commented Apr 6, 2024

cmake 3.29.1:

 -- CMAKE_SYSTEM_PROCESSOR: ARM64

cmake 3.28.3:

-- CMAKE_SYSTEM_PROCESSOR: ARM64

I also tried the last test too, and that still failed. I went back "major" versions of cmake until it worked. That was mingw-w64-clang-aarch64-cmake-3.26.4-4-any.pkg.tar.zst. mingw-w64-clang-aarch64-cmake-3.27.9-1-any.pkg.tar.zst was the newer version that failed.

in 3.26.4, CMAKE_SYSTEM_PROCESSOR was still ARM64

@jeremyd2019
Copy link
Member Author

Just the usual monthly cumulative updates

@jeremyd2019
Copy link
Member Author

Runner now has the 23H2 enablement update installed. I don't expect much for behavior changes since it is just an enablement update after all...

I noticed there was a cmake update and a python update since this report, but I don't think either did anything that would fix it. Changing the python "platform" tag at this point would be a major breakage (@naveen521kk). I would probably think about patching
https://github.com/Kitware/CMake/blob/1d31a00ee45545a7943e8b413b60b658b1565367/Modules/FindPython/Support.cmake#L975-L976
to check for ARM or AARCH in the platform instead of just ARM. I don't know cmake syntax that well, so I don't know if the MATCHES operator has a syntax to do regex like "ARM|AARCH" or if it would have to be done by adding additional ORs...

@naveen521kk
Copy link
Member

Changing the python "platform" tag at this point would be a major breakage (@naveen521kk)

Indeed. However, we could do it over at Python 3.12 if we need it. I would suggest including arm for all the arm-based platforms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants