Skip to content

Commit 749b999

Browse files
authored
Revise documentation to reflect recent changes (#9006)
1 parent 5748998 commit 749b999

3 files changed

Lines changed: 120 additions & 90 deletions

File tree

README.md

Lines changed: 92 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -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

3939
Full 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
5966
directory 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

6776
Alternatively, if you use macOS, you can install Halide via
@@ -80,16 +89,9 @@ We provide binary releases for many popular platforms and architectures,
8089
including 32/64-bit x86 Windows, 64-bit x86/ARM macOS, and 32/64-bit x86/ARM
8190
Ubuntu 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

103105
One caveat: vcpkg installs only the minimum Halide backends required to compile
104106
code 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
153154
of LLVM, the previous stable version of LLVM, or trunk. At the time of writing,
154155
this 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
172190
current trunk, use `main` instead)
173191

174192
Then build it like so:
@@ -210,6 +228,8 @@ Note that you _must_ add `clang` and `lld` to `LLVM_ENABLE_PROJECTS` and
210228
exception handling (EH) and RTTI if you don't want the Python bindings. We
211229
recommend enabling the full set to simplify builds during development.
212230

231+
</details>
232+
213233
## Building Halide with CMake
214234

215235
This 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
232252
between them. Do not use a relative path for `Halide_LLVM_ROOT`. It can cause
233253
problems 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

