GH-113464: Get LLVM from cpython-bin-deps on Windows (GH-133278)
This commit is contained in:
@@ -41,7 +41,9 @@ Homebrew won't add any of the tools to your `$PATH`. That's okay; the build scri
|
||||
|
||||
### Windows
|
||||
|
||||
Install LLVM 19 [by searching for it on LLVM's GitHub releases page](https://github.com/llvm/llvm-project/releases?q=19), clicking on "Assets", downloading the appropriate Windows installer for your platform (likely the file ending with `-win64.exe`), and running it. **When installing, be sure to select the option labeled "Add LLVM to the system PATH".**
|
||||
LLVM is downloaded automatically (along with other external binary dependencies) by `PCbuild\build.bat`.
|
||||
|
||||
Otherwise, you can install LLVM 19 [by searching for it on LLVM's GitHub releases page](https://github.com/llvm/llvm-project/releases?q=19), clicking on "Assets", downloading the appropriate Windows installer for your platform (likely the file ending with `-win64.exe`), and running it. **When installing, be sure to select the option labeled "Add LLVM to the system PATH".**
|
||||
|
||||
Alternatively, you can use [chocolatey](https://chocolatey.org):
|
||||
|
||||
|
||||
@@ -8,8 +8,11 @@ import shlex
|
||||
import subprocess
|
||||
import typing
|
||||
|
||||
import _targets
|
||||
|
||||
_LLVM_VERSION = 19
|
||||
_LLVM_VERSION_PATTERN = re.compile(rf"version\s+{_LLVM_VERSION}\.\d+\.\d+\S*\s+")
|
||||
_EXTERNALS_LLVM_TAG = "llvm-19.1.7.0"
|
||||
|
||||
_P = typing.ParamSpec("_P")
|
||||
_R = typing.TypeVar("_R")
|
||||
@@ -72,6 +75,11 @@ async def _find_tool(tool: str, *, echo: bool = False) -> str | None:
|
||||
return path
|
||||
# Versioned executables:
|
||||
path = f"{tool}-{_LLVM_VERSION}"
|
||||
if await _check_tool_version(path, echo=echo):
|
||||
return path
|
||||
# PCbuild externals:
|
||||
externals = os.environ.get("EXTERNALS_DIR", _targets.EXTERNALS)
|
||||
path = os.path.join(externals, _EXTERNALS_LLVM_TAG, "bin", tool)
|
||||
if await _check_tool_version(path, echo=echo):
|
||||
return path
|
||||
# Homebrew-installed executables:
|
||||
|
||||
@@ -23,8 +23,10 @@ TOOLS_JIT_BUILD = pathlib.Path(__file__).resolve()
|
||||
TOOLS_JIT = TOOLS_JIT_BUILD.parent
|
||||
TOOLS = TOOLS_JIT.parent
|
||||
CPYTHON = TOOLS.parent
|
||||
EXTERNALS = CPYTHON / "externals"
|
||||
PYTHON_EXECUTOR_CASES_C_H = CPYTHON / "Python" / "executor_cases.c.h"
|
||||
TOOLS_JIT_TEMPLATE_C = TOOLS_JIT / "template.c"
|
||||
|
||||
ASYNCIO_RUNNER = asyncio.Runner()
|
||||
|
||||
_S = typing.TypeVar("_S", _schema.COFFSection, _schema.ELFSection, _schema.MachOSection)
|
||||
|
||||
@@ -8,6 +8,7 @@ import sys
|
||||
import _targets
|
||||
|
||||
if __name__ == "__main__":
|
||||
out = pathlib.Path.cwd().resolve()
|
||||
comment = f"$ {shlex.join([pathlib.Path(sys.executable).name] + sys.argv)}"
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument(
|
||||
@@ -31,17 +32,22 @@ if __name__ == "__main__":
|
||||
target.force = args.force
|
||||
target.verbose = args.verbose
|
||||
target.build(
|
||||
pathlib.Path.cwd(),
|
||||
out,
|
||||
comment=comment,
|
||||
stencils_h=f"jit_stencils-{target.triple}.h",
|
||||
force=args.force,
|
||||
)
|
||||
|
||||
with open("jit_stencils.h", "w") as fp:
|
||||
for idx, target in enumerate(args.target):
|
||||
fp.write(f"#{'if' if idx == 0 else 'elif'} {target.condition}\n")
|
||||
fp.write(f'#include "jit_stencils-{target.triple}.h"\n')
|
||||
|
||||
fp.write("#else\n")
|
||||
fp.write('#error "unexpected target"\n')
|
||||
fp.write("#endif\n")
|
||||
jit_stencils_h = out / "jit_stencils.h"
|
||||
lines = [f"// {comment}\n"]
|
||||
guard = "#if"
|
||||
for target in args.target:
|
||||
lines.append(f"{guard} {target.condition}\n")
|
||||
lines.append(f'#include "jit_stencils-{target.triple}.h"\n')
|
||||
guard = "#elif"
|
||||
lines.append("#else\n")
|
||||
lines.append('#error "unexpected target"\n')
|
||||
lines.append("#endif\n")
|
||||
body = "".join(lines)
|
||||
# Don't touch the file if it hasn't changed (so we don't trigger a rebuild):
|
||||
if not jit_stencils_h.is_file() or jit_stencils_h.read_text() != body:
|
||||
jit_stencils_h.write_text(body)
|
||||
|
||||
Reference in New Issue
Block a user