@@ -32,18 +32,25 @@ If you've acquired a full source distribution and want to build Halide, see the
3232
3333## Pip
3434
35- As of Halide 19.0.0, we provide binary wheels on PyPI. Halide provides bindings
36- for C++ and Python. Even if you only intend to use Halide from C++, pip may be
37- the easiest way to get a binary build of Halide.
35+ We provide binary wheels on PyPI. Halide provides bindings for C++ and Python.
36+ Even if you only intend to use Halide from C++, pip may be the easiest way to
37+ get a binary build of Halide.
3838
3939Full releases may be installed with ` pip ` like so:
4040
4141``` shell
4242$ pip install halide
4343```
4444
45- Every commit to ` main ` is published to a private PyPI index as a development
46- version and these may be installed with a few extra flags:
45+ Every commit to ` main ` is published to our [ package index] [ halide-pypi ] as a
46+ development version. If you use [ uv] ( https://docs.astral.sh/uv/ ) , you can pin
47+ the nightly Halide in a project like so:
48+
49+ ``` shell
50+ $ uv add halide --prerelease=allow --index https://pypi.halide-lang.org/simple
51+ ```
52+
53+ Or install directly with ` pip ` :
4754
4855``` shell
4956$ pip install halide --pre --extra-index-url https://pypi.halide-lang.org/simple
@@ -59,9 +66,11 @@ installed it in. On Windows, you will need to add the virtual environment root
5966directory to ` CMAKE_PREFIX_PATH ` . This can be done by running
6067` set CMAKE_PREFIX_PATH=%VIRTUAL_ENV% ` in ` cmd ` .
6168
62- Other build systems can find the Halide root path by running `python -c
69+ Other build systems can find the Halide root path by running `python -c
6370"import halide; print(halide.install_dir())"`.
6471
72+ [ halide-pypi ] : https://pypi.halide-lang.org/simple
73+
6574## Homebrew
6675
6776Alternatively, if you use macOS, you can install Halide via
@@ -80,16 +89,9 @@ We provide binary releases for many popular platforms and architectures,
8089including 32/64-bit x86 Windows, 64-bit x86/ARM macOS, and 32/64-bit x86/ARM
8190Ubuntu Linux.
8291
83- The macOS releases are built using XCode's command-line tools with Apple Clang
84- 500.2.76. This means that we link against libc++ instead of libstdc++. You may
85- need to adjust compiler options accordingly if you're using an older XCode which
86- does not default to libc++.
87-
88- We use a recent Ubuntu LTS to build the Linux releases; if your distribution is
89- too old, it might not have the requisite glibc.
90-
91- Nightly builds of Halide and the LLVM versions we use in CI are also available
92- at https://buildbot.halide-lang.org/
92+ The Linux tarballs are built on a recent Ubuntu LTS; if your distribution is too
93+ old, it might not have the requisite glibc. The [ pip wheels] ( #pip ) are built for
94+ manylinux_2_28 and are more broadly compatible.
9395
9496## Vcpkg
9597
@@ -102,8 +104,7 @@ $ vcpkg install halide:x64-windows # or x64-linux/x64-osx
102104
103105One caveat: vcpkg installs only the minimum Halide backends required to compile
104106code for the active platform. If you want to include all the backends, you
105- should install ` halide[target-all]:x64-windows ` instead. Note that since this
106- will build LLVM, it will take a _ lot_ of disk space (up to 100GB).
107+ should install ` halide[target-all]:x64-windows ` instead.
107108
108109## Other package managers
109110
@@ -153,22 +154,39 @@ At any point in time, building Halide requires either the latest stable version
153154of LLVM, the previous stable version of LLVM, or trunk. At the time of writing,
154155this means versions 23, 22, and 21 are supported, but 20 is not.
155156
156- It is simplest to get a binary release of LLVM on macOS by using
157- [ Homebrew] ( https://brew.sh ) . Just run ` brew install llvm ` . On Debian flavors of
158- Linux, the [ LLVM APT repo] ( https://apt.llvm.org ) is best; use the provided
159- installation script. We know of no suitable official binary releases for
160- Windows, however the ones we use in CI can usually be found at
161- https://buildbot.halide-lang.org , along with tarballs for our other tested
162- platforms. See [ the section on Windows] ( #windows ) below for further advice.
157+ We publish the LLVM builds we use in CI as Python packages on our
158+ [ package index] [ halide-pypi ] . This is the easiest way to get a suitable LLVM on
159+ any platform. From the Halide source tree, install with
160+ [ uv] ( https://docs.astral.sh/uv/ ) :
161+
162+ ``` shell
163+ $ uv sync --group ci-llvm-22 --no-install-project
164+ $ export Halide_LLVM_ROOT=$( halide-llvm --prefix)
165+ ```
166+
167+ Replace ` 22 ` with the desired LLVM major version (` 21 ` , ` 22 ` , ` 23 ` , or ` main ` ).
168+ Binary wheels are available for Linux (x86-64, x86-32, AArch64, ARMv7), macOS
169+ (x86-64, ARM64), and Windows (x86-64, x86-32).
170+
171+ On macOS, [ Homebrew] ( https://brew.sh ) is also a good option: `brew install
172+ llvm`. On Debian flavors of Linux, the
173+ [ LLVM APT repo] ( https://apt.llvm.org ) works well; use the provided installation
174+ script.
175+
176+ <details >
177+ <summary >Building LLVM from source (advanced)</summary >
178+
179+ > [ !WARNING]
180+ > Building LLVM from source requires significant time, disk space, and RAM.
181+ > Prefer the pre-built binaries above unless you need a custom configuration.
163182
164- If your OS does not have packages for LLVM, or you want more control over the
165- configuration, you can build it yourself. First check it out from GitHub:
183+ First check it out from GitHub:
166184
167185``` shell
168- $ git clone --depth 1 --branch llvmorg-21.1.1 https://github.com/llvm/llvm-project.git
186+ $ git clone --depth 1 --branch llvmorg-21.1.8 https://github.com/llvm/llvm-project.git
169187```
170188
171- (LLVM 21.1.1 is the most recent released LLVM at the time of writing. For
189+ (LLVM 21.1.8 is the most recent released LLVM at the time of writing. For
172190current trunk, use ` main ` instead)
173191
174192Then build it like so:
@@ -210,6 +228,8 @@ Note that you _must_ add `clang` and `lld` to `LLVM_ENABLE_PROJECTS` and
210228exception handling (EH) and RTTI if you don't want the Python bindings. We
211229recommend enabling the full set to simplify builds during development.
212230
231+ </details >
232+
213233## Building Halide with CMake
214234
215235This is discussed in greater detail in [ BuildingHalideWithCMake.md] . CMake
@@ -219,11 +239,11 @@ version 3.28+ is required to build Halide.
219239
220240### MacOS and Linux
221241
222- Follow the above instructions to build LLVM or acquire a suitable binary
223- release. Then change directory to the Halide repository and run:
242+ After [ acquiring LLVM] ( #acquiring-llvm ) , change directory to the Halide
243+ repository and run:
224244
225245``` shell
226- $ cmake -G Ninja -S . -B build -DCMAKE_BUILD_TYPE=Release -DHalide_LLVM_ROOT=$LLVM_ROOT
246+ $ cmake -G Ninja -S . -B build -DCMAKE_BUILD_TYPE=Release -DHalide_LLVM_ROOT=$LLVM_ROOT
227247$ cmake --build build
228248```
229249
@@ -232,6 +252,16 @@ version installed. However, if you have multiple LLVMs installed, it can pick
232252between them. Do not use a relative path for ` Halide_LLVM_ROOT ` . It can cause
233253problems on some systems.
234254
255+ If you use [ Homebrew] ( https://brew.sh/ ) on macOS, you can use the provided CMake
256+ preset:
257+
258+ ``` shell
259+ $ cmake --preset=macOS -S . -B build
260+ $ cmake --build build
261+ ```
262+
263+ This automatically finds LLVM from Homebrew's install path.
264+
235265### Windows
236266
237267We suggest building with Visual Studio 2022. Your mileage may vary with earlier
@@ -267,14 +297,12 @@ D:\vcpkg> .\bootstrap-vcpkg.bat -disableMetrics
267297CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=D:/vcpkg/scripts/buildsystems/vcpkg.cmake"
268298```
269299
270- When using the toolchain file, vcpkg will automatically build all the necessary
271- dependencies. However, as stated above, be aware that acquiring LLVM this way
272- may use over 100 GB of disk space for its build trees and take a very long time
273- to build. You can manually delete the build trees afterward, but vcpkg will not
274- do this automatically.
275-
276- See [ BuildingHalideWithCMake.md] ( ./doc/BuildingHalideWithCMake.md#vcpkg-presets )
277- for directions to use Vcpkg for everything _ except_ LLVM.
300+ Halide includes a ` vcpkg-configuration.json ` that automatically configures
301+ [ overlay ports] ( https://learn.microsoft.com/en-us/vcpkg/concepts/overlay-ports )
302+ and overlay triplets. These overlays redirect LLVM and Python to system
303+ installations, so vcpkg only builds the smaller dependencies (flatbuffers, wabt,
304+ pybind11, etc.). You must have LLVM and Python installed separately
305+ (see [ Acquiring LLVM] ( #acquiring-llvm ) above).
278306
279307#### Building Halide
280308
@@ -288,9 +316,17 @@ D:\Halide> cmake -G Ninja -S . -B build ^
288316 -DCMAKE_BUILD_TYPE=Release
289317```
290318
291- Then run the build with :
319+ Or use a CMake preset (e.g. for a Visual Studio build) :
292320
293321```
322+ D:\Halide> cmake --preset=win64 &:: or win32 for 32-bit
323+ D:\Halide> cmake --build build\win64
324+ ```
325+
326+ For a Ninja-based build with vcpkg:
327+
328+ ```
329+ D:\Halide> cmake --preset=release-vcpkg -S . -B build
294330D:\Halide> cmake --build build
295331```
296332
@@ -303,13 +339,18 @@ D:\Halide> ctest --test-dir build --output-on-failure
303339Subsets of the tests can be selected with ` -L ` and include ` correctness ` ,
304340` generator ` , ` error ` , and the other directory names under ` tests/ ` .
305341
306- #### Building LLVM (optional)
342+ <details >
343+ <summary >Building LLVM from source on Windows (advanced)</summary >
307344
308- Follow these steps if you want to build LLVM yourself. First, download LLVM's
309- sources (these instructions use the 21.1.1 release).
345+ > [ !WARNING]
346+ > Building LLVM from source requires significant time, disk space, and RAM.
347+ > Prefer the pre-built ` halide-llvm ` binaries (see
348+ > [ Acquiring LLVM] ( #acquiring-llvm ) ) unless you need a custom configuration.
349+
350+ First, download LLVM's sources (these instructions use the 21.1.8 release).
310351
311352```
312- D:\> git clone --depth 1 --branch llvm-org- 21.1.1 https://github.com/llvm/llvm-project.git
353+ D:\> git clone --depth 1 --branch llvmorg- 21.1.8 https://github.com/llvm/llvm-project.git
313354```
314355
315356As above, run ` vcvarsall.bat ` to pick between x86 and x64. Then configure LLVM
@@ -347,10 +388,12 @@ D:\> cmake --install build --prefix llvm-install
347388You can substitute ` Debug ` for ` Release ` in the above ` cmake ` commands if you
348389want a debug build.
349390
350- To use this with Halide, but still allow vcpkg to manage other dependencies, you
351- must add two flags to Halide's CMake configure command line. First, disable LLVM
352- with ` -DVCPKG_OVERLAY_PORTS=cmake/vcpkg ` . Second, point CMake to our newly built
353- Halide with ` -DHalide_LLVM_ROOT=D:/llvm-install ` .
391+ To use this with Halide, but still allow vcpkg to manage other dependencies,
392+ point CMake to your LLVM with ` -DHalide_LLVM_ROOT=D:/llvm-install ` . The overlay
393+ ports in ` vcpkg-configuration.json ` automatically prevent vcpkg from trying to
394+ build its own LLVM.
395+
396+ </details >
354397
355398#### If all else fails...
356399
0 commit comments