237267
We suggest building with Visual Studio 2022. Your mileage may vary with earlier
@@ -267,14 +297,12 @@ D:\vcpkg> .\bootstrap-vcpkg.bat -disableMetrics
267297
CMake 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
294330
D:\Halide> cmake --build build
295331
```
296332

@@ -303,13 +339,18 @@ D:\Halide> ctest --test-dir build --output-on-failure
303339
Subsets 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

315356
As above, run `vcvarsall.bat` to pick between x86 and x64. Then configure LLVM
@@ -347,10 +388,12 @@ D:\> cmake --install build --prefix llvm-install
347388
You can substitute `Debug` for `Release` in the above `cmake` commands if you
348389
want 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

doc/BuildingHalideWithCMake.md

Lines changed: 24 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -187,26 +187,18 @@ for these packages is linked in the table above.
187187

188188
Halide has first-class support for using [vcpkg] to manage dependencies. The
189189
list of dependencies and features is contained inside `vcpkg.json` at the root
190-
of the repository.
190+
of the repository. LLVM and Python must be provided by the system; vcpkg handles
191+
the remaining dependencies (flatbuffers, wabt, pybind11, libjpeg, libpng, etc.).
191192

192-
By default, a minimum set of LLVM backends will be enabled to compile JIT code
193-
for the host and the serialization feature will be enabled. When using the vcpkg
194-
toolchain file, you can set `-DVCPKG_MANIFEST_FEATURES=developer`
195-
to enable building all dependencies (except Doxygen, which is not available on
196-
vcpkg).
193+
Halide includes a `vcpkg-configuration.json` file that automatically configures
194+
[overlay ports][vcpkg-overlay] and overlay triplets. The overlay ports redirect
195+
LLVM and Python to system installations, preventing vcpkg from trying to build
196+
them. This configuration is applied automatically when vcpkg is used from the
197+
Halide source tree.
197198

198-
By default, running `vcpkg install` will try to build all of LLVM. This is often
199-
undesirable as it takes very long to do and consumes a lot of disk space,
200-
especially as `vcpkg` requires special configuration to disable the debug build.
201-
It will _also_ attempt to build Python 3 as a dependency of pybind11.
202-
203-
To mitigate this issue, we provide a [vcpkg-overlay] that disables building LLVM
204-
and Python. When using the vcpkg toolchain, you can enable it by setting
205-
`-DVCPKG_OVERLAY_PORTS=cmake/vcpkg`.
206-
207-
If you do choose to use vcpkg to build LLVM (the easiest way on Windows), note
208-
that it is safe to delete the intermediate build files and caches in
209-
`D:\vcpkg\buildtrees` and `%APPDATA%\local\vcpkg`.
199+
When using the vcpkg toolchain file, you can set
200+
`-DVCPKG_MANIFEST_FEATURES=developer` to enable building all test dependencies
201+
(except Doxygen, which is not available on vcpkg).
210202

211203
For convenience, we provide [CMake presets](#cmake-presets) that set these flags
212204
appropriately per-platform. They are documented further below.
@@ -360,39 +352,32 @@ standard types: `Debug`, `RelWithDebInfo`, `MinSizeRel`, or `Release`.
360352

361353
## CMake Presets
362354

355+
Halide provides several [presets][cmake_presets] to make the above commands more
356+
convenient.
357+
363358
### Common presets
364359

365-
Halide provides several [presets][cmake_presets] to make the above commands more
366-
convenient. The following CMake preset commands correspond to the longer ones
367-
above.
360+
These presets do not use vcpkg. They assume that all dependencies are available
361+
via the system (e.g. Homebrew on macOS, APT on Linux).
368362

369363
```shell
370-
$ cmake --preset=win64 # VS 2022 generator, 64-bit build, vcpkg deps
371-
$ cmake --preset=win32 # VS 2022 generator, 32-bit build, vcpkg deps
372364
$ cmake --preset=macOS # Ninja generator, macOS host build, Homebrew deps
373365
$ cmake --preset=debug # Debug mode, any single-config generator / compiler
374366
$ cmake --preset=release # Release mode, any single-config generator / compiler
375367
```
376368

377369
### Vcpkg presets
378370

379-
Halide provides two sets of corresponding vcpkg-enabled presets: _base_ and
380-
_full_.
381-
382-
| Base preset | Full preset |
383-
|-----------------|----------------------|
384-
| `win32` | `win32-vcpkg-full` |
385-
| `win64` | `win64-vcpkg-full` |
386-
| `macOS-vcpkg` | `macOS-vcpkg-full` |
387-
| `debug-vcpkg` | `debug-vcpkg-full` |
388-
| `release-vcpkg` | `release-vcpkg-full` |
389-
390-
In simple terms, the base presets rely on the system to provide LLVM and Python,
391-
while the full presets delegate this to vcpkg (which consumes a large amount of
392-
hard disk space and time).
371+
The following presets use vcpkg to manage non-LLVM dependencies. LLVM and Python
372+
must be provided by the system.
393373

394-
The `macOS-vcpkg` preset adds `/opt/homebrew/opt/llvm` to
395-
`CMAKE_PREFIX_PATH`.
374+
| Preset | Description |
375+
|-----------------|----------------------------------------------------------|
376+
| `win32` | Visual Studio 2022 generator, 32-bit build |
377+
| `win64` | Visual Studio 2022 generator, 64-bit build |
378+
| `macOS-vcpkg` | macOS build with vcpkg + Homebrew LLVM |
379+
| `debug-vcpkg` | Debug build for any single-config generator |
380+
| `release-vcpkg` | Release build for any single-config generator |
396381

397382
### Sanitizer presets
398383

doc/Python.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,12 @@ If you don't have LLVM installed already, you can try using the same ones the
8686
buildbots use by adding `--group ci-llvm-<VERSION>` to the `uv sync` command,
8787
where `<VERSION>` is the LLVM major version number (e.g. `23`) or `main`.
8888

89-
If you install `ci-llvm-*`, you can set `Halide_LLVM_ROOT=$(halide-llvm
89+
If you install `ci-llvm-*`, you can set `Halide_LLVM_ROOT=$(halide-llvm
9090
--prefix)` in your environment.
9191

92-
Ensure you have `flatbuffers` and `wabt` installed, too.
92+
Ensure you have `flatbuffers` and `wabt` installed, too. (The wheel build does
93+
not use vcpkg for manylinux compatibility reasons, so these must be available as
94+
system packages or installed from source.)
9395

9496
### Using wheel infrastructure
9597

0 commit comments

Comments
 (0)