Skip to content

Conversation

rossburton
Copy link
Contributor

@rossburton rossburton commented Oct 15, 2025

Ensure that the nested native build uses the same python interpreter as the main build, in case the python that CMake detects first is not the python that the user has specified explicitly.

For example, if the person building LLVM wants to use a different python interpreter to build (eg, testing the build with python3.14 when python3 is a link to python3.8, or the default python doesn't have development headers available) then they could add -DPYTHON_EXECUTABLE=python3.14 when invoking CMake. This should be forwarded to the native CMake build to ensure that the same python is used.

Original fix by Anuj Mittal anuj.mittal@intel.com.

Ensure that the nested native build uses the same python interpreter as
the main build, in case the python that CMake detects first is not the
python that the user has specified explicitly.

Original fix by Anuj Mittal <anuj.mittal@intel.com>.
@llvmbot llvmbot added the cmake Build system in general and CMake in particular label Oct 15, 2025
Copy link
Member

@JDevlieghere JDevlieghere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've ran into this too when cross compiling. LGTM.

@DavidSpickett
Copy link
Collaborator

Ensure that the nested native build uses the same python interpreter as the main build, in case the python that CMake detects first is not the python that the user has specified explicitly.

Please include in the PR description one example of how the user might have specified that Python. So it is a bit more clear and maybe someone grepping through commits trying to solve their own problem in future will recognise the option.

Copy link
Collaborator

@DavidSpickett DavidSpickett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whenever I cross build lldb I disable Python so I haven't seen this happen myself, but I do see the logic of the change.

The Python the user specified is still a build-host Python, so it makes sense to use it for the build-host compatible build of native tools.

This is not like if I was cross compiling and said "over here is my cross compiled library you should use". We wouldn't use that in the native tools because it's for the other architecture.

This LGTM assuming I didn't misunderstand any of that.

@rossburton
Copy link
Contributor Author

Updated. You've not misunderstood. My impression is this was triggered during the great py2/py3 migration disaster, but I can see a number of edge cases where it's a problem.

@DavidSpickett
Copy link
Collaborator

I don't think there is a review team for general cmake issues, so let's give this a couple of days in case anyone does have comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cmake Build system in general and CMake in particular

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants