This is an archive of the discontinued LLVM Phabricator instance.

Make Python version setting actually effective
ClosedPublic

Authored by cbiesinger on Jul 11 2019, 11:49 AM.

Details

Event Timeline

cbiesinger created this revision.Jul 11 2019, 11:49 AM

Probably best to have someone else review cmake changes, as I am not very familiar with all the intricacies of all the settings. I will add some people with more cmake experience to the reviewers. Jonas and Stefan, feel free to add more cmake experts here.

I think it's more a question of our Python support and its tolerance. Are you sure about 2.6 and 2.5? LLVM's default sounds more comfortable:

set(Python_ADDITIONAL_VERSIONS 3.7 3.6 3.5 2.7)

Do we need any more then that?

JDevlieghere requested changes to this revision.Jul 11 2019, 1:56 PM

Stefan is right, no point in supporting anything less than LLVM.

Can you motivate why we need this in the first place? Don't we inherit the values form LLVM in the non-standalone scenario? Can we remove the same line in LLDBStandalone.cmake if we do it here?

This revision now requires changes to proceed.Jul 11 2019, 1:56 PM

Match LLVM and remove the line from LLDBStandalone

Yes, this does not seem to be used when building as part of LLVM, only standalone.

The motivation for this change is that without it, the versions line seems to be ignored and so CMake will pick Python 2.

I followed your suggestion to match the versions in LLVM and also removed the line from LLDBStandalone.cmake, which seems to work for still making it find Python 3. But I don't know why this code is duplicated between the two files.

Hi Christian, thanks for following up on this.

I think it should be the other way around. We don't need to set Python_ADDITIONAL_VERSIONS in in-tree builds, because then LLVM defines it already. We do need it in standalone builds, because then LLVM is not part of our configuration (its build-tree lives in a different location), so we must define it ourselves. The latter is exactly the purpose of LLDBStandalone.cmake. It is included in the very beginning to find LLVM&co and fill in all the definitions that an in-tree build would usually have at this point (some are imported via LLVMConfig.cmake). Ideally all subsequent code, like LLDBConfig.cmake, doesn't need to care about it anymore. In some cases, however, we still want to check later on. That's what LLDB_BUILT_STANDALONE is used for.

I guess the reason why it's not defined in your case is that it's behind the if (PYTHON_EXECUTABLE STREQUAL "") condition.

Move the version list outside of the strequal "" check

cbiesinger retitled this revision from Set Python versions also in LLDBConfig.cmake to Make Python version setting actually effective.Jul 12 2019, 4:57 PM
cbiesinger edited the summary of this revision. (Show Details)

How about this, then? It does seem to work.

JDevlieghere accepted this revision.Jul 12 2019, 5:11 PM

This looks reasonable to me.

This revision is now accepted and ready to land.Jul 12 2019, 5:11 PM

Thanks! Could you/someone land this? I'm not a committer.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJul 12 2019, 8:30 PM