Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Search for LLVM tools in ``LLVM_TOOLS_INSTALL_DIR`` during the build.
5 changes: 5 additions & 0 deletions Tools/jit/_llvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ async def _get_brew_llvm_prefix(*, echo: bool = False) -> str | None:

@_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:
Copy link
Member

Choose a reason for 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?

Copy link
Member

Choose a reason for hiding this comment

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

Also:

Suggested change
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.

Copy link
Member

Choose a reason for 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.

Copy link
Author

Choose a reason for 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.

Copy link
Member

Choose a reason for 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?

Copy link
Member

Choose a reason for 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.

path = os.path.join(llvm_tools_dir, tool)
if await _check_tool_version(path, echo=echo):
return path
# Unversioned executables:
path = tool
if await _check_tool_version(path, echo=echo):
Expand Down
Loading