From 9af482dcb52d74d7e14a0ee133c35c810a561101 Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Wed, 3 Sep 2025 16:47:32 +0200 Subject: [PATCH 1/5] Support custom LLVM installation path Add support for explicitly defined LLVM installation location. This is necessary as MSVC now comes with its own LLVM installation and activating MSVC via vcvars.bat will put LLVM tools on the `PATH` before the local ones. --- Tools/jit/_llvm.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Tools/jit/_llvm.py b/Tools/jit/_llvm.py index f09a8404871b24..5d477081b7d805 100644 --- a/Tools/jit/_llvm.py +++ b/Tools/jit/_llvm.py @@ -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_root := os.getenv("LLVM_ROOT")) is not None: + path = os.path.join(llvm_root, "bin", tool) + if await _check_tool_version(path, echo=echo): + return path # Unversioned executables: path = tool if await _check_tool_version(path, echo=echo): From 0bd835286b3d6ba94dc5869b63e63a7dc0111595 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Wed, 3 Sep 2025 14:56:00 +0000 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Build/2025-09-03-14-55-59.gh-issue-138451.-Qzh2S.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Build/2025-09-03-14-55-59.gh-issue-138451.-Qzh2S.rst diff --git a/Misc/NEWS.d/next/Build/2025-09-03-14-55-59.gh-issue-138451.-Qzh2S.rst b/Misc/NEWS.d/next/Build/2025-09-03-14-55-59.gh-issue-138451.-Qzh2S.rst new file mode 100644 index 00000000000000..cdbbfa70e3ae64 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2025-09-03-14-55-59.gh-issue-138451.-Qzh2S.rst @@ -0,0 +1 @@ +Search for LLVM tools in ``LLVM_ROOT`` during the build. From 859bfbd5cef7f08fc52d08870c410ffd9f1a618a Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Fri, 5 Sep 2025 11:35:51 +0200 Subject: [PATCH 3/5] Use `LLVM_TOOLS_INSTALL_DIR` to search for LLVM tools --- .../next/Build/2025-09-03-14-55-59.gh-issue-138451.-Qzh2S.rst | 2 +- Tools/jit/_llvm.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Misc/NEWS.d/next/Build/2025-09-03-14-55-59.gh-issue-138451.-Qzh2S.rst b/Misc/NEWS.d/next/Build/2025-09-03-14-55-59.gh-issue-138451.-Qzh2S.rst index cdbbfa70e3ae64..46cc6ffc05ea2d 100644 --- a/Misc/NEWS.d/next/Build/2025-09-03-14-55-59.gh-issue-138451.-Qzh2S.rst +++ b/Misc/NEWS.d/next/Build/2025-09-03-14-55-59.gh-issue-138451.-Qzh2S.rst @@ -1 +1 @@ -Search for LLVM tools in ``LLVM_ROOT`` during the build. +Search for LLVM tools in ``LLVM_TOOLS_INSTALL_DIR`` during the build. diff --git a/Tools/jit/_llvm.py b/Tools/jit/_llvm.py index 5d477081b7d805..fd6d9deffd5e8a 100644 --- a/Tools/jit/_llvm.py +++ b/Tools/jit/_llvm.py @@ -70,8 +70,8 @@ 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_root := os.getenv("LLVM_ROOT")) is not None: - path = os.path.join(llvm_root, "bin", tool) + if (llvm_tools_dir := os.getenv("LLVM_TOOLS_INSTALL_DIR")) is not None: + path = os.path.join(llvm_tools_dir, tool) if await _check_tool_version(path, echo=echo): return path # Unversioned executables: From 9492d920737f4b21381483f852b0e50dd8b30fcc Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Sun, 7 Sep 2025 16:24:30 +0200 Subject: [PATCH 4/5] Don't join on empty values. Co-authored-by: Steve Dower --- Tools/jit/_llvm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/jit/_llvm.py b/Tools/jit/_llvm.py index fd6d9deffd5e8a..5f752b82786222 100644 --- a/Tools/jit/_llvm.py +++ b/Tools/jit/_llvm.py @@ -70,7 +70,7 @@ 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: + if llvm_tools_dir := os.getenv("LLVM_TOOLS_INSTALL_DIR")): path = os.path.join(llvm_tools_dir, tool) if await _check_tool_version(path, echo=echo): return path From 788de077a748a6051fc1c3df768251b3c82447ea Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Sun, 7 Sep 2025 18:13:56 +0200 Subject: [PATCH 5/5] Fix syntax error --- Tools/jit/_llvm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/jit/_llvm.py b/Tools/jit/_llvm.py index 5f752b82786222..b714b9d810f9e5 100644 --- a/Tools/jit/_llvm.py +++ b/Tools/jit/_llvm.py @@ -70,7 +70,7 @@ 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")): + if llvm_tools_dir := os.getenv("LLVM_TOOLS_INSTALL_DIR"): path = os.path.join(llvm_tools_dir, tool) if await _check_tool_version(path, echo=echo): return path