GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-138451: Support custom LLVM installation path by xhochy · Pull Request #138452 · python/cpython Conversation
|
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| async def _find_tool(tool: str, *, echo: bool = False) -> str | None: | ||
| # Explicitly defined LLVM installation location | ||
| if (llvm_root := os.getenv("LLVM_ROOT")) is not None: | ||
| path = os.path.join(llvm_root, "bin", tool) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Are all LLVM installation folders guaranteed to have the tool located in the $LLVM_ROOT/bin directory? I think it's somewhat risky to assume that.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Actually there is a LLVM_TOOLS_INSTALL_DIR in the CMakeLists to customize this: https://github.com/llvm/llvm-project/blob/74ec38fad0a1289f936e5388fa8bbe74653c55d9/llvm/CMakeLists.txt#L494
I should probably use that instead?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Yeah that seems better
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Is LLVM_TOOLS_INSTALL_DIR (or LLVM_ROOT for that matter) documented anywhere?
It seems like an env var used for building/installing LLVM itself, not necessarily something meant to be used after-the-fact by people trying to find LLVM. Or am I misunderstanding?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| @_async_cache | ||
| async def _find_tool(tool: str, *, echo: bool = False) -> str | None: | ||
| # Explicitly defined LLVM installation location | ||
| if (llvm_tools_dir := os.getenv("LLVM_TOOLS_INSTALL_DIR")) is not None: |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Should we document this somewhere? If it gets a NEWS entry, then we probably have (or need) a list of environment variables that may need to be set when building.
I'd expect the list to be in the devguide, really, which is a different repo. But do we have one in the main repo?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Also:
| if (llvm_tools_dir := os.getenv("LLVM_TOOLS_INSTALL_DIR")) is not None: | |
| if llvm_tools_dir := os.getenv("LLVM_TOOLS_INSTALL_DIR")): |
We shouldn't join to an empty value either (since that's interchangeable with "not set"). And possibly we should make sure it's an absolute path as well, though that may not matter so much.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Considering the JIT is still experimental, I don't think we should document this in the CPython docs. I agree that it should be in the devguide.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
As I did not know about the devguide before this review: Where should I add something? On first sight there was no section obvious to me.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I assume it's somewhere on this page, but to be honest I didn't read the whole thing: https://github.com/python/devguide/blob/main/getting-started/setup-building.rst
Possibly we need a new section here anyway for building the JIT? @savannahostrowski @brandtbucher are there JIT-specific build docs somewhere to document a relevant environment variable?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
We have docs for building in https://github.com/python/cpython/blob/main/Tools/jit/README.md#building. We'd probably want to update this for now.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Rebased and added documentation to the mentioned README. Is there anything more I can do here to get it merged? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if we should make this a configure flag instead, like we did with #138498. That way, you can pass the flag into configure once (e.g., ./configure --with-llvm-tools-dir=/opt/homebrew/opt/llvm...) and then just run make without remembering to pass LLVM_TOOLS_INSTALL_DIR each time. That'd make it more consistent with other build options.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I have made the requested changes; please review again |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for making the requested changes! @savannahostrowski: please review the changes made to this pull request. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
One comment but I think this looks good.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
I think this is the same problem I've faced in #141967 (comment), so thanks for doing this! I've noticed there, that e.g. running will smuggle in the include path of the clang specified on the command line in front of the environment variable which the hard coded (and maybe different) clang version used in the jit builds doesn't like depending on the version mismatch ... |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Lines 23 to 31 in 8801c6d
cpython/PCbuild/pyproject-clangcl.props Line 31 in 8801c6d
Lines 69 to 73 in 8801c6d
Does that mean that we have to specify the additional |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There's no strict requirement for make/configure variables to match pcbuild.proj variables, but if it's specified as an environment variable then we should probably detect if it's set and copy it over the actual variable. That's one line in |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
IIUC, you mean setting I think it might be "too late", since AFAIR internally this is used by MS when preparing the environment according to "their" variable names, but we'll see. What's definitely easy: just use the MS variable names here because, as you said
and just update the jit readme accordingly if we cannot map the variables easily "early" enough ... Or we do it in |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Any file that sets |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@zooba @chris-eibl I'm a bit unsure what I need to do here to get this merged. Is there anything from your side that I should address in my code for windows builds? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
First I thought we have these choices:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I've first tried option 4 via adding to Lines 122 to 127 in 8c87bcd
This would have been my preferred choice, because then we would not have to "teach something new" and could have the same variables on Windows / Linux. However, if during installing of Visual Studio the bundled clang-cl is chosen to be installed, it turned out that |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Implementing option 3 is easy, too: just add after Lines 30 to 32 in 8c87bcd
Now we'd have to document that when overriding the clang used to build the jit stencils will chose that clang for building Python, too, if built with So option 1 gives more flexibility, but needs (?) a warning and "specifying the same thing twice" might feel like a wart. I am unsure what to do best, but considering the jit is maybe no longer experimental, we should care to find a good solution here? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
The JIT is still experimental, but Python build flags and in general build.bat flags are bound by backwards compatibility, so when adding things we have to treat it as non-experimental. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Just checking in here, is there anything else required for this one? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Sorry, seems I've stalled this. IMHO we can handle the "clang version to build python" vs "clang version to build the jit" quirk in a follow-up PR? Especially since the first seems to be niche on Windows? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I think that's reasonable but I'd defer to @zooba on how he feels about that. I also don't want the follow up to get lost in the ether. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I've furthermore tested this PR now locally successfully, too, in addition to my initial review(s).
I've created #146210. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I'm not totally up on all the nuance here, but provided it works to regen explicitly with one version and then build without it automatically regenerating, this should be a non-issue (perhaps a bit annoying for someone who wants to work on the JIT on Windows and also compile with a different version of Clang, having to switch environment variables, but irrelevant for someone compiling with the same version or with MSVC even if they're regenerating the JIT stencils)? The change itself looks fine to me. It just uses the environment variables directly (or overridden as |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Steve Dower <[email protected]> Co-authored-by: Savannah Ostrowski <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Wrong LLVM tools picked up if using MSVC activation and custom LLVM build
There was an error while loading. Please reload this page.