blob: faeb6abf14bf49a2530f4ea78cfa0f91e68a7334 [file] [log] [blame] [view]
Phoenix Meadowlark1633aa32020-06-17 12:28:58 -07001# Getting Started on macOS with CMake
2
3<!--
4Notes to those updating this guide:
5
6 * This document should be __simple__ and cover essential items only.
7 Notes for optional components should go in separate files.
8
9 * This document parallels getting_started_linux_cmake.md and
10 getting_started_windows_cmake.md
11 Please keep them in sync.
12-->
13
14This guide walks through building the core compiler and runtime parts of IREE
15from source. Auxiliary components like the Python bindings and Vulkan driver are
16not documented for macOS at this time.
17
18IREE is not officially supported on macOS at this time. It may work, but it is
19not a part of our open source CI, and may be intermittently broken.
20Contributions related to macOS support and documentation are welcome however.
21
22## Prerequisites
23
24### Install Homebrew
25
26This guide uses [Homebrew](https://brew.sh/) to install IREE's dependencies.
27
28```shell
29$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
30```
31
32### Install CMake
33
34IREE uses [CMake](https://cmake.org/) version `>= 3.13`. Brew ships the latest
35release.
36
37```shell
38$ brew install cmake
39$ cmake --version # >= 3.13
40```
41
42### Install Ninja
43
44[Ninja](https://ninja-build.org/) is a fast build system that you can use as a
45CMake generator.
46
47```shell
48$ brew install ninja
49```
50
51## Clone and Build
52
53### Clone
54
55Clone the repository and initialize its submodules:
56
57```shell
58$ git clone https://github.com/google/iree.git
59$ cd iree
60$ git submodule update --init
61```
62
63> Tip:<br>
64> &nbsp;&nbsp;&nbsp;&nbsp;Editors and other programs can also clone the
65> repository, just make sure that they initialize the submodules.
66
67### Build
68
69Configure:
70
71```shell
72$ cmake -G Ninja -B build/ .
73```
74
75Note: this should use `Clang` by default on macOS. `GCC` is not fully supported
76by IREE.
77
78> Tip:<br>
79> &nbsp;&nbsp;&nbsp;&nbsp;The root
Scott Todd4e5167d2020-06-29 09:30:35 -070080> [CMakeLists.txt](https://github.com/google/iree/blob/main/CMakeLists.txt)
Marius Brehlerc5c8b7c2020-06-22 14:38:05 -070081> file has options for configuring which parts of the project to enable.<br>
82> &nbsp;&nbsp;&nbsp;&nbsp;These are further documented in [CMake Options and Variables](cmake_options_and_variables.md).
Phoenix Meadowlark1633aa32020-06-17 12:28:58 -070083
84Build all targets:
85
86```shell
87$ cmake --build build/
88```
89
90## What's next?
91
92### Take a Look Around
93
94Check out the contents of the 'tools' build directory:
95
96```shell
97$ ls build/iree/tools
98$ ./build/iree/tools/iree-translate --help
99```
100
101Translate a
Scott Todd4e5167d2020-06-29 09:30:35 -0700102[MLIR file](https://github.com/google/iree/blob/main/iree/tools/test/simple.mlir)
Phoenix Meadowlark1633aa32020-06-17 12:28:58 -0700103and execute a function in the compiled module:
104
105```shell
106$ ./build/iree/tools/iree-run-mlir $PWD/iree/tools/test/simple.mlir \
107 -input-value="i32=-2" -iree-hal-target-backends=vmla -print-mlir
108```
109
110### Further Reading
111
112* For an introduction to IREE's project structure and developer tools, see
Lei Zhang6171a982020-09-08 12:48:25 -0400113 [Developer Overview](../developing_iree/developer_overview.md).
114* To understand how IREE implements HAL over Metal, see
Copybara-Service955256c2020-09-08 14:39:07 -0700115 [Metal HAL Driver](../design_docs/metal_hal_driver.md). <!-- TODO: Link to
116 macOS versions of these guides once they are developed.
Phoenix Meadowlark1633aa32020-06-17 12:28:58 -0700117* To use IREE's Python bindings, see
118 [Getting Started with Python](getting_started_python.md) -->